Re: kern/163091: commit references a PR

2011-12-21 Thread dfilter service
The following reply was made to PR kern/163091; it has been noted by GNATS.

From: dfil...@freebsd.org (dfilter service)
To: bug-follo...@freebsd.org
Cc:  
Subject: Re: kern/163091: commit references a PR
Date: Wed, 21 Dec 2011 08:46:17 + (UTC)

 Author: hselasky
 Date: Wed Dec 21 08:46:08 2011
 New Revision: 228758
 URL: http://svn.freebsd.org/changeset/base/228758
 
 Log:
   Fix for race against user-space applications trying to change the
   configuration on USB HUBs.
   
   PR:  kern/163091
   MFC after:   1 week
 
 Modified:
   head/sys/dev/usb/usb_hub.c
 
 Modified: head/sys/dev/usb/usb_hub.c
 ==
 --- head/sys/dev/usb/usb_hub.c Wed Dec 21 02:45:51 2011(r228757)
 +++ head/sys/dev/usb/usb_hub.c Wed Dec 21 08:46:08 2011(r228758)
 @@ -707,6 +707,13 @@ uhub_explore(struct usb_device *udev)
DPRINTF(Device is suspended!\n);
return (0);
}
 +
 +  /*
 +   * Make sure we don't race against user-space applications
 +   * like LibUSB:
 +   */
 +  usbd_enum_lock(udev);
 +
for (x = 0; x != hub-nports; x++) {
up = hub-ports + x;
portno = x + 1;
 @@ -784,6 +791,8 @@ uhub_explore(struct usb_device *udev)
up-restartcnt = 0;
}
  
 +  usbd_enum_unlock(udev);
 +
/* initial status checked */
sc-sc_flags |= UHUB_FLAG_DID_EXPLORE;
  
 ___
 svn-src-...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
 
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: a few usb issues related to edge cases

2011-12-21 Thread Andriy Gapon
on 20/12/2011 14:25 Andriy Gapon said the following:
 I just wanted to draw your attention to the fact that obtaining any locks in 
 the
 kdb context (or USB polling code in general, even) is not a good idea.
 Chances of getting into trouble on those locks are probably quite moderate or
 even low, but they do exist.  I am not sure if you are getting any bug reports
 about such troubles :-)  Regular users probably do not use kdb too often and a
 panic for them is just a crash, so they likely do not expect anything
 usable/debuggable after that :-)

Looking some more at the code I just got myself confused as to how the dumping
to a umass device could work when the scheduler is stopped.
It seems that the umass_command_start - usbd_transfer_start -
usbd_callback_ss_done_defer functions would always put a transfer request onto a
queue and try to wake up a thread to process that queue and the request.  But
that's obviously not going to work when the other thread is not going to be run.
Have I missed a code path that leads directly to the controller in this context?
Thank you for your help.
-- 
Andriy Gapon
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: a few usb issues related to edge cases

2011-12-21 Thread Hans Petter Selasky
On Wednesday 21 December 2011 12:29:49 Andriy Gapon wrote:
 on 20/12/2011 14:25 Andriy Gapon said the following:
  I just wanted to draw your attention to the fact that obtaining any locks
  in the kdb context (or USB polling code in general, even) is not a good
  idea. Chances of getting into trouble on those locks are probably quite
  moderate or even low, but they do exist.  I am not sure if you are
  getting any bug reports about such troubles :-)  Regular users probably
  do not use kdb too often and a panic for them is just a crash, so they
  likely do not expect anything usable/debuggable after that :-)
 
 Looking some more at the code I just got myself confused as to how the
 dumping to a umass device could work when the scheduler is stopped.
 It seems that the umass_command_start - usbd_transfer_start -
 usbd_callback_ss_done_defer functions would always put a transfer request
 onto a queue and try to wake up a thread to process that queue and the
 request.  But that's obviously not going to work when the other thread is
 not going to be run. Have I missed a code path that leads directly to the
 controller in this context? Thank you for your help.

Hi,

Those threads should be polled when calling usbd_transfer_poll(). I.E. the 
wakeup should be stubbed in the !scheduler_running case.

--HPS
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: a few usb issues related to edge cases

2011-12-21 Thread Andriy Gapon
on 21/12/2011 18:38 Hans Petter Selasky said the following:
 On Wednesday 21 December 2011 12:29:49 Andriy Gapon wrote:
 on 20/12/2011 14:25 Andriy Gapon said the following:
 I just wanted to draw your attention to the fact that obtaining any locks
 in the kdb context (or USB polling code in general, even) is not a good
 idea. Chances of getting into trouble on those locks are probably quite
 moderate or even low, but they do exist.  I am not sure if you are
 getting any bug reports about such troubles :-)  Regular users probably
 do not use kdb too often and a panic for them is just a crash, so they
 likely do not expect anything usable/debuggable after that :-)

 Looking some more at the code I just got myself confused as to how the
 dumping to a umass device could work when the scheduler is stopped.
 It seems that the umass_command_start - usbd_transfer_start -
 usbd_callback_ss_done_defer functions would always put a transfer request
 onto a queue and try to wake up a thread to process that queue and the
 request.  But that's obviously not going to work when the other thread is
 not going to be run. Have I missed a code path that leads directly to the
 controller in this context? Thank you for your help.
 
 Hi,
 
 Those threads should be polled when calling usbd_transfer_poll(). I.E. the 
 wakeup should be stubbed in the !scheduler_running case.

Ah, that's what I missed!

-- 
Andriy Gapon
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org