Re: [PATCH] usb: host: ehci: workaround PME bug on AMD EHCI controller

2017-06-14 Thread Alan Stern
On Tue, 13 Jun 2017, Bjorn Helgaas wrote: > [+cc Rafael, linux-pm] > > On Tue, Jun 13, 2017 at 12:21:15PM +0800, Kai-Heng Feng wrote: > > On Mon, Jun 12, 2017 at 10:18 PM, Alan Stern > > wrote: > > > Let's get some help from people who understand PCI w

Re: [PATCH] usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable

2017-06-14 Thread Alan Stern
t; > - if (retval < 0) > + if (retval < 0) { > + clk_disable_unprepare(pxa_ohci->clk); > return retval; > + } > > if (cpu_is_pxa3xx()) > pxa3xx_u2d_start_hc(&hcd->self); Aside from that one issue, Acked-by: Alan Stern Alan Stern

Re: usb/gadget: potential deadlock in gadgetfs_suspend

2017-06-13 Thread Alan Stern
xception > Shutting down cpus with NMI > Dumping ftrace buffer: >(ftrace buffer empty) > Kernel Offset: disabled > Rebooting in 86400 seconds.. I guess the structure containing the spinlock was already deallocated when gadgetfs_disconnect was called. But I don't see how that coul

Re: gadgetfs: how to wait for USB device initialization?

2017-06-13 Thread Alan Stern
y simple approach, just wait a fixed amount of time, like 10 seconds. Unless the system is highly loaded or probing takes a lot longer than usual, that should be enough. Alan Stern > To mount and unmount gadgetfs right now I do: > mount("none", "/dev/gadget", "gadgetfs", 0, NULL) > umount2("/dev/gadget", MNT_FORCE | MNT_DETACH) > > Thanks!

Re: usb/gadget: potential deadlock in gadgetfs_suspend

2017-06-12 Thread Alan Stern
clears dum->driver while the second dereferences it, and neither access is protected by a lock. It turns out this problem affects at least one other UDC driver (net2280.c). Below is a patch that adds the missing lock (and removes some unneeded unlocks) from these drivers. It turns out that the

Re: [PATCH] usb: host: ehci: workaround PME bug on AMD EHCI controller

2017-06-12 Thread Alan Stern
/marc.info/?l=linux-usb&m=149570231732519&w=2 On Mon, 12 Jun 2017, Kai-Heng Feng wrote: > On Mon, Jun 12, 2017 at 3:04 PM, Kai-Heng Feng > wrote: > > On Fri, Jun 9, 2017 at 10:43 PM, Alan Stern > > wrote: > >> On Fri, 9 Jun 2017, Kai-Heng Feng wrote: > >&

Re: [PATCH] usb: host: ehci-exynos: Handle return value of clk_prepare_enable

2017-06-12 Thread Alan Stern
= to_exynos_ehci(hcd); > int ret; > > - clk_prepare_enable(exynos_ehci->clk); > + ret = clk_prepare_enable(exynos_ehci->clk); > + if (ret) > + return ret; > > ret = exynos_ehci_phy_enable(dev); > if (ret) { Acked-by: Alan Stern

Re: usb/gadget: potential deadlock in gadgetfs_suspend

2017-06-09 Thread Alan Stern
core/hub.c:5105 [inline] > > hub_event+0xa0b/0x16e0 drivers/usb/core/hub.c:5189 > > process_one_work+0x1fb/0x4c0 kernel/workqueue.c:2097 > > process_scheduled_works kernel/workqueue.c:2157 [inline] > > worker_thread+0x2ab/0x4c0 kernel/workqueue.c:2233 > > kthread+0x140/0x160 kernel/kthread.c:231 > > ret_from_fork+0x25/0x30 arch/x86/entry/entry_64.S:424 > > Code: 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 0f 1f 44 00 00 ba > > 01 00 00 00 8b 07 85 c0 75 0a f0 0f b1 17 85 c0 75 f2 5d c3 f3 90 > > ec 81 fe 00 01 00 00 0f 84 92 00 00 00 41 b8 01 01 00 00 b9 Alan Stern

Re: [PATCH 0/3] USB: add API for interface driver to vote for autosuspend

2017-06-09 Thread Alan Stern
ce drivers are generally not supposed to enable or disable autosuspend -- that is a policy decision left up to userspace. There are a few exceptions for things like hubs, but this is generally true. Why should the USB digital audio driver want to enable autosuspend? Alan Stern

Re: [PATCH] usb: host: ehci: workaround PME bug on AMD EHCI controller

2017-06-09 Thread Alan Stern
On Fri, 9 Jun 2017, Kai-Heng Feng wrote: > As Alan Stern points out [1], the PME signal is not enabled when > controller is in D3, therefore it's not being woken up when new deivces > get plugged in. > > Workaround this bug by preventing the controller enters D3 power s

Re: usb/gadget: another GPF in usb_gadget_unregister_driver

2017-06-08 Thread Alan Stern
On Thu, 8 Jun 2017, Andrey Konovalov wrote: > On Wed, Jun 7, 2017 at 11:20 PM, Alan Stern wrote: > > On Wed, 7 Jun 2017, Andrey Konovalov wrote: > > > >> On Wed, Jun 7, 2017 at 4:43 PM, Alan Stern > >> wrote: > >> > On Wed, 7 Jun 20

Re: [PATCH 2/6] USB / PCI / PM: Allow the PCI core to do the resume cleanup

2017-06-08 Thread Alan Stern
e remote wakeup */ > - pci_back_from_sleep(pci_dev); > + powermac_set_asic(to_pci_dev(dev), 1); > return 0; > } Acked-by: Alan Stern

