linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [OOPS] Help needed for usb semaphore lock in 2.4.20-rc1 (since 2.4.13)
@ 2002-11-14  5:08 Duncan Haldane
  2002-11-14  5:20 ` Randy.Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Duncan Haldane @ 2002-11-14  5:08 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am the current maintainer of the cpia webcam driver.

I am tracking down a kernel Oops in 2.4.20-rc1 that was first
introduced in 2.4.13 by usb semaphore locking changes in usb.c,
and which was reported a while back on this list. See:
 http://www.uwsg.iu.edu/hypermail/linux/kernel/0208.1/1504.html
The Ooops occurs when the  system boots  if usb, video4linux , 
cpia and cpia_usb are compiled into the kernel.
There is no problem if they are compiled as modules.


No changes in the cpia drivers occurred when the Ooops was
introduced in 2.4.13.  usb_cpia-init() in drivers/media/video/cpia_usb.c 
calls usb_register() in drivers/usb/usb.c to register itself.   \
usb_register() calls usb_scan_devices().  The Oops occurs when
the usb list is locked  in usb_scan_devices(), by a call to 
" down (&usb_bus_list_lock);". 
The result is: "Unable to handle kernel NULL pointer dereference at 
virtual address 00000000","Oops: 0002".

If I comment out the lock, things work again. (no OOPS, cpa works).
So the problem is isolated.   Whats the fix?


Assuming this is a usb.c problem , I'm out of my depth here.


Or should some new entries to initialize something be added to
the "static struct usb_driver cpia_driver" declaration in cpia_usb.c below?
Please give me some hints on what to fix if some new initialization
in cpia_usb.c is needed since the 2.4.13 usb semaphore changes. 

Thanks!

Please cc me directly: 

duncan_haldane@users.sourceforge.net

----(drivers/media/video/cpia_usb.c)---------------
<snip>
static struct usb_driver cpia_driver = {
        name:           "cpia",
        probe:          cpia_probe,
        disconnect:     cpia_disconnect,
        id_table:       cpia_id_table,
};
<snip>
static int __init usb_cpia_init(void)
{
        cam_list = NULL;
        spin_lock_init(&cam_list_lock_usb);
        return usb_register(&cpia_driver);
}
<snip>

----(2.4.20-rc2 drivers/usb/usb.c)----------------------------

<snip>
LIST_HEAD(usb_driver_list);
LIST_HEAD(usb_bus_list);
struct semaphore usb_bus_list_lock;
<snip>

int usb_register(struct usb_driver *new_driver)
{
        if (new_driver->fops != NULL) {
                if (usb_minors[new_driver->minor/16]) {
                         err("error registering %s driver", new_driver->name);
                        return -EINVAL;
                }
                usb_minors[new_driver->minor/16] = new_driver;
        }

        info("registered new driver %s", new_driver->name);

        init_MUTEX(&new_driver->serialize);

        /* Add it to the list of known drivers */
        list_add_tail(&new_driver->driver_list, &usb_driver_list);

        usb_scan_devices();

        return 0;
}

<snip>

void usb_scan_devices(void)
{
        struct list_head *tmp;

        //      down (&usb_bus_list_lock);  <= WORKS IF THIS IS COMMENTED OUT!
        tmp = usb_bus_list.next;
        while (tmp != &usb_bus_list) {
                struct usb_bus *bus = list_entry(tmp,struct usb_bus, bus_list);

                tmp = tmp->next;
                usb_check_support(bus->root_hub);
        }
        //   up (&usb_bus_list_lock);       <= WORKS IF THIS IS COMMENTED OUT!
}

<snip>

-----------(old (working) lock in  2.4.12 drivers/usb/usb.c)--------------

rwlock_t usb_bus_list_lock = RW_LOCK_UNLOCKED;

        read_lock_irq (&usb_bus_list_lock);
         ....
        read_unlock_irq (&usb_bus_list_lock);

--------------------------------------------------------------------


----------------------------------
E-Mail: Duncan Haldane <f.duncan.m.haldane@worldnet.att.net>
Date: 13-Nov-2002
Time: 23:35:59

This message was sent by XFMail
----------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OOPS] Help needed for usb semaphore lock in 2.4.20-rc1 (since 2.4.13)
  2002-11-14  5:08 [OOPS] Help needed for usb semaphore lock in 2.4.20-rc1 (since 2.4.13) Duncan Haldane
@ 2002-11-14  5:20 ` Randy.Dunlap
  2002-11-14 16:43   ` Duncan Haldane
  0 siblings, 1 reply; 3+ messages in thread
From: Randy.Dunlap @ 2002-11-14  5:20 UTC (permalink / raw)
  To: Duncan Haldane; +Cc: linux-kernel, duncan_haldane, linux-usb-devel

| Hi,

On Thu, 14 Nov 2002, Duncan Haldane wrote:

| I am the current maintainer of the cpia webcam driver.
|
| I am tracking down a kernel Oops in 2.4.20-rc1 that was first
| introduced in 2.4.13 by usb semaphore locking changes in usb.c,
| and which was reported a while back on this list. See:
|  http://www.uwsg.iu.edu/hypermail/linux/kernel/0208.1/1504.html
| The Ooops occurs when the  system boots  if usb, video4linux ,
| cpia and cpia_usb are compiled into the kernel.
| There is no problem if they are compiled as modules.
|
|
| No changes in the cpia drivers occurred when the Ooops was
| introduced in 2.4.13.  usb_cpia-init() in drivers/media/video/cpia_usb.c
| calls usb_register() in drivers/usb/usb.c to register itself.   \
| usb_register() calls usb_scan_devices().  The Oops occurs when
| the usb list is locked  in usb_scan_devices(), by a call to
| " down (&usb_bus_list_lock);".
| The result is: "Unable to handle kernel NULL pointer dereference at
| virtual address 00000000","Oops: 0002".

It's good to have this info, but do you also have the decoded
Oops (ksymoops output)?  I'd like to see the code sequence etc.,
unless someone else just posts a patch first.  :)

| If I comment out the lock, things work again. (no OOPS, cpa works).
| So the problem is isolated.   Whats the fix?
|
|
| Assuming this is a usb.c problem , I'm out of my depth here.
|
|
| Or should some new entries to initialize something be added to
| the "static struct usb_driver cpia_driver" declaration in cpia_usb.c below?
| Please give me some hints on what to fix if some new initialization
| in cpia_usb.c is needed since the 2.4.13 usb semaphore changes.
|
| Thanks!
|
| Please cc me directly:
|
| duncan_haldane@users.sourceforge.net

Also copying linux-usb-devel@lists.sf.net .

Thanks,
-- 
~Randy
  "I read part of it all the way through." -- Samuel Goldwyn


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OOPS] Help needed for usb semaphore lock in 2.4.20-rc1 (since 2.4.13)
  2002-11-14  5:20 ` Randy.Dunlap
