Re: Help with dma on PCI driver

From: Luis Rossi
Date: Wed Mar 30 2011 - 12:11:44 EST


Thank you for your answer

Sorry for the code. I am not a kernel developer, i am a hardware
engineer, but i need to test a system i am designing. Most of the code
wasnt writen by me. I got it from another guy, the part that i wrote
so far was the one related to pci_alloc_constants. I will remake the
whole code soon to make it more readable. I was just testing some
concepts with it. I am trying to learn how to write  a driver based on
LDD3 and Linux Essential, but i was having a hard time. For now i
could find my problem. It was a dumb mistake and not realated to
kernel development. I forgot to allocate my structure.... so it was a
pointer to nothing.. But as you pointed me some problems.. just to
make sure.. should i stop the inti function on the device register,
and make all the rest inside probe? It makes a lot of sense as the
rest should be called just if the device is connected...

Thank you!!

On Wed, Mar 30, 2011 at 12:23 PM, Jonathan Corbet <corbet@xxxxxxx> wrote:
>
> On Wed, 30 Mar 2011 07:07:32 -0300
> Luis Filipe Rossi <luisf.rossi@xxxxxxxxx> wrote:
>
> > I am developing a driver for a custom PCI board. I am following the
> > example on Essential Linux Device Drivers, but when i am calling the
> > pci_alloc_consitent i get the following error:
> > Mar 29 15:18:42 luis-desktop kernel: [ 4520.075823] BUG: unable to
> > handle kernel NULL pointer dereference at 00000004
>
> Your source was horribly mangled, which is likely to reduce the number of
> responses you get.  I've not had the time to look at it in great detail,
> but I will say that the assumption that the PCI device is already probed
> and registered immediately after the pci_register_driver() call is
> dangerous at best.  Things like dma_descriptor_setup() should be called in
> your probe routine (or even later, when you actually need the buffer)
> rather than in your module init function.
>
> There's a lot of other issues with this driver, but that's the one I would
> look first at for the resolution of this particular crash.
>
> jon



--
Luís Filipe Rossi
Electrical Engineer
Biomechatronics Lab. / Grupo de Sensores Integráveis e Sistemas
Escola Politécnica
Universidade de São Paulo
Cel. +55 (11) 7662-9234
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/