Re: usb/gadget: another GPF in usb_gadget_unregister_driver

2017-06-07 Thread Alan Stern
On Wed, 7 Jun 2017, Andrey Konovalov wrote: > On Wed, Jun 7, 2017 at 4:43 PM, Alan Stern wrote: > > On Wed, 7 Jun 2017, Andrey Konovalov wrote: > > > >> Hi, > >> > >> I've got the following error report while fuzzing the k

Re: usb/gadget: another GPF in usb_gadget_unregister_driver

2017-06-07 Thread Alan Stern
d. Can you provide an strace or the equivalent? Alan Stern

Re: [PATCH v14 4/7] usb: core: add power sequence handling for USB devices

2017-06-05 Thread Alan Stern
afael > is waiting for USB MAINTAINERS's comments or ack. It resolves some > USB HUB issues for several persons. > > Peter > > > Signed-off-by: Peter Chen > > Tested-by Joshua Clayton > > Tested-by: Maciej S. Szmigiero >

Re: Asmedia USB 1343 crashes

2017-05-03 Thread Alan Stern
I host not responding to stop > endpoint command. > [294504.576805] xhci_hcd :02:00.0: Assuming host is dying, halting host. At this point you have reached the limit of my knowledge. The best person to help is Mathias Nyman, the xHCI maintainer (CC'ed). Is that WARNING at the start of the log connected with the later events? Alan Stern

Re: [PATCH v2] usb: gadget: udc: add null check before pointer dereference

2017-05-02 Thread Alan Stern
On Tue, 2 May 2017, Gustavo A. R. Silva wrote: > Add null check before dereferencing dev->regs pointer inside > net2280_led_shutdown() function. > > Addresses-Coverity-ID: 101783 > Cc: Alan Stern > Signed-off-by: Gustavo A. R. Silva > --- > Changes in v2: >

Re: [PATCH] usb: host: remove unnecessary null check

2017-05-02 Thread Alan Stern
On Tue, 2 May 2017, Gustavo A. R. Silva wrote: > Remove unnecessary null check. udev->tt cannot ever be NULL when this > section of code runs. > > Addresses-Coverity-ID: 100828 > Cc: Alan Stern > Signed-off-by: Gustavo A. R. Silva > --- > drivers/usb/host/ehci-sched

Re: [PATCH] usb: gadget: udc: add null check before pointer dereference

2017-05-02 Thread Alan Stern
pdev, 0)); No, you must not move the iounmap() call, because an interrupt could theoretically occur at any time. Either just live with an extra test of dev->regs, or else move the net2280_led_shutdown() call later. Alan Stern

Re: [usb-host] question about pointer dereference before null check

2017-05-02 Thread Alan Stern
r sure, so in case dev->tt is NULL, a good strategy > to properly update the _addr_ variable would be needed. > > What do you think? > > I would really appreciate any comment on this, > Thank you! You are right; udev->tt cannot ever be NULL when this section of code runs. The test should be removed. Alan Stern

Re: Asmedia USB 1343 crashes

2017-05-01 Thread Alan Stern
On Mon, 1 May 2017, Thomas Fjellstrom wrote: > On Monday, May 1, 2017 10:54:12 AM MDT Alan Stern wrote: > > On Mon, 1 May 2017, Thomas Fjellstrom wrote: > > > I've got a 970 Pro gaming aura motherboard with an Asmedia 1343 Usb 3.1 > > > controller. It's

Re: Asmedia USB 1343 crashes

2017-05-01 Thread Alan Stern
nsistently is: > > usbfs: process did not claim interface 0 before use This warning message is not related to the Asmedia controller. It refers to some program running on the computer, and the same message would appear no matter what sort of controller was being used. Alan Stern > Lat

Re: [PATCH v2] usb: core: Warn if an URB's transfer_buffer is on stack

2017-04-24 Thread Alan Stern
hat > urb->transfer_buffer is not a stack object. > > Signed-off-by: Florian Fainelli > --- > Changes in v2: > > - moved the check from usb_start_wait_urb() to usb_hcd_map_urb_for_dma() You probably should add a similar check to the pathway that maps urb->setup_packet, for

Re: [PATCH] usb: core: Warn if an URB's transfer_buffer is on stack

2017-04-23 Thread Alan Stern
the DMA mapping (it might use PIO for some types of transfer). In those cases we don't want to issue the warning. So perhaps usb_hcd_map_urb_for_dma() would be better for both checks. Alan Stern

Re: [PATCH] usb: core: Warn if an URB's transfer_buffer is on stack

2017-04-23 Thread Alan Stern
On Sun, 23 Apr 2017, Greg Kroah-Hartman wrote: > On Sat, Apr 22, 2017 at 05:31:27PM -0400, Alan Stern wrote: > > On Sat, 22 Apr 2017, Florian Fainelli wrote: > > > > > We see a large number of fixes to several drivers to remove the usage of > > > on-stack

