From: Phil Turmel <philip-xiX+HWoRdKcdnm+yROfE0A@public.gmane.org>
To: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>
Cc: Alan Stern
<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
Mat <jackdachef-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Guillaume Chazarain
<guichaz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Greg Kroah-Hartman <gregkh-l3A5Bk7waGM@public.gmane.org>,
Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>,
Alan Ott <alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andreas Bombe <aeb-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>,
Alex Riesen <raa.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Gabriel C <nix.or.die-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
Heinz Diehl <htd-iEI8Y0CNJBYdnm+yROfE0A@public.gmane.org>
Subject: Re: [BUG, Regression, bisected] USB mouse causes bug on 1st insert, ignored on 2nd insert, lsusb stuck at usbdev_open
Date: Tue, 21 Sep 2010 10:42:10 -0400 [thread overview]
Message-ID: <4C98C442.8030305@turmel.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1009211638450.26813-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
On 09/21/2010 10:40 AM, Jiri Kosina wrote:
> On Tue, 21 Sep 2010, Alan Stern wrote:
>
>> On Tue, 21 Sep 2010, Jiri Kosina wrote:
>>
>>> I have just found out that it's actually CONFIG_USB_DYNAMIC_MINORS which
>>> makes the difference. When unset, the problem doesn't trigger, and
>>> usb_find_interface() always returns the proper interface. When
>>> CONFIG_USB_DYNAMIC_MINORS is being used, the oops happen.
>>>
>>> I'll look into that.
>>
>> Apparently the problem is that intf->minors doesn't get initialized
>> properly. This patch should fix it. Everybody, please try it out.
>>
>> Alan Stern
>>
>>
>> Index: usb-2.6/drivers/usb/core/file.c
>> ===================================================================
>> --- usb-2.6.orig/drivers/usb/core/file.c
>> +++ usb-2.6/drivers/usb/core/file.c
>> @@ -159,9 +159,9 @@ void usb_major_cleanup(void)
>> int usb_register_dev(struct usb_interface *intf,
>> struct usb_class_driver *class_driver)
>> {
>> - int retval = -EINVAL;
>> + int retval;
>> int minor_base = class_driver->minor_base;
>> - int minor = 0;
>> + int minor;
>> char name[20];
>> char *temp;
>>
>> @@ -173,12 +173,17 @@ int usb_register_dev(struct usb_interfac
>> */
>> minor_base = 0;
>> #endif
>> - intf->minor = -1;
>> -
>> - dbg ("looking for a minor, starting at %d", minor_base);
>>
>> if (class_driver->fops == NULL)
>> - goto exit;
>> + return -EINVAL;
>> + if (intf->minor >= 0)
>> + return -EADDRINUSE;
>> +
>> + retval = init_usb_class();
>> + if (retval)
>> + return retval;
>> +
>> + dev_dbg(&intf->dev, "looking for a minor, starting at %d", minor_base);
>>
>> down_write(&minor_rwsem);
>> for (minor = minor_base; minor < MAX_USB_MINORS; ++minor) {
>> @@ -186,20 +191,12 @@ int usb_register_dev(struct usb_interfac
>> continue;
>>
>> usb_minors[minor] = class_driver->fops;
>> -
>> - retval = 0;
>> + intf->minor = minor;
>> break;
>> }
>> up_write(&minor_rwsem);
>> -
>> - if (retval)
>> - goto exit;
>> -
>> - retval = init_usb_class();
>> - if (retval)
>> - goto exit;
>> -
>> - intf->minor = minor;
>> + if (intf->minor < 0)
>> + return -EXFULL;
>>
>> /* create a usb class device for this usb interface */
>> snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
>> @@ -212,12 +209,12 @@ int usb_register_dev(struct usb_interfac
>> MKDEV(USB_MAJOR, minor), class_driver,
>> "%s", temp);
>> if (IS_ERR(intf->usb_dev)) {
>> + retval = PTR_ERR(intf->usb_dev);
>> down_write(&minor_rwsem);
>> - usb_minors[intf->minor] = NULL;
>> + usb_minors[minor] = NULL;
>> + intf->minor = -1;
>> up_write(&minor_rwsem);
>> - retval = PTR_ERR(intf->usb_dev);
>> }
>> -exit:
>> return retval;
>> }
>> EXPORT_SYMBOL_GPL(usb_register_dev);
>> Index: usb-2.6/drivers/usb/core/message.c
>> ===================================================================
>> --- usb-2.6.orig/drivers/usb/core/message.c
>> +++ usb-2.6/drivers/usb/core/message.c
>> @@ -1803,6 +1803,7 @@ free_interfaces:
>> intf->dev.groups = usb_interface_groups;
>> intf->dev.dma_mask = dev->dev.dma_mask;
>> INIT_WORK(&intf->reset_ws, __usb_queue_reset_device);
>> + intf->minor = -1;
>> device_initialize(&intf->dev);
>> dev_set_name(&intf->dev, "%d-%s:%d.%d",
>> dev->bus->busnum, dev->devpath,
>
> [ adding Heinz to CC ]
>
> If USB core would guarantee the initialization of intf->minor to -1, that
> would be of course nicer than having to do it myself in the driver (which
> is exactly what my previous patch has been doing).
>
> So everyone please test Alan's patch rather than mine, as it is more
> general.
>
For what it's worth, I just finished testing yours, and it works just fine. I'll try Alan's now.
Phil
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-09-21 14:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-20 1:33 [BUG, Regression, bisected] USB mouse causes bug on 1st insert, ignored on 2nd insert, lsusb stuck at usbdev_open Phil Turmel
2010-09-20 9:43 ` Guillaume Chazarain
2010-09-20 10:47 ` Phil Turmel
2010-09-20 12:42 ` Jiri Kosina
2010-09-20 13:19 ` Phil Turmel
2010-09-20 13:25 ` Jiri Kosina
2010-09-20 13:56 ` Mat
2010-09-20 15:10 ` Jiri Kosina
2010-09-20 17:05 ` Mat
2010-09-20 17:40 ` Phil Turmel
2010-09-21 12:31 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1009211156520.26813-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-09-21 13:57 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1009211556200.26813-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-09-21 14:48 ` Heinz Diehl
2010-09-21 14:55 ` Jiri Kosina
2010-09-21 14:30 ` Alan Stern
2010-09-21 14:40 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1009211638450.26813-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-09-21 14:42 ` Phil Turmel [this message]
2010-09-21 14:54 ` Phil Turmel
[not found] ` <4C98C70B.3080407-xiX+HWoRdKcdnm+yROfE0A@public.gmane.org>
2010-09-21 16:08 ` Gabriel C
2010-09-22 9:47 ` Mat
[not found] ` <AANLkTinQVNy4yOSW=aEbuYh6b_F8nKBLxsjxBDk8zq8O-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-09-24 16:46 ` Greg KH
2010-09-21 16:50 ` Greg KH
[not found] ` <20100921165048.GB8756-l3A5Bk7waGM@public.gmane.org>
2010-09-21 16:55 ` Jiri Kosina
2010-09-21 17:07 ` Greg KH
2010-09-21 17:14 ` Jiri Kosina
2010-09-20 20:55 ` Alan Stern
2010-09-20 22:48 ` Jiri Kosina
2010-09-21 0:41 ` Andreas Bombe
2010-09-20 14:11 ` Phil Turmel
[not found] ` <4C96B9DB.8030403-xiX+HWoRdKcdnm+yROfE0A@public.gmane.org>
2010-09-20 19:35 ` Maciej Rutecki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C98C442.8030305@turmel.org \
--to=philip-xix+hwordkcdnm+yrofe0a@public.gmane.org \
--cc=aeb-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org \
--cc=alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org \
--cc=gregkh-l3A5Bk7waGM@public.gmane.org \
--cc=guichaz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=htd-iEI8Y0CNJBYdnm+yROfE0A@public.gmane.org \
--cc=jackdachef-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nix.or.die-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org \
--cc=oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org \
--cc=raa.lkml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).