Re: DTS: clock not found

2014-02-09 Thread Javier Martinez Canillas
Hello Matthias,

On Wed, Feb 5, 2014 at 6:02 PM, Matthias Brugger matthias@gmail.com wrote:
 Hi,

 I'm stuck with dts problem. Whenever I try to find a clock for my
 device, the of_get_clk returns an error Kernel panic - not syncing:
 Can't get timer clock

 My DTS looks like this (reduced to relevant parts for easier reading):


Could you give more details about your platform?

I would take a look to Documentation/devicetree/bindings/clock/your
platform-clock.txt to be sure that you are using the bindings
correctly.

 #include dt-bindings/interrupt-controller/irq.h
 #include dt-bindings/interrupt-controller/arm-gic.h
 #include skeleton.dtsi

 / {

 [...]

 soc {
 #address-cells = 1;
 #size-cells = 1;
 compatible = simple-bus;
 ranges;

 gic: interrupt-controller@10212000 {
 compatible = arm,cortex-a9-gic;
 interrupt-controller;
 #interrupt-cells = 3;
 reg = 0x10211000 0x1000,
   0x10212000 0x1000;
 };

osc: oscillator {
 compatible = fixed-clock;
 #clock-cells = 1;

Looking at Documentation/devicetree/bindings/clock/fixed-clock.txt it says:

#clock-cells : from common clock binding; shall be set to 0

while your are setting your clock-cells to 1.

 clock-frequency  = 1500;
 clock-output-names = osc;
 };

 timer: timer-mysoc {
 compatible = mysoc,mysoc-timer;
 reg = 0x10008000 0x30;
 interrupts = GIC_SPI 113 IRQ_TYPE_EDGE_RISING;
 clocks = osc 0;
 clock-names = system15m;
 };
 };

Documentation/devicetree/bindings/clock/clock-bindings.txt also says:

==Clock consumers==

Required properties:
clocks: List of phandle and clock specifier pairs, one pair
for each clock input to the device.  Note: if the
clock provider specifies '0' for #clock-cells, then
only the phandle portion of the pair will appear.

So my educated guess is that you should use #clock-cells = 0; your
your clock provider device node and clocks = osc on your clock
consumer device node.

By looking at DTS and DTSI that uses the fixed-clock binding I see
that all platforms don't have their clocks providers device nodes
under soc {} but on a separate clocks {} node. I didn't find on the
clock-bindings.txt DT bindings documentation that this is a
requirement so probably that is not issue in your case but still
something to keep in mind.

 };


 my /drivers/clocksource/mysoc-timer.c looks like this (reduced to
 relevant parts for easier reading):

 [...]

 static void __init mysoc_timer_init(struct device_node *node)
 {
 unsigned long rate = 0;
 struct clk *clk;
 int ret, irq;
 u32 val;

 gpt_base = of_iomap(node, 0);
 if (!gpt_base)
 panic(Can't map registers);

 irq = irq_of_parse_and_map(node, 0);
 if (irq = 0)
 panic(Can't parse IRQ);

 clk = of_clk_get(node, 0);
 if (IS_ERR(clk))
 panic(Can't get timer clock);
 clk_prepare_enable(clk);

 rate = clk_get_rate(clk);

 }
 CLOCKSOURCE_OF_DECLARE(mtk_mt6589, mysoc,mysoc-timer,
 mysoc_timer_init);


 What I'm missing? I seems as if the clock osc is not found in the
 device tree. Any idea why. Building the DTB works without errors, but
 I suppose that doesn't mean too much anyway.

 Cheers,
 Matthias

 --
 motzblog.wordpress.com

Hope it helps,

Javier

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re:

2012-10-15 Thread Javier Martinez Canillas
On Mon, Oct 15, 2012 at 12:53 PM, Niroj Pokhrel nirojpokh...@gmail.com wrote:
 Thank Matthias!!!
 I have tried using printk . What I really want to do now is to implement the
 methods I have written by calling from the user space. Like I want to read
 or write to the character devices via  user space.


Hi Niroj,

Please don't top post, it is not polite since forces readers to scroll
to the bottom to gain some context about the conversation.

 On Mon, Oct 15, 2012 at 3:49 PM, Matthias Brugger
 matthias@googlemail.com wrote:

 Hi,


 On 10/15/2012 11:24 AM, Niroj Pokhrel wrote:

 Hi,
 I'm new to linux and kernel . I'm ongoing with the linux device drivers.
 I've followed the the book LDD but i'm lost about how to call my
 driver's specific method from the user space.
 Eg: if have developed a character device and inserted the module then
 how can i make sure that when I read or write that it implement the
 functions via the methods i have implemented in my module.


 the most easy way would be to put some printk output in your read/write
 functions of your driver. So with cat/echo from userspace you should be able
 to verify your implementation.

 Regards,
 Matthias


 --
 Niroj Pokhrel
 NIT Jamshedpur,
 B.Tech,Electronics and Communication


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies





 --
 Niroj Pokhrel
 NIT Jamshedpur,
 B.Tech,Electronics and Communication


There is no need to implement anything in user-space.

If your char dev driver has been correctly implemented and registered
then the standard file operation syscalls can be used to access the
device. The Linux kernel virtual filesystem will use the information
on the character device node (major number) to know which struct
file_operations (and hence file operations callbacks) has to be used.

Hope it helps,

-- 
Javier

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Syscalls: When can I use cond_syscall() macro?

2012-07-06 Thread Javier Martinez Canillas
On Fri, Jul 6, 2012 at 9:19 PM, Gustavo da Silva
gustavodasi...@gmail.com wrote:
 Ok!! All right. I'll follow the tips.


You keep not following the tips by the way :-)

Someone who wasn't following this thread probably would ask, which
tips did he not follow?

You see what happened? Because you top posted your answer (again) we
have lost the context of this conversation.


 2012/7/6 Ezequiel Garcia elezegar...@gmail.com

 On Fri, Jul 6, 2012 at 3:58 PM, Gustavo da Silva
 gustavodasi...@gmail.com wrote:
  And: How are the Argentina after Libertadores?!
 
 

 1. Please avoid top-posting! (as already suggested)

 2. Hehe, not every Argentinian citizen is soccer fan !! (despite what
 people seems to think)
 Meaning... I couldn't possible care less :-)


Most people in this mailing list are very nice and are willing to help
but also they are very busy and can be a little grumpy when they have
to repeat the same thing over and over. So please listen to Ezequiel,
Mulyadi and others when they give you advise.

Good luck and best regards,
Javier

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Why can not processes switch in atomic context?

2012-07-04 Thread Javier Martinez Canillas
On Tue, Jul 3, 2012 at 4:24 PM, Parmenides mobile.parmeni...@gmail.com wrote:
 Hi,

 It is said that kernel can not be preempted in interrupt context
 and when it is in a critical section protected by a spin lock.

 1. For the spinlock case, it is easy to get if preemption is allowed
 in critical section, the purpose of protection provided by spinlock
 can not be achieved readily.


A process cannot be preempted nor sleep while holding a spinlock due
spinlocks behavior. If a process grabs a spinlock and goes to sleep
before releasing it. A second process (or an interrupt handler) that
to grab the spinlock will busy wait. On an uniprocessor machine the
second process will lock the CPU not allowing the first process to
wake up and release the spinlock so the second process can continue,
it is basically a deadlock.

This happens since grabbing an spinlocks also disables interrupts and
this is required to synchronize threads with interrupt handlers.

 2. For the interrupt context case, I think when processing interrupt,
 kernel can be preempted in principle. But, this really increases the
 interrupt processing time which further cause longer response time and
 data missing in device. Except that, is there any other reasons?


The principal reason is quite simple, processes have an associated
task_struct and get executed when the scheduler chose to run it but
interrupt handlers are executed due an event (an interrupt happened on
the registered IRQ line).

So if you preempt an interrupt handler and schedule a process instead,
how could you execute the interrupt handler again? they don't have an
associated task_struct since they are not user-space process

 3. Kernel is responsible for prohibiiting passive process switches,
 namely preemption, in the above cases. But, It seems that it does not
 take care of active process swtiches, namely yield. For example, some
 code in a critical section protected by a spinlock can invoke
 schedule() to switch process passively. Is this the case?


Right, the kernel just avoid process switching by disabling preemption
but you could still call schedule() or do a function call that sleeps
like allocating big chunks of memory with GFP_KERNEL flag instead of
GFP_ATOMIC, this is indeed a bug in the same way that is a bug
dereferencing a NULL pointer.

On the kernel hacking section of the Kbuild configuration you can find
many kconfig options to enable different debug facilities that helps
you detect these scenarios and avoid deadlock.


Hope it helps,
Javier

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: New kernel for Chipbox

2012-06-08 Thread Javier Martinez Canillas
On Thu, Jun 7, 2012 at 1:53 PM, Sertac TULLUK ser...@merihvideo.com.tr wrote:
 Dear Harishkumar;

 I already know how to find the changes, please see my 1st e-mail below.

 The problem is, those changes are more than thousands of lines of code, and
 hundreds of files are added or modified.

 I wonder, how can I apply those thousands of changes to new kernel source
 quickly and easily?


The bad news is that there isn't a quickly and easily way to do it.
The kernel doesn't have an stable API (read
Documentation/stable_api_nonsense.txt) and the ARM part of the kernel
is one of the most fast changing lately. So probably most of the
drivers and SoC enablement platform code won't work with newer
kernels.

So, this isn't a trivial task.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Can't find macro SAVE_ALL

2012-05-17 Thread Javier Martinez Canillas
On Thu, May 17, 2012 at 3:59 PM, 王哲 wangzhe5...@gmail.com wrote:
 Hi all:
         i am a kernelnewbies.during studying the linux system call,and
 analysis the following code (linux kernel 2.6.38)

 529ENTRY(system_call)
 530 RING0_INT_FRAME # can't unwind into user space anyway
 531 pushl %eax # save orig_eax
 532 CFI_ADJUST_CFA_OFFSET 4
 533 SAVE_ALL
 534 GET_THREAD_INFO(%ebp)
 535 # system call tracing in operation / emulation
 536 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
 537 jnz syscall_trace_entry
 538 cmpl $(nr_syscalls), %eax
 539 jae syscall_badsys
 540syscall_call:
 541 call *sys_call_table(,%eax,4)
 542 movl %eax,PT_EAX(%esp) # store the return value

 Question:
    i want to see what the SAVE_ALL have done.and can't find the
 Macro SAVE_ALL
 if anyone knows please help

  Thanks

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


http://lxr.free-electrons.com/ident?i=SAVE_ALL

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Driver Project

2012-04-26 Thread Javier Martinez Canillas
On Thu, Apr 26, 2012 at 8:59 AM, Rabee Al-Maqabi
rabee.almaq...@gmail.com wrote:


 On Wed, Apr 25, 2012 at 8:26 PM, Javier Martinez Canillas
 martinez.jav...@gmail.com wrote:

 On Wed, Apr 25, 2012 at 11:19 AM, Rabee Al-Maqabi
 rabee.almaq...@gmail.com wrote:
  Hi,
 
  I am looking for not yet supported piece of hardware to write a driver
  for
  it. anyone can help?
 
  Regards,
  Rabee Al-Maqabi

 Hi Rabee,

 Linux Device Drivers 3rd edition (LDD3) is a great book to learn how
 to write Linux device drivers. The best thing about this book is that
 teaches how to write device drivers for memory-based virtual devices,
 which mean that you don't need any special hardware to run the example
 drivers on your computer.

 Fortunately the Linux internal API is not stable and that allows us to
 improve the kernel every day. But this has the side effect that any
 documentation about the Linux kernel quickly becomes obsolete.

 A long time ago I updated the LDD3 examples so they could be compiled
 and used on newer kernels, this was for academic purposes so my
 students would be able to use that code.

 Sadly I haven't had any time to update to more recent kernels so if
 you want to work on Linux device drivers you can fork my tree [1] and
 make the drivers work on recent kernels, I know that many people would
 be happy (specially students).

 [1]: https://github.com/martinezjavier/ldd3

 Best regards,

 --
 Javier Martínez Canillas
 (+34) 682 39 81 69
 Barcelona, Spain


 Hi Javier,

 Thank you for your reply. Linux Device Drivers is indeed a great book. I
 have read it in addition to Understanding the Linux Kernel and I have
 experimented with my Linux box. At this point, I would like to have a
 real-world experience and write a driver for a piece of hardware not yet
 supported.

 Best regards,

 --
 Rabee Al-Maqabi

Ok, in that case you can buy an IGEPv2 board
(http://www.isee.biz/products/processor-boards/igepv2-board) from
Spaniard company ISEE.

ISEE manufactures very powerful System-on-Chip ARM OMAP3 based boards.

They don't use the mainline kernel but instead have their own forked
v2.3.37 kernel and their own first stage bootloader (igep-x-loader).
ISEE code can be found here: http://git.isee.biz/

So a great project could be give complete support to this board on the
mainline kernel. IGEPv2 is one of the boards that Linaro uses as a
reference for OMAP3 to test their kernels and rootfs images.

I own one of these boards an in my free time I hack both the kernel
and the U-boot bootloader to properly support the IGEPv2, but  there
is a lot of work to do and I found everytime more hard to find free
time to work on this.

So if you want to join me on this project it would be great :-)

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Driver Project

2012-04-25 Thread Javier Martinez Canillas
On Wed, Apr 25, 2012 at 11:19 AM, Rabee Al-Maqabi
rabee.almaq...@gmail.com wrote:
 Hi,

 I am looking for not yet supported piece of hardware to write a driver for
 it. anyone can help?

 Regards,
 Rabee Al-Maqabi

Hi Rabee,

Linux Device Drivers 3rd edition (LDD3) is a great book to learn how
to write Linux device drivers. The best thing about this book is that
teaches how to write device drivers for memory-based virtual devices,
which mean that you don't need any special hardware to run the example
drivers on your computer.

Fortunately the Linux internal API is not stable and that allows us to
improve the kernel every day. But this has the side effect that any
documentation about the Linux kernel quickly becomes obsolete.

A long time ago I updated the LDD3 examples so they could be compiled
and used on newer kernels, this was for academic purposes so my
students would be able to use that code.

Sadly I haven't had any time to update to more recent kernels so if
you want to work on Linux device drivers you can fork my tree [1] and
make the drivers work on recent kernels, I know that many people would
be happy (specially students).

[1]: https://github.com/martinezjavier/ldd3

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to use the memory allocated in kernel?

2012-04-18 Thread Javier Martinez Canillas
2012/4/18 夏业添 summer...@gmail.com:
 Hi Dave,

 Thanks for reply. My English is not very good, and so I want to ask about a
 term:map. Does map mean that create a relationship between the virtual space
 and physical memory?

 Thanks again!


As Dave said, unless you know what you are doing, you should really
use kmalloc() and friends (kzalloc(), etc) for assigning physically
contiguous kernel memory or
vmalloc() that assigns virtually (but not necessarily physical)
contiguous memory.

vmalloc() performs worse that kmalloc() but has more changes to
succeed when trying to get large memory chunks.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How does the driver initialize corresponding with several same devices ?

2012-04-18 Thread Javier Martinez Canillas
On Wed, Apr 18, 2012 at 11:16 AM, Li Haifeng omy...@gmail.com wrote:
 I make a driver module and built in the kernel. There are three devices use
 the same driver on the hardware platform. To use each device, the probe
 function of the driver module should be probed. So, the driver module is
 registered in the kernel.

 My question is, how times should the probe function of the driver be called
 and create nodes in devfs to corresponding with the three devices?


Your driver probe function has to be called only once. You should have
in your driver a software representation of each device and register
each one with the corresponding subsystem and with the kernel kernel
device model to populate /dev with your device nodes.

How do you represent your devices internally is up to you, it can be
assigned on your module init function as a static array or you can do
it dynamically using a linked list.

Look at any driver inside drivers/char for reference.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How does the driver initialize corresponding with several same devices ?

2012-04-18 Thread Javier Martinez Canillas
On Wed, Apr 18, 2012 at 12:59 PM, Javier Martinez Canillas
martinez.jav...@gmail.com wrote:
 On Wed, Apr 18, 2012 at 11:16 AM, Li Haifeng omy...@gmail.com wrote:
 I make a driver module and built in the kernel. There are three devices use
 the same driver on the hardware platform. To use each device, the probe
 function of the driver module should be probed. So, the driver module is
 registered in the kernel.

 My question is, how times should the probe function of the driver be called
 and create nodes in devfs to corresponding with the three devices?


 Your driver probe function has to be called only once. You should have
 in your driver a software representation of each device and register
 each one with the corresponding subsystem and with the kernel kernel
 device model to populate /dev with your device nodes.

 How do you represent your devices internally is up to you, it can be
 assigned on your module init function as a static array or you can do
 it dynamically using a linked list.

 Look at any driver inside drivers/char for reference.


Sorry, didn't understand your question. Forget about my answer and
sorry for the noise :)

