Re: [GIT PULL] USB-serial fixes for 5.4-rc4

2019-10-18 Thread Greg Kroah-Hartman
On Fri, Oct 18, 2019 at 05:39:53PM +0200, Johan Hovold wrote:
> The following changes since commit 4f5cafb5cb8471e54afdc9054d973535614f7675:
> 
>   Linux 5.4-rc3 (2019-10-13 16:37:36 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.4-rc4

Pulled and pushed out, thanks.

greg k-h


Re: [PATCH 5/5] USB: yurex: fix NULL-derefs on disconnect

2019-10-10 Thread Greg Kroah-Hartman
On Thu, Oct 10, 2019 at 01:05:32PM +0200, Johan Hovold wrote:
> On Wed, Oct 09, 2019 at 05:38:48PM +0200, Johan Hovold wrote:
> > The driver was using its struct usb_interface pointer as an inverted
> > disconnected flag, but was setting it to NULL without making sure all
> > code paths that used it were done with it.
> > 
> > Before commit ef61eb43ada6 ("USB: yurex: Fix protection fault after
> > device removal") this included the interrupt-in completion handler, but
> > there are further accesses in dev_err and dev_dbg statements in
> > yurex_write() and the driver-data destructor (sic!).
> > 
> > Fix this by unconditionally stopping also the control URB at disconnect
> > and by using a dedicated disconnected flag.
> > 
> > Note that we need to take a reference to the struct usb_interface to
> > avoid a use-after-free in the destructor whenever the device was
> > disconnected while the character device was still open.
> > 
> > Fixes: aadd6472d904 ("USB: yurex.c: remove dbg() usage")
> > Fixes: 45714104b9e8 ("USB: yurex.c: remove err() usage")
> > Cc: stable  # 3.5: ef61eb43ada6
> > Signed-off-by: Johan Hovold 
> 
> Greg, I noticed that you picked up all patches in this series except
> this last one.
> 
> Was that one purpose or by mistake?

Mistake, thanks for catching that.  Now queued up.

greg k-h


Re: [GIT PULL] USB-serial fixes for 5.4-rc2

2019-10-04 Thread Greg Kroah-Hartman
On Fri, Oct 04, 2019 at 03:52:19PM +0200, Johan Hovold wrote:
> The following changes since commit 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c:
> 
>   Linux 5.4-rc1 (2019-09-30 10:35:40 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.4-rc2

Pulled and pushed out, thanks!

greg k-h


Re: [PATCH] USB: serial: keyspan: fix NULL-derefs on open() and write()

2019-10-04 Thread Greg Kroah-Hartman
On Thu, Oct 03, 2019 at 03:49:58PM +0200, Johan Hovold wrote:
> Fix NULL-pointer dereferences on open() and write() which can be
> triggered by a malicious USB device.
> 
> The current URB allocation helper would fail to initialise the newly
> allocated URB if the device has unexpected endpoint descriptors,
> something which could lead NULL-pointer dereferences in a number of
> open() and write() paths when accessing the URB. For example:
> 
>   BUG: kernel NULL pointer dereference, address: 
>   ...
>   RIP: 0010:usb_clear_halt+0x11/0xc0
>   ...
>   Call Trace:
>? tty_port_open+0x4d/0xd0
>keyspan_open+0x70/0x160 [keyspan]
>serial_port_activate+0x5b/0x80 [usbserial]
>tty_port_open+0x7b/0xd0
>? check_tty_count+0x43/0xa0
>tty_open+0xf1/0x490
> 
>   BUG: kernel NULL pointer dereference, address: 
>   ...
>   RIP: 0010:keyspan_write+0x14e/0x1f3 [keyspan]
>   ...
>   Call Trace:
>serial_write+0x43/0xa0 [usbserial]
>n_tty_write+0x1af/0x4f0
>? do_wait_intr_irq+0x80/0x80
>? process_echoes+0x60/0x60
>tty_write+0x13f/0x2f0
> 
>   BUG: kernel NULL pointer dereference, address: 
>   ...
>   RIP: 0010:keyspan_usa26_send_setup+0x298/0x305 [keyspan]
>   ...
>   Call Trace:
>keyspan_open+0x10f/0x160 [keyspan]
>serial_port_activate+0x5b/0x80 [usbserial]
>tty_port_open+0x7b/0xd0
>? check_tty_count+0x43/0xa0
>tty_open+0xf1/0x490
> 
> Fixes: fdcba53e2d58 ("fix for bugzilla #7544 (keyspan USB-to-serial 
> converter)")
> Cc: stable# 2.6.21
> Signed-off-by: Johan Hovold 

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH] USB: rio500: Remove Rio 500 kernel driver

2019-10-03 Thread Greg Kroah-Hartman
On Thu, Oct 03, 2019 at 03:18:16PM +0200, Bastien Nocera wrote:
> On Mon, 2019-09-23 at 18:18 +0200, Bastien Nocera wrote:
> > The Rio500 kernel driver has not been used by Rio500 owners since 2001
> > not long after the rio500 project added support for a user-space USB stack
> > through the very first versions of usbdevfs and then libusb.
> > 
> > Support for the kernel driver was removed from the upstream utilities
> > in 2008:
> > https://gitlab.freedesktop.org/hadess/rio500/commit/943f624ab721eb8281c287650fcc9e2026f6f5db
> > 
> > Cc: Cesar Miquel 
> > Signed-off-by: Bastien Nocera 
> 
> Anything else I need to do to land this?

Patience, 5.4-rc1 just came out, my queue is 1500+ patches deep, I will
dig through it in the next week...

thanks,

greg k-h


Re: Reminder: 52 active syzbot reports in usb subsystem

2019-09-19 Thread Greg Kroah-Hartman
On Thu, Sep 19, 2019 at 10:32:49AM -0700, Eric Biggers wrote:
> On Thu, Sep 19, 2019 at 08:40:58AM +0200, Greg Kroah-Hartman wrote:
> > On Wed, Sep 18, 2019 at 10:23:42PM -0700, Eric Biggers wrote:
> > > [This email was generated by a script.  Let me know if you have any 
> > > suggestions
> > > to make it better, or if you want it re-generated with the latest status.]
> > > 
> > > Of the syzbot reports that have (re-)occurred in the last 7 days, I've 
> > > manually
> > > marked 52 of them as possibly being bugs in the usb subsystem.  This 
> > > category
> > > mostly includes USB driver bugs, but it might include some core USB bugs 
> > > too. 
> > > I've listed these bug reports below.
> > > 
> > > If you believe a bug is no longer valid, please close it by sending a 
> > > '#syz
> > > fix', '#syz dup', or '#syz invalid' command in reply to the original 
> > > thread, as
> > > explained at https://goo.gl/tpsmEJ#status
> > > 
> > > If you believe I misattributed a bug to the usb subsystem, please let me 
> > > know
> > > and (if possible) forward it to the correct place.
> > > 
> > > Note: in total, I've actually assigned 90 open syzbot reports to this 
> > > subsystem.
> > > But to help focus people's efforts, I've only listed the 52 that have
> > > (re-)occurred in the last week.  Let me know if you want the full list.
> > 
> > Thanks for doing all of this.  There's a load of syzbot usb open bugs
> > right now, hopefully the huge majority of them will "auto close" now
> > that a lot of USB fixes are merged in Linus's tree.
> > 
> > Then we can sift through the rest to see what we have missed and wait
> > for the next round of fuzzing that will happen, as the codepaths we have
> > fixed up can now go deeper :)
> > 
> > thanks,
> > 
> 
> AFAICS, only 2 syzbot bugs were fixed in the USB pull request for 5.4, and 
> they
> were already closed by syzbot before I sent this reminder, as it seems to 
> close
> bugs within a matter of hours.  So probably almost all of these bugs are still
> valid.  I'd be glad to resend a refreshed list in a week or two, but if you're
> expecting the number of open bugs (or even "active" bugs) to go down much by
> itself, you may be disappointed :-(

Ugh, yeah, I'm going to be sad.  There's a lot of different USB drivers
that are having problems handling things when descriptors don't "look
like they should"...

thanks,

greg k-h


Re: Reminder: 52 active syzbot reports in usb subsystem

2019-09-18 Thread Greg Kroah-Hartman
On Wed, Sep 18, 2019 at 10:23:42PM -0700, Eric Biggers wrote:
> [This email was generated by a script.  Let me know if you have any 
> suggestions
> to make it better, or if you want it re-generated with the latest status.]
> 
> Of the syzbot reports that have (re-)occurred in the last 7 days, I've 
> manually
> marked 52 of them as possibly being bugs in the usb subsystem.  This category
> mostly includes USB driver bugs, but it might include some core USB bugs too. 
> I've listed these bug reports below.
> 
> If you believe a bug is no longer valid, please close it by sending a '#syz
> fix', '#syz dup', or '#syz invalid' command in reply to the original thread, 
> as
> explained at https://goo.gl/tpsmEJ#status
> 
> If you believe I misattributed a bug to the usb subsystem, please let me know
> and (if possible) forward it to the correct place.
> 
> Note: in total, I've actually assigned 90 open syzbot reports to this 
> subsystem.
> But to help focus people's efforts, I've only listed the 52 that have
> (re-)occurred in the last week.  Let me know if you want the full list.

Thanks for doing all of this.  There's a load of syzbot usb open bugs
right now, hopefully the huge majority of them will "auto close" now
that a lot of USB fixes are merged in Linus's tree.

Then we can sift through the rest to see what we have missed and wait
for the next round of fuzzing that will happen, as the codepaths we have
fixed up can now go deeper :)

thanks,

greg k-h


[PATCH 5.2 28/37] usb: chipidea: imx: fix EPROBE_DEFER support during driver probe

2019-09-13 Thread Greg Kroah-Hartman
If driver probe needs to be deferred, e.g. because ci_hdrc_add_device()
isn't ready yet, this driver currently misbehaves badly:
a) success is still reported to the driver core (meaning a 2nd
   probe attempt will never be done), leaving the driver in
   a dysfunctional state and the hardware unusable

b) driver remove / shutdown OOPSes:
[  206.786916] Unable to handle kernel paging request at virtual address 
fdff
[  206.794148] pgd = 880b9f82
[  206.796890] [fdff] *pgd=abf5e861, *pte=, *ppte=
[  206.803179] Internal error: Oops: 37 [#1] PREEMPT SMP ARM
[  206.808581] Modules linked in: wl18xx evbug
[  206.813308] CPU: 1 PID: 1 Comm: systemd-shutdow Not tainted 
4.19.35+gf345c93b4195 #1
[  206.821053] Hardware name: Freescale i.MX7 Dual (Device Tree)
[  206.826813] PC is at ci_hdrc_remove_device+0x4/0x20
[  206.831699] LR is at ci_hdrc_imx_remove+0x20/0xe8
[  206.836407] pc : [<805cd4b0>]lr : [<805d62cc>]psr: 2013
[  206.842678] sp : a806be40  ip : 0001  fp : 80adbd3c
[  206.847906] r10: 80b1b794  r9 : 80d5dfe0  r8 : a8192c44
[  206.853136] r7 : 80db93a0  r6 : a8192c10  r5 : a8192c00  r4 : a93a4a00
[  206.859668] r3 :   r2 : a8192ce4  r1 :   r0 : fdfb
[  206.866201] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
none
[  206.873341] Control: 10c5387d  Table: a9e0c06a  DAC: 0051
[  206.879092] Process systemd-shutdow (pid: 1, stack limit = 0xb271353c)
[  206.885624] Stack: (0xa806be40 to 0xa806c000)
[  206.889992] be40: a93a4a00 805d62cc a8192c1c a8170e10 a8192c10 8049a490 
80d04d08 
[  206.898179] be60:  80d0da2c fee1dead  a806a000 0058 
 80148b08
[  206.906366] be80: 01234567 80148d8c a9858600    
 80d04d08
[  206.914553] bea0:   a82741e0 a9858600 0024 0002 
a9858608 0005
[  206.922740] bec0: 001e 8022c058   a806bf14 a9858600 
 a806befc
[  206.930927] bee0: a806bf78  7ee12c30 8022c18c a806bef8 a806befc 
 0001
[  206.939115] bf00:  0024 a806bf14 0005 7ee13b34 7ee12c68 
0004 7ee13f20
[  206.947302] bf20: 0010 7ee12c7c 0005 7ee12d04 000a 76e7dc00 
0001 80d0f140
[  206.955490] bf40: ab637880 a974de40 6013 80d0f140 ab6378a0 80d04d08 
a8080470 a9858600
[  206.963677] bf60: a9858600   8022c24c  80144310 
 
[  206.971864] bf80: 80101204 80d04d08  80d04d08   
0003 0058
[  206.980051] bfa0: 80101204 80101000   fee1dead 28121969 
01234567 
[  206.988237] bfc0:   0003 0058   
 
[  206.996425] bfe0: 0049ffb0 7ee13d58 0048a84b 76f245a6 6030 fee1dead 
 
[  207.004622] [<805cd4b0>] (ci_hdrc_remove_device) from [<805d62cc>] 
(ci_hdrc_imx_remove+0x20/0xe8)
[  207.013509] [<805d62cc>] (ci_hdrc_imx_remove) from [<8049a490>] 
(device_shutdown+0x16c/0x218)
[  207.022050] [<8049a490>] (device_shutdown) from [<80148b08>] 
(kernel_restart+0xc/0x50)
[  207.029980] [<80148b08>] (kernel_restart) from [<80148d8c>] 
(sys_reboot+0xf4/0x1f0)
[  207.037648] [<80148d8c>] (sys_reboot) from [<80101000>] 
(ret_fast_syscall+0x0/0x54)
[  207.045308] Exception stack(0xa806bfa8 to 0xa806bff0)
[  207.050368] bfa0:     fee1dead 28121969 
01234567 
[  207.058554] bfc0:   0003 0058   
 
[  207.066737] bfe0: 0049ffb0 7ee13d58 0048a84b 76f245a6
[  207.071799] Code: eba8 e3a0 e8bd8010 e92d4010 (e5904004)
[  207.078021] ---[ end trace be47424e3fd46e9f ]---
[  207.082647] Kernel panic - not syncing: Fatal exception
[  207.087894] ---[ end Kernel panic - not syncing: Fatal exception ]---

c) the error path in combination with driver removal causes
   imbalanced calls to the clk_*() and pm_()* APIs

a) happens because the original intended return value is
   overwritten (with 0) by the return code of
   regulator_disable() in ci_hdrc_imx_probe()'s error path
b) happens because ci_pdev is -EPROBE_DEFER, which causes
   ci_hdrc_remove_device() to OOPS

Fix a) by being more careful in ci_hdrc_imx_probe()'s error
path and not overwriting the real error code

Fix b) by calling the respective cleanup functions during
remove only when needed (when ci_pdev != NULL, i.e. when
everything was initialised correctly). This also has the
side effect of not causing imbalanced clk_*() and pm_*()
API calls as part of the error code path.

Fixes: 7c8e8909417e ("usb: chipidea: imx: add HSIC support")
Signed-off-by: André Draszik 
Cc: stable 
CC: Pet

Re: [GIT PULL] USB-serial updates for 5.4-rc1