@ 2002-11-14 16:43   ` Duncan Haldane
  0 siblings, 0 replies; 3+ messages in thread
From: Duncan Haldane @ 2002-11-14 16:43 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: linux-kernel


On 14-Nov-2002 Randy.Dunlap wrote:
>| Hi,
> 
> On Thu, 14 Nov 2002, Duncan Haldane wrote:
> 
>| I am the current maintainer of the cpia webcam driver.
>|
>| I am tracking down a kernel Oops in 2.4.20-rc1 that was first
>| introduced in 2.4.13 by usb semaphore locking changes in usb.c,
>| and which was reported a while back on this list. See:
>|  http://www.uwsg.iu.edu/hypermail/linux/kernel/0208.1/1504.html
>| The Ooops occurs when the  system boots  if usb, video4linux ,
>| cpia and cpia_usb are compiled into the kernel.
>| There is no problem if they are compiled as modules.
>|
>|
>| No changes in the cpia drivers occurred when the Ooops was
>| introduced in 2.4.13.  usb_cpia-init() in drivers/media/video/cpia_usb.c
>| calls usb_register() in drivers/usb/usb.c to register itself.   \
>| usb_register() calls usb_scan_devices().  The Oops occurs when
>| the usb list is locked  in usb_scan_devices(), by a call to
>| " down (&usb_bus_list_lock);".
>| The result is: "Unable to handle kernel NULL pointer dereference at
>| virtual address 00000000","Oops: 0002".
> 
> It's good to have this info, but do you also have the decoded
> Oops (ksymoops output)?  I'd like to see the code sequence etc.,
> unless someone else just posts a patch first.  :)
> 
I couldn get ksymoops to give me anything useful,   there is a kernel panic
after the oops and the kernel is unbootable.  If I comment out the problematic
lock and recompile, the kernel boots, but is changed and the ksyms file doesnt
match.

This problem is reproducible in any 2.4 kernel since 2.4.13.   I tracked it
down to the lock by hacking in lots of printk 's. to see exactly where the
Oops occurred.....   The call to down() seems to invoke some inline asm code
in include/asm-i386/semaphore.h    and I can't go further to see what the
problem was.

I hope someone knowledgeable can help!
In particular, can this be fixed by initializing something in cpia_usb.c
by adding something to the declaration: 

static struct usb_driver cpia_driver = {
        name:           "cpia",
        probe:          cpia_probe,
        disconnect:     cpia_disconnect,
        id_table:       cpia_id_table,
};


Or is it completely a usb.c problem outside my scope as cpia maintainer?

For what its worth, here is a manually transcribed oops console screen:

Unable to handle kernel NULL pointer dereference at virtual address 00000000
Printing eip
c0113e0a
*pde = 00000000
Oops: 0002
CPU:  0
EIP:  0010:[<c0113e0a>]   Not tainted
EFLAGS: 00010002
eax: c0342ea8  ebx: 00000000 ecx: c143ff84  edx: c143777c
esi: 00000202  edi: c0105000 ebp: c143ff74  esp: c143ff6c
ds: 0018  es: 0018 ss:  0018
Process swapper (pid: 1, stackpage=c143f000 )
Stack: c0324ea0 c143e000 c143ff94 c0105bab 00000001 c143e000 c0324ea8 00000000 
       c02b77c0 c02e5fbc c143ffa8 c0105d27 c0324ea0 c02df2a0 c02b7710 c143ffb4
       c0204b6f c02b77c0 c143ffc0 c02019eb c02fb920 c143ffcc c02f25a7 c02b77c0
Call trace: [<c0105bab>] [<c0105d27>] [<c0204b6f>][c02019eb>][c010503b>]
            [<c0105636>] [<c0105000>] [<c0105030>]
Code: 89 0b 56 9d 5b 5e 5d c3 8d b4 26 00 00 00 00 8d bc 27 00 00
<0>Kernel panic: Attempted to kill init!


Thanks
Duncan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-14 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-14  5:08 [OOPS] Help needed for usb semaphore lock in 2.4.20-rc1 (since 2.4.13) Duncan Haldane
2002-11-14  5:20 ` Randy.Dunlap
2002-11-14 16:43   ` Duncan Haldane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).