Regards,


-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Question about tlv message support

2012-04-17 Thread Javier Martinez Canillas
On Tue, Apr 17, 2012 at 2:36 AM, NorthPole morfeas3...@gmail.com wrote:
 @JAYESH TANK
 thank you very much :-) that was a very good starting poind :D


 @Javier
 you are right, so here is something more specific

 I want to add a framework for tlv message construction and parsing in
 a wireless mesh routing protocol so as it can have the advantages of
 the tlv way of communication (one of which is backwards compatibility)

 afaik tlvs are used in many places in the kernel and as Jayesh stated
 there are no ready made apis.
 So if I want to do that I have to copy someone else's code and modify
 it accordingly


Hi,

Netlink has some sort of TLV:

nla_put_string(), nla_put_u32(), nla_put_u8(), etc.

But use a socket buffer (struct sk_buff) to store this data. Since you
will use to store and retrieve this info for a networking protocol
(mesh routing), it probably makes sense to reuse Netlink functions.

Take a look to: include/net/netlink.h

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Question about tlv message support

2012-04-16 Thread Javier Martinez Canillas
On Fri, Apr 13, 2012 at 8:22 PM, NorthPole morfeas3...@gmail.com wrote:
 Hello everyone

 I'm completely new to linux kernel and I would be grateful if you
 could help me get started.
 I read some basic things about the kernel. But I couldnt find anything
 relevant to the question below.

 So: Does the kernel have any support for the construction and encoding
 of type/length/value (TLV) or other information element messages?
  if it has(or if you dont know) where can I find a list or more documentation?