2019-09-04 Thread Greg Kroah-Hartman
On Wed, Sep 04, 2019 at 05:03:56PM +0200, Johan Hovold wrote:
> The following changes since commit d1abaeb3be7b5fa6d7a1fbbd2e14e3310005c4c1:
> 
>   Linux 5.3-rc5 (2019-08-18 14:31:08 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.4-rc1

Pulled and pushed out, thanks!

greg k-h


Re: [GIT PULL] USB changes for v5.4 merge window

2019-09-02 Thread Greg Kroah-Hartman
On Fri, Aug 30, 2019 at 12:14:28PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's my pull request for the next merge window. The biggest chunk is
> the addition of Cadence USB3 DRD Driver which, finally, compiles on x86,
> ARM and ARM64 without any issues. I haven't gotten any failure reports
> from 0-day either.
> 
> Relevant changes have been testing on platforms I have access to. Most
> importantly the generalization of the dwc3 control request decoders
> didn't cause any visible regressions that I could trigger.
> 
> Let me know if you want anything to be changed.
> 
> cheers
> 
>   
> < New Driver >
>   
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
> 
> The following changes since commit e21a712a9685488f5ce80495b37b9fdbe96c230d:
> 
>   Linux 5.3-rc3 (2019-08-04 18:40:12 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v5.4
> 
> for you to fetch changes up to 18a93cd38be3e69ac5b067c570a78a369b79e31d:
> 
>   usb: gadget: net2280: Add workaround for AB chip Errata 11 (2019-08-30 
> 09:27:33 +0300)
> 
> 
> USB: Changes for v5.4 merge window
> 
> With only 45 non-merge commits, we have a small merge window from the
> Gadget perspective.
> 
> The biggest change here is the addition of the Cadence USB3 DRD
> Driver. All other changes are small, non-critical fixes or smaller new
> features like the improvement to BESL handling in dwc3.
> 
> Signed-off-by: Felipe Balbi 

Pulled and pushed out, thanks.

greg k-h


Re: next take at setting up a dma mask by default for platform devices v2

2019-08-22 Thread Greg Kroah-Hartman
On Fri, Aug 16, 2019 at 08:24:29AM +0200, Christoph Hellwig wrote:
> Hi all,
> 
> this is another attempt to make sure the dma_mask pointer is always
> initialized for platform devices.  Not doing so lead to lots of
> boilerplate code, and makes platform devices different from all our
> major busses like PCI where we always set up a dma_mask.  In the long
> run this should also help to eventually make dma_mask a scalar value
> instead of a pointer and remove even more cruft.
> 
> The bigger blocker for this last time was the fact that the usb
> subsystem uses the presence or lack of a dma_mask to check if the core
> should do dma mapping for the driver, which is highly unusual.  So we
> fix this first.  Note that this has some overlap with the pending
> desire to use the proper dma_mmap_coherent helper for mapping usb
> buffers.  The first two patches have already been queued up by Greg
> and are only included for completeness.

Note to everyone.  The first two patches in this series is already in
5.3-rc5.

I've applied the rest of the series to my usb-next branch (with the 6th
patch landing there later today.)  They are scheduled to be merge to
Linus in 5.4-rc1.

Christoph, thanks so much for these cleanups.

greg k-h


Re: USB: gadget: f_midi: fixing a possible double-free in f_midi

2019-08-20 Thread Greg Kroah-Hartman
On Tue, Aug 20, 2019 at 10:45:13AM -0700, Mark Salyzyn wrote:
> From: "Yavuz, Tuba" 
> 
> cherry pick from commit 7fafcfdf6377b18b2a726ea554d6e593ba44349f
> ("USB: gadget: f_midi: fixing a possible double-free in f_midi")
> Removing 'return err;' from conflict.
> 
> It looks like there is a possibility of a double-free vulnerability on an
> error path of the f_midi_set_alt function in the f_midi driver. If the
> path is feasible then free_ep_req gets called twice:
> 
>  req->complete = f_midi_complete;
>  err = usb_ep_queue(midi->out_ep, req, GFP_ATOMIC);
> => ...
>  usb_gadget_giveback_request
>=>
>  f_midi_complete (CALLBACK)
>(inside f_midi_complete, for various cases of status)
>free_ep_req(ep, req); // first kfree
>  if (err) {
>  ERROR(midi, "%s: couldn't enqueue request: %d\n",
>  midi->out_ep->name, err);
>  free_ep_req(midi->out_ep, req); // second kfree
>  return err;
>  }
> 
> The double-free possibility was introduced with commit ad0d1a058eac
> ("usb: gadget: f_midi: fix leak on failed to enqueue out requests").
> 
> Found by MOXCAFE tool.
> 
> Signed-off-by: Tuba Yavuz 
> Fixes: ad0d1a058eac ("usb: gadget: f_midi: fix leak on failed to enqueue out 
> requests")
> Acked-by: Felipe Balbi 
> Cc: stable  # 4.4.y

No signed-off-by from you?

Anyway, this is already in the 4.4.y queue and will be in the next
release.

thanks,

greg k-h


Re: [GIT PULL] USB-serial fixes for 5.3-rc5

2019-08-17 Thread Greg Kroah-Hartman
On Sat, Aug 17, 2019 at 10:22:07AM +0200, Johan Hovold wrote:
> The following changes since commit e21a712a9685488f5ce80495b37b9fdbe96c230d:
> 
>   Linux 5.3-rc3 (2019-08-04 18:40:12 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.3-rc5

Pulled and pushed out, thanks.

greg k-h


Re: Policy to keep USB ports powered in low-power states

2019-08-16 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 05:42:05PM -0600, Duncan Laurie wrote:
> On Wed, Aug 14, 2019 at 6:08 PM Nick Crews  wrote:
> >
> > Adding Duncan Laurie who I think has some more intimate knowledge
> > of how this is implemented in HW. Duncan, could you correct or elaborate
> > on my answers below as you see fit? Also, sorry if I make some beginner
> > mistakes here, I'm just getting familiar with the USB subsystem, and thanks 
> > for
> > your patience.
> >
> > On Wed, Aug 14, 2019 at 3:20 PM Greg Kroah-Hartman
> >  wrote:
> > >
> > > On Wed, Aug 14, 2019 at 02:12:07PM -0600, Nick Crews wrote:
> > > > Thanks for the fast response!
> > > >
> > > > On Tue, Aug 13, 2019 at 12:02 AM Greg Kroah-Hartman
> > > >  wrote:
> > > > >
> > > > > On Mon, Aug 12, 2019 at 06:08:43PM -0600, Nick Crews wrote:
> > > > > > Hi Greg!
> > > > >
> > > > > Hi!
> > > > >
> > > > > First off, please fix your email client to not send html so that vger
> > > > > does not reject your messages :)
> > > >
> > > > Thanks, should be good now.
> > > >
> > > > >
> > > > > > I am working on a Chrome OS device that supports a policy called 
> > > > > > "USB Power
> > > > > > Share," which allows users to turn the laptop into a charge pack 
> > > > > > for their
> > > > > > phone. When the policy is enabled, power will be supplied to the 
> > > > > > USB ports
> > > > > > even when the system is in low power states such as S3 and S5. When
> > > > > > disabled, then no power will be supplied in S3 and S5. I wrote a 
> > > > > > driver
> > > > > > <https://lore.kernel.org/patchwork/patch/1062995/> for this already 
> > > > > > as part
> > > > > > of drivers/platform/chrome/, but Enric Balletbo i Serra, the 
> > > > > > maintainer,
> > > > > > had the reasonable suggestion of trying to move this into the USB 
> > > > > > subsystem.
> > > > >
> > > > > Correct suggestion.
> > > > >
> > > > > > Has anything like this been done before? Do you have any preliminary
> > > > > > thoughts on this before I start writing code? A few things that I 
> > > > > > haven't
> > > > > > figured out yet:
> > > > > > - How to make this feature only available on certain devices. Using 
> > > > > > device
> > > > > > tree? Kconfig? Making a separate driver just for this device that 
> > > > > > plugs
> > > > > > into the USB core?
> > > > > > - The feature is only supported on some USB ports, so we need a way 
> > > > > > of
> > > > > > filtering on a per-port basis.
> > > > >
> > > > > Look at the drivers/usb/typec/ code, I think that should do everything
> > > > > you need here as this is a typec standard functionality, right?
> > > >
> > > > Unfortunately this is for USB 2.0 ports, so it's not type-C.
> > > > Is the type-C code still worth looking at?
> > >
> > > If this is for USB 2, does it use the "non-standard" hub commands to
> > > turn on and off power?  If so, why not just use the usbreset userspace
> > > program for that?
> >
> > It does not use the standard hub commands. The USB ports are controlled
> > by an Embedded Controller (EC), so to control this policy we send a command
> > to the EC. Since the command to send to the EC is very specific, this would 
> > need
> > to go into a "hub driver" unique for these Wilco devices. We would make it 
> > so
> > that the normal hub registration is intercepted by something that sees this 
> > is a
> > Wilco device, and instead register the hub as a "wilco-hub", which has its 
> > own
> > special "power_share" sysfs attribute, but still is treated as a normal USB 
> > hub
> > otherwise?
> >
> 
> 
> I would say it is somewhat similar to the USB port power control which
> eventually calls into usb_acpi_set_power_state() but in this case it only
> affects the behavior when the system is NOT running.

Ok, if this is when the system is not running, why does Linux need to be
involved at all?

And if Linux is running, wh

Re: [PATCH 0/3] usb: typec: fusb302: Small changes

2019-08-15 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 07:26:42PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 14-08-19 15:24, Heikki Krogerus wrote:
> > Hi,
> > 
> > This series removes the deprecated fusb302 specific properties, and
> > stops using struct tcpc_config in the driver.
> > 
> > thanks,
> > 
> > Heikki Krogerus (3):
> >usb: typec: fusb302: Remove unused properties
> >dt-bindings: usb: fusb302: Remove deprecated properties
> >usb: typec: fusb302: Always provide fwnode for the port
> 
> I know this series is already in usb-testing, still I thought
> it would be a good idea to test it on my CHT hw with a fusb302
> TypeC controller. So I've just completed testing this and it
> works as advertised:
> 
> So FWIW:
> 
> Tested-by: Hans de Goede 

Thanks, I'll go add this as I can rebase that branch...

greg k-h


Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 03:25:31PM +0200, Christoph Hellwig wrote:
> On Thu, Aug 15, 2019 at 03:23:18PM +0200, Greg Kroah-Hartman wrote:
> > I've taken the first 2 patches for 5.3-final.  Given that patch 3 needs
> > to be fixed, I'll wait for a respin of these before considering them.
> 
> I have a respun version ready, but I'd really like to hear some
> comments from usb developers about the approach before spamming
> everyone again..

Spam away, we can take it :)


Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 03:38:12PM +0200, Christoph Hellwig wrote:
> On Thu, Aug 15, 2019 at 03:03:25PM +0200, Greg Kroah-Hartman wrote:
> > > --- a/include/linux/platform_device.h
> > > +++ b/include/linux/platform_device.h
> > > @@ -24,6 +24,7 @@ struct platform_device {
> > >   int id;
> > >   boolid_auto;
> > >   struct device   dev;
> > > + u64 dma_mask;
> > 
> > Why is the dma_mask in 'struct device' which is part of this structure,
> > not sufficient here?  Shouldn't the "platform" be setting that up
> > correctly already in the "archdata" type callback?
> 
> Becaus the dma_mask in struct device is a pointer that needs to point
> to something, and this is the best space we can allocate for 'something'.
> m68k and powerpc currently do something roughly equivalent at the moment,
> while everyone else just has horrible, horrible hacks.  As mentioned in
> the changelog the intent of this patch is that we treat platform devices
> like any other bus, where the bus allocates the space for the dma_mask.
> The long term plan is to eventually kill that weird pointer indirection
> that doesn't help anyone, but for that we need to sort out the basics
> first.

Ah, missed that, sorry.  Ok, no objection from me.  Might as well respin
this series and I can queue it up after 5.3-rc5 is out (which will have
your first 2 patches in it.)

thanks,

greg k-h


Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Greg Kroah-Hartman
On Sun, Aug 11, 2019 at 10:05:14AM +0200, Christoph Hellwig wrote:
> Hi all,
> 
> this is another attempt to make sure the dma_mask pointer is always
> initialized for platform devices.  Not doing so lead to lots of
> boilerplate code, and makes platform devices different from all our
> major busses like PCI where we always set up a dma_mask.  In the long
> run this should also help to eventually make dma_mask a scalar value
> instead of a pointer and remove even more cruft.
> 
> The bigger blocker for this last time was the fact that the usb
> subsystem uses the presence or lack of a dma_mask to check if the core
> should do dma mapping for the driver, which is highly unusual.  So we
> fix this first.  Note that this has some overlap with the pending
> desire to use the proper dma_mmap_coherent helper for mapping usb
> buffers.  The first two patches from this series should probably
> go into 5.3 and then uses as the basis for the decision to use
> dma_mmap_coherent.

I've taken the first 2 patches for 5.3-final.  Given that patch 3 needs
to be fixed, I'll wait for a respin of these before considering them.

thanks,

greg k-h


Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Greg Kroah-Hartman
On Sun, Aug 11, 2019 at 10:05:20AM +0200, Christoph Hellwig wrote:
> We still treat devices without a DMA mask as defaulting to 32-bits for
> both mask, but a few releases ago we've started warning about such
> cases, as they require special cases to work around this sloppyness.
> Add a dma_mask field to struct platform_object so that we can initialize
> the dma_mask pointer in struct device and initialize both masks to
> 32-bits by default.  Architectures can still override this in
> arch_setup_pdev_archdata if needed.
> 
> Note that the code looks a little odd with the various conditionals
> because we have to support platform_device structures that are
> statically allocated.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/base/platform.c | 15 +--
>  include/linux/platform_device.h |  1 +
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index ec974ba9c0c4..b216fcb0a8af 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -264,6 +264,17 @@ struct platform_object {
>   char name[];
>  };
>  
> +static void setup_pdev_archdata(struct platform_device *pdev)
> +{
> + if (!pdev->dev.coherent_dma_mask)
> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> + if (!pdev->dma_mask)
> + pdev->dma_mask = DMA_BIT_MASK(32);
> + if (!pdev->dev.dma_mask)
> + pdev->dev.dma_mask = &pdev->dma_mask;
> + arch_setup_pdev_archdata(pdev);
> +};
> +
>  /**
>   * platform_device_put - destroy a platform device
>   * @pdev: platform device to free
> @@ -310,7 +321,7 @@ struct platform_device *platform_device_alloc(const char 
> *name, int id)
>   pa->pdev.id = id;
>   device_initialize(&pa->pdev.dev);
>   pa->pdev.dev.release = platform_device_release;
> - arch_setup_pdev_archdata(&pa->pdev);
> + setup_pdev_archdata(&pa->pdev);
>   }
>  
>   return pa ? &pa->pdev : NULL;
> @@ -512,7 +523,7 @@ EXPORT_SYMBOL_GPL(platform_device_del);
>  int platform_device_register(struct platform_device *pdev)
>  {
>   device_initialize(&pdev->dev);
> - arch_setup_pdev_archdata(pdev);
> + setup_pdev_archdata(pdev);
>   return platform_device_add(pdev);
>  }
>  EXPORT_SYMBOL_GPL(platform_device_register);
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 9bc36b589827..a2abde2aef25 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -24,6 +24,7 @@ struct platform_device {
>   int id;
>   boolid_auto;
>   struct device   dev;
> + u64 dma_mask;

Why is the dma_mask in 'struct device' which is part of this structure,
not sufficient here?  Shouldn't the "platform" be setting that up
correctly already in the "archdata" type callback?

confused,

greg k-h


[PATCH v2] USB: phy: fsl-usb: convert platform driver to use dev_groups

2019-08-15 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
v2: fix build errors caught by 0-day

 drivers/usb/phy/phy-fsl-usb.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f7c96d209eda..f6a037b5e9ef 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -1043,6 +1043,11 @@ static ssize_t show_fsl_usb2_otg_state(struct device 
*dev,
 
 static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);
 
+static struct attribute *fsl_otg_attrs[] = {
+   &dev_attr_fsl_usb2_otg_state.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(fsl_otg);
 
 /* Char driver interface to control some OTG input */
 
@@ -1132,10 +1137,6 @@ static int fsl_otg_probe(struct platform_device *pdev)
return ret;
}
 
-   ret = device_create_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
-   if (ret)
-   dev_warn(&pdev->dev, "Can't register sysfs attribute\n");
-
return ret;
 }
 
@@ -1152,8 +1153,6 @@ static int fsl_otg_remove(struct platform_device *pdev)
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev);
 
-   device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
-
unregister_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME);
 
if (pdata->exit)
@@ -1168,6 +1167,7 @@ struct platform_driver fsl_otg_driver = {
.driver = {
.name = driver_name,
.owner = THIS_MODULE,
+   .dev_groups = fsl_otg_groups,
},
 };
 
-- 
2.22.1



Re: [PATCH 0/3] usb: typec: fusb302: Small changes

2019-08-15 Thread Greg Kroah-Hartman
On Wed, Aug 14, 2019 at 03:42:46PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 14-08-19 15:24, Heikki Krogerus wrote:
> > Hi,
> > 
> > This series removes the deprecated fusb302 specific properties, and
> > stops using struct tcpc_config in the driver.
> 
> Series looks good to me:
> 
> Reviewed-by: Hans de Goede 
> 
> This has a small conflict with my
> "[PATCH] usb: typec: fusb302: Call fusb302_debugfs_init earlier"
> patch.
> 
> Since we've agreed to do the rootdir leak fix as a separate patch
> (which I will write when I find some time probably tomorrow), I
> was wondering if we can merge my patch first. I would like to see
> a "Cc: sta...@vger.kernel.org" added to my patch and then it would
> be good to have it merged first.
> 
> Regardless we should probable prepare one series with all patches
> for Greg to make this easy to merge for him.

I'll take this series now, and you can redo your patch based on my
usb-next branch with them in it.

thanks,

greg k-h


Re: [PATCH] usb: typec: fusb302: Call fusb302_debugfs_init earlier

2019-08-15 Thread Greg Kroah-Hartman
On Tue, Aug 13, 2019 at 01:52:16PM +0300, Heikki Krogerus wrote:
> Hi Hans,
> 
> On Tue, Aug 13, 2019 at 12:15:24PM +0200, Hans de Goede wrote:
> > tcpm_register_port() will call some of the fusb302 code's callbacks
> > wich in turn will call fusb302_log(). So we need to call
> > fusb302_debugfs_init() before we call tcpm_register_port().
> > 
> > This fixes the following warning, which was caused by the logbuffer_lock
> > not yet being initialized (which is done by fusb302_debugfs_init):
> > 
> >  DEBUG_LOCKS_WARN_ON(lock->magic != lock)
> >  WARNING: CPU: 0 PID: 1306 at kernel/locking/mutex.c:912 
> > __mutex_lock+0x978/0x9a0
> >  Modules linked in: fusb302(+) tcpm pi3usb30532 typec bq24190_charger 
> > snd_soc_sst_cht_bsw_rt5645 mei_hdcp dwc3 intel_rapl_msr udc_core ulpi 
> > gpio_keys intel_powerclamp coretemp kvm_intel brcmfmac kvm brcmutil joydev 
> > cfg80211 wdat_wdt irqbypass pcspkr intel_cstate extcon_intel_cht_wc 
> > i2c_cht_wc(E) snd_intel_sst_acpi snd_intel_sst_core snd_soc_rt5645 
> > snd_soc_sst_atom_hifi2_platform snd_soc_acpi_intel_match snd_soc_rl6231 
> > snd_soc_acpi intel_xhci_usb_role_switch roles hci_uart snd_soc_core btqca 
> > mei_txe btrtl processor_thermal_device mei snd_hdmi_lpe_audio lpc_ich 
> > snd_compress btbcm intel_rapl_common ac97_bus dwc3_pci snd_pcm_dmaengine 
> > intel_soc_dts_iosf btintel snd_seq bluetooth snd_seq_device snd_pcm 
> > intel_cht_int33fe_musb snd_timer intel_cht_int33fe_typec intel_hid 
> > intel_cht_int33fe_common sparse_keymap snd ecdh_generic goodix rfkill 
> > soundcore ecc spi_pxa2xx_platform max17042_battery dw_dmac int3406_thermal 
> > dptf_power acpi_pad soc_button_array int3400_thermal int3403_thermal
> >   gpd_pocket_fan intel_int0002_vgpio int340x_thermal_zone acpi_thermal_rel 
> > dm_crypt mmc_block i915 crct10dif_pclmul crc32_pclmul crc32c_intel 
> > ghash_clmulni_intel i2c_algo_bit drm_kms_helper drm video sdhci_acpi sdhci 
> > mmc_core pwm_lpss_platform pwm_lpss i2c_dev
> >  CPU: 0 PID: 1306 Comm: systemd-udevd Tainted: GE 
> > 5.3.0-rc4+ #83
> >  Hardware name: Default string Default string/Default string, BIOS 5.11 
> > 06/28/2017
> >  RIP: 0010:__mutex_lock+0x978/0x9a0
> >  Code: c0 0f 84 26 f7 ff ff 44 8b 05 24 25 c8 00 45 85 c0 0f 85 16 f7 ff ff 
> > 48 c7 c6 da 55 2f ae 48 c7 c7 98 8c 2d ae e8 a0 f9 5c ff <0f> 0b e9 fc f6 
> > ff ff 4c 89 f0 4d 89 fe 49 89 c7 e9 cf fa ff ff e8
> >  RSP: 0018:b7a8c0523800 EFLAGS: 00010286
> >  RAX:  RBX:  RCX: 
> >  RDX: 0002 RSI: 0001 RDI: 0246
> >  RBP: b7a8c05238c0 R08:  R09: 
> >  R10: b7a8c0523648 R11: 0030 R12: 
> >  R13: b7a8c0523990 R14: 9bf22f70c028 R15: 9bf22f70c360
> >  FS:  7f39ca234940() GS:9bf23740() 
> > knlGS:
> >  CS:  0010 DS:  ES:  CR0: 80050033
> >  CR2: 7f1f108481a0 CR3: 000271f28000 CR4: 001006f0
> >  Call Trace:
> >   ? find_held_lock+0x39/0x90
> >   ? _fusb302_log+0x81/0x1d0 [fusb302]
> >   ? vsnprintf+0x3aa/0x4f0
> >   ? _fusb302_log+0x81/0x1d0 [fusb302]
> >   _fusb302_log+0x81/0x1d0 [fusb302]
> >  ...
> > 
> > Signed-off-by: Hans de Goede 
> > ---
> >  drivers/usb/typec/tcpm/fusb302.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/typec/tcpm/fusb302.c 
> > b/drivers/usb/typec/tcpm/fusb302.c
> > index ccfc7e91e7a3..04c76b9d0065 100644
> > --- a/drivers/usb/typec/tcpm/fusb302.c
> > +++ b/drivers/usb/typec/tcpm/fusb302.c
> > @@ -1759,6 +1759,7 @@ static int fusb302_probe(struct i2c_client *client,
> > INIT_WORK(&chip->irq_work, fusb302_irq_work);
> > INIT_DELAYED_WORK(&chip->bc_lvl_handler, fusb302_bc_lvl_handler_work);
> > init_tcpc_dev(&chip->tcpc_dev);
> > +   fusb302_debugfs_init(chip);
> >  
> > if (client->irq) {
> > chip->gpio_int_n_irq = client->irq;
> > @@ -1784,7 +1785,6 @@ static int fusb302_probe(struct i2c_client *client,
> > goto tcpm_unregister_port;
> > }
> > enable_irq_wake(chip->gpio_int_n_irq);
> > -   fusb302_debugfs_init(chip);
> > i2c_set_clientdata(client, chip);
> 
> That leaves the rootdir variable pointing to something again for
> example if a failure happens (like -EPROBE_AGAIN) during probe (the
> "fusb302" directory is removed, but the rootdir static variable still
> points to something).
> 
> Let's just create that rootdir directory during driver init. I don't
> really understand why should we only create it when/if the first
> instance of fusb302 is registered. I think something like this would
> work:
> 
> diff --git a/drivers/usb/typec/tcpm/fusb302.c 
> b/drivers/usb/typec/tcpm/fusb302.c
> index c524088246ee..7a950a6e5f0d 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -212,9 +212,6 @@ static struct dentry *rootdir;
>  static void fusb302_debugfs_init(str

Re: [PATCH v2 01/13] usb: ohci-nxp: enable compile-testing

2019-08-15 Thread Greg Kroah-Hartman
On Fri, Aug 09, 2019 at 04:40:27PM +0200, Arnd Bergmann wrote:
> The driver hardcodes a hardware I/O address the way one should
> generally not do, and this prevents both compile-testing, and
> moving the platform to CONFIG_ARCH_MULTIPLATFORM.
> 
> Change the code to be independent of the machine headers
> to allow those two. Removing the hardcoded address would
> be hard and is not necessary, so leave that in place for now.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/host/Kconfig|  3 ++-
>  drivers/usb/host/ohci-nxp.c | 25 ++---
>  2 files changed, 20 insertions(+), 8 deletions(-)

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH] usb: host: ohci-pxa27x: Fix and & vs | typo

2019-08-15 Thread Greg Kroah-Hartman
On Wed, Aug 14, 2019 at 05:04:14PM +0300, Dan Carpenter wrote:
> I was looking at this code again today and I'm still convinced this
> patch is correct.  Should I resend?

Please resend, it's not in my queue anywhere :(



Re: Policy to keep USB ports powered in low-power states

2019-08-14 Thread Greg Kroah-Hartman
On Wed, Aug 14, 2019 at 02:12:07PM -0600, Nick Crews wrote:
> Thanks for the fast response!
> 
> On Tue, Aug 13, 2019 at 12:02 AM Greg Kroah-Hartman
>  wrote:
> >
> > On Mon, Aug 12, 2019 at 06:08:43PM -0600, Nick Crews wrote:
> > > Hi Greg!
> >
> > Hi!
> >
> > First off, please fix your email client to not send html so that vger
> > does not reject your messages :)
> 
> Thanks, should be good now.
> 
> >
> > > I am working on a Chrome OS device that supports a policy called "USB 
> > > Power
> > > Share," which allows users to turn the laptop into a charge pack for their
> > > phone. When the policy is enabled, power will be supplied to the USB ports
> > > even when the system is in low power states such as S3 and S5. When
> > > disabled, then no power will be supplied in S3 and S5. I wrote a driver
> > > <https://lore.kernel.org/patchwork/patch/1062995/> for this already as 
> > > part
> > > of drivers/platform/chrome/, but Enric Balletbo i Serra, the maintainer,
> > > had the reasonable suggestion of trying to move this into the USB 
> > > subsystem.
> >
> > Correct suggestion.
> >
> > > Has anything like this been done before? Do you have any preliminary
> > > thoughts on this before I start writing code? A few things that I haven't
> > > figured out yet:
> > > - How to make this feature only available on certain devices. Using device
> > > tree? Kconfig? Making a separate driver just for this device that plugs
> > > into the USB core?
> > > - The feature is only supported on some USB ports, so we need a way of
> > > filtering on a per-port basis.
> >
> > Look at the drivers/usb/typec/ code, I think that should do everything
> > you need here as this is a typec standard functionality, right?
> 
> Unfortunately this is for USB 2.0 ports, so it's not type-C.
> Is the type-C code still worth looking at?

If this is for USB 2, does it use the "non-standard" hub commands to
turn on and off power?  If so, why not just use the usbreset userspace
program for that?

And how are you turning a USB 2 port into a power source?  That feels
really odd given the spec.  Is this part of the standard somewhere or
just a firmware/hardware hack that you are adding to a device?

Is there some port information in the firmware that describes this
functionality?  If so, can you expose it through sysfs to the port that
way?

thanks,

greg k-h


Re: Policy to keep USB ports powered in low-power states

2019-08-12 Thread Greg Kroah-Hartman
On Mon, Aug 12, 2019 at 06:08:43PM -0600, Nick Crews wrote:
> Hi Greg!

Hi!

First off, please fix your email client to not send html so that vger
does not reject your messages :)

> I am working on a Chrome OS device that supports a policy called "USB Power
> Share," which allows users to turn the laptop into a charge pack for their
> phone. When the policy is enabled, power will be supplied to the USB ports
> even when the system is in low power states such as S3 and S5. When
> disabled, then no power will be supplied in S3 and S5. I wrote a driver
>  for this already as part
> of drivers/platform/chrome/, but Enric Balletbo i Serra, the maintainer,
> had the reasonable suggestion of trying to move this into the USB subsystem.

Correct suggestion.

> Has anything like this been done before? Do you have any preliminary
> thoughts on this before I start writing code? A few things that I haven't
> figured out yet:
> - How to make this feature only available on certain devices. Using device
> tree? Kconfig? Making a separate driver just for this device that plugs
> into the USB core?
> - The feature is only supported on some USB ports, so we need a way of
> filtering on a per-port basis.

Look at the drivers/usb/typec/ code, I think that should do everything
you need here as this is a typec standard functionality, right?