Re: [PATCH] usb: core: Warn if an URB's transfer_buffer is on stack

2017-04-22 Thread Alan Stern
urb->actual_length = 0; Does this really help? I mean, don't we already get warnings when the host controller drivers try to map on-stack buffers for DMA? The only difference is that one wouldn't have to read as far back into the stack trace. But that hardly seems like an important consideration. Alan Stern

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-12 Thread Alan Stern
refore the struct device is located in dynamically allocated memory. > Now, if this kzalloc() would be replaced with devm_kzalloc() wouldn't > this result on a functionally equivalent execution to the patch I > proposed above? It would, and it would be equally wrong. Alan Stern

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-11 Thread Alan Stern
ase callback, deallocating the private data structure without > > giving the caller (i.e., the UDC driver) a chance to clean up. > > it won't deallocate anything :-) dev_set_drvdata() was never called, > we will endup with kfree(NULL) which is safe and just silently returns. But if you change gadget_release() to use the parent's drvdata field, like you proposed earlier, and fix up the refcounting in net2280_remove() so that the structure doesn't get deallocated too quickly, then this does become a real problem. And it can affect other UDC drivers, not just net2280. Alan Stern

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Felipe Balbi wrote: > Hi, > > Alan Stern writes: > > On Wed, 5 Apr 2017, Felipe Balbi wrote: > > > >> >> >> --- a/drivers/usb/gadget/udc/core.c > >> >> >> +++ b/drivers/usb/gadget/udc/core.c > >&g

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-05 Thread Alan Stern
ng "dev"... IIRC, at one time he had a line of code that went something like: dev->dev.dev = &pdev->dev !) > >> I'm actually thinking that struct usb_gadget shouldn't have a struct > >> device at all. Just a pointer to a device, that would solve all these > >> issues. > > > > A pointer to which device? The UDC? That would change the directory > > layout in sysfs. > > indeed. Would that be a problem? Possibly for some userspace tool. > > Or a pointer to a separate dynamically allocated device (the way struct > > usb_hcd contains a pointer to the root hub device)? That would work. > > If the UDC driver wanted to re-register the gadget, it would have to > > allocate a new device. > > That could be done as well, if maintaining the directory structure is a > must. Alan Stern

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-04 Thread Alan Stern
On Tue, 4 Apr 2017, Felipe Balbi wrote: > Hi, > > Alan Stern writes: > > On Mon, 3 Apr 2017, Roger Quadros wrote: > > > >> allow usb_del_gadget_udc() and usb add_gadget_udc() to be called > >> repeatedly on the same gadget->dev structure. > >>

Re: [PATCH v2 2/2] usb: misc: refactor code

2017-04-04 Thread Alan Stern
On Mon, 3 Apr 2017, Gustavo A. R. Silva wrote: > Code refactoring to make the flow easier to follow. > > Cc: Alan Stern > Cc: Greg Kroah-Hartman > Signed-off-by: Gustavo A. R. Silva > --- > Changes in v2: > Remove unfruitful changes in previous patch. > Revert c

Re: [PATCH 2/2] usb: misc: refactor code

2017-04-03 Thread Alan Stern
On Mon, 3 Apr 2017, Gustavo A. R. Silva wrote: > Code refactoring to make the flow easier to follow. > > Cc: Alan Stern > Cc: Greg Kroah-Hartman > Signed-off-by: Gustavo A. R. Silva > --- > drivers/usb/misc/usbtest.c | 67 > +---

Re: [PATCH] usb: misc: add missing continue and refactor code

2017-04-03 Thread Alan Stern
hings in the same patch, please make these multiple > patches. And do the "add missing continue" first, so it can be > backported to other kernels easier please. Also, make sure your patch does not contain gratuitous whitespace changes. Alan Stern

Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device

2017-04-03 Thread Alan Stern
new memset will oops. In general, if an object relies on reference counting for its lifetime, you cannot register and unregister it more than once. A typical issue is that some code retains a reference to the old instance and tries to use it after the new instance has been registered, thereby m

Re: [PATCH 1/3] usb: pci-quirks: Add a header for SB800 I/O ports and mutex for locking

2017-04-01 Thread Alan Stern
gt; > +#define SB800_PIIX4_SMB_IDX0xcd6 > > +#define SB800_PIIX4_SMB_DATA 0xcd7 > > + > > +extern struct mutex sb800_mutex; > > + > > +#define enter_sb800() mutex_lock(&sb800_mutex) > > +#define leave_sb800() mutex_unlock

Re: usb: use-after-free write in usb_hcd_link_urb_to_ep

2017-03-24 Thread Alan Stern
On Fri, 24 Mar 2017, Dmitry Vyukov wrote: > On Thu, Mar 23, 2017 at 4:22 PM, Dmitry Vyukov wrote: > >> On Thu, 23 Mar 2017, Dmitry Vyukov wrote: > >> > >>> > Putting these together: > >>> > > >>> > The memory was allocated in usb_internal_control_msg() line 93. > >>> > The later e