I think what you are looking for is the Generic Netlink API.

Here is a good howto:
http://www.linuxfoundation.org/collaborate/workgroups/networking/genericnetlinkhowto

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: wrapfs sources

2012-04-05 Thread Javier Martinez Canillas
On Wed, Apr 4, 2012 at 6:32 AM, V.Ravikumar
ravikumar.valla...@gmail.com wrote:
 Hi all,

 Could some body let me know wrapfs sources which is compatible to Linux
 2.6.18 kernel sources.

 I tried to get sources using google search , but all are compatible with
 latest kernel sources.

 Thanks  Regards,
 Ravi


Hi Ravi,

If I were you I would clone from
git://git.fsl.cs.sunysb.edu/wrapfs-latest.git and checkout from a
commitid that is near to a release data of your kernel, that will
minimize the merge problems.

This one seems a good candidate:
http://git.fsl.cs.sunysb.edu/?p=wrapfs-latest.git;a=commit;h=e478bec0ba0a83a48a0f6982934b6de079e7e6b3

But why are you force to use such and old kernel? Seriously, 2.6.18 is
at least 5 years old.

If you are forced to use this kernel by a vendor, then ask your vendor
for support. Sorry, the community can't help you when using forked
kernels.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Re request_threaded_irq

2012-01-26 Thread Javier Martinez Canillas
On Wed, Jan 25, 2012 at 5:45 AM, Asutosh Das das.asut...@gmail.com wrote:
 Hi
 I have a query regarding the difference between request_irq and
 request_threaded_irq.
 I am aware that the thread_fn_handler may sleep, allocate memory,
 acquire locks etc.

 What context does the thread fn passed to the request_threaded_irq run in ?

 TIA

 --
 ~/asd

It runs in process context not in interrupt context. It is a normal
kernel thread. That is why as you said it can sleep (since it can be
schedule again), can allocate any time of memory (even if this
operations leads to a sleep) and acquire locks (which also makes the
process sleep if it fails to do it).

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: what is the + sigh in the modules folder name?

2012-01-23 Thread Javier Martinez Canillas
On Mon, Jan 23, 2012 at 8:52 PM, Graeme Russ graeme.r...@gmail.com wrote:
 On 01/24/2012 05:15 AM, Greg KH wrote:
 On Mon, Jan 23, 2012 at 12:40:41PM -0500, Robert P. J. Day wrote:
 On Mon, 23 Jan 2012, Greg KH wrote:

 On Tue, Jan 24, 2012 at 12:25:20AM +0700, Mulyadi Santosa wrote:
 Hi...

 On Mon, Jan 23, 2012 at 23:15, Christopher Harvey
 ch...@basementcode.com wrote:
 I have a path on system called:
 '/lib/modules/2.6.37+/'
 It used to be called:
 '/lib/modules/2.6.37/'

 Hm strange. You said you have the kernel source, right? Can you show
 us about ten top lines of the Makefile in the main kernel source
 directory?

 I am suspecting there is + character in the extraversion..but that
 needs to be checked

 No, it just means you have a modified kernel tree, that is not reall
 2.6.37, you have changed it somehow.  The build system asks git about
 this when building the kernel.

   you sure?  i thought that if it was a modified working tree, you'd
 get the -dirty qualifier added, not just a +.

 Try it and see :)

 From what I can tell, the '+' means you are building source which includes
 upstream commits after the last tag in the tree


Well that commits not necessarily are upstream ;-)

It only means that are commits after the last tag.

Regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: from where to start..

2012-01-21 Thread Javier Martinez Canillas
On Sat, Jan 21, 2012 at 4:52 AM, SaNtosh kuLkarni
santosh.yesop...@gmail.com wrote:
 Hi Sukrit,

 Ya kernel development..kernel space is fun...but since kernel has loads of
 subsystems...you must be or will be later interested in certain
 subsytems,,,but you ought to understand the basic working and operations
 carried by a kernel and sorting of programming and structures required...i
 would suggest Kernel Development by Rober Love

 http://blog.rlove.org/2010/07/linux-kernel-development-third-edition.html

  as he doesnt dig deep into core kernel development instead focuses on stuff
 such as Process mgnt , synchronization ,VFS...etc etc...in a rather simple
 easy to understand manner...but if you are interested or rather want to get
 into specific subsystems like Networking ...network stack,...etc you can
 always start off with network internals...but my suggestion is Robert Love
 and start of writing few LKMstats my opinion

 On Sat, Jan 21, 2012 at 6:58 AM, Jeff Haran jha...@bytemobile.com wrote:



 From: kernelnewbies-boun...@kernelnewbies.org
 [mailto:kernelnewbies-boun...@kernelnewbies.org] On Behalf Of Sukrit Sangwan
 Sent: Friday, January 20, 2012 4:19 PM
 To: Kernelnewbies@kernelnewbies.org
 Subject: from where to start..



 I want to become a kernel developer. I have never done anything related to
 kernel uptil now. I am unable to figure out how to start off. Please help me
 doing my first exercise on kernel development.



 --

 Sukrit Sangwan


Hi Sukrit,

People ask me this a lot so I wrote a post in blog about it, you can
read it here:

http://martinezjavier.blogspot.com/2011/10/what-is-best-way-to-learn-linux-kernel.html

Also I used to maintain a repo with the Linux Device Drivers 3 book examples:


But I haven't committed anything for over a year because I'm too busy
to do it. So cloning that tree, forward porting those virtual drivers
and send me the patches would be a good way to learn and also great
for the newbies community.

Even you can fork that tree and try to maintain yourself :)

Good luck
Javier

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[BUG] SIOCSIFFLAGS returns -EIO on SMSC LAN911x

2011-12-30 Thread Javier Martinez Canillas
Hello,

We have an issue with the SMSC LAN911x driver with today linux-2.6 [1]
executing on an IGEPv2 [2] board using omap2plus_defconfig.

When I try to bring up the network interface, the ioctl set interface
flags command (SIOCSIFFLAGS)  fails returning -EIO:

root@igep00x0:~# ifconfig eth0 up
ifconfig: SIOCSIFFLAGS: Input/output error

But if I execute again it succeeds:

root@igep00x0:~# ifconfig eth0 up
[  832.465423] smsc911x smsc911x.0: eth0: SMSC911x/921x identified at
0xdb086000, IRQ: 336

We found that the problem is on the SMSC LAN911x driver
(drivers/net/ethernet/smsc/smsc911x.c) net_dev ndo_open function
handler smsc911x_open.

When the handler is called, it tries to software reset the device by
writing a bit to a self-clearing configuration register. According to
the data-sheet the hardware clears that bit to notify that the reset
was successfully:

 static int smsc911x_soft_reset(struct smsc911x_data *pdata)
{
unsigned int timeout;
unsigned int temp;

/* Reset the LAN911x */
smsc911x_reg_write(pdata, HW_CFG, HW_CFG_SRST_);
timeout = 10;
do {
udelay(10);
temp = smsc911x_reg_read(pdata, HW_CFG);
} while ((--timeout)  (temp  HW_CFG_SRST_));

if (unlikely(temp  HW_CFG_SRST_)) {
SMSC_WARN(pdata, drv, Failed to complete reset);
return -EIO;
}
return 0;
}

The condition temp  HW_CFG_SRST_ is false so the error code -EIO is
returned and propagated to user-space.

By doing a git bisect we found that this strange behavior exists when
the Kconfig tristate compilation condition SMSC_PHY has the value yes
to be compiled built-in:

SMSC_PHY=y

If this config symbol has the value module (m) or not build at all,
then bringing up the network interface never fails.

Did anyone have the same problem?

The problem is really strange to me, especially since we are sure that
all the requirements to software reset the device are meet in both
cases (with SMSC_PHY compiled built-in and without it)

[1]: HEAD on commit 371de6e4e0042adf4f9b54c414154f57414ddd37 drm/i915:
Disable RC6 on Sandybridge by default
[2]: https://wiki.linaro.org/Boards/Igep

Thank you and best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Conditional compilation depending on CONFIG_FOOBAR

2011-12-12 Thread Javier Martinez Canillas
On Mon, Dec 12, 2011 at 8:59 AM, Srivatsa Bhat bhat.sriva...@gmail.com wrote:


 On Mon, Dec 12, 2011 at 9:17 AM, contemplating zombie
 contemplatingzom...@gmail.com wrote:

 Just to clarify more, if I put my code in something like:
 #ifdef CONFIG_FOOBAR
 my code
 #endif

 Then my module's Makefile should check if this parameter is defined in the
 .config file. How should I modify my Makefile to do that?


 On Sun, Dec 11, 2011 at 10:44 PM, contemplating zombie
 contemplatingzom...@gmail.com wrote:

 Hi,

 I want to conditionally compile some code in module if CONFIG_FOOBAR is
 defined.
 How can I add this check to my module's makefile?

 -Thanks.



 If I understand correctly, you want some part of your module to be compiled
 only
 when CONFIG_FOOBAR is defined. You already mentioned the solution yourself!:
 Just put that code within #ifdef CONFIG_FOOBAR and #endif
 That would check the .config file and see if CONFIG_FOOBAR is defined; and
 only if it
 is defined, that code piece gets compiled, else it will simply get stripped
 off.