thanks,

greg k-h


Re: [GIT PULL] USB fixes for v5.3-rc

2019-08-12 Thread Greg Kroah-Hartman
On Mon, Aug 12, 2019 at 01:00:15PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> here's a pull request for some fixes that I collected from linux-usb
> mailing list.
> 
> Let me know if you want anything to be changed.
> 
> Cheers
> 
> The following changes since commit d45331b00ddb179e291766617259261c112db872:
> 
>   Linux 5.3-rc4 (2019-08-11 13:26:41 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v5.3-rc4

Pulled and pushed out, thanks.

greg k-h


Re: [PATCH v2] dt-bindings: usb: renesas_gen3: Rename bindings documentation file to reflect IP block

2019-08-10 Thread Greg Kroah-Hartman
On Sat, Aug 10, 2019 at 08:40:15AM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Fri, Aug 9, 2019 at 11:37 PM Simon Horman  
> wrote:
> > For consistency with the naming of (most) other documentation files for DT
> > bindings for Renesas IP blocks rename the Renesas USB3.0 peripheral
> > documentation file from renesas,usb3.txt to renesas,usb3-peri.txt
> >
> > This refines a recent rename from renesas_usb3.txt to renesas-usb3.txt.
> 
> s/renesas-usb3.txt/renesas,usb3.txt/

I'll fix it up now, no need for a resend...



Re: [balbi-usb:testing/next 2/13] drivers/usb/phy/phy-tahvo.c:434:4: error: 'struct device_driver' has no member named 'dev_groups'; did you mean 'groups'?

2019-08-09 Thread Greg Kroah-Hartman
On Fri, Aug 09, 2019 at 08:27:52AM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> kbuild test robot  writes:
> 
> > tree:   
> > https://kernel.googlesource.com/pub/scm/linux/kernel/git/balbi/usb.git 
> > testing/next
> > head:   d06a2c3f683a591efce9d02b2b60ef346df5ae02
> > commit: 2a714ea6d90d9d1b510ba424652a2e3dfd547267 [2/13] USB: phy: tahvo: 
> > convert platform driver to use dev_groups
> > config: sh-allmodconfig (attached as .config)
> > compiler: sh4-linux-gcc (GCC) 7.4.0
> > reproduce:
> > wget 
> > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> > ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > git checkout 2a714ea6d90d9d1b510ba424652a2e3dfd547267
> > # save the attached .config to linux build tree
> > GCC_VERSION=7.4.0 make.cross ARCH=sh 
> >
> > If you fix the issue, kindly add following tag
> > Reported-by: kbuild test robot 
> >
> > All errors (new ones prefixed by >>):
> >
> >>> drivers/usb/phy/phy-tahvo.c:434:4: error: 'struct device_driver' has no 
> >>> member named 'dev_groups'; did you mean 'groups'?
> >   .dev_groups = tahvo_groups,
> >^~
> 
> 
> looks like these patches depend on something else that's not upstream
> yet. I'll drop the patches from my queue. Greg,if you'd like to add my
> ack:
> 
> Acked-by: Felipe Balbi 

Thanks, they depend on a patch that is in linux-next and in my tree (and
a few other developer's trees) already.

greg k-h


Re: [PATCH 10/22] usb: omap: avoid mach/*.h headers

2019-08-09 Thread Greg Kroah-Hartman
On Thu, Aug 08, 2019 at 11:22:19PM +0200, Arnd Bergmann wrote:
> The omap usb drivers still rely on mach/*.h headers that
> are explicitly or implicitly included, but all the required
> definitions are now in include/linux/soc/ti/, so use those
> instead and allow compile-testing on other architectures.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/gadget/udc/Kconfig | 2 +-
>  drivers/usb/gadget/udc/omap_udc.c  | 2 ++
>  drivers/usb/host/Kconfig   | 2 +-
>  drivers/usb/host/ohci-omap.c   | 7 +++
>  drivers/usb/phy/Kconfig| 3 ++-
>  drivers/usb/phy/phy-isp1301-omap.c | 4 ++--
>  6 files changed, 11 insertions(+), 9 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH] MAINTAINERS: mark wusbcore and UWB as obsolete

2019-08-08 Thread Greg Kroah-Hartman
On Thu, Aug 08, 2019 at 04:15:44AM -0700, Joe Perches wrote:
> On Thu, 2019-08-08 at 11:41 +0200, Greg Kroah-Hartman wrote:
> > On Thu, Aug 08, 2019 at 11:25:09AM +0200, Greg Kroah-Hartman wrote:
> > > Joe rightly points out that we should be using the "Obsolete" status for
> > > these two subsystems.
> > 
> > Even with that change, I don't see get_maintainers.pl tell me I
> > shouldn't be sending a patch in for this area:
> 
> Nor should you.  It's checkpatch that should warn.

Ah, wrong tool.  Yes, it does, let's see if anyone actually notices that
when sending checkpatch changes for these files in the future :)

thanks,

greg k-h


Re: [PATCH] MAINTAINERS: mark wusbcore and UWB as obsolete

2019-08-08 Thread Greg Kroah-Hartman
On Thu, Aug 08, 2019 at 11:25:09AM +0200, Greg Kroah-Hartman wrote:
> Joe rightly points out that we should be using the "Obsolete" status for
> these two subsystems.

Even with that change, I don't see get_maintainers.pl tell me I
shouldn't be sending a patch in for this area:


$ cat x.patch
diff --git a/drivers/staging/uwb/Kconfig b/drivers/staging/uwb/Kconfig
index 259e053e1e09..d9658c46686e 100644
--- a/drivers/staging/uwb/Kconfig
+++ b/drivers/staging/uwb/Kconfig
@@ -3,6 +3,8 @@
 # UWB device configuration
 #

+
+
 menuconfig UWB
tristate "Ultra Wideband devices"
default n
$ ./scripts/get_maintainer.pl x.patch
Greg Kroah-Hartman  (supporter:STAGING 
SUBSYSTEM,commit_signer:2/2=100%,authored:1/2=50%)
Thomas Gleixner  (commit_signer:1/2=50%,authored:1/2=50%)
de...@driverdev.osuosl.org (open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:)
linux-ker...@vger.kernel.org (open list)


Am I missing something?

thanks,

greg k-h


[PATCH] MAINTAINERS: mark wusbcore and UWB as obsolete

2019-08-08 Thread Greg Kroah-Hartman
Joe rightly points out that we should be using the "Obsolete" status for
these two subsystems.

Also I got the path name wrong for the wusbcore tree.

Reported-by: Joe Perches 
Fixes: 71ed79b0e4be ("USB: Move wusbcore and UWB to staging as it is obsolete")
Signed-off-by: Greg Kroah-Hartman 

diff --git a/MAINTAINERS b/MAINTAINERS
index f4463fb48249..6f2d988fe7b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3801,8 +3801,8 @@ F:scripts/extract-cert.c
 
 CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM:
 L: de...@driverdev.osuosl.org
-S: Orphan
-F: drivers/staging/wbusbcore/
+S: Obsolete
+F: drivers/staging/wusbcore/
 
 CFAG12864B LCD DRIVER
 M: Miguel Ojeda Sandonis 
@@ -16443,7 +16443,7 @@ F:  include/linux/ulpi/
 
 ULTRA-WIDEBAND (UWB) SUBSYSTEM:
 L: de...@driverdev.osuosl.org
-S: Orphan
+S: Obsolete
 F: drivers/staging/uwb/
 
 UNICODE SUBSYSTEM:


Re: [PATCH] USB: phy: fsl-usb: convert platform driver to use dev_groups

2019-08-07 Thread Greg Kroah-Hartman
On Wed, Aug 07, 2019 at 05:01:22PM +0800, kbuild test robot wrote:
> Hi Greg,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on usb/usb-testing]
> [cannot apply to v5.3-rc3]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Greg-Kroah-Hartman/USB-phy-fsl-usb-convert-platform-driver-to-use-dev_groups/20190807-021855
> base:   
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb.git 
> usb-testing
> config: arm64-allyesconfig (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 7.4.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> GCC_VERSION=7.4.0 make.cross ARCH=arm64 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot 
> 
> All error/warnings (new ones prefixed by >>):
> 
>In file included from include/linux/kobject.h:20:0,
> from include/linux/module.h:17,
> from drivers/usb/phy/phy-fsl-usb.c:11:
> >> drivers/usb/phy/phy-fsl-usb.c:1050:18: error: 'fsl_otg_attrs_attrs' 
> >> undeclared here (not in a function); did you mean 'fsl_otg_attrs_group'?
> ATTRIBUTE_GROUPS(fsl_otg_attrs);
>  ^

Argh, that's what i get for not compiling the code...

Will resend a fix...

thanks,

greg k-h


[PATCH 09/12] USB: lvstest: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/lvstest.c | 19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
index e5c03c6d16e9..407fe7570f3b 100644
--- a/drivers/usb/misc/lvstest.c
+++ b/drivers/usb/misc/lvstest.c
@@ -310,7 +310,7 @@ static ssize_t enable_compliance_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(enable_compliance);
 
-static struct attribute *lvs_attributes[] = {
+static struct attribute *lvs_attrs[] = {
&dev_attr_get_dev_desc.attr,
&dev_attr_u1_timeout.attr,
&dev_attr_u2_timeout.attr,
@@ -321,10 +321,7 @@ static struct attribute *lvs_attributes[] = {
&dev_attr_enable_compliance.attr,
NULL
 };
-
-static const struct attribute_group lvs_attr_group = {
-   .attrs = lvs_attributes,
-};
+ATTRIBUTE_GROUPS(lvs);
 
 static void lvs_rh_work(struct work_struct *work)
 {
@@ -439,12 +436,6 @@ static int lvs_rh_probe(struct usb_interface *intf,
 
INIT_WORK(&lvs->rh_work, lvs_rh_work);
 
-   ret = sysfs_create_group(&intf->dev.kobj, &lvs_attr_group);
-   if (ret < 0) {
-   dev_err(&intf->dev, "Failed to create sysfs node %d\n", ret);
-   goto free_urb;
-   }
-
pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp,
@@ -453,13 +444,11 @@ static int lvs_rh_probe(struct usb_interface *intf,
ret = usb_submit_urb(lvs->urb, GFP_KERNEL);
if (ret < 0) {
dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret);
-   goto sysfs_remove;
+   goto free_urb;
}
 
return ret;
 
-sysfs_remove:
-   sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
 free_urb:
usb_free_urb(lvs->urb);
return ret;
@@ -469,7 +458,6 @@ static void lvs_rh_disconnect(struct usb_interface *intf)
 {
struct lvs_rh *lvs = usb_get_intfdata(intf);
 
-   sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
usb_poison_urb(lvs->urb); /* used in scheduled work */
flush_work(&lvs->rh_work);
usb_free_urb(lvs->urb);
@@ -479,6 +467,7 @@ static struct usb_driver lvs_driver = {
.name = "lvs",
.probe =lvs_rh_probe,
.disconnect =   lvs_rh_disconnect,
+   .dev_groups =   lvs_groups,
 };
 
 module_usb_driver(lvs_driver);
-- 
2.22.0



[PATCH 08/12] USB: cytherm: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/cytherm.c | 64 +++---
 1 file changed, 19 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 8b15ab5e1450..3e3802aaefa3 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -36,20 +36,6 @@ struct usb_cytherm {
 };
 
 
-/* local function prototypes */
-static int cytherm_probe(struct usb_interface *interface, 
-const struct usb_device_id *id);
-static void cytherm_disconnect(struct usb_interface *interface);
-
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver cytherm_driver = {
-   .name = "cytherm",
-   .probe =cytherm_probe,
-   .disconnect =   cytherm_disconnect,
-   .id_table = id_table,
-};
-
 /* Vendor requests */
 /* They all operate on one byte at a time */
 #define PING   0x00
@@ -304,6 +290,15 @@ static ssize_t port1_store(struct device *dev, struct 
device_attribute *attr, co
 }
 static DEVICE_ATTR_RW(port1);
 
+static struct attribute *cytherm_attrs[] = {
+   &dev_attr_brightness.attr,
+   &dev_attr_temp.attr,
+   &dev_attr_button.attr,
+   &dev_attr_port0.attr,
+   &dev_attr_port1.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(cytherm);
 
 static int cytherm_probe(struct usb_interface *interface, 
 const struct usb_device_id *id)
@@ -322,34 +317,10 @@ static int cytherm_probe(struct usb_interface *interface,
 
dev->brightness = 0xFF;
 
-   retval = device_create_file(&interface->dev, &dev_attr_brightness);
-   if (retval)
-   goto error;
-   retval = device_create_file(&interface->dev, &dev_attr_temp);
-   if (retval)
-   goto error;
-   retval = device_create_file(&interface->dev, &dev_attr_button);
-   if (retval)
-   goto error;
-   retval = device_create_file(&interface->dev, &dev_attr_port0);
-   if (retval)
-   goto error;
-   retval = device_create_file(&interface->dev, &dev_attr_port1);
-   if (retval)
-   goto error;
-
dev_info (&interface->dev,
  "Cypress thermometer device now attached\n");
return 0;
-error:
-   device_remove_file(&interface->dev, &dev_attr_brightness);
-   device_remove_file(&interface->dev, &dev_attr_temp);
-   device_remove_file(&interface->dev, &dev_attr_button);
-   device_remove_file(&interface->dev, &dev_attr_port0);
-   device_remove_file(&interface->dev, &dev_attr_port1);
-   usb_set_intfdata (interface, NULL);
-   usb_put_dev(dev->udev);
-   kfree(dev);
+
 error_mem:
return retval;
 }
@@ -360,12 +331,6 @@ static void cytherm_disconnect(struct usb_interface 
*interface)
 
dev = usb_get_intfdata (interface);
 
-   device_remove_file(&interface->dev, &dev_attr_brightness);
-   device_remove_file(&interface->dev, &dev_attr_temp);
-   device_remove_file(&interface->dev, &dev_attr_button);
-   device_remove_file(&interface->dev, &dev_attr_port0);
-   device_remove_file(&interface->dev, &dev_attr_port1);
-
/* first remove the files, then NULL the pointer */
usb_set_intfdata (interface, NULL);
 
@@ -376,6 +341,15 @@ static void cytherm_disconnect(struct usb_interface 
*interface)
dev_info(&interface->dev, "Cypress thermometer now disconnected\n");
 }
 
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver cytherm_driver = {
+   .name = "cytherm",
+   .probe =cytherm_probe,
+   .disconnect =   cytherm_disconnect,
+   .id_table = id_table,
+   .dev_groups =   cytherm_groups,
+};
+
 module_usb_driver(cytherm_driver);
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
-- 
2.22.0



[PATCH 06/12] USB: usbtmc: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Guido Kiener 
Cc: Steve Bayless 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/class/usbtmc.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 4942122b2346..7ff831f2fd21 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1836,17 +1836,14 @@ capability_attribute(device_capabilities);
 capability_attribute(usb488_interface_capabilities);
 capability_attribute(usb488_device_capabilities);
 
-static struct attribute *capability_attrs[] = {
+static struct attribute *usbtmc_attrs[] = {
&dev_attr_interface_capabilities.attr,
&dev_attr_device_capabilities.attr,
&dev_attr_usb488_interface_capabilities.attr,
&dev_attr_usb488_device_capabilities.attr,
NULL,
 };
-
-static const struct attribute_group capability_attr_grp = {
-   .attrs = capability_attrs,
-};
+ATTRIBUTE_GROUPS(usbtmc);
 
 static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data)
 {
@@ -2383,9 +2380,6 @@ static int usbtmc_probe(struct usb_interface *intf,
retcode = get_capabilities(data);
if (retcode)
dev_err(&intf->dev, "can't read capabilities\n");
-   else
-   retcode = sysfs_create_group(&intf->dev.kobj,
-&capability_attr_grp);
 
if (data->iin_ep_present) {
/* allocate int urb */
@@ -2432,7 +2426,6 @@ static int usbtmc_probe(struct usb_interface *intf,
return 0;
 
 error_register:
-   sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
usbtmc_free_int(data);
 err_put:
kref_put(&data->kref, usbtmc_delete);
@@ -2445,7 +2438,6 @@ static void usbtmc_disconnect(struct usb_interface *intf)
struct list_head *elem;
 
usb_deregister_dev(intf, &usbtmc_class);
-   sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
mutex_lock(&data->io_mutex);
data->zombie = 1;
wake_up_interruptible_all(&data->waitq);
@@ -2551,6 +2543,7 @@ static struct usb_driver usbtmc_driver = {
.resume = usbtmc_resume,
.pre_reset  = usbtmc_pre_reset,
.post_reset = usbtmc_post_reset,
+   .dev_groups = usbtmc_groups,
 };
 
 module_usb_driver(usbtmc_driver);
-- 
2.22.0



[PATCH 07/12] USB: cypress_cy7c63: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/cypress_cy7c63.c | 29 -
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/misc/cypress_cy7c63.c 
b/drivers/usb/misc/cypress_cy7c63.c
index 9d780b77314b..14faec51d7a5 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -183,6 +183,7 @@ static ssize_t port0_show(struct device *dev,
 {
return read_port(dev, attr, buf, 0, CYPRESS_READ_PORT_ID0);
 }
+static DEVICE_ATTR_RW(port0);
 
 /* attribute callback handler (read) */
 static ssize_t port1_show(struct device *dev,
@@ -190,11 +191,14 @@ static ssize_t port1_show(struct device *dev,
 {
return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1);
 }
-
-static DEVICE_ATTR_RW(port0);
-
 static DEVICE_ATTR_RW(port1);
 
+static struct attribute *cypress_attrs[] = {
+   &dev_attr_port0.attr,
+   &dev_attr_port1.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(cypress);
 
 static int cypress_probe(struct usb_interface *interface,
 const struct usb_device_id *id)
@@ -212,26 +216,11 @@ static int cypress_probe(struct usb_interface *interface,
/* save our data pointer in this interface device */
usb_set_intfdata(interface, dev);
 
-   /* create device attribute files */
-   retval = device_create_file(&interface->dev, &dev_attr_port0);
-   if (retval)
-   goto error;
-   retval = device_create_file(&interface->dev, &dev_attr_port1);
-   if (retval)
-   goto error;
-
/* let the user know that the device is now attached */
dev_info(&interface->dev,
 "Cypress CY7C63xxx device now attached\n");
return 0;
 
-error:
-   device_remove_file(&interface->dev, &dev_attr_port0);
-   device_remove_file(&interface->dev, &dev_attr_port1);
-   usb_set_intfdata(interface, NULL);
-   usb_put_dev(dev->udev);
-   kfree(dev);
-
 error_mem:
return retval;
 }
@@ -242,9 +231,6 @@ static void cypress_disconnect(struct usb_interface 
*interface)
 
dev = usb_get_intfdata(interface);
 
-   /* remove device attribute files */
-   device_remove_file(&interface->dev, &dev_attr_port0);
-   device_remove_file(&interface->dev, &dev_attr_port1);
/* the intfdata can be set to NULL only after the
 * device files have been removed */
usb_set_intfdata(interface, NULL);
@@ -262,6 +248,7 @@ static struct usb_driver cypress_driver = {
.probe = cypress_probe,
.disconnect = cypress_disconnect,
.id_table = cypress_table,
+   .dev_groups = cypress_groups,
 };
 
 module_usb_driver(cypress_driver);
-- 
2.22.0



[PATCH 03/12] USB: atm: cxacru: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/atm/cxacru.c | 58 +++-
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index e57a2be8754a..5d41f85a7445 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -539,6 +539,37 @@ CXACRU_SET_##_action(  
  adsl_config);
 
 CXACRU_ALL_FILES(INIT);
 
+static struct attribute *cxacru_attrs[] = {
+   &dev_attr_adsl_config.attr,
+   &dev_attr_adsl_state.attr,
+   &dev_attr_adsl_controller_version.attr,
+   &dev_attr_adsl_headend_environment.attr,
+   &dev_attr_adsl_headend.attr,
+   &dev_attr_modulation.attr,
+   &dev_attr_line_startable.attr,
+   &dev_attr_downstream_hec_errors.attr,
+   &dev_attr_upstream_hec_errors.attr,
+   &dev_attr_downstream_fec_errors.attr,
+   &dev_attr_upstream_fec_errors.attr,
+   &dev_attr_downstream_crc_errors.attr,
+   &dev_attr_upstream_crc_errors.attr,
+   &dev_attr_startup_attempts.attr,
+   &dev_attr_downstream_bits_per_frame.attr,
+   &dev_attr_upstream_bits_per_frame.attr,
+   &dev_attr_transmitter_power.attr,
+   &dev_attr_downstream_attenuation.attr,
+   &dev_attr_upstream_attenuation.attr,
+   &dev_attr_downstream_snr_margin.attr,
+   &dev_attr_upstream_snr_margin.attr,
+   &dev_attr_mac_address.attr,
+   &dev_attr_line_status.attr,
+   &dev_attr_link_status.attr,
+   &dev_attr_upstream_rate.attr,
+   &dev_attr_downstream_rate.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(cxacru);
+
 /* the following three functions are stolen from drivers/usb/core/message.c */
 static void cxacru_blocking_completion(struct urb *urb)
 {
@@ -736,17 +767,6 @@ static int cxacru_card_status(struct cxacru_data *instance)
return 0;
 }
 
-static void cxacru_remove_device_files(struct usbatm_data *usbatm_instance,
-   struct atm_dev *atm_dev)
-{
-   struct usb_interface *intf = usbatm_instance->usb_intf;
-
-   #define CXACRU_DEVICE_REMOVE_FILE(_name) \
-   device_remove_file(&intf->dev, &dev_attr_##_name);
-   CXACRU_ALL_FILES(REMOVE);
-   #undef CXACRU_DEVICE_REMOVE_FILE
-}
-
 static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
struct atm_dev *atm_dev)
 {
@@ -765,13 +785,6 @@ static int cxacru_atm_start(struct usbatm_data 
*usbatm_instance,
return ret;
}
 
-   #define CXACRU_DEVICE_CREATE_FILE(_name) \
-   ret = device_create_file(&intf->dev, &dev_attr_##_name); \
-   if (unlikely(ret)) \
-   goto fail_sysfs;
-   CXACRU_ALL_FILES(CREATE);
-   #undef CXACRU_DEVICE_CREATE_FILE
-
/* start ADSL */
mutex_lock(&instance->adsl_state_serialize);
ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, 
NULL, 0);
@@ -804,11 +817,6 @@ static int cxacru_atm_start(struct usbatm_data 
*usbatm_instance,
if (start_polling)
cxacru_poll_status(&instance->poll_work.work);
return 0;
-
-fail_sysfs:
-   usb_err(usbatm_instance, "cxacru_atm_start: device_create_file failed 
(%d)\n", ret);
-   cxacru_remove_device_files(usbatm_instance, atm_dev);
-   return ret;
 }
 
 static void cxacru_poll_status(struct work_struct *work)
@@ -1332,7 +1340,6 @@ static struct usbatm_driver cxacru_driver = {
.heavy_init = cxacru_heavy_init,
.unbind = cxacru_unbind,
.atm_start  = cxacru_atm_start,
-   .atm_stop   = cxacru_remove_device_files,
.bulk_in= CXACRU_EP_DATA,
.bulk_out   = CXACRU_EP_DATA,
.rx_padding = 3,
@@ -1364,7 +1371,8 @@ static struct usb_driver cxacru_usb_driver = {
.name   = cxacru_driver_name,
.probe  = cxacru_usb_probe,
.disconnect = usbatm_usb_disconnect,
-   .id_table   = cxacru_usb_ids
+   .id_table   = cxacru_usb_ids,
+   .dev_groups = cxacru_groups,
 };
 
 module_usb_driver(cxacru_usb_driver);
-- 
2.22.0



[PATCH 04/12] USB: ueagle-atm: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Matthieu CASTET 
Cc: Stanislaw Gruszka 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/atm/ueagle-atm.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 8faa51b1a520..8b0ea8c70d73 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2458,7 +2458,7 @@ static int claim_interface(struct usb_device *usb_dev,
return ret;
 }
 
-static struct attribute *attrs[] = {
+static struct attribute *uea_attrs[] = {
&dev_attr_stat_status.attr,
&dev_attr_stat_mflags.attr,
&dev_attr_stat_human_status.attr,
@@ -2479,9 +2479,7 @@ static struct attribute *attrs[] = {
&dev_attr_stat_firmid.attr,
NULL,
 };
-static const struct attribute_group attr_grp = {
-   .attrs = attrs,
-};
+ATTRIBUTE_GROUPS(uea);
 
 static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
   const struct usb_device_id *id)
@@ -2550,18 +2548,12 @@ static int uea_bind(struct usbatm_data *usbatm, struct 
usb_interface *intf,
}
}
 
-   ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
-   if (ret < 0)
-   goto error;
-
ret = uea_boot(sc);
if (ret < 0)
-   goto error_rm_grp;
+   goto error;
 
return 0;
 
-error_rm_grp:
-   sysfs_remove_group(&intf->dev.kobj, &attr_grp);
 error:
kfree(sc);
return ret;
@@ -2571,7 +2563,6 @@ static void uea_unbind(struct usbatm_data *usbatm, struct 
usb_interface *intf)
 {
struct uea_softc *sc = usbatm->driver_data;
 
-   sysfs_remove_group(&intf->dev.kobj, &attr_grp);
uea_stop(sc);
kfree(sc);
 }
@@ -2721,6 +2712,7 @@ static struct usb_driver uea_driver = {
.id_table = uea_ids,
.probe = uea_probe,
.disconnect = uea_disconnect,
+   .dev_groups = uea_groups,
 };
 
 MODULE_DEVICE_TABLE(usb, uea_ids);
-- 
2.22.0



[PATCH 05/12] USB: usblp: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Pete Zaitcev 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/class/usblp.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 407a7a6198a2..7fea4999d352 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1082,6 +1082,12 @@ static ssize_t ieee1284_id_show(struct device *dev, 
struct device_attribute *att
 
 static DEVICE_ATTR_RO(ieee1284_id);
 
+static struct attribute *usblp_attrs[] = {
+   &dev_attr_ieee1284_id.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(usblp);
+
 static int usblp_probe(struct usb_interface *intf,
   const struct usb_device_id *id)
 {
@@ -1156,9 +1162,6 @@ static int usblp_probe(struct usb_interface *intf,
 
/* Retrieve and store the device ID string. */
usblp_cache_device_id_string(usblp);
-   retval = device_create_file(&intf->dev, &dev_attr_ieee1284_id);
-   if (retval)
-   goto abort_intfdata;
 
 #ifdef DEBUG
usblp_check_status(usblp, 0);
@@ -1189,7 +1192,6 @@ static int usblp_probe(struct usb_interface *intf,
 
 abort_intfdata:
usb_set_intfdata(intf, NULL);
-   device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
 abort:
kfree(usblp->readbuf);
kfree(usblp->statusbuf);
@@ -1360,8 +1362,6 @@ static void usblp_disconnect(struct usb_interface *intf)
BUG();
}
 
-   device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
-
mutex_lock(&usblp_mutex);
mutex_lock(&usblp->mut);
usblp->present = 0;
@@ -1421,6 +1421,7 @@ static struct usb_driver usblp_driver = {
.suspend =  usblp_suspend,
.resume =   usblp_resume,
.id_table = usblp_ids,
+   .dev_groups =   usblp_groups,
.supports_autosuspend = 1,
 };
 
-- 
2.22.0



[PATCH 02/12] USB: add support for dev_groups to struct usb_device_driver

2019-08-06 Thread Greg Kroah-Hartman
Now that the driver core supports dev_groups for individual drivers,
expose that pointer to struct usb_device_driver to make it easier for USB
drivers to also use it.

Yes, users of usb_device_driver are much rare, but there are instances
already that use custom sysfs files, so adding this support will make
things easier for those drivers.  usbip is one example, hubs might be
another one.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/core/driver.c | 1 +
 include/linux/usb.h   | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 687fc5df4c17..2b27d232d7a7 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -892,6 +892,7 @@ int usb_register_device_driver(struct usb_device_driver 
*new_udriver,
new_udriver->drvwrap.driver.probe = usb_probe_device;
new_udriver->drvwrap.driver.remove = usb_unbind_device;
new_udriver->drvwrap.driver.owner = owner;
+   new_udriver->drvwrap.driver.dev_groups = new_udriver->dev_groups;
 
retval = driver_register(&new_udriver->drvwrap.driver);
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index af4eb6419ae8..57f667cad3ec 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1224,6 +1224,8 @@ struct usb_driver {
  * module is being unloaded.
  * @suspend: Called when the device is going to be suspended by the system.
  * @resume: Called when the device is being resumed by the system.
+ * @dev_groups: Attributes attached to the device that will be created once it
+ * is bound to the driver.
  * @drvwrap: Driver-model core structure wrapper.
  * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
  * for devices bound to this driver.
@@ -1238,6 +1240,7 @@ struct usb_device_driver {
 
int (*suspend) (struct usb_device *udev, pm_message_t message);
int (*resume) (struct usb_device *udev, pm_message_t message);
+   const struct attribute_group **dev_groups;
struct usbdrv_wrap drvwrap;
unsigned int supports_autosuspend:1;
 };
-- 
2.22.0



[PATCH 11/12] USB: usbsevseg: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/usbsevseg.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index 1923d5b6d9c9..551074f5b7ad 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -316,7 +316,7 @@ MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered);
 MYDEV_ATTR_SIMPLE_UNSIGNED(mode_msb, update_display_mode);
 MYDEV_ATTR_SIMPLE_UNSIGNED(mode_lsb, update_display_mode);
 
-static struct attribute *dev_attrs[] = {
+static struct attribute *sevseg_attrs[] = {
&dev_attr_powered.attr,
&dev_attr_text.attr,
&dev_attr_textmode.attr,
@@ -325,10 +325,7 @@ static struct attribute *dev_attrs[] = {
&dev_attr_mode_lsb.attr,
NULL
 };
-
-static const struct attribute_group dev_attr_grp = {
-   .attrs = dev_attrs,
-};
+ATTRIBUTE_GROUPS(sevseg);
 
 static int sevseg_probe(struct usb_interface *interface,
const struct usb_device_id *id)
@@ -354,17 +351,9 @@ static int sevseg_probe(struct usb_interface *interface,
mydev->mode_msb = 0x06; /* 6 characters */
mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */
 
-   rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp);
-   if (rc)
-   goto error;
-
dev_info(&interface->dev, "USB 7 Segment device now attached\n");
return 0;
 
-error:
-   usb_set_intfdata(interface, NULL);
-   usb_put_dev(mydev->udev);
-   kfree(mydev);
 error_mem:
return rc;
 }
@@ -374,7 +363,6 @@ static void sevseg_disconnect(struct usb_interface 
*interface)
struct usb_sevsegdev *mydev;
 
mydev = usb_get_intfdata(interface);
-   sysfs_remove_group(&interface->dev.kobj, &dev_attr_grp);
usb_set_intfdata(interface, NULL);
usb_put_dev(mydev->udev);
kfree(mydev);
@@ -423,6 +411,7 @@ static struct usb_driver sevseg_driver = {
.resume =   sevseg_resume,
.reset_resume = sevseg_reset_resume,
.id_table = id_table,
+   .dev_groups =   sevseg_groups,
.supports_autosuspend = 1,
 };
 
-- 
2.22.0



[PATCH 12/12] USB: usbip: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Valentina Manea 
Cc: Shuah Khan 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/usbip/stub_dev.c | 50 ++--
 1 file changed, 8 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 7931e6cecc70..2305d425e6c9 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -106,38 +106,13 @@ static ssize_t usbip_sockfd_store(struct device *dev, 
struct device_attribute *a
 }
 static DEVICE_ATTR_WO(usbip_sockfd);
 
-static int stub_add_files(struct device *dev)
-{
-   int err = 0;
-
-   err = device_create_file(dev, &dev_attr_usbip_status);
-   if (err)
-   goto err_status;
-
-   err = device_create_file(dev, &dev_attr_usbip_sockfd);
-   if (err)
-   goto err_sockfd;
-
-   err = device_create_file(dev, &dev_attr_usbip_debug);
-   if (err)
-   goto err_debug;
-
-   return 0;
-
-err_debug:
-   device_remove_file(dev, &dev_attr_usbip_sockfd);
-err_sockfd:
-   device_remove_file(dev, &dev_attr_usbip_status);
-err_status:
-   return err;
-}
-
-static void stub_remove_files(struct device *dev)
-{
-   device_remove_file(dev, &dev_attr_usbip_status);
-   device_remove_file(dev, &dev_attr_usbip_sockfd);
-   device_remove_file(dev, &dev_attr_usbip_debug);
-}
+static struct attribute *usbip_attrs[] = {
+   &dev_attr_usbip_status.attr,
+   &dev_attr_usbip_sockfd.attr,
+   &dev_attr_usbip_debug.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(usbip);
 
 static void stub_shutdown_connection(struct usbip_device *ud)
 {
@@ -379,17 +354,8 @@ static int stub_probe(struct usb_device *udev)
goto err_port;
}
 
-   rc = stub_add_files(&udev->dev);
-   if (rc) {
-   dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
-   goto err_files;
-   }
-
return 0;
 
-err_files:
-   usb_hub_release_port(udev->parent, udev->portnum,
-(struct usb_dev_state *) udev);
 err_port:
dev_set_drvdata(&udev->dev, NULL);
usb_put_dev(udev);
@@ -457,7 +423,6 @@ static void stub_disconnect(struct usb_device *udev)
/*
 * NOTE: rx/tx threads are invoked for each usb_device.
 */
-   stub_remove_files(&udev->dev);
 
/* release port */
rc = usb_hub_release_port(udev->parent, udev->portnum,
@@ -526,4 +491,5 @@ struct usb_device_driver stub_driver = {
.resume = stub_resume,
 #endif
.supports_autosuspend   =   0,
+   .dev_groups = usbip_groups,
 };
-- 
2.22.0



[PATCH 10/12] USB: trancevibrator: convert to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Ding Xiang 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/trancevibrator.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/misc/trancevibrator.c 
b/drivers/usb/misc/trancevibrator.c
index ac357ce2d1a6..a3dfc77578ea 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -71,9 +71,14 @@ static ssize_t speed_store(struct device *dev, struct 
device_attribute *attr,
}
return count;
 }
-
 static DEVICE_ATTR_RW(speed);
 
+static struct attribute *tv_attrs[] = {
+   &dev_attr_speed.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(tv);
+
 static int tv_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
@@ -89,15 +94,9 @@ static int tv_probe(struct usb_interface *interface,
 
dev->udev = usb_get_dev(udev);
usb_set_intfdata(interface, dev);
-   retval = device_create_file(&interface->dev, &dev_attr_speed);
-   if (retval)
-   goto error_create_file;
 
return 0;
 
-error_create_file:
-   usb_put_dev(udev);
-   usb_set_intfdata(interface, NULL);
 error:
kfree(dev);
return retval;
@@ -108,7 +107,6 @@ static void tv_disconnect(struct usb_interface *interface)
struct trancevibrator *dev;
 
dev = usb_get_intfdata (interface);
-   device_remove_file(&interface->dev, &dev_attr_speed);
usb_set_intfdata(interface, NULL);
usb_put_dev(dev->udev);
kfree(dev);
@@ -120,6 +118,7 @@ static struct usb_driver tv_driver = {
.probe =tv_probe,
.disconnect =   tv_disconnect,
.id_table = id_table,
+   .dev_groups =   tv_groups,
 };
 
 module_usb_driver(tv_driver);
-- 
2.22.0



[PATCH 00/12] USB: dev_groups support for usb drivers

2019-08-06 Thread Greg Kroah-Hartman
Now that the driver core supports the ability for individual drivers to
have attribute groups added/removed when a device is bound/unbound to a
driver automatically, we should take advantage of that in the USB
subsystem.

This patch series adds dev_groups support to struct usb_driver and
struct usb_device_driver (needed for the usbip driver), and then
converts a number of individual USB drivers over to use this api.

Greg Kroah-Hartman (12):
  USB: add support for dev_groups to struct usb_driver
  USB: add support for dev_groups to struct usb_device_driver
  USB: atm: cxacru: convert to use dev_groups
  USB: ueagle-atm: convert to use dev_groups
  USB: usblp: convert to use dev_groups
  USB: usbtmc: convert to use dev_groups
  USB: cypress_cy7c63: convert to use dev_groups
  USB: cytherm: convert to use dev_groups
  USB: lvstest: convert to use dev_groups
  USB: trancevibrator: convert to use dev_groups
  USB: usbsevseg: convert to use dev_groups
  USB: usbip: convert to use dev_groups

 drivers/usb/atm/cxacru.c  | 58 
 drivers/usb/atm/ueagle-atm.c  | 16 ++--
 drivers/usb/class/usblp.c | 13 ---
 drivers/usb/class/usbtmc.c| 13 ++-
 drivers/usb/core/driver.c |  2 +
 drivers/usb/misc/cypress_cy7c63.c | 29 --
 drivers/usb/misc/cytherm.c| 64 +--
 drivers/usb/misc/lvstest.c| 19 ++---
 drivers/usb/misc/trancevibrator.c | 15 
 drivers/usb/misc/usbsevseg.c  | 17 ++--
 drivers/usb/usbip/stub_dev.c  | 50 
 include/linux/usb.h   |  6 +++
 12 files changed, 104 insertions(+), 198 deletions(-)

-- 
2.22.0



[PATCH 01/12] USB: add support for dev_groups to struct usb_driver

2019-08-06 Thread Greg Kroah-Hartman
Now that the driver core supports dev_groups for individual drivers,
expose that pointer to struct usb_driver to make it easier for USB
drivers to also use it.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/core/driver.c | 1 +
 include/linux/usb.h   | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index ebcadaad89d1..687fc5df4c17 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -954,6 +954,7 @@ int usb_register_driver(struct usb_driver *new_driver, 
struct module *owner,
new_driver->drvwrap.driver.remove = usb_unbind_interface;
new_driver->drvwrap.driver.owner = owner;
new_driver->drvwrap.driver.mod_name = mod_name;
+   new_driver->drvwrap.driver.dev_groups = new_driver->dev_groups;
spin_lock_init(&new_driver->dynids.lock);
INIT_LIST_HEAD(&new_driver->dynids.list);
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 83d35d993e8c..af4eb6419ae8 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1151,6 +1151,8 @@ struct usbdrv_wrap {
  * @id_table: USB drivers use ID table to support hotplugging.
  * Export this with MODULE_DEVICE_TABLE(usb,...).  This must be set
  * or your driver's probe function will never get called.
+ * @dev_groups: Attributes attached to the device that will be created once it
+ * is bound to the driver.
  * @dynids: used internally to hold the list of dynamically added device
  * ids for this driver.
  * @drvwrap: Driver-model core structure wrapper.
@@ -1198,6 +1200,7 @@ struct usb_driver {
int (*post_reset)(struct usb_interface *intf);
 
const struct usb_device_id *id_table;
+   const struct attribute_group **dev_groups;
 
struct usb_dynids dynids;
struct usbdrv_wrap drvwrap;
-- 
2.22.0



Re: [PATCH] usb: setup authorized_default using usb_bus_notify

2019-08-06 Thread Greg Kroah-Hartman
On Tue, Aug 06, 2019 at 01:00:50PM +0200, Thiébaud Weksteen wrote:
> Currently, the authorized_default and interface_authorized_default
> attributes for HCD are set up after the uevent has been sent to userland.
> This creates a race condition where userland may fail to access this
> file when processing the event. Move the appending of these attributes
> earlier relying on the usb_bus_notify dispatcher.
> 
> Signed-off-by: Thiébaud Weksteen 
> ---
>  drivers/usb/core/hcd.c   | 123 ---
>  drivers/usb/core/sysfs.c | 121 ++
>  drivers/usb/core/usb.h   |   5 ++
>  3 files changed, 126 insertions(+), 123 deletions(-)

And does this solve the issue you reported yesterday?  If so, I'll be
glad to backport this to the older stable kernels as well.

thanks,

greg k-h


Re: [PATCH] USB: Move wusbcore and UWB to staging as it is obsolete

2019-08-06 Thread Greg Kroah-Hartman
On Tue, Aug 06, 2019 at 03:29:40AM -0700, Joe Perches wrote:
> On Tue, 2019-08-06 at 12:15 +0200, Greg Kroah-Hartman wrote:
> > The UWB and wusbcore code is long obsolete, so let us just move the code
> > out of the real part of the kernel and into the drivers/staging/
> > location with plans to remove it entirely in a few releases.
> []
> >  MAINTAINERS   | 15 +++---
> []
> > diff --git a/MAINTAINERS b/MAINTAINERS
> []
> > @@ -3800,14 +3800,9 @@ F:   scripts/sign-file.c
> >  F: scripts/extract-cert.c
> >  
> >  CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM:
> > -L: linux-usb@vger.kernel.org
> > +L: de...@driverdev.osuosl.org
> >  S: Orphan
> 
> Better to mark this as obsolete so checkpatch emits
> a message saying "no unnecessary modifications"
> 
> 

Ah, good point, will do that as an add-on patch after this.

thanks,

greg k-h


[PATCH] USB: Move wusbcore and UWB to staging as it is obsolete

2019-08-06 Thread Greg Kroah-Hartman
The UWB and wusbcore code is long obsolete, so let us just move the code
out of the real part of the kernel and into the drivers/staging/
location with plans to remove it entirely in a few releases.

Signed-off-by: Greg Kroah-Hartman 
---
 MAINTAINERS   | 15 +++---
 drivers/Kconfig   |  2 --
 drivers/Makefile  |  1 -
 drivers/staging/Kconfig   |  3 ++
 drivers/staging/Makefile  |  2 ++
 drivers/{ => staging}/uwb/Kconfig |  0
 drivers/{ => staging}/uwb/Makefile|  0
 drivers/staging/uwb/TODO  |  8 ++
 drivers/{ => staging}/uwb/address.c   |  0
 drivers/{ => staging}/uwb/allocator.c |  2 +-
 drivers/{ => staging}/uwb/beacon.c|  0
 drivers/{ => staging}/uwb/driver.c|  0
 drivers/{ => staging}/uwb/drp-avail.c |  0
 drivers/{ => staging}/uwb/drp-ie.c|  2 +-
 drivers/{ => staging}/uwb/drp.c   |  0
 drivers/{ => staging}/uwb/est.c   |  0
 drivers/{ => staging}/uwb/hwa-rc.c|  6 ++--
 drivers/{ => staging}/uwb/i1480/Makefile  |  0
 drivers/{ => staging}/uwb/i1480/dfu/Makefile  |  0
 drivers/{ => staging}/uwb/i1480/dfu/dfu.c |  2 +-
 .../{ => staging}/uwb/i1480/dfu/i1480-dfu.h   |  2 +-
 drivers/{ => staging}/uwb/i1480/dfu/mac.c |  2 +-
 drivers/{ => staging}/uwb/i1480/dfu/phy.c |  2 +-
 drivers/{ => staging}/uwb/i1480/dfu/usb.c |  6 ++--
 drivers/{ => staging}/uwb/i1480/i1480-est.c   |  2 +-
 drivers/{ => staging}/uwb/ie-rcv.c|  0
 drivers/{ => staging}/uwb/ie.c|  0
 .../staging/uwb/include}/debug-cmd.h  |  0
 .../staging/uwb/include}/spec.h   |  0
 .../uwb => drivers/staging/uwb/include}/umc.h |  0
 .../staging/uwb/include}/whci.h   |  0
 drivers/{ => staging}/uwb/lc-dev.c|  0
 drivers/{ => staging}/uwb/lc-rc.c |  0
 drivers/{ => staging}/uwb/neh.c   |  0
 drivers/{ => staging}/uwb/pal.c   |  2 +-
 drivers/{ => staging}/uwb/radio.c |  2 +-
 drivers/{ => staging}/uwb/reset.c |  0
 drivers/{ => staging}/uwb/rsv.c   |  2 +-
 drivers/{ => staging}/uwb/scan.c  |  0
 drivers/{ => staging}/uwb/umc-bus.c   |  2 +-
 drivers/{ => staging}/uwb/umc-dev.c   |  2 +-
 drivers/{ => staging}/uwb/umc-drv.c   |  2 +-
 drivers/{ => staging}/uwb/uwb-debug.c |  3 +-
 drivers/{ => staging}/uwb/uwb-internal.h  |  2 +-
 {include/linux => drivers/staging/uwb}/uwb.h  |  2 +-
 drivers/{ => staging}/uwb/uwbd.c  |  0
 drivers/{ => staging}/uwb/whc-rc.c|  6 ++--
 drivers/{ => staging}/uwb/whci.c  |  4 +--
 .../staging/wusbcore/Documentation}/wusb-cbaf |  0
 .../Documentation}/wusb-design-overview.rst   |  0
 drivers/{usb => staging}/wusbcore/Kconfig |  1 +
 drivers/{usb => staging}/wusbcore/Makefile|  2 ++
 drivers/staging/wusbcore/TODO |  8 ++
 drivers/{usb => staging}/wusbcore/cbaf.c  |  6 ++--
 drivers/{usb => staging}/wusbcore/crypto.c|  4 +--
 drivers/{usb => staging}/wusbcore/dev-sysfs.c |  0
 .../{usb => staging}/wusbcore/devconnect.c|  0
 drivers/staging/wusbcore/host/Kconfig | 28 +++
 drivers/staging/wusbcore/host/Makefile|  3 ++
 .../{usb => staging/wusbcore}/host/hwa-hc.c   |  4 +--
 .../wusbcore}/host/whci/Makefile  |  0
 .../{usb => staging/wusbcore}/host/whci/asl.c |  4 +--
 .../wusbcore}/host/whci/debug.c   |  2 +-
 .../{usb => staging/wusbcore}/host/whci/hcd.c |  4 +--
 .../{usb => staging/wusbcore}/host/whci/hw.c  |  4 +--
 .../wusbcore}/host/whci/init.c|  4 +--
 .../{usb => staging/wusbcore}/host/whci/int.c |  4 +--
 .../{usb => staging/wusbcore}/host/whci/pzl.c |  4 +--
 .../wusbcore}/host/whci/qset.c|  4 +--
 .../wusbcore}/host/whci/whcd.h|  4 +--
 .../wusbcore}/host/whci/whci-hc.h |  0
 .../wusbcore}/host/whci/wusb.c|  4 +--
 .../staging/wusbcore/include}/association.h   |  0
 .../staging/wusbcore/include}/wusb-wa.h   |  0
 .../staging/wusbcore/include}/wusb.h  |  2 +-
 drivers/{usb => staging}/wusbcore/mmc.c   |  2 +-
 drivers/{usb => staging}/wusbcore/pal.c   |  0
 .../{usb => staging}/wusbcore/reservation.c   |  2 +-
 drivers/{usb => staging}/wusbcore/rh.c|  0
 drivers/{usb => staging}/wusbcore/security.c  |  0
 drivers/{usb => staging}/wusbcore/wa-hc.c |  0
 drivers/{usb => staging}/wusbcore/wa-hc.h |  6 ++--
 drivers/{usb => staging}/wusbcore/wa-nep.c|  0
 drivers/{usb => staging}/wusbcore/wa-rpipe.c  |  0

Re: [PATCH] USB: usbip: convert platform driver to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
On Mon, Aug 05, 2019 at 02:22:18PM -0600, shuah wrote:
> On 8/5/19 1:36 PM, Greg Kroah-Hartman wrote:
> > Platform drivers now have the option to have the platform core create
> > and remove any needed sysfs attribute files.  So take advantage of that
> > and do not register "by hand" any sysfs files.
> > 
> > Cc: Valentina Manea 
> > Cc: Shuah Khan 
> > Signed-off-by: Greg Kroah-Hartman 
> > ---
> >   drivers/usb/usbip/vudc.h   | 2 +-
> >   drivers/usb/usbip/vudc_dev.c   | 9 -
> >   drivers/usb/usbip/vudc_main.c  | 1 +
> >   drivers/usb/usbip/vudc_sysfs.c | 7 ++-
> >   4 files changed, 8 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
> > index cf968192e59f..1bd4bc005829 100644
> > --- a/drivers/usb/usbip/vudc.h
> > +++ b/drivers/usb/usbip/vudc.h
> > @@ -115,7 +115,7 @@ struct vudc_device {
> > struct list_head dev_entry;
> >   };
> > -extern const struct attribute_group vudc_attr_group;
> > +extern const struct attribute_group *vudc_groups[];
> >   /* visible everywhere */
> > diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
> > index a72c17ff1c6a..c8eeabdd9b56 100644
> > --- a/drivers/usb/usbip/vudc_dev.c
> > +++ b/drivers/usb/usbip/vudc_dev.c
> > @@ -616,18 +616,10 @@ int vudc_probe(struct platform_device *pdev)
> > if (ret < 0)
> > goto err_add_udc;
> > -   ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group);
> > -   if (ret) {
> > -   dev_err(&udc->pdev->dev, "create sysfs files\n");
> > -   goto err_sysfs;
> > -   }
> > -
> > platform_set_drvdata(pdev, udc);
> > return ret;
> > -err_sysfs:
> > -   usb_del_gadget_udc(&udc->gadget);
> >   err_add_udc:
> > cleanup_vudc_hw(udc);
> >   err_init_vudc_hw:
> > @@ -640,7 +632,6 @@ int vudc_remove(struct platform_device *pdev)
> >   {
> > struct vudc *udc = platform_get_drvdata(pdev);
> > -   sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group);
> > usb_del_gadget_udc(&udc->gadget);
> > cleanup_vudc_hw(udc);
> > kfree(udc);
> > diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
> > index 390733e6937e..678faa82598c 100644
> > --- a/drivers/usb/usbip/vudc_main.c
> > +++ b/drivers/usb/usbip/vudc_main.c
> > @@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
> > .remove = vudc_remove,
> > .driver = {
> > .name   = GADGET_NAME,
> > +   .dev_groups = vudc_groups,
> > },
> >   };
> > diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
> > index 6dcd3ff655c3..100f680c572a 100644
> > --- a/drivers/usb/usbip/vudc_sysfs.c
> > +++ b/drivers/usb/usbip/vudc_sysfs.c
> > @@ -215,7 +215,12 @@ static struct bin_attribute *dev_bin_attrs[] = {
> > NULL,
> >   };
> > -const struct attribute_group vudc_attr_group = {
> > +static const struct attribute_group vudc_attr_group = {
> > .attrs = dev_attrs,
> > .bin_attrs = dev_bin_attrs,
> >   };
> > +
> > +const struct attribute_group *vudc_groups[] = {
> > +   &vudc_attr_group,
> > +   NULL,
> > +};
> > 
> 
> Looks good to me.
> 
> Acked-by: Shuah Khan 

Thanks for the review!

greg k-h


[PATCH] USB: phy: fsl-usb: convert platform driver to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/phy/phy-fsl-usb.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f7c96d209eda..dae2f21d3276 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -1043,6 +1043,11 @@ static ssize_t show_fsl_usb2_otg_state(struct device 
*dev,
 
 static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);
 
+static struct attribute *fsl_otg_attrs[] = {
+   &dev_attr_fsl_usb2_otg_state.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(fsl_otg_attrs);
 
 /* Char driver interface to control some OTG input */
 
@@ -1132,10 +1137,6 @@ static int fsl_otg_probe(struct platform_device *pdev)
return ret;
}
 
-   ret = device_create_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
-   if (ret)
-   dev_warn(&pdev->dev, "Can't register sysfs attribute\n");
-
return ret;
 }
 
@@ -1152,8 +1153,6 @@ static int fsl_otg_remove(struct platform_device *pdev)
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev);
 
-   device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state);
-
unregister_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME);
 
if (pdata->exit)
@@ -1168,6 +1167,7 @@ struct platform_driver fsl_otg_driver = {
.driver = {
.name = driver_name,
.owner = THIS_MODULE,
+   .dev_groups = fsl_otg_groups,
},
 };
 
-- 
2.22.0



[PATCH] USB: phy: twl6030: convert platform driver to use dev_groups

2019-08-06 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/phy/phy-twl6030-usb.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-twl6030-usb.c 
b/drivers/usb/phy/phy-twl6030-usb.c
index dade34d70419..bfebf1f2e991 100644
--- a/drivers/usb/phy/phy-twl6030-usb.c
+++ b/drivers/usb/phy/phy-twl6030-usb.c
@@ -196,6 +196,12 @@ static ssize_t vbus_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(vbus);
 
+static struct attribute *twl6030_attrs[] = {
+   &dev_attr_vbus.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(twl6030);
+
 static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
 {
struct twl6030_usb *twl = _twl;
@@ -361,8 +367,6 @@ static int twl6030_usb_probe(struct platform_device *pdev)
}
 
platform_set_drvdata(pdev, twl);
-   if (device_create_file(&pdev->dev, &dev_attr_vbus))
-   dev_warn(&pdev->dev, "could not create sysfs file\n");
 
INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work);
INIT_DELAYED_WORK(&twl->get_status_work, twl6030_status_work);
@@ -373,7 +377,6 @@ static int twl6030_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
twl->irq1, status);
-   device_remove_file(twl->dev, &dev_attr_vbus);
return status;
}
 
@@ -384,7 +387,6 @@ static int twl6030_usb_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
twl->irq2, status);
free_irq(twl->irq1, twl);
-   device_remove_file(twl->dev, &dev_attr_vbus);
return status;
}
 