Re: usb: use-after-free write in usb_hcd_link_urb_to_ep

2017-03-23 Thread Alan Stern
deallocated separately for each call. You can see this very plainly by reading the source code for usb_internal_control_msg() and usb_start_wait_urb(). It's possible that the same memory location was allocated and deallocated for two different calls at different times. That wouldn't fool syzkaller, would it? Alan Stern

Re: usb: use-after-free write in usb_hcd_link_urb_to_ep

2017-03-23 Thread Alan Stern
On Thu, 23 Mar 2017, Dmitry Vyukov wrote: > Hello, > > I've got the following report while running syzkaller fuzzer on > 093b995e3b55a0ae0670226ddfcb05bfbf0099ae. Not the preceding injected > kmalloc failure, most likely it's the root cause. I find this bug report puzzling. Maybe I don't unders

Re: [PATCH v2] ohci-pci: add qemu quirk

2017-03-21 Thread Alan Stern
+418,7 @@ struct ohci_hcd { > #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL > quirk*/ > #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch > for ISO transfer */ > #define OHCI_QUIRK_GLOBAL_SUSPEND 0x800 /* must suspend > ports */ > +#define OHCI_QUIRK_QEMU 0x1000 /* relax timing > expectations */ > > // there are also chip quirks/bugs in init logic Signed-off-by: Alan Stern

Re: [PATCH v2] usb: hub: Do not attempt to autosuspend disconnected devices

2017-03-20 Thread Alan Stern
> + > dev_info(&udev->dev, "USB disconnect, device number %d\n", > udev->devnum); > Very minor nit: I would place the pm_runtime_barrier() after the dev_info(), so that we would know the device is going away if anything should go wrong during the barrier call. Aside from that, Acked-by: Alan Stern Alan Stern

Re: [RFC PATCH] usb: hub: Disable autosuspend before disabling usb device

2017-03-17 Thread Alan Stern
hink the right thing to do is test udev->state at the start of autosuspend_check(), much like the test at the start of usb_suspend_both(). udev->state gets set to USB_STATE_NOTATTACHED in usb_disconnect() before usb_disable_device() is called. Then there will be no need for usb_disab

Re: EHCI

2017-03-17 Thread Alan Stern
with interrupts disabled. You probably should release the spinlock and enable interrupts during the handshake. Have you seen any errors with the current 1000 us value? If you haven't, there's no reason to change the code. Alan Stern

Re: [PATCH v3] usb: hub: Fix error loop seen after hub communication errors

2017-03-17 Thread Alan Stern
s still accessible if the error returned > from hub_port_status() is -EBUSY. > v2: Instead of not triggering the hub wq after an error to submit an urb, > implement a more complex error detection and handling. Do it in two > places. Marked as RFC to determine if one (or both

Re: Dell Inspiron 5558/0VNM2T hangs at resume from suspend when USB 3 is enabled

2017-03-17 Thread Alan Stern
n trying to resume from suspend. > > https://bugzilla.kernel.org/attachment.cgi?id=255309 I'm not an expert on xHCI. This should be CC'ed to the xhci-hcd maintainer. Alan Stern > > Please let me know if I should provide something else. > > Thanks, > Diego >

Re: Dell Inspiron 5558/0VNM2T hangs at resume from suspend when USB 3 is enabled

2017-03-16 Thread Alan Stern
iego > >>> > >>> Hello, > >>> > >>> I've found something interesting and what it seems to be the cause of > >>> my problem. > >>> > >>> As soon as I boot my system I can see this process being in the D-state: >

Re: [RFC PATCH v2] usb: hub: Fix error loop seen after hub communication errors

2017-03-15 Thread Alan Stern
} > + } > + > if (udev || (portstatus & USB_PORT_STAT_CONNECTION)) > dev_dbg(&port_dev->dev, "status %04x change %04x\n", > portstatus, portchange); > @@ -1198,7 +1211,7 @@ static void hub_activate(struct usb_hub *hub, enum > hub_activation_type type) > > /* Scan all ports that need attention */ > kick_hub_wq(hub); > - > +abort: > if (type == HUB_INIT2 || type == HUB_INIT3) { > /* Allow autosuspend if it was suppressed */ > disconnected: On the whole, this looks very good. Alan Stern

Re: [PATCH v2 13/14] usb: host: ehci-st: simplify optional reset handling

2017-03-15 Thread Alan Stern
d code sets priv->pwr or priv->rst to NULL and continues; the new code returns with an error. The only way the patch could be equivalent to the existing code would be if devm_reset_control_get_optional_shared() returns no errors other than EPROBE_DEFER. But the patch description doesn't say this. Alan Stern

Re: [PATCH] ohci-pci: add qemu quirk

2017-03-14 Thread Alan Stern
- a/drivers/usb/host/ohci.h > +++ b/drivers/usb/host/ohci.h > @@ -418,6 +418,7 @@ struct ohci_hcd { > #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL > quirk*/ > #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch > for ISO transfer */ > #define OHCI_QUIRK_GLOBAL_SUSPEND 0x800 /* must suspend > ports */ > +#define OHCI_QUIRK_QEMU 0x1000 /* relax timing > expectations */ > > // there are also chip quirks/bugs in init logic Aside from that minor point, Acked-by: Alan Stern Alan Stern

Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk

2017-03-13 Thread Alan Stern
On Mon, 13 Mar 2017, Samuel Thibault wrote: > Alan Stern, on dim. 12 mars 2017 21:40:33 -0400, wrote: > > On Sun, 12 Mar 2017, Dave Mielke wrote: > > > [quoted lines by Alan Stern on 2017/03/12 at 21:31 -0400] > > > > > > >A device's speed is o

Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk

2017-03-13 Thread Alan Stern
On Sun, 12 Mar 2017, Dave Mielke wrote: > [quoted lines by Alan Stern on 2017/03/12 at 21:40 -0400] > > >No, I was wondering why an HID device would run at high speed. Both > >you and Samuel implied that this was because it was a USB-2 device. > >But that is not an ade

Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk

2017-03-12 Thread Alan Stern
On Sun, 12 Mar 2017, Dave Mielke wrote: > [quoted lines by Alan Stern on 2017/03/12 at 21:31 -0400] > > >A device's speed is only partially related to its USB version. A > >USB-1.1 device can run at low speed or full speed. A USB-2 device can > >run at low, full

Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk

2017-03-12 Thread Alan Stern
On Sun, 12 Mar 2017, Dave Mielke wrote: > [quoted lines by Alan Stern on 2017/03/12 at 17:18 -0400] > > >Interesting. This is a high-speed device that mistakenly uses the > >low/full-speed encoding for an interrupt bInterval value? > > Yes. > > >That&#x

Re: [PATCHv2] usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk

2017-03-12 Thread Alan Stern
R_FRAME_INTR_BINTERVAL }, > + { USB_DEVICE(0x0904, 0x6102), .driver_info = > + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, > + { USB_DEVICE(0x0904, 0x6103), .driver_info = > + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, > + > /* Keytouch QWERTY Panel keyboard */ > { USB_DEVICE(0x0926, 0x), .driver_info = > USB_QUIRK_CONFIG_INTF_STRINGS }, Acked-by: Alan Stern

Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk

2017-03-12 Thread Alan Stern
gt; + USB_QUIRK_MS_INTR_BINTERVAL }, > + { USB_DEVICE(0x0904, 0x6102), .driver_info = > + USB_QUIRK_MS_INTR_BINTERVAL }, > + { USB_DEVICE(0x0904, 0x6103), .driver_info = > + USB_QUIRK_MS_INTR_BINTERVAL }, You didn't read the comment at the start of the file.

Re: [PATCH] usb: hub: Fix error loop seen after hub communication errors

2017-03-10 Thread Alan Stern
(It would be interesting to know exactly at which point usb_port_suspend fails during your test. And why didn't your system mark the hub as disconnected when the host controller was unbound?) An even worse problem is what to do when the device is working okay but runtime suspend still fails (for example, if remote wakeup cannot be enabled). How do we prevent the system from going into a similar loop then? Alan Stern

Re: [PATCH v4 1/3] usb: orion-echi: Add support for the Armada 3700

2017-03-09 Thread Alan Stern
; [gregory.clem...@free-electrons.com: - reword commit and comments >- fix error path in ehci_orion_drv_reset() >- fix checkpatch warning] > Signed-off-by: Hua Jing > Signed-off-by: Gregory CLEMENT > Reviewed-by

Re: [PATCH v2 1/3] usb: orion-echi: Add support for the Armada 3700

2017-03-09 Thread Alan Stern
here's no good reason to add it. > + > + /* > + * For SoC without hlock, need to program sbuscfg value to guarantee > + * AHB master's burst would not overrun or underrun FIFO. > + * > + * sbuscfg reg has to be set after usb controller reset, otherwise > + * t

Re: Subject: [PATCH v4] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-03-07 Thread Alan Stern
>kref, release_usb_class); > + mutex_unlock(&init_usb_class_mutex); > } > > int usb_major_init(void) > @@ -171,7 +173,10 @@ int usb_register_dev(struct usb_interface *intf, > if (intf->minor >= 0) > return -EADDRINUSE; > > + mutex_lock(&init_usb_class_mutex); > retval = init_usb_class(); > + mutex_unlock(&init_usb_class_mutex); > + > if (retval) > return retval; Acked-by: Alan Stern Alan Stern

Re: FW: FW: RE: Re: FW: RE: Re: Subject: [PATCH v3] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-03-03 Thread Alan Stern
does destroy_usb_class() have that "if (usb_class) "test? Isn't it true that usb_class can never be NULL there? Alan Stern > thanks, > ajay kaher >   >   > Signed-off-by: Ajay Kaher >   > --- >   >  drivers/usb/core/file.c |6 ++ >  1 file changed

Re: [PATCH] hid: usbhid: usbkbd: fix checkpatch.pl issues

2017-03-01 Thread Alan Stern
On Wed, 1 Mar 2017, Avraham Shukron wrote: > I thought fixing a driver that I actually use daily will be more satisfying. Unless there are special reasons, you should not be using the usbkbd driver. It is legacy code; everyone should now use usbhid instead. Alan Stern

Re: FW: RE: Re: Subject: [PATCH v3] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-03-01 Thread Alan Stern
as per your inputs to prevent > the race condition during simultaneously calling of init_usb_class(). > If you think there is scope to improve the patch, please share your inputs. Under the circumstances, your patch is acceptable. If you really want to make the point crystal clear, you could rep

Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase

2017-02-28 Thread Alan Stern
On Tue, 28 Feb 2017, Felipe Balbi wrote: > > Hi, > > Alan Stern writes: > >> So I am not sure how the Gadget driver can figure out that it needs to > >> usb_ep_queue() another request for status stage when handling the > >> no-data control? > >

Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase

2017-02-27 Thread Alan Stern
hase > later. > > So I am not sure how the Gadget driver can figure out that it needs to > usb_ep_queue() another request for status stage when handling the > no-data control? Gadget drivers already queue status-stage requests for no-data control-OUT requests. The difficulty comes when you want to handle an IN request or an OUT request with a data stage. Alan Stern

Re: [PATCH] usb: misc: add a missing continue and refactor code

2017-02-21 Thread Alan Stern
On Tue, 21 Feb 2017, Gustavo A. R. Silva wrote: > Code refactoring to make the flow easier to follow and add missing > 'continue' for case USB_ENDPOINT_XFER_INT. > > Addresses-Coverity-ID: 1248733 > Cc: Alan Stern > Signed-off-by: Gustavo A. R. Silva > --- >

Re: Subject: [PATCH v3] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-02-20 Thread Alan Stern
till holding a reference to usb_class? And what if the last reference gets dropped later on, while init_usb_class() is running? Maybe that's not possible here, but it is possible in general for refcounted objects. So yes, this code is probably okay, but it isn't good form. Alan Stern

RE: RE: Re: Re: Re: Subject: [PATCH v2] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-02-16 Thread Alan Stern
On Thu, 16 Feb 2017, Ajay Kaher wrote: > > On Thu, 14 Feb 2017, Alan Stern wrote: > >  > > I think Ajay's argument is correct and a patch is needed.  But this > > patch misses the race between init_usb_class() and release_usb_class().   > > Thanks Alan for your

Re: [usb-storage] [PATCH] usb: storage: add missing pre-increment to variable

2017-02-15 Thread Alan Stern
amp; (++waitcount < > 10)); > > if (result != USB_STOR_TRANSPORT_GOOD) > usb_stor_dbg(us, "Gah! Waitcount = 10. Bad > write!?\n"); > This has already been reported and fixed. See http://marc.info/?l=linux-usb&m=148604164024557&w=2 Alan Stern

Re: v4.10-rc8 (-rc6) boot regression on Intel desktop, does not boot after cold boots, boots after reboot

2017-02-14 Thread Alan Stern
I fixup... pass 3 done > > > > ...followed by hang. So yes, it looks USB related. > > > > (Sometimes it hangs with some kind backtrace involving secondary CPU > > startup, unfortunately useful info is off screen at that point). > > Forgot to say, 1d.7 is EHCI controller. > > 00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI > Controller (rev 01) So this looks like a problem in the PCI subsystem affecting a USB controller. Linus is right; bisection is the best approach now that you know a reliable trigger. Alan Stern

RE: Re: Re: Re: Subject: [PATCH v1] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

2017-02-14 Thread Alan Stern
  > ajay kaher > > > Signed-off-by: Ajay Kaher I think Ajay's argument is correct and a patch is needed. But this patch misses the race between init_usb_class() and release_usb_class(). The basic problem is that reference counting doesn't work when you try to use the same global pointer (usb_class) to refer to multiple generations of a dynamically allocated entity. We had the same sort of problem many years ago with the usb_interface structure (and we ultimately fixed it by creating a separate usb_interface_cache structure). The best approach here would be to forget about all the reference counting. Get rid of usb_class entirely, and create the "usbmisc" class structure just once, when usbcore initializes. Or, if you prefer, use a mutex to protect a routine that allocates the class structure dynamically, just once. Either way, don't deallocate it until usbcore is unloaded. Alan Stern

Re: Question about DEC Alpha memory ordering

2017-02-13 Thread Alan Stern
On Mon, 13 Feb 2017, Paul E. McKenney wrote: > On Mon, Feb 13, 2017 at 08:14:23PM +0100, Tobias Klausmann wrote: > > Hi! > > > > On Mon, 13 Feb 2017, Paul E. McKenney wrote: > > > On Mon, Feb 13, 2017 at 01:53:27PM -0500, bob smith wrote: > > > > On 2/13/17 1:39 PM, Paul E. McKenney wrote: > > >

Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Alan Stern
return retval; > > you're changing return value here, are you sure there's nothing else > depending on this error? I bet you didn't look at the original code. :-) Just before the start of the patch there is: if (retval == -EPIPE) { ... So no, the patch does not change the return value. Alan Stern

Re: [PATCH v3 1/3] lib/string: introduce ascii2utf16le() helper

2017-02-06 Thread Alan Stern
On Mon, 6 Feb 2017, Richard Leitner wrote: > On 02/06/2017 04:12 PM, Alan Stern wrote: > > On Mon, 6 Feb 2017, Richard Leitner wrote: > > > >> For USB string descriptors we need to convert ASCII strings to UTF16-LE. > >> Therefore make a simple helper f

Re: [PATCH v3 1/3] lib/string: introduce ascii2utf16le() helper

2017-02-06 Thread Alan Stern
ls_base.c. Maybe it doesn't do exactly what you want, but it should be pretty close. Adding another helper function to do essentially the same thing seems unnecessary. Alan Stern

Re: v4.10-rc6 boot regression on Intel desktop, does not boot after cold boots, boots after reboot

2017-02-03 Thread Alan Stern
e is keyboard plugged > > in" but in "reboot" vs. "cold boot". I did not do a cold boot in quite > > a while :-(. > > > > Booting to grub, then hitting ctrl-alt-del is enough to make it work. Ouch. > > > > It happens with current Linus'

Re: v4.10-rc6 boot regression on Intel desktop, maybe related to EHCI hadnoff?

2017-02-03 Thread Alan Stern
could try to boot with CONFIG_USB=n, but that will be pretty useless > configuration. If necessary, you could disable EHCI in the BIOS. That also would be pretty drastic, though. What does the dmesg log in 4.10-rc6 say when the keyboard is plugged into its original port? No obvious explanations spring to mind. You may have to bisect. Alan Stern

Re: [PATCH] r8152: Allocate interrupt buffer as part of struct r8152

2017-01-31 Thread Alan Stern
roblem. I am open to suggestions > for a better fix. The proper approach is to keep the allocation as it is, but _before_ deallocating the buffer, make sure that the interrupt buffer won't be accessed any more. This may involve calling usb_kill_urb(), or synchronize_irq(), or something similar. Alan Stern

Re: [PATCH] usb: storage: sddr09: Remove a set-but-not-used variable

2017-01-24 Thread Alan Stern
info->pba_to_lba[pba] = lba; > info->lba_to_pba[lba] = pba; > - isnew = 1; > } > > if (pba == 1) { Acked-by: Alan Stern

Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase

2017-01-17 Thread Alan Stern
ng explicit status requests. Implementing it will be a little tricky, because right now some status requests already are explicit (those for length-0 OUT transfers) while others are implicit. (One possible approach would be to have the setup routine return different values for explicit and implicit status stages -- for example, return 1 if it wants to submit an explicit status request. That wouldn't be very different from the current USB_GADGET_DELAYED_STATUS approach.) On the other hand, I am very doubtful about requiring explicit setup requests. Alan Stern

Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase

2017-01-16 Thread Alan Stern
ge or status-stage request before the UDC driver is ready to handle it (for example, before or shortly after the setup routine returns). To work properly, the UDC driver must be able to accept a request for ep0 any time after it invokes the setup callback -- either before the callback returns or after. It seems that this was the real problem Baolin wanted to fix. Alan Stern

Re: Memory barrier needed with wake_up_process()?

2017-01-16 Thread Alan Stern
ppening, but probably not today (testing stuff for -rc). Does anything change if the host and peripheral are separate machines? Alan Stern

Re: [PATCH] usb: hcd: initialize hcd->flags to 0 when rm hcd

2017-01-12 Thread Alan Stern
a/drivers/usb/core/hcd.c > > +++ b/drivers/usb/core/hcd.c > > @@ -3017,6 +3017,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) > > } > > > > usb_put_invalidate_rhdev(hcd); > > + hcd->flags = 0; > > } > > EXPORT_SYMBOL_GPL(usb_remove_hcd); > > > > > I suggest to initialize hcd->flags to 0 in usb_add_hcd() instead. > > cheers, > -roger Roger, didn't you originally propose this very same patch in http://marc.info/?l=linux-usb&m=146556415503583&w=2 (and of course, the earlier versions before v10)? What happened to it? Alan Stern