Now if the question is _how_ to define the configuration symbol
FOOBAR. Then you have to add a new configuration option to a Kconfig
file (probably the one that exists in the directory where you have the
file that is using it).

For example, suppose that you have a char device driver located in
drivers/char/yourdev.c and yourdev uses a FOOBAR option to do
something. Then you have to add something like this in
drivers/char/Kconfig

config FOOBAR
bool decide to use foobar or not
 help
 Say Y here if you want to enable the foobar option.

When you execute make menuconfig or other make targets that generate
the compilation options menu. You will see your option under Device
drivers - Character devices

The mconf binary will write in .config the value that you chose for
FOOBAR and will append CONFIG_

So if you enable FOOBAR, you will have something like:

CONFIG_FOOBAR=y

Then this symbols are used to create a generated autoconf.h file in
include/generated/autoconf.h

every compilation command in the kernel includes this file

gcc yourdev.c -I include/generated/autoconf.h

For a detailed description of the kernel build system look at
Documentation/kbuild/

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Learning Linux Kernel

2011-12-12 Thread Javier Martinez Canillas
On Tue, Dec 13, 2011 at 1:07 AM, Kaushal Shriyan
kaushalshri...@gmail.com wrote:


 On Tue, Dec 13, 2011 at 5:21 AM, Alexandru Juncu alex.ju...@rosedu.org
 wrote:

 On Tue, Dec 13, 2011 at 1:39 AM, Kaushal Shriyan
 kaushalshri...@gmail.com wrote:
  Hi
 
  I have been working on Linux OS for the last 10 years and it has been
  very
  exiting and challenging to learn new technologies based on Linux. I am
  basically a Sys Admin for Linux with bash programming and configuring
  and
  setting up Linux Server including network services like BIND DNS,Apache
  etc...
 
  Although i do not know C and ASM Language, I am very much eager to start
  learning Linux Kernel Code and contribute to linux kernel codebase
  sometimes
  down the line.
  Please guide/suggest me.
 
  Regards,

 Hello!

 I think people appreciate your enthusiasm. I do think that knowing C
 programming is a prerequisite. So you need to start with that.
 For the theory, if you want to start learning how the kernel works, I
 recommend the book Linux Kernel Development [1] by Robert Love.
 Another thing I would give you is this video [2] to know how to submit
 your first patch.

 [1]
 http://www.amazon.com/Linux-Kernel-Development-Robert-Love/dp/0672329468/ref=pd_sim_b_3
 [2] http://www.youtube.com/watch?v=LLBrBBImJt4



 Hi

 Just curious to know about total number of linux kernel developers in the
 world who contribute to linux kernel codebase. Any wiki or webpage which
 mentions about it?

 Regards


These are a statistics page, not sure how accurate it is though:
http://www.remword.com/kps_result/

I think that the best place to look at this are the annual reports of
the Linux foundation:
https://www.linuxfoundation.org/sites/main/files/lf_linux_kernel_development_2010.pdf

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Scull -unable to handle kernel paging request

2011-11-24 Thread Javier Martinez Canillas
On Sat, Nov 19, 2011 at 1:34 PM, anish kumar
anish198519851...@gmail.com wrote:
 Hello,

 Testing the scullwuid produced attached crash logs.


Hello Anish,

Sadly I don't have more time to keep updates the LDD3 examples. I did
a long time ago to use for academic purposes. As you can see my last
commit is from almost a year ago and even then I only used to be sure
that the modules compiles cleanly without warning (not sure if they
compile anymore, probably not) but didn't try it, since I don't use
the modules anymore.

Hope that someone with more time than me can fork the git tree and
continue with this work since the LDD3 book is an amazing book to
introduce newcomers to Linux driver development.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Guidance on writing device drivers

2011-11-24 Thread Javier Martinez Canillas
On Fri, Nov 18, 2011 at 5:50 PM, Matthias Brugger
matthias@googlemail.com wrote:
 On 11/10/2011 05:26 AM, Prajosh Premdas wrote:

 [...]
 On Thu, Nov 10, 2011 at 10:08 AM, rohan puri rohan.pur...@gmail.com
 mailto:rohan.pur...@gmail.com wrote:
    On Wed, Nov 9, 2011 at 10:40 PM, suraj khurana
    surajkhuran...@gmail.com mailto:surajkhuran...@gmail.com wrote:

        Hi all,
        I am a newbie in linux world and want to learn linux device
 drivers.

        I am currently reading book - Linux Device Drivers by O'reilly.

        Does anyone has any problem statements based on device drivers
        for practice
        so that I can enhance my skills in writing device drivers.

 The Linux Device Driver book (ldd3) is outdated, as Linux kernel ABI changes
 constantly, although I would still recommend the book as good starting
 point.
 Martinez Javier started to port the source code examples to the actual
 Kernel versions. I'm not sure about the actual status of the work, but I
 vaguely remember that I tried to use the block device driver some month ago.
 It compiled without any warning but crashed when used.

 Maybe you want to dig in the example code and see if you can find and
 resolve some issues.

 https://github.com/martinezjavier/ldd3

 Regards,
 Matthias

Hello Suraj,

As the author of that repo I confirme you that I'm not updating the
examples anymore. Looking at the commit history you can see that the
last one was about a year ago. An even there I only make sure that the
drivers compile cleanly but I didn't try it as Matthias says.

A long time ago I update the drivers for academic purposes but since
then I have ever used anymore.

Hope that someone can continue this forking my git tree since I think
the LDD3 books is one of the best for newbies to understand how Linux
drivers are developed.

BTW: I do have time to push patches is someone send to me to fix the issues.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Getting a block from a block device?

2011-11-08 Thread Javier Martinez Canillas
On Tue, Nov 8, 2011 at 12:06 PM, Dan Luedtke mailda...@googlemail.com wrote:
 Hallo everyone,

 could someone please give me a hint on how to get a block (e.g. 512
 bytes) from a block device from a kernel module?

 What .txt should I consult? Which headerfiles must I include?
 Where can I find the required function's definitions?

 In userspace I used fopen() with the device path as filename, I bet it
 isn't that easy in kernel mode.


Well even when is not considered a good practice, you can invoke the
file operations syscall handlers from your module.

Look at this LJ article: http://www.linuxjournal.com/node/8110/print

But I think that the right question is not _how_ to do it but _why_.

The kernel can't assume a filesystem layout and the location of a file.

Can you tell what are you trying to achieve? Maybe there are better
ways to do it.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Is there a way to build a cross reference with kernel file

2011-10-25 Thread Javier Martinez Canillas
Hello Jimmy,

On Mon, Oct 24, 2011 at 5:00 PM, Jimmy Pan dsp...@gmail.com wrote:
 It seems we can use ctags, while, I don't really know how to implement it.
 I don't want to use the online cross reference every time...
 Thanks.


Emacs + etags + cscope is for my the best approach to navigate the kernel.

A few months ago I wrote a blog post about this, you could take a look:

http://martinezjavier.blogspot.com/2011/07/emacs-configuration-for-linux-kernel.html

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Is there a tool which can generate a small and simple source tree after config?

2011-10-25 Thread Javier Martinez Canillas
On Sun, Oct 23, 2011 at 6:29 PM, jiangtao.jit jiangtao@gmail.com wrote:
 Hi:


Hi jiangtao,

 While reading the kernel code
 1. the huge amount of files make me scared
    there are too many alike functions in different files
    sometimes I can't figure out which one was really compiled
 2. too many macros in the definition of a struct or functions declaration
    confused me a lot
    I tried to follow the generated file autoconf.h to guess the final face
    but it's really a difficult thing

 Is there a tool which can generate a small and simple source tree after 
 config?
 not pre-processor

Not that I'm aware of.

 just generate a small source tree contains the files and dirs which really 
 will be compiled
 and no macros like CONFIG_SMP etc.
 according to the configuration

 or some other way to understand the architecture of the final working source 
 tree?


The Linux kernel is a very complex beast yet it is highly modularized.
I recommend you to focus on the specific subsystem that you need to
work and don't worry about the rest.