@@ -408,7 +410,6 @@ static int twl6030_usb_remove(struct platform_device *pdev)
free_irq(twl->irq1, twl);
free_irq(twl->irq2, twl);
regulator_put(twl->usb3v3);
-   device_remove_file(twl->dev, &dev_attr_vbus);
cancel_work_sync(&twl->set_vbus_work);
 
return 0;
@@ -426,6 +427,7 @@ static struct platform_driver twl6030_usb_driver = {
.driver = {
.name   = "twl6030_usb",
.of_match_table = of_match_ptr(twl6030_usb_id_table),
+   .dev_groups = twl6030_groups,
},
 };
 
-- 
2.22.0



[PATCH] USB: musb: convert platform driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Bin Liu 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/musb/musb_core.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2bc55e0ceace..bd63450af76a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1829,16 +1829,13 @@ static ssize_t srp_store(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR_WO(srp);
 
-static struct attribute *musb_attributes[] = {
+static struct attribute *musb_attrs[] = {
&dev_attr_mode.attr,
&dev_attr_vbus.attr,
&dev_attr_srp.attr,
NULL
 };
-
-static const struct attribute_group musb_attr_group = {
-   .attrs = musb_attributes,
-};
+ATTRIBUTE_GROUPS(musb);
 
 #define MUSB_QUIRK_B_INVALID_VBUS_91   (MUSB_DEVCTL_BDEVICE | \
 (2 << MUSB_DEVCTL_VBUS_SHIFT) | \
@@ -2038,10 +2035,6 @@ static void musb_free(struct musb *musb)
 * cleanup after everything's been de-activated.
 */
 
-#ifdef CONFIG_SYSFS
-   sysfs_remove_group(&musb->controller->kobj, &musb_attr_group);
-#endif
-
if (musb->nIrq >= 0) {
if (musb->irq_wake)
disable_irq_wake(musb->nIrq);
@@ -2390,22 +2383,12 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
 
musb_init_debugfs(musb);
 
-   status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
-   if (status)
-   goto fail5;
-
musb->is_initialized = 1;
pm_runtime_mark_last_busy(musb->controller);
pm_runtime_put_autosuspend(musb->controller);
 
return 0;
 
-fail5:
-   musb_exit_debugfs(musb);
-
-   musb_gadget_cleanup(musb);
-   musb_host_cleanup(musb);
-
 fail3:
cancel_delayed_work_sync(&musb->irq_work);
cancel_delayed_work_sync(&musb->finish_resume_work);
@@ -2798,6 +2781,7 @@ static struct platform_driver musb_driver = {
.name   = (char *)musb_driver_name,
.bus= &platform_bus_type,
.pm = MUSB_DEV_PM_OPS,
+   .dev_groups = musb_groups,
},
.probe  = musb_probe,
.remove = musb_remove,
-- 
2.22.0



[PATCH] USB: chipidea: convert platform driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Peter Chen 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/chipidea/core.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 36c964cd40a3..215c655295b8 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -903,10 +903,7 @@ static struct attribute *ci_attrs[] = {
&dev_attr_role.attr,
NULL,
 };
-
-static const struct attribute_group ci_attr_group = {
-   .attrs = ci_attrs,
-};
+ATTRIBUTE_GROUPS(ci);
 
 static int ci_hdrc_probe(struct platform_device *pdev)
 {
@@ -1105,14 +1102,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
device_set_wakeup_capable(&pdev->dev, true);
dbg_create_files(ci);
 
-   ret = sysfs_create_group(&dev->kobj, &ci_attr_group);
-   if (ret)
-   goto remove_debug;
-
return 0;
 
-remove_debug:
-   dbg_remove_files(ci);
 stop:
if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
ci_hdrc_otg_destroy(ci);
@@ -1139,7 +1130,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
}
 
dbg_remove_files(ci);
-   sysfs_remove_group(&ci->dev->kobj, &ci_attr_group);
ci_role_destroy(ci);
ci_hdrc_enter_lpm(ci, true);
ci_usb_phy_exit(ci);
@@ -1318,6 +1308,7 @@ static struct platform_driver ci_hdrc_driver = {
.driver = {
.name   = "ci_hdrc",
.pm = &ci_pm_ops,
+   .dev_groups = ci_groups,
},
 };
 
-- 
2.22.0



[PATCH] USB: usbip: convert platform driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Valentina Manea 
Cc: Shuah Khan 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/usbip/vudc.h   | 2 +-
 drivers/usb/usbip/vudc_dev.c   | 9 -
 drivers/usb/usbip/vudc_main.c  | 1 +
 drivers/usb/usbip/vudc_sysfs.c | 7 ++-
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
index cf968192e59f..1bd4bc005829 100644
--- a/drivers/usb/usbip/vudc.h
+++ b/drivers/usb/usbip/vudc.h
@@ -115,7 +115,7 @@ struct vudc_device {
struct list_head dev_entry;
 };
 
-extern const struct attribute_group vudc_attr_group;
+extern const struct attribute_group *vudc_groups[];
 
 /* visible everywhere */
 
diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index a72c17ff1c6a..c8eeabdd9b56 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -616,18 +616,10 @@ int vudc_probe(struct platform_device *pdev)
if (ret < 0)
goto err_add_udc;
 
-   ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group);
-   if (ret) {
-   dev_err(&udc->pdev->dev, "create sysfs files\n");
-   goto err_sysfs;
-   }
-
platform_set_drvdata(pdev, udc);
 
return ret;
 
-err_sysfs:
-   usb_del_gadget_udc(&udc->gadget);
 err_add_udc:
cleanup_vudc_hw(udc);
 err_init_vudc_hw:
@@ -640,7 +632,6 @@ int vudc_remove(struct platform_device *pdev)
 {
struct vudc *udc = platform_get_drvdata(pdev);
 
-   sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group);
usb_del_gadget_udc(&udc->gadget);
cleanup_vudc_hw(udc);
kfree(udc);
diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
index 390733e6937e..678faa82598c 100644
--- a/drivers/usb/usbip/vudc_main.c
+++ b/drivers/usb/usbip/vudc_main.c
@@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
.remove = vudc_remove,
.driver = {
.name   = GADGET_NAME,
+   .dev_groups = vudc_groups,
},
 };
 
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 6dcd3ff655c3..100f680c572a 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -215,7 +215,12 @@ static struct bin_attribute *dev_bin_attrs[] = {
NULL,
 };
 
-const struct attribute_group vudc_attr_group = {
+static const struct attribute_group vudc_attr_group = {
.attrs = dev_attrs,
.bin_attrs = dev_bin_attrs,
 };
+
+const struct attribute_group *vudc_groups[] = {
+   &vudc_attr_group,
+   NULL,
+};
-- 
2.22.0



[PATCH] USB: phy: tahvo: convert platform driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/phy/phy-tahvo.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index 0981abc3d1ad..baebb1f5a973 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -312,15 +312,12 @@ static ssize_t otg_mode_store(struct device *device,
 }
 static DEVICE_ATTR_RW(otg_mode);
 
-static struct attribute *tahvo_attributes[] = {
+static struct attribute *tahvo_attrs[] = {
&dev_attr_vbus.attr,
&dev_attr_otg_mode.attr,
NULL
 };
-
-static const struct attribute_group tahvo_attr_group = {
-   .attrs = tahvo_attributes,
-};
+ATTRIBUTE_GROUPS(tahvo);
 
 static int tahvo_usb_probe(struct platform_device *pdev)
 {
@@ -406,17 +403,8 @@ static int tahvo_usb_probe(struct platform_device *pdev)
goto err_remove_phy;
}
 
-   /* Attributes */
-   ret = sysfs_create_group(&pdev->dev.kobj, &tahvo_attr_group);
-   if (ret) {
-   dev_err(&pdev->dev, "cannot create sysfs group: %d\n", ret);
-   goto err_free_irq;
-   }
-
return 0;
 
-err_free_irq:
-   free_irq(tu->irq, tu);
 err_remove_phy:
usb_remove_phy(&tu->phy);
 err_disable_clk:
@@ -430,7 +418,6 @@ static int tahvo_usb_remove(struct platform_device *pdev)
 {
struct tahvo_usb *tu = platform_get_drvdata(pdev);
 
-   sysfs_remove_group(&pdev->dev.kobj, &tahvo_attr_group);
free_irq(tu->irq, tu);
usb_remove_phy(&tu->phy);
if (!IS_ERR(tu->ick))
@@ -444,6 +431,7 @@ static struct platform_driver tahvo_usb_driver = {
.remove = tahvo_usb_remove,
.driver = {
.name   = "tahvo-usb",
+   .dev_groups = tahvo_groups,
},
 };
 module_platform_driver(tahvo_usb_driver);
-- 
2.22.0



[PATCH] USB: phy: mv-usb: convert platform driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/phy/phy-mv-usb.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index cf7ecdc9a9d4..06b47f1028b3 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -641,12 +641,15 @@ static const struct attribute_group inputs_attr_group = {
.attrs = inputs_attrs,
 };
 
+static const struct attribute_group *mv_otg_groups[] = {
+   &inputs_attr_group,
+   NULL,
+};
+
 static int mv_otg_remove(struct platform_device *pdev)
 {
struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
-   sysfs_remove_group(&mvotg->pdev->dev.kobj, &inputs_attr_group);
-
if (mvotg->qwork) {
flush_workqueue(mvotg->qwork);
destroy_workqueue(mvotg->qwork);
@@ -809,13 +812,6 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_disable_clk;
}
 
-   retval = sysfs_create_group(&pdev->dev.kobj, &inputs_attr_group);
-   if (retval < 0) {
-   dev_dbg(&pdev->dev,
-   "Can't register sysfs attr group: %d\n", retval);
-   goto err_remove_phy;
-   }
-
spin_lock_init(&mvotg->wq_lock);
if (spin_trylock(&mvotg->wq_lock)) {
mv_otg_run_state_machine(mvotg, 2 * HZ);
@@ -828,8 +824,6 @@ static int mv_otg_probe(struct platform_device *pdev)
 
return 0;
 
-err_remove_phy:
-   usb_remove_phy(&mvotg->phy);
 err_disable_clk:
mv_otg_disable_internal(mvotg);
 err_destroy_workqueue:
@@ -883,6 +877,7 @@ static struct platform_driver mv_otg_driver = {
.remove = mv_otg_remove,
.driver = {
   .name = driver_name,
+  .dev_groups = mv_otg_groups,
   },
 #ifdef CONFIG_PM
.suspend = mv_otg_suspend,
-- 
2.22.0



[PATCH] USB: typec: ucsi_ccg: convert i2c driver to use dev_groups

2019-08-05 Thread Greg Kroah-Hartman
The driver core now supports the option to automatically create and
remove any needed sysfs attribute files for a driver when the device is
bound/removed from it.  Convert the uscsi_ccg code to use that instead
of trying to create sysfs files "by hand".

Cc: Heikki Krogerus 
Cc: Ajay Gupta 
Cc: Wolfram Sang 
Cc: Wei Yongjun 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c 
b/drivers/usb/typec/ucsi/ucsi_ccg.c
index f7a79a23ebed..e283a42e4f06 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1104,14 +1104,11 @@ static ssize_t do_flash_store(struct device *dev,
 
 static DEVICE_ATTR_WO(do_flash);
 
-static struct attribute *ucsi_ccg_sysfs_attrs[] = {
+static struct attribute *ucsi_ccg_attrs[] = {
&dev_attr_do_flash.attr,
NULL,
 };
-
-static struct attribute_group ucsi_ccg_attr_group = {
-   .attrs = ucsi_ccg_sysfs_attrs,
-};
+ATTRIBUTE_GROUPS(ucsi_ccg);
 
 static int ucsi_ccg_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
@@ -1189,10 +1186,6 @@ static int ucsi_ccg_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, uc);
 
-   status = sysfs_create_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
-   if (status)
-   dev_err(uc->dev, "cannot create sysfs group: %d\n", status);
-
pm_runtime_set_active(uc->dev);
pm_runtime_enable(uc->dev);
pm_runtime_idle(uc->dev);
@@ -1209,7 +1202,6 @@ static int ucsi_ccg_remove(struct i2c_client *client)
ucsi_unregister_ppm(uc->ucsi);
pm_runtime_disable(uc->dev);
free_irq(uc->irq, uc);
-   sysfs_remove_group(&uc->dev->kobj, &ucsi_ccg_attr_group);
 
return 0;
 }
@@ -1270,6 +1262,7 @@ static struct i2c_driver ucsi_ccg_driver = {
.driver = {
.name = "ucsi_ccg",
.pm = &ucsi_ccg_pm,
+   .dev_groups = ucsi_ccg_groups,
},
.probe = ucsi_ccg_probe,
.remove = ucsi_ccg_remove,
-- 
2.22.0



Re: Race condition when accessing authorized_default for a root hub

2019-08-05 Thread Greg Kroah-Hartman
On Mon, Aug 05, 2019 at 12:29:27PM +0200, Thiébaud Weksteen wrote:
> Hi,
> 
> I believe there is a race condition for userland in hcd.c where the
> kernel sends a uevent before the underlying sysfs is fully populated:
> 
> (drivers/usb/core/hcd.c)
>   /* starting here, usbcore will pay attention to this root hub */
>   retval = register_root_hub(hcd);
>   if (retval != 0)
>   goto err_register_root_hub;
>   [...]
>   retval = sysfs_create_group(&rhdev->dev.kobj, &usb_bus_attr_group);
>   if (retval < 0) {
>   printk(KERN_ERR "Cannot register USB bus sysfs
> attributes: %d\n",
>  retval);
>   goto error_create_attr_group;
>   }
> 
> Here, register_root_hub will call kobject_uevent(&dev->kobj, KOBJ_ADD)
> (via usb_new_device and device_add). This was found in userland (see
> https://github.com/USBGuard/usbguard/issues/321).
> 
> The fix is not as simple as swapping both blocks (that is, calling
> sysfs_create_group before register_root_hub) as device_add is
> responsible for calling kobject_add and kobject_uevent.
> 
> This can potentially be solved by adding the sysfs_create_group call
> to the bus_notifier list (blocking). Thoughts?

Yes, this type of race condition is _ALL_ over the kernel tree.  I am
working on solving these with the addition of the dev_groups pointer to
struct driver that went into linux-next last week.  I have a series of
patches I'm working on for all USB drivers to take advantage of this and
will post them later this week when they are done.

Ideally no driver should ever call sysfs_create_group(s) on their own,
their "parent" code should be the one doing it (either in the driver
core, or in the bus specific code.)  But, this one is a bit tricker as
root hubs are a bit different.  I'll add this to my list to fix up,
unless you want to send a patch earlier?

And as I said above, this is a well-known, and very old issue.  If you
are relying on sysfs attributes to always be present when KOBJ_ADD is
called, you _will_ race with the kernel at the moment.  Hopefully these
can all be fixed up so that next year you will not have to worry about
this :)

thanks,

greg k-h


Re: [RFC PATCH] usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests

2019-08-02 Thread Greg Kroah-Hartman
On Wed, Jul 24, 2019 at 09:30:37PM -0700, Guenter Roeck wrote:
> TCPM may receive PD messages associated with unknown or unsupported
> alternate modes. If that happens, calls to typec_match_altmode()
> will return NULL. The tcpm code does not currently take this into
> account. This results in crashes.
> 
> Unable to handle kernel NULL pointer dereference at virtual address 01f0
> pgd = 41dad9a1
> [01f0] *pgd=
> Internal error: Oops: 5 [#1] THUMB2
> Modules linked in: tcpci tcpm
> CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 5.1.18-sama5-armv7-r2 #6
> Hardware name: Atmel SAMA5
> Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
> PC is at typec_altmode_attention+0x0/0x14
> LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
> ...
> [] (typec_altmode_attention) from []
>   (tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
> [] (tcpm_pd_rx_handler [tcpm]) from []
>   (process_one_work+0x123/0x2a8)
> [] (process_one_work) from []
>   (worker_thread+0xbd/0x3b0)
> [] (worker_thread) from [] (kthread+0xcf/0xf4)
> [] (kthread) from [] (ret_from_fork+0x11/0x38)
> 
> Ignore PD messages if the asociated alternate mode is not supported.
> 
> Reported-by: Douglas Gilbert 
> Cc: Douglas Gilbert 
> Fixes: e9576fe8e605c ("usb: typec: tcpm: Support for Alternate Modes")
> Signed-off-by: Guenter Roeck 
> ---
> Taking a stab at the problem. I don't really know if this is the correct
> fix, or even if my understanding of the problem is correct, thus marking
> the patch as RFC.

Now that I think everyone agrees this is a "real" fix, can you resend it
in a format that I can apply it in, with the various acks added?

thanks,

greg k-h


Re: [RFC PATCH] usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests

2019-08-01 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 12:55:55PM +0300, Heikki Krogerus wrote:
> On Tue, Jul 30, 2019 at 06:28:52AM -0700, Guenter Roeck wrote:
> > On 7/30/19 5:07 AM, Heikki Krogerus wrote:
> > > On Mon, Jul 29, 2019 at 10:31:04AM -0700, Guenter Roeck wrote:
> > > > On Mon, Jul 29, 2019 at 05:04:57PM +0300, Heikki Krogerus wrote:
> > > > > Hi,
> > > > > 
> > > > > On Wed, Jul 24, 2019 at 09:30:37PM -0700, Guenter Roeck wrote:
> > > > > > TCPM may receive PD messages associated with unknown or unsupported
> > > > > > alternate modes. If that happens, calls to typec_match_altmode()
> > > > > > will return NULL. The tcpm code does not currently take this into
> > > > > > account. This results in crashes.
> > > > > > 
> > > > > > Unable to handle kernel NULL pointer dereference at virtual address 
> > > > > > 01f0
> > > > > > pgd = 41dad9a1
> > > > > > [01f0] *pgd=
> > > > > > Internal error: Oops: 5 [#1] THUMB2
> > > > > > Modules linked in: tcpci tcpm
> > > > > > CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 
> > > > > > 5.1.18-sama5-armv7-r2 #6
> > > > > > Hardware name: Atmel SAMA5
> > > > > > Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
> > > > > > PC is at typec_altmode_attention+0x0/0x14
> > > > > > LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
> > > > > > ...
> > > > > > [] (typec_altmode_attention) from []
> > > > > > (tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
> > > > > > [] (tcpm_pd_rx_handler [tcpm]) from []
> > > > > > (process_one_work+0x123/0x2a8)
> > > > > > [] (process_one_work) from []
> > > > > > (worker_thread+0xbd/0x3b0)
> > > > > > [] (worker_thread) from [] (kthread+0xcf/0xf4)
> > > > > > [] (kthread) from [] (ret_from_fork+0x11/0x38)
> > > > > > 
> > > > > > Ignore PD messages if the asociated alternate mode is not supported.
> > > > > > 
> > > > > > Reported-by: Douglas Gilbert 
> > > > > > Cc: Douglas Gilbert 
> > > > > > Fixes: e9576fe8e605c ("usb: typec: tcpm: Support for Alternate 
> > > > > > Modes")
> > > > > > Signed-off-by: Guenter Roeck 
> > > > > > ---
> > > > > > Taking a stab at the problem. I don't really know if this is the 
> > > > > > correct
> > > > > > fix, or even if my understanding of the problem is correct, thus 
> > > > > > marking
> > > > > > the patch as RFC.
> > > > > 
> > > > > My guess is that typec_match_altmode() is the real culprit. We can't
> > > > > rely on the partner mode index number when identifying the port alt
> > > > > mode.
> > > > > 
> > > > > Douglas, can you test the attached hack instead of this patch?
> > > > > 
> > > > > 
> > > > > thanks,
> > > > > 
> > > > > -- 
> > > > > heikki
> > > > 
> > > > > diff --git a/drivers/usb/typec/tcpm/tcpm.c 
> > > > > b/drivers/usb/typec/tcpm/tcpm.c
> > > > > index ec525811a9eb..033dc097ba83 100644
> > > > > --- a/drivers/usb/typec/tcpm/tcpm.c
> > > > > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > > > > @@ -1067,12 +1067,11 @@ static int tcpm_pd_svdm(struct tcpm_port 
> > > > > *port, const __le32 *payload, int cnt,
> > > > >   modep = &port->mode_data;
> > > > > - adev = typec_match_altmode(port->port_altmode, 
> > > > > ALTMODE_DISCOVERY_MAX,
> > > > > -PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0]));
> > > > > -
> > > > >   pdev = typec_match_altmode(port->partner_altmode, 
> > > > > ALTMODE_DISCOVERY_MAX,
> > > > >  PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0]));
> > > > > + adev = (void *)typec_altmode_get_partner(pdev);
> > > > > +
> > > > 
> > > > I understand that typec_altmode_get_partner() returns a const *;
> > > > maybe adev should be declared as const struct typec_altmode *
> > > > instead of using a typecast.
> > > 
> > > Yes...
> > > 
> > > > Also, typec_altmode_get_partner() can return NULL as well if pdev is 
> > > > NULL.
> > > > Is it guaranteed that typec_match_altmode() never returns NULL for pdev 
> > > > ?
> > > 
> > > ...and probable no. But I don't think we can receive Attention to a
> > > mode that hasn't been entered.
> > > 
> > 
> > If I understand correctly, the Attention was generated by a test system.
> > What prevents badly implemented code in the connected system from sending
> > such an Attention message ?
> 
> Oh, if that is the case, then I don't think my change has any effect.
> I misunderstood the scenario. Sorry for that.
> 
> I think we should use your patch to fix this issue.

So is this an "ack"?  I'm confused as to if this patch should be applied
or not...

thanks,

greg k-h


Re: [PATCH 09/14] serial: lpc32xx: allow compile testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:51PM +0200, Arnd Bergmann wrote:
> The lpc32xx_loopback_set() function in hte lpc32xx_hs driver is the
> one thing that relies on platform header files. Move that into the
> core platform code so we only need a variable declaration for it,
> and enable COMPILE_TEST building.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm/mach-lpc32xx/serial.c   | 30 
>  drivers/tty/serial/lpc32xx_hs.c  | 35 
>  include/linux/soc/nxp/lpc32xx-misc.h |  4 
>  3 files changed, 38 insertions(+), 31 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 04/14] serial: lpc32xx_hs: allow compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:46PM +0200, Arnd Bergmann wrote:
> The only thing that prevents building this driver on other
> platforms is the mach/hardware.h include, which is not actually
> used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/tty/serial/Kconfig  | 3 ++-
>  drivers/tty/serial/lpc32xx_hs.c | 2 --
>  2 files changed, 2 insertions(+), 3 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 02/14] usb: udc: lpc32xx: allow compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:44PM +0200, Arnd Bergmann wrote:
> The only thing that prevents building this driver on other
> platforms is the mach/hardware.h include, which is not actually
> used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/gadget/udc/Kconfig   | 3 ++-
>  drivers/usb/gadget/udc/lpc32xx_udc.c | 2 --
>  2 files changed, 2 insertions(+), 3 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 01/14] usb: ohci-nxp: enable compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:43PM +0200, Arnd Bergmann wrote:
> The driver hardcodes a hardware I/O address the way one should
> generally not do, and this prevents both compile-testing, and
> moving the platform to CONFIG_ARCH_MULTIPLATFORM.
> 
> Change the code to be independent of the machine headers
> to allow those two. Removing the hardcoded address would
> be hard and is not necessary, so leave that in place for now.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/host/Kconfig|  3 ++-
>  drivers/usb/host/ohci-nxp.c | 25 ++---
>  2 files changed, 20 insertions(+), 8 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH v2 2/2] dt-bindings: usb: renesas_gen3: Rename bindings documentation file

2019-07-25 Thread Greg Kroah-Hartman
On Thu, Jul 11, 2019 at 10:03:03AM +0200, Simon Horman wrote:
> On Wed, Jul 03, 2019 at 02:28:51PM +0200, Geert Uytterhoeven wrote:
> > Hi Simon,
> > 
> > On Wed, Jul 3, 2019 at 10:35 AM Simon Horman  
> > wrote:
> > > For consistency with the naming of (most) other documentation files for DT
> > > bindings for Renesas IP blocks rename the Renesas USB3.0 peripheral
> > > documentation file from renesas-gen3.txt to renesas,usb3-peri.txt
> > >
> > > Signed-off-by: Simon Horman 
> > > Reviewed-by: Geert Uytterhoeven 
> > > Reviewed-by: Yoshihiro Shimoda 
> > > Reviewed-by: Niklas Söderlund 
> > >
> > > ---
> > > v2
> > > * Accumulate review tags
> > > * Use renesas,usb3-peri.txt as new filename as suggested by Shimoda-san
> > 
> > Unfortunately the previous version has already made it into usb-next
> > 23c46801d14cb647 dt-bindings: usb: renesas_gen3: Rename bindings
> > documentation file
> 
> Ok, I guess we should go with that version.

So can you resend this series based on 5.3-rc1 so I know what to apply?

thanks,

greg k-h


[PATCH 5.1 308/371] signal/usb: Replace kill_pid_info_as_cred with kill_pid_usb_asyncio

2019-07-24 Thread Greg Kroah-Hartman
, USBDEVFS_REAPURB, &ptr);
if (rc == -1) {
perror("Error in REAPURB ioctl");
return 1;
}

memset(&ds, 0, sizeof(ds));
ds.signr = SIGUSR2;
ds.context = &ds;
rc = ioctl(fd, USBDEVFS_DISCSIGNAL, &ds);
if (rc == -1) {
        perror("Error in DISCSIGNAL ioctl");
return 1;
}

printf("Waiting for usb disconnect\n");
while (!done) {
    sleep(1);
    }

close(fd);
return 0;
 }

Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Cc: Alan Stern 
Cc: Oliver Neukum 
Fixes: v2.3.39
Cc: sta...@vger.kernel.org
Acked-by: Alan Stern 
Signed-off-by: "Eric W. Biederman" 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/core/devio.c |   48 ++---
 include/linux/sched/signal.h |2 -
 kernel/signal.c  |   69 ++-
 3 files changed, 86 insertions(+), 33 deletions(-)

--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -63,7 +63,7 @@ struct usb_dev_state {
unsigned int discsignr;
struct pid *disc_pid;
const struct cred *cred;
-   void __user *disccontext;
+   sigval_t disccontext;
unsigned long ifclaimed;
u32 disabled_bulk_eps;
bool privileges_dropped;
@@ -90,6 +90,7 @@ struct async {
unsigned int ifnum;
void __user *userbuffer;
void __user *userurb;
+   sigval_t userurb_sigval;
struct urb *urb;
struct usb_memory *usbm;
unsigned int mem_usage;
@@ -582,22 +583,19 @@ static void async_completed(struct urb *
 {
struct async *as = urb->context;
struct usb_dev_state *ps = as->ps;
-   struct kernel_siginfo sinfo;
struct pid *pid = NULL;
const struct cred *cred = NULL;
unsigned long flags;
-   int signr;
+   sigval_t addr;
+   int signr, errno;
 
spin_lock_irqsave(&ps->lock, flags);
list_move_tail(&as->asynclist, &ps->async_completed);
as->status = urb->status;
signr = as->signr;
if (signr) {
-   clear_siginfo(&sinfo);
-   sinfo.si_signo = as->signr;
-   sinfo.si_errno = as->status;
-   sinfo.si_code = SI_ASYNCIO;
-   sinfo.si_addr = as->userurb;
+   errno = as->status;
+   addr = as->userurb_sigval;
pid = get_pid(as->pid);
cred = get_cred(as->cred);
}
@@ -615,7 +613,7 @@ static void async_completed(struct urb *
spin_unlock_irqrestore(&ps->lock, flags);
 
if (signr) {
-   kill_pid_info_as_cred(sinfo.si_signo, &sinfo, pid, cred);
+   kill_pid_usb_asyncio(signr, errno, addr, pid, cred);
put_pid(pid);
put_cred(cred);
}
@@ -1427,7 +1425,7 @@ find_memory_area(struct usb_dev_state *p
 
 static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb 
*uurb,
struct usbdevfs_iso_packet_desc __user *iso_frame_desc,
-   void __user *arg)
+   void __user *arg, sigval_t userurb_sigval)
 {
struct usbdevfs_iso_packet_desc *isopkt = NULL;
struct usb_host_endpoint *ep;
@@ -1727,6 +1725,7 @@ static int proc_do_submiturb(struct usb_
isopkt = NULL;
as->ps = ps;
as->userurb = arg;
+   as->userurb_sigval = userurb_sigval;
if (as->usbm) {
unsigned long uurb_start = (unsigned long)uurb->buffer;
 
@@ -1801,13 +1800,17 @@ static int proc_do_submiturb(struct usb_
 static int proc_submiturb(struct usb_dev_state *ps, void __user *arg)
 {
struct usbdevfs_urb uurb;
+   sigval_t userurb_sigval;
 
if (copy_from_user(&uurb, arg, sizeof(uurb)))
return -EFAULT;
 
+   memset(&userurb_sigval, 0, sizeof(userurb_sigval));
+   userurb_sigval.sival_ptr = arg;
+
return proc_do_submiturb(ps, &uurb,
(((struct usbdevfs_urb __user *)arg)->iso_frame_desc),
-   arg);
+   arg, userurb_sigval);
 }
 
 static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg)
@@ -1977,7 +1980,7 @@ static int proc_disconnectsignal_compat(
if (copy_from_user(&ds, arg, sizeof(ds)))
return -EFAULT;
ps->discsignr = ds.signr;
-   ps->disccontext = compat_ptr(ds.context);
+   ps->disccontext.sival_int = ds.context;
return 0;
 }
 
@@ -2005,13 +2008,17 @@ static int get_urb32(struct usbdevfs_urb
 static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg)
 {
struct usbdevfs_urb uurb;
+   sigval_t userurb_sigval;
 
if (get_urb32(&uurb, (st

[PATCH 5.2 340/413] signal/usb: Replace kill_pid_info_as_cred with kill_pid_usb_asyncio

2019-07-24 Thread Greg Kroah-Hartman
, USBDEVFS_REAPURB, &ptr);
if (rc == -1) {
perror("Error in REAPURB ioctl");
return 1;
}

memset(&ds, 0, sizeof(ds));
ds.signr = SIGUSR2;
ds.context = &ds;
rc = ioctl(fd, USBDEVFS_DISCSIGNAL, &ds);
if (rc == -1) {
        perror("Error in DISCSIGNAL ioctl");
return 1;
}

printf("Waiting for usb disconnect\n");
while (!done) {
    sleep(1);
    }

close(fd);
return 0;
 }

Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Cc: Alan Stern 
Cc: Oliver Neukum 
Fixes: v2.3.39
Cc: sta...@vger.kernel.org
Acked-by: Alan Stern 
Signed-off-by: "Eric W. Biederman" 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/core/devio.c |   48 ++---
 include/linux/sched/signal.h |2 -
 kernel/signal.c  |   69 ++-
 3 files changed, 86 insertions(+), 33 deletions(-)

--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -63,7 +63,7 @@ struct usb_dev_state {
unsigned int discsignr;
struct pid *disc_pid;
const struct cred *cred;
-   void __user *disccontext;
+   sigval_t disccontext;
unsigned long ifclaimed;
u32 disabled_bulk_eps;
bool privileges_dropped;
@@ -90,6 +90,7 @@ struct async {
unsigned int ifnum;
void __user *userbuffer;
void __user *userurb;
+   sigval_t userurb_sigval;
struct urb *urb;
struct usb_memory *usbm;
unsigned int mem_usage;
@@ -582,22 +583,19 @@ static void async_completed(struct urb *
 {
struct async *as = urb->context;
struct usb_dev_state *ps = as->ps;
-   struct kernel_siginfo sinfo;
struct pid *pid = NULL;
const struct cred *cred = NULL;
unsigned long flags;
-   int signr;
+   sigval_t addr;
+   int signr, errno;
 
spin_lock_irqsave(&ps->lock, flags);
list_move_tail(&as->asynclist, &ps->async_completed);
as->status = urb->status;
signr = as->signr;
if (signr) {
-   clear_siginfo(&sinfo);
-   sinfo.si_signo = as->signr;
-   sinfo.si_errno = as->status;
-   sinfo.si_code = SI_ASYNCIO;
-   sinfo.si_addr = as->userurb;
+   errno = as->status;
+   addr = as->userurb_sigval;
pid = get_pid(as->pid);
cred = get_cred(as->cred);
}
@@ -615,7 +613,7 @@ static void async_completed(struct urb *
spin_unlock_irqrestore(&ps->lock, flags);
 
if (signr) {
-   kill_pid_info_as_cred(sinfo.si_signo, &sinfo, pid, cred);
+   kill_pid_usb_asyncio(signr, errno, addr, pid, cred);
put_pid(pid);
put_cred(cred);
}
@@ -1427,7 +1425,7 @@ find_memory_area(struct usb_dev_state *p
 
 static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb 
*uurb,
struct usbdevfs_iso_packet_desc __user *iso_frame_desc,
-   void __user *arg)
+   void __user *arg, sigval_t userurb_sigval)
 {
struct usbdevfs_iso_packet_desc *isopkt = NULL;
struct usb_host_endpoint *ep;
@@ -1727,6 +1725,7 @@ static int proc_do_submiturb(struct usb_
isopkt = NULL;
as->ps = ps;
as->userurb = arg;
+   as->userurb_sigval = userurb_sigval;
if (as->usbm) {
unsigned long uurb_start = (unsigned long)uurb->buffer;
 
@@ -1801,13 +1800,17 @@ static int proc_do_submiturb(struct usb_
 static int proc_submiturb(struct usb_dev_state *ps, void __user *arg)
 {
struct usbdevfs_urb uurb;
+   sigval_t userurb_sigval;
 
if (copy_from_user(&uurb, arg, sizeof(uurb)))
return -EFAULT;
 
+   memset(&userurb_sigval, 0, sizeof(userurb_sigval));
+   userurb_sigval.sival_ptr = arg;
+
return proc_do_submiturb(ps, &uurb,
(((struct usbdevfs_urb __user *)arg)->iso_frame_desc),
-   arg);
+   arg, userurb_sigval);
 }
 
 static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg)
@@ -1977,7 +1980,7 @@ static int proc_disconnectsignal_compat(
if (copy_from_user(&ds, arg, sizeof(ds)))
return -EFAULT;
ps->discsignr = ds.signr;
-   ps->disccontext = compat_ptr(ds.context);
+   ps->disccontext.sival_int = ds.context;
return 0;
 }
 
@@ -2005,13 +2008,17 @@ static int get_urb32(struct usbdevfs_urb
 static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg)
 {
struct usbdevfs_urb uurb;
+   sigval_t userurb_sigval;
 
if (get_urb32(&uurb, (st

Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width

2019-07-03 Thread Greg Kroah-Hartman
On Fri, Jun 28, 2019 at 12:10:41PM +0200, Nikolaus Voss wrote:
> On Fri, 28 Jun 2019, Heikki Krogerus wrote:
> > On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
> > > Portinfo bit field is 3 bits wide, not 2 bits. This led to
> > > a wrong driver configuration for some tps6598x configurations.
> > > 
> > > Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power 
> > > Delivery controllers")
> > > Signed-off-by: Nikolaus Voss 
> > 
> > Shouldn't this be applied to the stable trees as well?
> 
> Oh, yes, forgot that again... Greg, could you...?

It's not like I have anything else to do... :)



Re: [GIT PULL part2] USB: changes for v5.3 merge window

2019-07-03 Thread Greg Kroah-Hartman
On Wed, Jul 03, 2019 at 02:41:36PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Hopefully there's still time to merge these other patches.
> 
> They came a little late but should be safe to merge. I've tested what I
> could with platforms I had.
> 
> The biggest thing here is the new Cadence USB DRD controller driver and
> an important fix on dwc2.
> 
> cheers
> 
> The following changes since commit aa23ce847ddac1fd5ffe987ff12e12ff48318e45:
> 
>   usb: dwc3: remove unused @lock member of dwc3_ep struct (2019-06-20 
> 11:50:19 +0300)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v5.3-part2

Pulled and pushed out, thanks.

greg k-h


Re: [GIT PULL] USB-serial updates for 5.3-rc1

2019-07-03 Thread Greg Kroah-Hartman
On Wed, Jul 03, 2019 at 08:34:51AM +0200, Johan Hovold wrote:
> The following changes since commit 9e0babf2c06c73cda2c0cd37a1653d823adb40ec:
> 
>   Linux 5.2-rc5 (2019-06-16 08:49:45 -1000)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.3-rc1

Pulled and pushed out, thanks!

greg k-h


Re: [PATCH] Fix chipmunk-like voice when using Logitech C270 for recording audio.

2019-07-02 Thread Greg Kroah-Hartman
On Tue, Jul 02, 2019 at 02:46:42PM +0200, Oliver Neukum wrote:
> Am Donnerstag, den 20.06.2019, 21:19 +0100 schrieb Aidan Thornton:
> 
> > This doesn't make much sense though. e387ef5c47dd should apply this
> > quirk to all Logitech UVC webcams, and this is definitely a UVC-based
> > Logitech webcam with the appropriate VID and interface descriptor.
> > Surely it shouldn't make any difference whether I add an entry for the
> > specific VID+PID pair of my particular camera or not? The C270 is as
> > well, I think.
> 
> Well, it is applied a little later.
> 
> > What's particularly annoying is that since this is an intermittent
> > problem, it's hard to tell if I'm chasing a phantom solution for it
> > again. Haven't managed to replicate it since applying this fix and did
> > so pretty quickly before but you never know.
> 
> Should I just readd everything removed in e387ef5c47dd?
> 
> Greg, what do you think? This is hard to test, the hardware is old
> and I want to avoid chasing them all separately.

It's up to you, if you think the issue is resolved if we readd
everything, that's fine with me.

thanks,

greg k-h


[PATCH 4.19 30/72] usb: dwc3: gadget: remove wait_end_transfer

2019-07-02 Thread Greg Kroah-Hartman
commit fec9095bdef4e7c988adb603d0d4f92ee735d4a1 upstream

Now that we have a list of cancelled requests, we can skip over TRBs
when END_TRANSFER command completes.

Cc: Fei Yang 
Cc: Sam Protsenko 
Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Cc: sta...@vger.kernel.org # 4.19.y
Signed-off-by: Felipe Balbi 
(cherry picked from commit fec9095bdef4e7c988adb603d0d4f92ee735d4a1)
Signed-off-by: John Stultz 
Signed-off-by: Sasha Levin 
---
 drivers/usb/dwc3/core.h   |  3 ---
 drivers/usb/dwc3/gadget.c | 40 +--
 2 files changed, 1 insertion(+), 42 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 24f0b108b7f6..131028501752 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -639,7 +639,6 @@ struct dwc3_event_buffer {
  * @cancelled_list: list of cancelled requests for this endpoint
  * @pending_list: list of pending requests for this endpoint
  * @started_list: list of started requests on this endpoint
- * @wait_end_transfer: wait_queue_head_t for waiting on End Transfer complete
  * @lock: spinlock for endpoint request queue traversal
  * @regs: pointer to first endpoint register
  * @trb_pool: array of transaction buffers
@@ -664,8 +663,6 @@ struct dwc3_ep {
struct list_headpending_list;
struct list_headstarted_list;
 
-   wait_queue_head_t   wait_end_transfer;
-
spinlock_t  lock;
void __iomem*regs;
 
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 8291fa1624e1..843586f20572 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -638,8 +638,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, 
unsigned int action)
reg |= DWC3_DALEPENA_EP(dep->number);
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
 
-   init_waitqueue_head(&dep->wait_end_transfer);
-
if (usb_endpoint_xfer_control(desc))
goto out;
 
@@ -1404,15 +1402,11 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
if (r == req) {
/* wait until it is processed */
dwc3_stop_active_transfer(dep, true);
-   wait_event_lock_irq(dep->wait_end_transfer,
-   !(dep->flags & 
DWC3_EP_END_TRANSFER_PENDING),
-   dwc->lock);
 
if (!r->trb)
goto out0;
 
dwc3_gadget_move_cancelled_request(req);
-   dwc3_gadget_ep_cleanup_cancelled_requests(dep);
goto out0;
}
dev_err(dwc->dev, "request %pK was not queued to %s\n",
@@ -1913,8 +1907,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
 {
struct dwc3 *dwc = gadget_to_dwc(g);
unsigned long   flags;
-   int epnum;
-   u32 tmo_eps = 0;
 
spin_lock_irqsave(&dwc->lock, flags);
 
@@ -1923,36 +1915,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
 
__dwc3_gadget_stop(dwc);
 
-   for (epnum = 2; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
-   struct dwc3_ep  *dep = dwc->eps[epnum];
-   int ret;
-
-   if (!dep)
-   continue;
-
-   if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
-   continue;
-
-   ret = 
wait_event_interruptible_lock_irq_timeout(dep->wait_end_transfer,
-   !(dep->flags & DWC3_EP_END_TRANSFER_PENDING),
-   dwc->lock, msecs_to_jiffies(5));
-
-   if (ret <= 0) {
-   /* Timed out or interrupted! There's nothing much
-* we can do so we just log here and print which
-* endpoints timed out at the end.
-*/
-   tmo_eps |= 1 << epnum;
-   dep->flags &= DWC3_EP_END_TRANSFER_PENDING;
-   }
-   }
-
-   if (tmo_eps) {
-   dev_err(dwc->dev,
-   "end transfer timed out on endpoints 0x%x [bitmap]\n",
-   tmo_eps);
-   }
-
 out:
dwc->gadget_driver  = NULL;
spin_unlock_irqrestore(&dwc->lock, flags);
@@ -2449,7 +2411,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
 
if (cmd == DWC3_DEPCMD_ENDTRANSFER) {
dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING;
-   wake_up(&dep->wait_end_transfer);
+   dwc3_gadget_ep_cleanup_cancelled_requests(dep);
}
break;
case DWC3_DEPEVT_STREAMEVT:
-- 
2.20.1





[PATCH 4.19 31/72] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup

2019-07-02 Thread Greg Kroah-Hartman
commit bd6742249b9ca918565e4e3abaa06665e587f4b5 upstream

OUT endpoint requests may somtimes have this flag set when
preparing to be submitted to HW indicating that there is an
additional TRB chained to the request for alignment purposes.
If that request is removed before the controller can execute the
transfer (e.g. ep_dequeue/ep_disable), the request will not go
through the dwc3_gadget_ep_cleanup_completed_request() handler
and will not have its needs_extra_trb flag cleared when
dwc3_gadget_giveback() is called.  This same request could be
later requeued for a new transfer that does not require an
extra TRB and if it is successfully completed, the cleanup
and TRB reclamation will incorrectly process the additional TRB
which belongs to the next request, and incorrectly advances the
TRB dequeue pointer, thereby messing up calculation of the next
requeust's actual/remaining count when it completes.

The right thing to do here is to ensure that the flag is cleared
before it is given back to the function driver.  A good place
to do that is in dwc3_gadget_del_and_unmap_request().

Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Cc: Fei Yang 
Cc: Sam Protsenko 
Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Cc: sta...@vger.kernel.org # 4.19.y
Signed-off-by: Jack Pham 
Signed-off-by: Felipe Balbi 
(cherry picked from commit bd6742249b9ca918565e4e3abaa06665e587f4b5)
Signed-off-by: John Stultz 
Signed-off-by: Sasha Levin 
---
 drivers/usb/dwc3/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 843586f20572..e7122b5199d2 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -177,6 +177,7 @@ static void dwc3_gadget_del_and_unmap_request(struct 
dwc3_ep *dep,
req->started = false;
list_del(&req->list);
req->remaining = 0;
+   req->needs_extra_trb = false;
 
if (req->request.status == -EINPROGRESS)
req->request.status = status;
-- 
2.20.1





Re: [GIT PULL] USB: changes for v5.3 merge window

2019-07-01 Thread Greg Kroah-Hartman
On Thu, Jun 27, 2019 at 10:55:47AM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's my pull request for v5.3 merge window. Relevant patches have been
> tested on platforms I have available.
> 
> Let me know if you want anything to be changed
> 
> cheers
> 
> The following changes since commit a954e5fb4bc2d401b8fc3b4c7cd316497ff80225:
> 
>   Merge 5.2-rc5 into usb-next (2019-06-17 11:23:24 +0200)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v5.3

Pulled and pushed out, thanks.

greg k-h


Re: [usb:usb-testing 46/46] drivers/usb//misc/adutux.c:375:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t {aka unsigned int}'

2019-06-20 Thread Greg Kroah-Hartman
On Thu, Jun 20, 2019 at 08:01:30AM -0700, dmg wrote:
> 
> kbuild test robot  writes:
> 
> [...]
> >
> > All warnings (new ones prefixed by >>):
> >
> >In file included from include/linux/printk.h:332:0,
> > from include/linux/kernel.h:15,
> > from drivers/usb//misc/adutux.c:19:
> >drivers/usb//misc/adutux.c: In function 'adu_read':
> >>> drivers/usb//misc/adutux.c:375:4: warning: format '%lu' expects argument 
> >>> of type 'long unsigned int', but argument 5 has type 'size_t {aka 
> >>> unsigned int}' [-Wformat=]
> >"%s : while, data_in_secondary=%lu, status=%d\n",
> 
> I am not sure what is the best way to address this warning.
> 
> size_t seems to be architecture dependent. On my computer (intel64)
> size_t is long unsigned int, but in this test it is int unsigned.
> 
> Are there any suggestions on what is the best way to deal with this?
> 
> casting size_t to long unsigned int will work, but it sounds kind of
> ugly.

As others have pointed out, there's a printk modifier for this.

I'll go drop your patch from my testing branch now, please fix up your
patch and resend.

thanks,

greg k-h


Re: [GIT PULL] USB: fixes for v5.2-rc5

2019-06-20 Thread Greg Kroah-Hartman
On Thu, Jun 20, 2019 at 12:13:01PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Just one pending fix this time.
> 
> Let me know if you need anything to be changed
> 
> cheers
> 
> 
> The following changes since commit 9e0babf2c06c73cda2c0cd37a1653d823adb40ec:
> 
>   Linux 5.2-rc5 (2019-06-16 08:49:45 -1000)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v5.2-rc5

Pulled and pushed out, thanks.

greg k-h


Re: [GIT PULL] USB-serial fixes for 5.2-rc5

2019-06-10 Thread Greg Kroah-Hartman
On Mon, Jun 10, 2019 at 03:48:29PM +0200, Johan Hovold wrote:
> The following changes since commit a188339ca5a396acc588e5851ed7e19f66b0ebd9:
> 
>   Linux 5.2-rc1 (2019-05-19 15:47:09 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.2-rc5

Pulled and pushed out, thanks.

greg k-h


Re: [GIT PULL] USB: fixes for v5.2-rc4

2019-06-08 Thread Greg Kroah-Hartman
On Fri, Jun 07, 2019 at 09:33:29AM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's my first set of fixes for this -rc cycle. Looks like most of what
> I have in my inbox these days are new features. Very little fixes. I
> guess folks are writing perfect code now :-p
> 
> Let me know if you want anything to be changed.
> 
> Cheers
> 
>  _ 
> < That's some perfect C, partner. >
>  - 
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
> 
> The following changes since commit f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a:
> 
>   Linux 5.2-rc3 (2019-06-02 13:55:33 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v5.2-rc4

Pulled and pushed out, thanks!

greg k-h


Re: [PATCH usbutils] usb-devices.1: don't mention bash

2019-06-06 Thread Greg Kroah-Hartman
On Tue, May 28, 2019 at 02:37:04PM +0300, Baruch Siach wrote:
> Since commit 508d1acf42e ("usb-devices: use /bin/sh hashbang")
> usb-devices does not require bash.
> 
> Signed-off-by: Baruch Siach 
> ---
>  usb-devices.1.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/usb-devices.1.in b/usb-devices.1.in
> index c5c1b798e4c3..2b142371cd67 100644
> --- a/usb-devices.1.in
> +++ b/usb-devices.1.in
> @@ -11,7 +11,7 @@ usb-devices \- print USB device details
>  
>  .SH DESCRIPTION
>  .B usb-devices
> -is a (bash) shell script that can be used to display details of USB
> +is a shell script that can be used to display details of USB
>  buses in the system and the devices connected to them.
>  
>  The output of the script is similar to the \fIusb/devices\fP file
> -- 
> 2.20.1
> 

Now applied, thanks!

greg k-h


Re: [PATCH v2] USB: move usb debugfs directory creation to the usb common core

2019-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2019 at 01:44:26PM +0200, Marc Gonzalez wrote:
> On 05/06/2019 11:28, Greg Kroah-Hartman wrote:
> 
> > The USB gadget subsystem wants to use the USB debugfs root directory, so
> > move it to the common "core" USB code so that it is properly initialized
> > and removed as needed.
> > 
> > In order to properly do this, we need to load the common code before the
> > usb core code, when everything is linked into the kernel, so reorder the
> > link order of the code.
> > 
> > Also as the usb common code has the possibility of the led trigger logic
> > to be merged into it, handle the build option properly by only having
> > one module init/exit function and have the common code initialize the
> > led trigger if needed.
> > 
> > Reported-by: From: Chunfeng Yun 
> 
> You have a spurious "From: " in there ;-)

Ugh, cut/paste error, thanks, will fix!


Re: [PATCH] Fix chipmunk-like voice when using Logitech C270 for recording audio.

2019-06-05 Thread Greg Kroah-Hartman
On Tue, Jun 04, 2019 at 11:14:37AM +0200, Oliver Neukum wrote:
> Am Montag, den 03.06.2019, 19:55 +0200 schrieb Marco Zatta:
> > On Mon, Jun 03, 2019 at 11:58:10AM +0200, Oliver Neukum wrote:
> > > Are you sure only the C270 is affected?
> > > 
> > >   Regards
> > >   Oliver
> > 
> > Hello Oliver,
> > 
> > No, unfortunately I am not sure but I am missing the hardware to
> > properly test. I am quite sure that it fixes the problem in the C270
> > though :)
> 
> Well, after all that time neither do I have the test hardware.
> And I doubt that for some reason only the C270 should be affected.
> 
> > Thanks for that, since you were the author of the first commit.
> 
> I appreciate your patch, but I think teh safe option would be to do
> it for all models.

As we don't have anyone else complaining at the moment, let's just take
this patch as-for now.

thanks,

greg k-h


Re: Extending USB_CONNECTINFO ioctl

2019-06-04 Thread Greg Kroah-Hartman
On Tue, Jun 04, 2019 at 09:14:51AM -0700, Dmitry Torokhov wrote:
> Hi Alan,
> 
> On Tue, Jun 04, 2019 at 10:17:25AM -0400, Alan Stern wrote:
> > On Mon, 3 Jun 2019, Dmitry Torokhov wrote:
> > 
> > > Hi Alan, Greg,
> > > 
> > > When running software in a jailed environment where sysfs or udev is not
> > > readily available and one can only have an FD to usbdevfs device passed
> > > into the jail, there is a desire to allow libusb working. Alan recently
> > > added USBDEVFS_GET_SPEED, but we are still missing bus number and list
> > > of port numbers on the way to the root to be able to better identify the
> > > device in question.
> > > 
> > > What do you think about adding a new ioctl:
> > > 
> > > struct usbdevfs_connectinfo_ex {
> > >   __u32 size; /* size of the structure from the kernel POV */
> > 
> > This should be an input/output parameter.  That is, the original value
> > says how big the userspace structure is, and the value stored by the
> > kernel says how much space was actually filled in.  Or alternatively, 
> > have two size fields (one for input and one for output).
> 
> The "incoming" size is encoded in the ioctl number (the 'len' argument
> in USBDEVFS_CONNINFO_EX()), there is no reason to add it separately (or
> make read/write).
> 
> > 
> > >   __u32 busnum;
> > >   __u32 devnum;
> > >   __u32 speed;/* USB_SPEED_* form ch9.h */
> > >   u8 num_ports;   /* Number of entries in port_numbers array */
> > >   u8 port_numbers[31];/* Current limit in USB3.0 spec is 7 */
> > > };
> > 
> > Yeah, 31 is overkill.  Even the USB-2.0 spec limits the topology to 7
> > tiers (including the root hub), meaning that only 6 port numbers are
> > needed.
> 
> If you insist I can bring it down to 7, but this structure is short
> lived, on stack, and there should not be many of them in the kernel, so
> if we can avoid extending a particular field in the future I think it is
> worth it.

I don't know what USB 4 has in it (and if I did, I couldn't mention it),
but someone who can see those specs might want to take a look at them to
just say "yeah, 31 looks like a good number" or "nope, make it a bit
bigger please!"

thanks,

greg k-h


Re: [PATCH v4] usb: create usb_debug_root for gadget only

2019-06-04 Thread Greg Kroah-Hartman
On Tue, Jun 04, 2019 at 04:59:14PM +0800, Chunfeng Yun wrote:
> On Tue, 2019-06-04 at 09:37 +0200, Greg Kroah-Hartman wrote:
> > On Tue, Jun 04, 2019 at 03:34:07PM +0800, Chunfeng Yun wrote:
> > > When CONFIG_USB is not set, and CONFIG_USB_GADGET is set,
> > > there is an issue, e.g.:
> > > 
> > > drivers/usb/mtu3/mtu3_debugfs.o: in function 'ssusb_debugfs_create_root':
> > > mtu3_debugfs.c:(.text+0xba3): undefined reference to 'usb_debug_root'
> > > 
> > > usb_debug_root is currently only built when host is supported
> > > (CONFIG_USB is set), for convenience, we also want it created when
> > > gadget only is enabled, this patch try to support it.
> > > 
> > > Reported-by: Randy Dunlap 
> > > Signed-off-by: Chunfeng Yun 
> > > ---
> > > v4:
> > >   move common API into common.c suggested by Felipe
> > > 
> > > v3:
> > >   1. still create usb_debug_root for gadget only
> > >   2. abandon mtu3's change
> > >   3. drop acked-by Randy
> > > 
> > > v2(resend): add acked-by Randy
> > > 
> > > v1: fix mtu3's build error, replace usb_debug_root by NULL;
> > > ---
> > >  drivers/usb/common/common.c   | 26 ++
> > >  drivers/usb/core/usb.c| 16 
> > >  drivers/usb/gadget/udc/core.c |  3 +++
> > >  include/linux/usb.h   |  2 ++
> > >  4 files changed, 35 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> > > index 18f5dcf58b0d..c52e9c9f58ec 100644
> > > --- a/drivers/usb/common/common.c
> > > +++ b/drivers/usb/common/common.c
> > > @@ -15,6 +15,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  
> > >  static const char *const ep_type_names[] = {
> > >   [USB_ENDPOINT_XFER_CONTROL] = "ctrl",
> > > @@ -139,6 +140,31 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev)
> > >  }
> > >  EXPORT_SYMBOL_GPL(usb_get_dr_mode);
> > >  
> > > +struct dentry *usb_debug_root;
> > > +EXPORT_SYMBOL_GPL(usb_debug_root);
> > > +
> > > +static atomic_t usb_debug_root_refcnt = ATOMIC_INIT(0);
> > 
> > Ick, no.
> > 
> > > +
> > > +struct dentry *usb_debugfs_init(void)
> > > +{
> > > + if (!usb_debug_root)
> > > + usb_debug_root = debugfs_create_dir("usb", NULL);
> > > +
> > > + atomic_inc(&usb_debug_root_refcnt);
> > > +
> > > + return usb_debug_root;
> > > +}
> > > +EXPORT_SYMBOL_GPL(usb_debugfs_init);
> > > +
> > > +void usb_debugfs_cleanup(void)
> > > +{
> > > + if (atomic_dec_and_test(&usb_debug_root_refcnt)) {
> > > + debugfs_remove_recursive(usb_debug_root);
> > > + usb_debug_root = NULL;
> > > + }
> > > +}
> > > +EXPORT_SYMBOL_GPL(usb_debugfs_cleanup);
> > 
> > Only remove the debugfs subdir if the usbcore module is removed. 
> Both usbcore module and gadget module will use this "usb" subdir now.
> Gadget module may still use it when remove usbcore module.

Did you try to remove the usb-common module with the udc gadget module
remaining loaded with this change in place?  I think you will find that
it is impossible given that the udc gadget module now depends on a
symbol in the usb-common code.

So again, just use the module reference counting logic to drive this
functionality, don't create an atomic variable that duplicates the
logic we already have in place today.

thanks,

greg k-h


Re: Extending USB_CONNECTINFO ioctl

2019-06-03 Thread Greg Kroah-Hartman
On Mon, Jun 03, 2019 at 05:24:10PM -0700, Dmitry Torokhov wrote:
> Hi Alan, Greg,
> 
> When running software in a jailed environment where sysfs or udev is not
> readily available and one can only have an FD to usbdevfs device passed
> into the jail, there is a desire to allow libusb working. Alan recently
> added USBDEVFS_GET_SPEED, but we are still missing bus number and list
> of port numbers on the way to the root to be able to better identify the
> device in question.
> 
> What do you think about adding a new ioctl:
> 
> struct usbdevfs_connectinfo_ex {
>   __u32 size; /* size of the structure from the kernel POV */
>   __u32 busnum;
>   __u32 devnum;
>   __u32 speed;/* USB_SPEED_* form ch9.h */
>   u8 num_ports;   /* Number of entries in port_numbers array */
>   u8 port_numbers[31];/* Current limit in USB3.0 spec is 7 */
> };
> 
> /*
>  * Returns struct usbdevfs_connectinfo_ex; length is variable to allow
>  * extending size of the data returned.
>  */
> #define USBDEVFS_CONNINFO_EX(len)  _IOC(_IOC_READ, 'U', 32, len)

Sounds reasonable, as long as you get the 'variable data' portion
correct :)

thanks,

greg k-h


[PATCH 2/2] USB: atm: ueagle-atm.c: remove redundant license text

2019-05-24 Thread Greg Kroah-Hartman
Now that we have the correct SPDX tag for the ueagle-atm.c file, the
wall of "boiler-plate" text is not needed.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Thomas Gleixner 
Cc: Matthieu CASTET 
Cc: Stanislaw Gruszka 
Cc: Damien Bergamini 
Cc: Duncan Sands 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/atm/ueagle-atm.c | 46 +---
 1 file changed, 1 insertion(+), 45 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f0c622a87436..8faa51b1a520 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1,55 +1,11 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause)
-/*-
+/*
  * Copyright (c) 2003, 2004
  * Damien Bergamini . All rights reserved.
  *
  * Copyright (c) 2005-2007 Matthieu Castet 
  * Copyright (c) 2005-2007 Stanislaw Gruszka 
  *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * BSD license below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice unmodified, this list of conditions, and the following
- *disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * GPL license :
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- *
  * HISTORY : some part of the code was base on ueagle 1.3 BSD driver,
  * Damien Bergamini agree to put his code under a DUAL GPL/BSD license.
  *
-- 
2.21.0



[PATCH 1/2] USB: atm: ueagle-atm.c: fix SPDX tag to be BSD2

2019-05-24 Thread Greg Kroah-Hartman
Thomas rightly points out that I got the BSD clause count wrong for this
driver, it should be 2, not 3 based on the text in the license here, so
fix that up.

He also raises the question that the license text points to a v2 only
license, yet the text in the header says "or later".  Given that the
text in the header says "or later" and all of the other USB atm drivers
are licensed in that way, I am going to leave the string as-is for that
mark.

Reported-by: Thomas Gleixner 
Cc: Matthieu CASTET 
Cc: Stanislaw Gruszka 
Cc: Damien Bergamini 
Cc: Duncan Sands 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/atm/ueagle-atm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 2754b4ce7136..f0c622a87436 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause)
 /*-
  * Copyright (c) 2003, 2004
  * Damien Bergamini . All rights reserved.
-- 
2.21.0



Re: [usb:usb-linus] BUILD REGRESSION c1a145a3ed9a40f3b6145feb97789e8eb49c5566

2019-05-23 Thread Greg Kroah-Hartman
On Thu, May 23, 2019 at 01:58:01AM +0800, kbuild test robot wrote:
> tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git  
> usb-linus
> branch HEAD: c1a145a3ed9a40f3b6145feb97789e8eb49c5566  xhci: Use %zu for 
> printing size_t type
> 
> Regressions in current branch:
> 
> drivers/usb/usbip/stub_dev.c:399:9: sparse: sparse: context imbalance in 
> 'stub_probe' - different lock contexts for basic block
> drivers/usb/usbip/stub_dev.c:418:13: sparse: sparse: context imbalance in 
> 'stub_disconnect' - different lock contexts for basic block
> drivers/usb/usbip/stub_dev.c:464:1-10: second lock on line 476
> 
> Error ids grouped by kconfigs:
> 
> recent_errors
> ├── i386-allmodconfig
> │   └── drivers-usb-usbip-stub_dev.c:second-lock-on-line
> ├── x86_64-allmodconfig
> │   ├── 
> drivers-usb-usbip-stub_dev.c:sparse:sparse:context-imbalance-in-stub_disconnect-different-lock-contexts-for-basic-block
> │   └── 
> drivers-usb-usbip-stub_dev.c:sparse:sparse:context-imbalance-in-stub_probe-different-lock-contexts-for-basic-block
> └── x86_64-allyesconfig
> └── drivers-usb-usbip-stub_dev.c:second-lock-on-line


Shuah, I just got this new report from 0-day about your commit
0c9e8b3cad65 ("usbip: usbip_host: fix BUG: sleeping function called from
invalid context") that got added to my tree recently.  Can you look into
this to see if it is a real error caused by this commit, or just
something that has always been there?

thanks,

greg k-h


Re: [usb:usb-linus 12/16] drivers/usb/host/xhci-ring.c:676:19: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t {aka unsigned int}'

2019-05-22 Thread Greg Kroah-Hartman
On Wed, May 22, 2019 at 08:54:56PM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
> usb-linus
> head:   f7fac17ca925faa03fc5eb854c081a24075f8bad
> commit: 597c56e372dab2c7f79b8d700aad3a5deebf9d1b [12/16] xhci: update bounce 
> buffer with correct sg num
> config: i386-randconfig-x018-201920 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> git checkout 597c56e372dab2c7f79b8d700aad3a5deebf9d1b
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot 
> 
> All warnings (new ones prefixed by >>):
> 
>In file included from include/linux/dma-mapping.h:7:0,
> from drivers/usb/host/xhci-ring.c:57:
>drivers/usb/host/xhci-ring.c: In function 'xhci_unmap_td_bounce_buffer':
> >> drivers/usb/host/xhci-ring.c:676:19: warning: format '%ld' expects 
> >> argument of type 'long int', but argument 3 has type 'size_t {aka unsigned 
> >> int}' [-Wformat=]
>   xhci_warn(xhci, "WARN Wrong bounce buffer read length: %ld != %d\n",
>   ^
>include/linux/device.h:1400:22: note: in definition of macro 'dev_fmt'
> #define dev_fmt(fmt) fmt
>  ^~~
> >> drivers/usb/host/xhci.h:1920:2: note: in expansion of macro 'dev_warn'
>  dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
>  ^~~~
> >> drivers/usb/host/xhci-ring.c:676:3: note: in expansion of macro 'xhci_warn'
>   xhci_warn(xhci, "WARN Wrong bounce buffer read length: %ld != %d\n",
>   ^
>drivers/usb/host/xhci-ring.c: In function 'xhci_align_td':
>drivers/usb/host/xhci-ring.c:3169:5: warning: format '%ld' expects 
> argument of type 'long int', but argument 3 has type 'size_t {aka unsigned 
> int}' [-Wformat=]
> "WARN Wrong bounce buffer write length: %ld != %d\n",
> ^
>include/linux/device.h:1400:22: note: in definition of macro 'dev_fmt'
> #define dev_fmt(fmt) fmt
>  ^~~
> >> drivers/usb/host/xhci.h:1920:2: note: in expansion of macro 'dev_warn'
>  dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
>  ^~~~
>drivers/usb/host/xhci-ring.c:3168:4: note: in expansion of macro 
> 'xhci_warn'
>xhci_warn(xhci,
>^

Can someone send me a follow-on patch to fix this up please?

thanks,

greg k-h


Re: [usb:usb-linus 3/10] drivers/media//usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function

2019-05-21 Thread Greg Kroah-Hartman
On Tue, May 21, 2019 at 09:49:36AM -0400, Alan Stern wrote:
> On Tue, 21 May 2019, Greg Kroah-Hartman wrote:
> 
> > On Tue, May 21, 2019 at 04:48:47PM +0800, kbuild test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
> > > usb-linus
> > > head:   53c7b63f797c96a30c21dd3b781fafaae096a12b
> > > commit: 31e0456de5be379b10fea0fa94a681057114a96e [3/10] media: usb: 
> > > siano: Fix general protection fault in smsusb
> > > config: mips-allmodconfig (attached as .config)
> > > compiler: mips-linux-gcc (GCC) 8.1.0
> > > reproduce:
> > > wget 
> > > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross 
> > > -O ~/bin/make.cross
> > > chmod +x ~/bin/make.cross
> > > git checkout 31e0456de5be379b10fea0fa94a681057114a96e
> > > # save the attached .config to linux build tree
> > > GCC_VERSION=8.1.0 make.cross ARCH=mips 
> > > 
> > > If you fix the issue, kindly add following tag
> > > Reported-by: kbuild test robot 
> > > 
> > > Note: it may well be a FALSE warning. FWIW you are at least aware of it 
> > > now.
> > > http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
> > 
> > False positive, gcc isn't smart enough here.
> 
> Should I send a patch initializing the value to 0 anyway?

Probably :(



Re: [usb:usb-linus 3/10] drivers/media//usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function

2019-05-21 Thread Greg Kroah-Hartman
On Tue, May 21, 2019 at 04:48:47PM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
> usb-linus
> head:   53c7b63f797c96a30c21dd3b781fafaae096a12b
> commit: 31e0456de5be379b10fea0fa94a681057114a96e [3/10] media: usb: siano: 
> Fix general protection fault in smsusb
> config: mips-allmodconfig (attached as .config)
> compiler: mips-linux-gcc (GCC) 8.1.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 31e0456de5be379b10fea0fa94a681057114a96e
> # save the attached .config to linux build tree
> GCC_VERSION=8.1.0 make.cross ARCH=mips 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot 
> 
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

False positive, gcc isn't smart enough here.

greg k-h


Re: TODO advice for octeon-usb?

2019-05-21 Thread Greg Kroah-Hartman
On Tue, May 21, 2019 at 02:05:32AM +0300, Aaro Koskinen wrote:
> Hi,
> 
> I'm looking for input what should be done next to get
> drivers/staging/octeon-usb out of staging.
> 
> Thousands of checkpatch errors/warnings have been fixed (starting point
> was ),
> also the size of the driver has shrunken considerably.
> 
> If there are still some other bigger issues with this driver, please
> let me know.

Submit it as a patch that just adds the files to the drivers/usb/host/
directory so we can review it on linux-usb@vger and if it gets accepted,
I can then drop it from the staging directory, or just move it over if
no changes are needed.

thanks,

greg k-h


Re: [PATCH 1/5] USB: serial: fix unthrottle races

2019-05-13 Thread Greg Kroah-Hartman
On Mon, May 13, 2019 at 01:46:01PM +0200, Johan Hovold wrote:
> On Mon, May 13, 2019 at 12:56:06PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, May 13, 2019 at 12:43:39PM +0200, Johan Hovold wrote:
> > > On Thu, Apr 25, 2019 at 06:05:36PM +0200, Johan Hovold wrote:
> > > > Fix two long-standing bugs which could potentially lead to memory
> > > > corruption or leave the port throttled until it is reopened (on weakly
> > > > ordered systems), respectively, when read-URB completion races with
> > > > unthrottle().
> 
> > > > Fixes: d83b405383c9 ("USB: serial: add support for multiple read urbs")
> > > > Signed-off-by: Johan Hovold 
> > > 
> > > Greg, I noticed you added a stable tag to the corresponding cdc-acm fix
> > > and think I should have added on one from the start to this one as well.
> > > 
> > > Would you mind queuing this one up for stable?
> > > 
> > > Upstream commit 3f5edd58d040bfa4b74fb89bc02f0bc6b9cd06ab.
> > 
> > Sure, now queued up for 4.9+
> 
> Thanks. The issue has been there since v3.3 so I guess you could queue
> it for all stable trees.

Doesn't apply cleanly for 4.4.y or 3.18.y, so if it's really worth
adding there (and I kind of doubt it), I would need a backport :)

thanks,

greg k-h


Re: [PATCH 1/5] USB: serial: fix unthrottle races

2019-05-13 Thread Greg Kroah-Hartman
On Mon, May 13, 2019 at 12:43:39PM +0200, Johan Hovold wrote:
> On Thu, Apr 25, 2019 at 06:05:36PM +0200, Johan Hovold wrote:
> > Fix two long-standing bugs which could potentially lead to memory
> > corruption or leave the port throttled until it is reopened (on weakly
> > ordered systems), respectively, when read-URB completion races with
> > unthrottle().
> > 
> > First, the URB must not be marked as free before processing is complete
> > to prevent it from being submitted by unthrottle() on another CPU.
> > 
> > CPU 1   CPU 2
> > 
> > complete()  unthrottle()
> >   process_urb();
> >   smp_mb__before_atomic();
> >   set_bit(i, free);   if (test_and_clear_bit(i, free))
> >   submit_urb();
> > 
> > Second, the URB must be marked as free before checking the throttled
> > flag to prevent unthrottle() on another CPU from failing to observe that
> > the URB needs to be submitted if complete() sees that the throttled flag
> > is set.
> > 
> > CPU 1   CPU 2
> > 
> > complete()  unthrottle()
> >   set_bit(i, free);   throttled = 0;
> >   smp_mb__after_atomic(); smp_mb();
> >   if (throttled)  if (test_and_clear_bit(i, free))
> >   return; submit_urb();
> > 
> > Note that test_and_clear_bit() only implies barriers when the test is
> > successful. To handle the case where the URB is still in use an explicit
> > barrier needs to be added to unthrottle() for the second race condition.
> > 
> > Fixes: d83b405383c9 ("USB: serial: add support for multiple read urbs")
> > Signed-off-by: Johan Hovold 
> 
> Greg, I noticed you added a stable tag to the corresponding cdc-acm fix
> and think I should have added on one from the start to this one as well.
> 
> Would you mind queuing this one up for stable?
> 
> Upstream commit 3f5edd58d040bfa4b74fb89bc02f0bc6b9cd06ab.

Sure, now queued up for 4.9+

thanks,

greg k-h


Re: [GIT PULL] USB changes for v5.2 merge window

2019-05-03 Thread Greg Kroah-Hartman
On Fri, May 03, 2019 at 12:15:18PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> here's my pull request for the next merge window. A bit later than
> usuall this time around, due to internal high-priority tasks. Sorry
> about that.
> 
> Let me know if you need anything to be changed.
> 
> cheers
> 
>  ___ 
> < Busy as a bee >
>  --- 
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
> 
> The following changes since commit 085b7755808aa11f78ab9377257e1dad2e6fa4bb:
> 
>   Linux 5.1-rc6 (2019-04-21 10:45:57 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v5.2

Pulled and pushed out, thanks.

greg k-h


Re: [GIT PULL] USB-serial updates for 5.2-rc1

2019-05-03 Thread Greg Kroah-Hartman
On Fri, May 03, 2019 at 05:36:50PM +0200, Johan Hovold wrote:
> The following changes since commit 79a3aaa7b82e3106be97842dedfd8429248896e6:
> 
>   Linux 5.1-rc3 (2019-03-31 14:39:29 -0700)
> 
> are available in the Git repository at:
> 
>   https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git 
> tags/usb-serial-5.2-rc1

Pulled and pushed out, thanks.

greg k-h


[PATCH] USB: serial: io_edgeport: fix up switch fall-through comments

2019-05-02 Thread Greg Kroah-Hartman
Gustavo has been working to fix up all of the switch statements that
"fall through" such that we can eventually turn on
-Wimplicit-fallthrough.  As part of that, the io_edgeport.c driver is a
bit "messy" with the parsing logic of a data packet.  Clean that logic
up a bit by unindenting one level of the logic, and properly label
/* Fall through */ to make gcc happy.

Reported-by: Gustavo A. R. Silva 
Signed-off-by: Greg Kroah-Hartman 

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 4ca31c0e4174..48a439298a68 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1751,7 +1751,7 @@ static void process_rcvd_data(struct edgeport_serial 
*edge_serial,
edge_serial->rxState = EXPECT_HDR2;
break;
}
-   /* otherwise, drop on through */
+   /* Fall through */
case EXPECT_HDR2:
edge_serial->rxHeader2 = *buffer;
++buffer;
@@ -1790,29 +1790,20 @@ static void process_rcvd_data(struct edgeport_serial 
*edge_serial,
edge_serial->rxHeader2, 0);
edge_serial->rxState = EXPECT_HDR1;
break;
-   } else {
-   edge_serial->rxPort =
-   IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
-   edge_serial->rxBytesRemaining =
-   IOSP_GET_HDR_DATA_LEN(
-   edge_serial->rxHeader1,
-   edge_serial->rxHeader2);
-   dev_dbg(dev, "%s - Data for Port %u Len %u\n",
-   __func__,
-   edge_serial->rxPort,
-   edge_serial->rxBytesRemaining);
-
-   /* ASSERT(DevExt->RxPort < DevExt->NumPorts);
-* ASSERT(DevExt->RxBytesRemaining <
-*  IOSP_MAX_DATA_LENGTH);
-*/
-
-   if (bufferLength == 0) {
-   edge_serial->rxState = EXPECT_DATA;
-   break;
-   }
-   /* Else, drop through */
}
+
+   edge_serial->rxPort = 
IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
+   edge_serial->rxBytesRemaining = 
IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1,
+ 
edge_serial->rxHeader2);
+   dev_dbg(dev, "%s - Data for Port %u Len %u\n", __func__,
+   edge_serial->rxPort,
+   edge_serial->rxBytesRemaining);
+
+   if (bufferLength == 0) {
+   edge_serial->rxState = EXPECT_DATA;
+   break;
+   }
+   /* Fall through */
case EXPECT_DATA: /* Expect data */
if (bufferLength < edge_serial->rxBytesRemaining) {
rxLen = bufferLength;


Re: USB fuzzing with syzbot

2019-04-25 Thread Greg Kroah-Hartman
On Thu, Apr 25, 2019 at 02:44:11PM +0200, Andrey Konovalov wrote:
> On Wed, Apr 24, 2019 at 6:05 PM Andrey Konovalov  
> wrote:
> >
> > On Fri, Apr 19, 2019 at 10:35 AM Greg Kroah-Hartman
> >  wrote:
> > >
> > > > 2. Is there an easy way to figure out which config options enable
> > > > drivers reachable over USB?
> > >
> > > Looking for all options that depend on USB is a good start.
> > >
> > > > Right now our kernel config is based on one of the Debian kernel
> > > > configs, that supposedly enables enough relevant USB drivers. At the
> > > > same time it enables a lot of other unnecessary stuff, which makes the
> > > > kernel big and long to compile. Ideally, we would to have a way to
> > > > auto-generate a kernel config that enables all the relevant (enabled
> > > > by at least one of the distros) USB drivers. I've looked at whether
> > > > it's possible to figure out which particular options in some kernel
> > > > config are related to USB, but it seems that neither the option names,
> > > > nor the way they are grouped in the config file, are representative
> > > > enough.
> > >
> > > Yeah, it's hard to just carve out this type of configuration, but here's
> > > what I have done in the past to try to be sure I enabled all USB drivers
> > > in my kernel configuration.
> > >
> > > First, start with a "minimally working configuration" by running:
> > > make localmodconfig
> > > on a working system, with the needed modules for booting and operating
> > > properly already loaded.
> > >
> > > That gives you a .config file that should take only minutes to build,
> > > compared to much longer for the normal distro configuration (also be
> > > sure to disable some debugging options so you don't spend extra time
> > > building and stripping symbols).
> > >
> > > Boot and make sure that configuration works.
> > >
> > > Then, take that .config and do:
> > > - disable USB from the configuration by deleting the:
> > > CONFIG_USB_SUPPORT=y
> > >   option from your .config
> > > - run 'make oldconfig' to disable all USB drivers
> > > - turn USB back on by setting CONFIG_USB_SUPPORT=y back on in
> > >   your .config
> > > - run 'make oldconfig' and answer 'y' or 'm' to all of the
> > >   driver options you are presented with.
> > >
> > > That usually catches almost all of them.  Sometimes you need to make
> > > sure you have some other subsystem enabled (like SCSI), but odds are, if
> > > you start with a "normally stripped down" configuration that works, you
> > > should be fine.
> >
> > I suspect that make localmodconfig (+ switching CONFIG_USB_SUPPORT off
> > and on) would likely include a lot of stuff that we don't need (there
> > are many options that are =y, but not related to USB at all), but it
> > definitely sounds better than what I have right now (converting almost
> > all =m into =y). I'll give it a shot, thanks!
> 
> I've tried this and unfortunately it doesn't work as desired. The
> reason is that localmodconfig will only enable options for the modules
> that are currently loaded, and if a module that some USB driver
> depends on is not loaded, then this driver won't be enabled after yes
> | make oldconfig. For example my machine didn't have the cfg80211
> module loaded, and thus e.g. CONFIG_AT76C50X_USB didn't get enabled
> after oldconfig. However when I plug in a wireless USB adapter,
> cfg80211 gets loaded together with the USB driver for that adapter. I
> guess the same applies to other kinds of dependency modules (e.g.
> bluetooth). So this would only work if all the dependency modules are
> already loaded.

Yes, sorry, I thought I said that with:

> > > First, start with a "minimally working configuration" by running:
> > > make localmodconfig
> > > on a working system, with the needed modules for booting and operating
> > > properly already loaded.

I guess "working system" implied everything that you _knew_ you wanted
to have loaded :)

Sorry about the dependancy mess, hopefully you have sorted this out
better now.

thanks,

greg k-h


Re: [PATCH v4 0/7] usb: typec: ucsi: Remaining changes for v5.2

2019-04-25 Thread Greg Kroah-Hartman
On Tue, Apr 23, 2019 at 05:21:44PM +0300, Heikki Krogerus wrote:
> Hi Greg,
> 
> Ajay noticed that I was not considering earlier releases of the UCSI
> specification with a specific UCSI command, GET_CURRENT_CAM, in v3.
> The definition for the command was changed in UCSI specification v1.1.
> The issue is now fixed.

Looks good, thanks for sticking with these, now all queued up.

greg k-h


  1   2   3   4   5   6   7   8   9   10   >