Re: [PATCH v5 4/6] usb: xhci: use bus->sysdev for DMA configuration

2017-01-11 Thread Alan Stern
ks really tailored to make PCI > dwc3 > controllers with xhci support work. > > Was there some reason child devices can't automatically inherit the dma mask > from the parents, > forcing us to dig it from grandparents? > > Anyway, looks like the dwc3 part is already in 4.10-rc, > If Greg and Alan want to take this series that's fine by me I have no objections. Alan Stern > I haven't tested that it won't break anything on PCI XHCI controllers though > > -Mathias

Re: [PATCH 1/2] usb: host: ehci-exynos: Decrese node refcount on exynos_ehci_get_phy() error paths

2017-01-09 Thread Alan Stern
err(dev, > "Error retrieving usb2 phy: %d\n", ret); > + of_node_put(child); > return ret; > } > } > Acked-by: Alan Stern

Re: [PATCH 2/2] usb: host: ohci-exynos: Decrese node refcount on exynos_ehci_get_phy() error paths

2017-01-09 Thread Alan Stern
err(dev, > "Error retrieving usb2 phy: %d\n", ret); > + of_node_put(child); > return ret; > } > } Acked-by: Alan Stern

Re: net/gadget: slab-out-of-bounds write in dev_config

2016-12-27 Thread Alan Stern
On Tue, 27 Dec 2016, Felipe Balbi wrote: > > Hi, > > Alan Stern writes: > > On Tue, 6 Dec 2016, Andrey Konovalov wrote: > > > >> Hi! > >> > >> I've got the following error report while running the syzkaller fuzzer. > >>

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-16 Thread Alan Stern
/core/message.c:1030 > [] usb_set_configuration+0x1083/0x18d0 > drivers/usb/core/message.c:1937 Hi, Andrey: Please check whether the patch below fixes this problem. Alan Stern Index: usb-4.x/drivers/usb/core/config.c ===

Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask

2016-12-14 Thread Alan Stern
On Wed, 14 Dec 2016, Michal Hocko wrote: > On Tue 13-12-16 08:33:34, Alan Stern wrote: > > On Tue, 13 Dec 2016, Michal Hocko wrote: > > > > > > > That being said, what ep_write_iter does sounds quite stupit. It just > > > > > allocates a large c

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-13 Thread Alan Stern
On Tue, 13 Dec 2016, Dmitry Vyukov wrote: > On Tue, Dec 13, 2016 at 7:38 PM, Alan Stern wrote: > > On Tue, 13 Dec 2016, Dmitry Vyukov wrote: > > > >> On Tue, Dec 13, 2016 at 4:52 PM, Alan Stern > >> wrote: > >> > On Tue, 13 Dec 2016, Dmitr

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-13 Thread Alan Stern
On Tue, 13 Dec 2016, Dmitry Vyukov wrote: > On Tue, Dec 13, 2016 at 4:52 PM, Alan Stern wrote: > > On Tue, 13 Dec 2016, Dmitry Vyukov wrote: > > > >> >> > If it is > >> >> > not a bug in kernel source code, then it must not produce a WARNING. &

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-13 Thread Alan Stern
ooking at these WARNINGs, > and we will not spend your time by reporting these WARNINGs. Maybe you should decide that ERROR messages indicate a kernel bug, rather than WARNING messages. Even that is questionable, but you will get far fewer false positives. Even better, you should publicize this decision (in the kernel documentation, on various mailing lists, on LWN, and so forth), and enforce it by reducing existing ERROR severity levels to WARNINGs in places where they do not indicate a kernel bug. Alan Stern

Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask

2016-12-13 Thread Alan Stern
really hard to imagine to deplete > larger contiguous memory blocks (say PAGE_ALLOC_COSTLY_ORDER). Those are > still causing the OOM killer and chances are that a controlled flood of > these requests could completely DoS the system. Putting a limit on the total size of a single transfer would prevent this. Alan Stern

Re: [RFC][PATCH 5/5] usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220

2016-12-13 Thread Alan Stern
er and both a high-speed and a full-speed device plugged into the hub? Do you end up forcing the high-speed device to run at full speed? Alan Stern

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-12 Thread Alan Stern
On Mon, 12 Dec 2016, Alan Stern wrote: > On Mon, 12 Dec 2016, Dmitry Vyukov wrote: > > > On Mon, Dec 12, 2016 at 10:05 PM, Alan Stern > > wrote: > > > On Mon, 12 Dec 2016, Andrey Konovalov wrote: > > > > > >> Hi! > > >> > >

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-12 Thread Alan Stern
On Mon, 12 Dec 2016, Dmitry Vyukov wrote: > On Mon, Dec 12, 2016 at 10:05 PM, Alan Stern > wrote: > > On Mon, 12 Dec 2016, Andrey Konovalov wrote: > > > >> Hi! > >> > >> While running the syzkaller fuzzer I've g

Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask

2016-12-12 Thread Alan Stern
ally want to prevent the driver from attempting to allocate a large buffer, all that's needed is an upper limit on the total size. For example, 64 KB. Alan Stern

Re: usb/core: warning in usb_create_ep_devs/sysfs_create_dir_ns

2016-12-12 Thread Alan Stern
But is it really worthwhile? A kernel warning isn't so bad when you're dealing with buggy device firmware. Alan Stern

Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask

2016-12-12 Thread Alan Stern
d I'm not an expert in this area, but it seems like length checking of I/O operations should be done in a more central location, like the VFS, rather than in a million different drivers. Anyway, it's not a big deal if the memory allocation fails. Users who try to transfer large amounts of data at once should expect that sometimes it won't work. Alan Stern

Re: net/gadget: slab-out-of-bounds write in dev_config

2016-12-06 Thread Alan Stern
inline >] ep0_write drivers/usb/gadget/legacy/inode.c:1135 > [] dev_config+0x86f/0x1190 > drivers/usb/gadget/legacy/inode.c:1759 > [] __vfs_write+0x5d5/0x760 fs/read_write.c:510 > [] vfs_write+0x170/0x4e0 fs/read_write.c:560 > [< inline >] SYSC_write

Re: usb/gadget: use-after-free in gadgetfs_setup

2016-12-05 Thread Alan Stern
ernel/sched/core.c:469 > [] futex_wake+0x5be/0x6c0 kernel/futex.c:1453 > [] do_futex+0x11bd/0x1f00 kernel/futex.c:3219 > [< inline >] SYSC_futex kernel/futex.c:3275 > [] SyS_futex+0x2fc/0x400 kernel/futex.c:3243 > [] entry_SYSCALL_64_fastpath+0x1f/0xc2 Can you test

<    5   6   7   8   9   10   11   12   13   14   >