To know if a specific file is included in your kernel I usually do
this (it works for me but I'm not sure if is the right way to do it):

For example if I want to know if the driver to support nand memories
on ARM OMAP platforms is included in my kernel.

1- Find the file that implements the driver (drivers/mtd/nand/omap2.c)

2- See which Kconfig symbol determines its compilation:

$ fgrep omap2 drivers/mtd/nand/Makefile
obj-$(CONFIG_MTD_NAND_OMAP2)+= omap2.o

3- Look if that symbol is included in my config file:

$ fgrep MTD_NAND_OMAP2 .config
CONFIG_MTD_NAND_OMAP2=y

Then I know that my kernels includes that file.


Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: question in request_threaded_irq

2011-08-13 Thread Javier Martinez Canillas
On Sat, Aug 13, 2011 at 9:25 PM, radhika bhaskaran radhib...@gmail.com wrote:
 Hi,
 I have a question with respect to request_threaded_irq.
 Assume that one driver has registered and ISR on some particular irq number.
 Can i use the same irq number and register and isr in another driver.
 Because that is my requirement.
 when i try to do that is an error message with an error no as -19.
  err = request_threaded_irq(pdata-irq , NULL, testing_fucntion,
                             IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
 testing_function, dev);
 Can some one please help me whether it is possible.
 Regards,
 RB

You have to use the IRQF_SHARED flag that specifies the IRQ will be
shared for two devices:

err = request_threaded_irq(pdata-irq , NULL, testing_fucntion, IRQF_SHARED |
  IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING,
  testing_function, dev);

Have in mind that the kernel invokes every handler registered for that
IRQ every time an interrupt occurs on that line. So you have to check
in each ISR if the hardware raised the interrupt.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: about gcc-3.4.6

2011-08-11 Thread Javier Martinez Canillas
On Fri, Jul 29, 2011 at 4:22 PM, esmaeil mirzaee
esmaeil.deb...@gmail.com wrote:
 On Fri, Jul 29, 2011 at 8:16 AM, Bernd Petrovitsch
 be...@petrovitsch.priv.at wrote:
 On Fre, 2011-07-29 at 08:01 -0400, esmaeil mirzaee wrote:
 On Fri, Jul 29, 2011 at 7:46 AM, Pravin Shedage
 pravinshedage2...@gmail.com wrote:
         Hi Samuel,

         check the FTP link
         ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/
 Actually I have gcc-3.4.6.tar.bz2 for process of installation I did:

Why do you want to use such an old compiler?


 For the most simplest case - a compiler for the current host+OS -, `make
 bootstrap` is the way to go.
 could you explain more? I'm new.

I think he means that you should use the standard GCC package that can
be installed using whatever package manager your Linux distribution
has (i.e: apt/yum/yast)

Building a compiler from source code is not an easy task, it has
dependencies with at least a C library, such as glibc. And I don't
know if you need binutils source code also to compile (I have never
compile GCC from scratch).

Why an standard GCC installation doesn't fit your needs? Even if you
need a cross tool-chain for a not so common arch, you have projects
like Ptxdist
 and Crosstool that automates the tool-chain compilation.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: mount FS without filesystem type

2011-07-21 Thread Javier Martinez Canillas
On Thu, Jul 21, 2011 at 10:36 PM, Greg Freemyer greg.freem...@gmail.com wrote:

 Don't forget /etc/fstab.

 I almost positive the priority is:

  - command line arg
  - /etc/fstab
  - auto-detect

 Greg


Didn't know that mount uses /etc/fstab, but you are right there is
valuable information there.

Thanks a lot.

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to submit multiple related patches

2011-07-21 Thread Javier Martinez Canillas
On Fri, Jul 22, 2011 at 1:11 AM, Zac Storer zac.3.14...@gmail.com wrote:
 What is the best way to send multiple related patches?

 for example:

 A series of patches that fix indentation issues within a single
 src file.

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



Well the best way to send related patches is using git IMHO. For each
change that you do, you can commit to a branch in your git tree. Then
you can let git generate the patches for you and finally use
git-send-email to send the patch series.

For example:

Create a local branch for a tree:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
$ cd linux-next
$ git checkout -b devel origin/master

Do some change and commit:

$ emacs drivers/staging/pohmelfs/dir.c
$ git add drivers/staging/pohmelfs/dir.c
$ git commit -m Staging: pohmelfs/dir.c: Fix something

Do another change and commit:

$ emacs drivers/staging/pohmelfs/dir.c
$ git commit -m Staging: pohmelfs/dir.c: Fix another thing

Generate your patchset with your last two commits

$ git format-patch -s -2

This will create one file for each patch generated.

So to send your patchset you can use the command:

$ git send-email --compose --to='Zac Storer zac.3.14...@gmail.com'
--cc='kernelnewbies@kernelnewbies.org' *.patch

The command will extract the commit message and use it as the mail
subject, with the --compose flag you can create a prelude mail
explaining your patchset.

So this command will create 3 mails with these subjects

[PATCH 0/2]  Staging: pohmelfs/dir.c: Fixes
[PATCH 1/2]  Staging: pohmelfs/dir.c: Fix something
[PATCH 2/2]  Staging: pohmelfs/dir.c: Fix another thing

Also you can be sure that your email client didn't wrap lines and the
message era encoded in ASCII.

Remember always to use scripts/checkpatch.pl to check your patches and
scripts/get_maintainer.pl to check who are the developers that have to
be cc'ed.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: interview question how does application connects to device

2011-07-07 Thread Javier Martinez Canillas
 My question is, why netlink sockets are better than ioctls? It is not
 yet another interface to use as a wildcard to pass any data you wan't
 between the kernel and userpace with the only difference that you use
 another paradigm? (network sockets with a specific protocol family
 instead file operations over a device).

 Sorry if my question is stupid but I just don't get the point.

 Regards,

 Javier,

 I think the main issue with ioctl is that with some architectures, the
 userspace and kernel compiler treat 64-bit structure members
 differently, so it is very easy to create a structure which can not
 easily be passed via a simple pointer in-all-architectures.

 With netlink sockets, one is expected to have a well defined byte
 order coming across the socket.

 Greg


Greg,

Thank you very much for your answer, I wasn't aware of that ioctl limitation.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: interview question how does application connects to device

2011-07-06 Thread Javier Martinez Canillas
2011/7/6 Mandeep Sandhu mandeepsandhu@gmail.com:
 How would using sysfs be useful if we were to talk about interacting with, 
 let's say, a file system? ioctl's are quite versatile and rather easy to use 
 when one wants to interact with a given FS.

 For instance, one can manage a Btrfs file system by using an user-level 
 tool, which heavily uses ioctl's. Requiring it to interact with sysfs 
 instead seems like complicating something simple with no apparent purpose.


Something that always has caught my attention is why netlink sockets
are so popular. I know that ioctl is deprecated and all new kernel
code that needs full-duplex communication between userspace and
kernelspace shoud use netlink as its interface.

But one of the arguments against ioctl is that you don't have type
checking which makes really hard to audit the parameters passed from
userspace. Also ioctl can be provided by third party as modules (that
can also be proprietary binary only ones) which even complicates more
to have a general security mechanism.

My question is, why netlink sockets are better than ioctls? It is not
yet another interface to use as a wildcard to pass any data you wan't
between the kernel and userpace with the only difference that you use
another paradigm? (network sockets with a specific protocol family
instead file operations over a device).

Sorry if my question is stupid but I just don't get the point.

Regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re:

2011-06-16 Thread Javier Martinez Canillas
On Thu, Jun 16, 2011 at 8:41 PM, Venkateswarlu P
p.venkatesh...@gmail.com wrote:
 how to understand the kernerl source  files in a simple way


 what header  files i have to understand first


 for example  to understand  do_fork() function  for process
 creation  which is defined in  kernel/fork.c


In the end the Linux kernel is just a big project written in C.
Instead of asking what files do you need to understand. You should ask
yourself what subsystem do you want to learn?

Focus on functionality and browse the code to understand. As others
pointed before there are lots of good books that will give you a high
overview of the kernel.

The first book that I recommend reading is Linux kernel development by
Robert Love, but only if you have already read a book on operating
system concepts. The best book for me is Andrew Tanenbaum's Modern
Operating Systems.

Hope it helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: OS Books suggestion

2011-06-02 Thread Javier Martinez Canillas

 Also waiting anxiously for LDD 4 ! That is the book that got me started :D


Another excellent (and more updated) book about Linux device drivers is:

Essential Linux Device Drivers (http://amzn.to/bvELFI).

Is a good complement to LDD3 because it explains how drivers are
implemented for real devices instead of virtual ones.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: questions for Linus

2011-06-02 Thread Javier Martinez Canillas
 It just happened a few hours ago, so I think it might be a week or so
 before the video is posted to the web site.  I'll ask the orginizers and
 try to find out when it will show up.

 I'm sure there will be some news reports of the talk in a few days as
 well, there were lots of fun quotes that I'm sure will be repeated, they
 are already all over twitter in places...


In case that someone didn't notice there is a lwn.net coverage of the interview:

http://lwn.net/Articles/445687/

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: academia contribution to the kernel

2011-05-31 Thread Javier Martinez Canillas
On Tue, May 31, 2011 at 2:58 PM, Greg KH g...@kroah.com wrote:
 On Tue, May 31, 2011 at 09:44:25PM +1200, Ronnie Collinson wrote:
 Quite generic, but over the last N months or year what feature or some form 
 of
 milestone has excited and/or pleased you the most, excluding 2.3 numbering.
 Could be intersting.

 Ah, yes, you were not the first one to think of this one, it's on my
 list already :)


I have another question. Maybe a silly one but here it goes:

As far as I know linux staging is not only a mean to add code that
still is not in a mergeable form but also to deprecate old code. This
also applies to old subsystem like IBM MCA and ISA? Are these old
buses and ancient architectures being deprecated in the next 3.x
releases?

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: academia contribution to the kernel

2011-05-30 Thread Javier Martinez Canillas
2011/5/31 João Eduardo Luís jecl...@gmail.com:

 At the moment, and to my knowledge, in my computer science department there 
 are two on-going MSc thesis focused on Linux, one of them being mine. The 
 thing about having a thesis based on a beast such as Linux, as my supervisor 
 always points out, is that there is a lot of room to mess things up. If you 
 mess it up, and given the thesis has a limited time-frame, you are unable to 
 write (or even publish) any papers. This gets even worse whenever the 
 on-going work is part of a bigger research project, which must deliver some 
 sort of results.


You are totally right and I second you. For me the problem is using
the number of papers as a mean to measure the a research quality. As
the lwn.net article says, academia is so concerned in writing papers
that they forgive to solve problems while the industry is so worry in
solving problems that they don't have time to write papers. Using
conferences and journals to share your research results may be good
for other disciplines but in the computer science world we can share
our knowledge through open source software.

 Therefore, most of the academic work I'm acquainted with is fundamentally 
 focused on providing proof-of-concept prototypes. On the field of File 
 Systems there are quite a lot of published papers using Linux as their 
 backbone, but most of the work is focused on providing some sort of research 
 objective, and the implementation is presented as nothing but a PoC 
 sustaining whatever it is that the paper claims. I'm rarely able to find a 
 working implementation, publicly available.


The proof-of-concept prototypes, analytical models and simulation
probably made sense in a proprietary world where one didn't have an
operating system to try a different process scheduler for example. Of
course one would not develop a OS just to try something a new
scheduler, but today with the high quality and good modularization of
most well known open source projects (Linux, Apache, Postgresql, etc)
I don't understand why academia doesn't want to use them to try their
ideas. I don't expect to push the code upstream (it costs money) but
that is something that students can do in their free time if they are
allowed to do and develop against these projects.


 I'm not sure how it goes outside Portugal, but most projects I'm aware of 
 seldomly care about this. Usually, projects are funded through our National 
 Science and Technology Foundation (with government ties), or by EU funding. 
 To my knowledge, there are no restrictions on which licenses are to be 
 applied to research projects. In my opinion, being publicly financed 
 research, it *should* be open sourced and subject to a public license, if not 
 public domain all the way down. Then again, this is merely my opinion.


Same thing here in Spain. Most of the projects funding is made by EU
agencies and government (as far as I know). I hope that in the future
pushing your code upstream can be used as a metric of research
advances. Maybe could even be the goal of the project. I think
academia needs to modernize and embrace open source as a way to share
knowledge, otherwise we will continue publishing micro-improvements
papers that has almost zero impact and are behind high prices walls
(IEEE/ACM). Unless you work in a university the knowledge in these
papers are a privilege that no one can afford. In the other hand
making a git clone from an open source repo is free.

I hope that in the future governments and universities understand this
and change the way academia works today. Otherwise I think that
propietary academia will have the same fate as proprietary software.

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: knewbies project? - updating LDD3 source

2011-05-24 Thread Javier Martinez Canillas
On Tue, May 24, 2011 at 8:14 PM, DG dang...@gmail.com wrote:
 On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
 rpj...@crashcourse.ca wrote:
 On Tue, 24 May 2011, Jim Cromie wrote:

 over at http://code.google.com/p/ldd3/
 it says:
 The famous Linux Device Drivers released the sample code. but the
 code does not reflect the latest kernel updates, some of code cannot
 even compile. This project is to make it compatible with the current
 kernel.

 http://lwn.net/Kernel/LDD3/
 http://examples.oreilly.com/9780596005900/

  the one caution i would give here is that quite a bit of code in
 LDD3 shouldn't be updated, anyway, since it reflects features that
 have been deprecated for quite some time.

  for instance, no one should be writing proc files anymore.  also,
 ioctl()s are also discouraged for the most part.  so i would be
 selective about what parts of LDD3 code *should* be updated as
 examples of good kernel programming.

 rday


Robert is right, the drivers are quite old. As Robert says proc files
are deprecated in favor of sysfs and ioctl are discouraged in favor of
netlink sockets. Another example is that most LDD3 driver modules are
loaded with a script that create the device nodes. Unless your system
is a embedded device (an even in that case) you should let udev do
this).  So instead of having drivers that just compile cleanly and
works, it would be better to update the APIs the drivers use and how
they interact with userspace.

 There is a repo on GitHub with the same purpose.  I haven't checked it
 out personally, but it's probably worth a look.

 https://github.com/martinezjavier/ldd3


As the author of the repo I can tell that the drivers compile with
kernels 2.6.32, 2.6.35 and from 2.6.37 forward (including 2.6.39 and
linux-next). I create it for academic purposes, I haven't thest all
the drivers, only the ones I needed for the students.

Best regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: knewbies project? - updating LDD3 source

2011-05-24 Thread Javier Martinez Canillas

  i would take a closer look at the samples/ directory in the kernel
 source tree.  i am, in fact, writing a number of sample modules and
 drivers to be incorporated into an introductory kernel programming
 and device drivers course but i don't think i can share them all as
 they're part of the official courseware.  but i'm sure there are
 plenty of people who can write sample modules and drivers that would
 fit nicely in that samples/ directory.

 rday


The samples/ directory would be an excellent place to add examples
because the code would have to be maintained.

Does anyone know what is the policy to make a sample worth its place
in samples dir an not be considered as a bloat? Looking at the dir
seems to be that is only for samples about the usage of internal
kernel API (kfifo, kprobes, kobject, etc).

Regards,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Rv: Re: knewbies project? - updating LDD3 source

2011-05-24 Thread Javier Martinez Canillas
 
  There is a repo on GitHub with the same purpose.  I
  haven't checked it
  out personally, but it's probably worth a look.
 
  https://github.com/martinezjavier/ldd3

 I've found the same googlecode svn repo a while ago, but
 since it was very out-dated, I decided to start my own
 project on github.

 https://github.com/ezequielgarcia/ldd3-examples

 I am working against 2.6.37; but currently, the only module
 that really compiles is scull and scullpipe. martinezjavier
 git repo seems much updated; too bad I haven't find that
 when I looked for !

 Maybe we should concentrate our efforts, despite for me it
 was just a learning project.

 Greetings,
 Ezequiel.

Yes, it would be better to concentrate our efforts. When I needed to
update the examples to a more recent kernel I had the same problem
than you do. I did find a few repos but they were outdated. I send a
few patches to some of the authors but i didn't have any feedback so I
(sadly) had to start (yet another) LDD3 repo.

But probably the best idea is to think a good example set to include
in the kernel's samples dir. I just don't know what is the policy
about the code that reside in that dir. In the meantime patches are
welcomed so I can include more examples in this repo. I will try to
keep this repo compiling with newer kernels but I probably won't have
to much time to add more examples.

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Please recommend linux network kernel books...

2011-05-03 Thread Javier Martinez Canillas
On Tue, May 3, 2011 at 3:12 AM, J.Hwan.Kim j.hwan.ki...@gmail.com wrote:
 Hi, everyone

 Could you please recommend books on linux network stack of 2.6 Kernel?


The Linux foundation website has also good information regarding the
Linux kernel network stack:

http://www.linuxfoundation.org/collaborate/workgroups/networking

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Query Regarding static and shared (dynamic) libraries linking

2011-03-23 Thread Javier Martinez Canillas
On Wed, Mar 23, 2011 at 10:25 AM, Leelakrishna A
amudala.kris...@gmail.com wrote:

 Hi All,
 I have few doubts regarding static and shared (dynamic) libraries linking.
 Can anybody please clarify it.

Hello Leelakrishna,

This list is about Linux kernel development, not user-space
application development. There is a special mailing list for that
purpose that is: linux-c-programm...@vger.kernel.org.

But I will try to answer your questions:

 There are two kinds of libraries - static libary(.a file) and shared library
 (.so file).
 Also there are two types of library linkages static linkage and dynamic
 linkage.

Yes, static linkage is used with static libraries and dynamic linkage
is used with shared (dynamic) libraries. You can't static link a
shared library nor dynamic link a static library.

Although there are tools that create a pseudo-static binary, but is
more a hack than a normal behaviour (i have never used those tools so
I can't tell you how well they work).

 So Static library can be linked to an executable in either ways (Statically
 and dynamically).
 in the same way shared libraries can be linked to executable in both the
 ways (Statically and dynamically).

As I said you can only static link a static library. For example the command:

gcc -static main.c -lhello

Will create an executable statically linked with the static version of
the library libhello (libhello.a) and not the shared (dynamic) version
of the library (libhello.so).

 Here my doubt is what is the use if we statically linked the shared library
 to the executable binary
 (by this way the shared library is part of the executable) and what is the
 point in calling it as shared libary if it can be linked statically to the
 executable file.


The shared library never is part of the executable. Linkage can happen
in three different moments: at compile time (statically), at load time
(if you dynamical linked your program to a shared library) or at run
time (dynamic loading) by requesting the dynamic linker to load and
link shared libraries.

Only when you static link a static library with a program, the library
becomes part of the executable.

If you use dynamical linking your binary has information that tells
the loader that it has to load the shared library and resolve symbols
upon execution while dynamic loading allows you to load a shared
library and call a particular function even when you didn't dynamic
link your program against the library.

There is a small but powerful API to do dyamic loading (dlopen, dlsym,
dlerror, dlclose). It is used mostly for programs that implements
plug-ins and to do function interposition (also known as function
hijacking).

 If we linked the shared library to the executable file using dynamic
 linkage, executable file will pick the library at run time.

It is not the executable who pick the library but the loader.

 Here my doubt is to pick up the library at run time who will load the
 library into the memory and how will the executable know about the address
 of the function in the library to invoke the function.
 Thanks in advance,
 Leela krishna.

It is the loader who pick the library upon execution and bind the
binary symbols with the ones found in the shared library. Which
library it will pick depends on your configuration (i.e: the value in
your LD_LIBRARY_PATH var and ld.so.conf file).

The picked library doesn't even has to be the same that was used to
dynamic link at compile time. To see what libraries the loader will
pick for a binary execute the ldd command.

$ ldd binary

You can also force to load a specific shared library before any other
(including libc) by setting LD_PRELOAD to the library path.

Hope its helps.

Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Common signal handler system call

2011-03-20 Thread Javier Martinez Canillas
On Sun, Mar 20, 2011 at 8:38 AM, mohit verma mohit89m...@gmail.com wrote:
 Well, you can implement your idea as a library function too.
 Apart from the just for fun factor or to learn how to implement a new
 system call, I see no real gain to move that into kernel.

 I think it should be there in kernel not because it is my idea but for good
 reasons (personally think so).


Hi Mohit,

A problem I see with your idea is that it is not POSIX-compliant.
Linux being a Unix-like operating system tries to adhere to the
standard as much as possible. Although is true that it is not tied to
the specification. Whenever a change has strong arguments (an more
important valid use cases) Linux can deviate from the standard.

But as Bernd says, taking to the kernel something that can be done in
users-pace with no real gain and also breaking POSIX signals semantics
is something that will be hard to merge into the kernel.

Also, to implement a syscall you have to convince not only the kernel
developers that this change makes sense but also propose a patch to
glibc to implement a function library that uses your new syscall.

Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [PATCH 3/5] tg3: Enclose macro with complex values in parenthesis

2011-03-03 Thread Javier Martinez Canillas

 This seems unnecessary, what problem do the current macro definitions
 create?


Probably the change is unnecessary, the only value is that it silences
a checkpatch error:

ERROR: Macros with complex values should be enclosed in parenthesis

Sorry for the noise.

-- 
-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH 1/5] tg3: use linux/io.h and linux/uaccess.h instead asm/io.h and asm/uaccess.h

2011-03-01 Thread Javier Martinez Canillas
It is proper style to include linux/foo.h instead asm/foo.h if both exist

Signed-off-by: Javier Martinez Canillas martinez.jav...@gmail.com
---
 drivers/net/tg3.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6be4185..4410d73 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -48,9 +48,9 @@
 #include net/ip.h
 
 #include asm/system.h
-#include asm/io.h
+#include linux/io.h
 #include asm/byteorder.h
-#include asm/uaccess.h
+#include linux/uaccess.h
 
 #ifdef CONFIG_SPARC
 #include asm/idprom.h
-- 
1.7.2.3


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH 1/5] tg3: use usleep_range not msleep for small sleeps

2011-03-01 Thread Javier Martinez Canillas

Signed-off-by: Javier Martinez Canillas martinez.jav...@gmail.com
---
 drivers/net/tg3.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6be4185..3310c7a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -2410,7 +2410,7 @@ static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
 
if (tmp  EEPROM_ADDR_COMPLETE)
break;
-   msleep(1);
+   usleep_range(1000, 2000);
}
if (!(tmp  EEPROM_ADDR_COMPLETE))
return -EBUSY;
@@ -2688,7 +2688,7 @@ static int tg3_power_down_prepare(struct tg3 *tp)
tg3_read_mem(tp, NIC_SRAM_FW_ASF_STATUS_MBOX, val);
if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
break;
-   msleep(1);
+   usleep_range(1000, 2000);
}
}
if (tp-tg3_flags  TG3_FLAG_WOL_CAP)
@@ -8901,7 +8901,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
break;
}
 
-   msleep(10);
+   usleep_range(1, 2);
}
 
tg3_disable_ints(tp);
@@ -11863,7 +11863,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
  (EEPROM_DEFAULT_CLOCK_PERIOD 
   EEPROM_ADDR_CLKPERD_SHIFT)));
 
-   msleep(1);
+   usleep_range(1000, 2000);
 
/* Enable seeprom accesses. */
tw32_f(GRC_LOCAL_CTRL,
@@ -11956,7 +11956,7 @@ static int tg3_nvram_write_block_using_eeprom(struct 
tg3 *tp,
 
if (val  EEPROM_ADDR_COMPLETE)
break;
-   msleep(1);
+   usleep_range(1000, 2000);
}
if (!(val  EEPROM_ADDR_COMPLETE)) {
rc = -EBUSY;
@@ -12263,7 +12263,7 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 
*tp)
pci_read_config_word(tp-pdev, tp-pm_cap + PCI_PM_CTRL, pmcsr);
pmcsr = ~PCI_PM_CTRL_STATE_MASK;
pci_write_config_word(tp-pdev, tp-pm_cap + PCI_PM_CTRL, pmcsr);
-   msleep(1);
+   usleep_range(1000, 2000);
 
/* Make sure register accesses (indirect or otherwise)
 * will function correctly.
-- 
1.7.2.3


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH 3/5] tg3: Enclose macro with complex values in parenthesis

2011-03-01 Thread Javier Martinez Canillas
Macros with complex values should be enclosed in parenthesis.
Change accordingly.

Signed-off-by: Javier Martinez Canillas martinez.jav...@gmail.com
---
 drivers/net/tg3.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6dc7a8a..c67eb19 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -513,16 +513,16 @@ static void tg3_write32_mbox_5906(struct tg3 *tp, u32 
off, u32 val)
writel(val, tp-regs + off + GRCMBOX_BASE);
 }
 
-#define tw32_mailbox(reg, val) tp-write32_mbox(tp, reg, val)
+#define tw32_mailbox(reg, val) (tp-write32_mbox(tp, reg, val))
 #define tw32_mailbox_f(reg, val)   tw32_mailbox_flush(tp, (reg), (val))
-#define tw32_rx_mbox(reg, val) tp-write32_rx_mbox(tp, reg, val)
-#define tw32_tx_mbox(reg, val) tp-write32_tx_mbox(tp, reg, val)
-#define tr32_mailbox(reg)  tp-read32_mbox(tp, reg)
+#define tw32_rx_mbox(reg, val) (tp-write32_rx_mbox(tp, reg, val))
+#define tw32_tx_mbox(reg, val) (tp-write32_tx_mbox(tp, reg, val))
+#define tr32_mailbox(reg)  (tp-read32_mbox(tp, reg))
 
-#define tw32(reg, val) tp-write32(tp, reg, val)
+#define tw32(reg, val) (tp-write32(tp, reg, val))
 #define tw32_f(reg, val)   _tw32_flush(tp, (reg), (val), 0)
 #define tw32_wait_f(reg, val, us)  _tw32_flush(tp, (reg), (val), (us))
-#define tr32(reg)  tp-read32(tp, reg)
+#define tr32(reg)  (tp-read32(tp, reg))
 
 static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
 {
-- 
1.7.2.3


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH 4/5] tg3: Don't use IRQF_SAMPLE_RANDOM

2011-03-01 Thread Javier Martinez Canillas
This flag is scheduled for removal so we shouldn't used it.

Signed-off-by: Javier Martinez Canillas martinez.jav...@gmail.com
---
 drivers/net/tg3.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c67eb19..58c6049 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -8844,12 +8844,11 @@ static int tg3_request_irq(struct tg3 *tp, int irq_num)
fn = tg3_msi;
if (tp-tg3_flags2  TG3_FLG2_1SHOT_MSI)
fn = tg3_msi_1shot;
-   flags = IRQF_SAMPLE_RANDOM;
} else {
fn = tg3_interrupt;
if (tp-tg3_flags  TG3_FLAG_TAGGED_STATUS)
fn = tg3_interrupt_tagged;
-   flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
+   flags = IRQF_SHARED;
}
 
return request_irq(tnapi-irq_vec, fn, flags, name, tnapi);
@@ -8880,7 +8879,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
}
 
err = request_irq(tnapi-irq_vec, tg3_test_isr,
- IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev-name, tnapi);
+ IRQF_SHARED, dev-name, tnapi);
if (err)
return err;
 
-- 
1.7.2.3


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH 5/5] tg3: Fix inline keyword usage

2011-03-01 Thread Javier Martinez Canillas
The correct usage is static inline void not static void inline.

Signed-off-by: Javier Martinez Canillas martinez.jav...@gmail.com
---
 drivers/net/tg3.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 58c6049..d7e564d 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -13061,7 +13061,7 @@ done:
 
 static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
 
-static void inline vlan_features_add(struct net_device *dev, unsigned long 
flags)
+static inline void vlan_features_add(struct net_device *dev, unsigned long 
flags)
 {
dev-vlan_features |= flags;
 }
-- 
1.7.2.3


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Socket program in kernel

2011-02-22 Thread Javier Martinez Canillas
On Tue, Feb 22, 2011 at 10:43 AM, prabhu prab...@msys-tech.com wrote:
 Hi All,

 I wrote socket program in user level but i want to write the same program in
 kernel. Like the driver(socket server) should receive all the incoming
 TCP or UDP pocket(may be say raw socket) and write into the file.

 Please provide your valuable idea to do this program ... Also please point
 out pitfalls.


Hello Prabhu,

Please can you told us more about what do you want to achieve? Do you
want to receive information sended by a userspace program using
sockets? In that case netlink sockets is the way to go I think.

But if what you want to capture all the TCP and UDP messages and log
it, maybe you can register a new protocol handler.

Look at the packet_type structure and dev_add_pack() registration function.

Either way, accesing files from inside the kernel is not a good idea,
you should export your data via netlink sockets, sysfs, etc and write
to files from userpace.

Look at this excelent article  written by Greg KH about Things You
Should Never Do in the Kernel

http://www.linuxjournal.com/article/8130

Hope it helps.

Best regards,

-- 
-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: new link list

2011-02-22 Thread Javier Martinez Canillas
 if i  add a new system call and define a new link list in that and some
 kernel function want to access that list
 is it possible for that kernel code to make use of this?


Since the Linux kernel is monolithic, all kernel code is in the same
memory address space. So it will depend of the scope of your
variables.
For example if your structure is global, it will be accesible from any
place in the kernel.

 actually i am making changes 2 side : one introducing a new kernel function
 and that kernel function has to use the link list created by the system call
 which i make in system call code.


Generally is not a good idea to introduce a new system call. You have
to make changes in many places an recompile the kernel to make it
work. It is better to use netlink or other mechanism to communicate
kernel and userspace.

 how can i intigrate them so that the things become easier?

 any further help is appreciable , javier. :)


I still don't know your context but a common approach is to create a
kernel module that has both your data structures (linked list) and
some way export that data to userspace (netlink sockets, sysfs,
procfs, virtual devices, etc)


-- 
-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: struct assignment?

2011-02-19 Thread Javier Martinez Canillas
 I found there seems no declaring about struct ftrace_entry.

 usually we use a struct we will declare its elements such as:

 struct usb_host_endpoint {
        struct usb_endpoint_descriptor  desc;
        struct list_head                urb_list;
        void                            *hcpriv;
 ..
 };


There is not an explicit declaration but if you look at
kernel/trace/trace.h you will find this macro:

#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
struct struct_name {\
struct trace_entry  ent;\
tstruct \
}

 I guess the secret should be if_assign, but how does compiler interpret it?

 --

Actually in kernel/trace/trace_entries.h the macro is used to declare
the ftrace_entry

FTRACE_ENTRY(function, ftrace_entry,

TRACE_FN,

F_STRUCT(
__field(unsigned long,  ip  )
__field(unsigned long,  parent_ip   )
),

F_printk( %lx -- %lx, __entry-ip, __entry-parent_ip)
);

Also in this header other structures are declared in the same way for
example ftrace_graph_ent_entry and and ftrace_graph_ret_entry. If you
search for struct ftrace_graph_ret_entry declaration you won't find
anything either.

Best regards,

-- 
-
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Regarding Kernel Project

2011-01-17 Thread Javier Martinez Canillas
On Sun, Jan 16, 2011 at 9:24 PM, Pein Junior salmon...@hotmail.com wrote:
 Well said Mohit, but problem I am having is to find something in the kernel
 janitor section that's for Newbie but can not find any simple link to click
 to look at code and adjust and compile. I read all I need already just need
 to apply myself.


Well you could start looking at your hardware drivers source code and
try to improve it.

If you want some code that you can adjust and compile, LDD3 book comes
with example drivers for memory devices . Maybe you can start
modifiying these drivers to learn how kernel drivers works.

I create a project that contains all the LDD3 book examples updated to
compile and work with recent kernels, you can find the source code
here:

https://github.com/martinezjavier/ldd3

 Also interesting in wireless devices.



http://wireless.kernel.org/en/developers

There you can find todo-list, GSoC ideas and wireless developer
summits notes. So you can know what kind of work is needed in the
wireless subsystem.

-- 
Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to compile the 0.01 version of kernel

2011-01-09 Thread Javier Martinez Canillas
Hello,


 Then the next thing I was trying to do was to compile the source code
 and try to understand the various methods/function calls, system calls
 etc, but I'm not able to compile the code, I'm getting the following
 errors:


If you want to compile this kernel to understand how an operating
system works. I would recommend using a newer kernel version that you
can easily compile and test with current tools. Compiling a 0.01 with
today tools will be a pain and you would learn more about C compiling
and linking than operating system internals.

The Linux kernel is a really complex beast but also it is highly
modularized, so you can try to understand one aspect at a time. Also
there is much more documentation about recent kernels code that for a
kernel that old.

I would recommend buying some of the excellent books about Linux
kernel internals, the best book in my opinion is Robert Love's Linux
Kernel Development (http://amzn.to/i34vbB).

Another great books  are Linux Device Drivers
(http://lwn.net/Kernel/LDD3/), Essential Linux Device Drivers
(http://amzn.to/bvELFI) and IA-64 Linux Kernel: Design and
Implementation (http://amzn.to/fTvV9z). Also lwn.net site has a lot of
documentation about the kernel in its Kernel index page
(http://lwn.net/Kernel/Index/).

I think that reading about the kernel internals while looking at the
source code and latter trying to hack the code is the best way to
learn about the Linux kernel an operating systems internals.

-- 
Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: LDD3 examples updated

2011-01-07 Thread Javier Martinez Canillas

 We can for example have three branches: 2.6.32, 2.6.35 and linux-next.

 --

Hello,

I created two branches:

v2.6.32 that will be in sync with
git://git.kernel.org/pub/scm/linux/kernel/git/longterm/linux-2.6.32.y.git
v2.6.35 that will be in sync with
git://git.kernel.org/pub/scm/linux/kernel/git/longterm/linux-2.6.35.y.git

the branch master will be in sync with linux-next tree.

Also made some re-basing to keep the history coherent.

you can see how everything is now here: https://github.com/martinezjavier/ldd3

This way we can have the LDD3 examples working with some popular
long-term kernel versions and keeping up-to-date with the last kernel
release.

-- 
Best regards

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: LDD3 examples updated

2011-01-06 Thread Javier Martinez Canillas
Shrey


 I will try to keep the code always in sync with linux-next but there
 will be tags to stable versions. Now there are tags that compile with
 kernel versions 2.6.32, 2.6.35 and 2.6.37.

 Do you need help in making the ldd3 files compliant for any other
 kernels? Do you have any plans for others kernels (besides the
 linux-next) in your mind which might need porting work - probably some
 people on the list (including me) might be interested.



Any help will be appreciate thank you very much! There are other projects that
updated the LDD3 examples but the person who was doing that lost interest and
the project was abandoned.

Before creating my repo I send a few patches to some of them but none updated
their project. I think that the LDD3 examples are a valuable resource
and keeping
an up-to-date version is very important to kernel developer newbies.

My idea is to have a community maintained project so If I don't have
more time to
maintain others will do.

Also probably I introduced bugs while changing the code so bug-fixing
its the best help now.

Thank you

-- 
Best regards

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: LDD3 examples updated

2011-01-06 Thread Javier Martinez Canillas

 Note that 2.6.32 has been designated a LTS (Long Term Support) kernel
 by the powers that be.

 So that kernel would be good one to focus training resources on.  It
 will likely be supported for several years by Redhat, Suse, Canonical,
 etc.  Thus testing all the LDD3 examples with it would be very
 beneficial.

 ie. It is the basis of SLES 11.1 SP1, etc. so these firms are
 contractually obligated to support a LTS kernel for years.  To lighten
 the load, they got together and chose the 2.6.32 kernel as one they
 would support together.  I think this is the first time they have
 tried this approach.  I suspect they will do it again a couple years
 from now.

 Greg


I totally agree with Greg. 2.6.35 could also be a good version to
focus because people in the embedded world agreed that to reduce
fragmentation they will define kernels Embedded Flag Versions. A
flag version will be a specific kernel version that vendors will based
their products on.

Many big players (Sony, Google, Meego, and Linaro)  will be using
2.6.35 in its upcoming products so it seems that this version will be
declare as a flag version for embedded use.

We can for example have three branches: 2.6.32, 2.6.35 and linux-next.

-- 
Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


LDD3 examples updated

2011-01-05 Thread Javier Martinez Canillas
Hello,

I see many people in the list asking where do I start? In my opinion
the best way to learn kernel development is first learning some basic
concepts and start coding to get your hands dirty.

The Linux Device Drivers 3 book is a good start. Both the book and
source code examples are freely available.

The problem is that the book is a few years old and the example
drivers do not compile in recent kernels.

I started a project to keep the LDD3 examples up-to-date with recent kernels.

The git tree can be cloned from git://github.com/martinezjavier/ldd3.git

I will try to keep the code always in sync with linux-next but there
will be tags to stable versions. Now there are tags that compile with
kernel versions 2.6.32, 2.6.35 and 2.6.37.

I didn't try all the drivers with the three kernel versions, just
compile tested. So any bug, comment or patch is always welcome

-- 
Best regards,

-
Javier Martínez Canillas
(+34) 682 39 81 69

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies