1. 15 3月, 2020 3 次提交
  2. 04 3月, 2020 9 次提交
  3. 17 2月, 2020 1 次提交
  4. 13 2月, 2020 6 次提交
  5. 11 2月, 2020 17 次提交
    • C
      usb: dwc3: debug: fix string position formatting mixup with ret and len · 42cd5ffe
      Colin Ian King 提交于
      Currently the string formatting is mixing up the offset of ret and
      len. Re-work the code to use just len, remove ret and use scnprintf
      instead of snprintf and len position accumulation where required.
      Remove the -ve return check since scnprintf never returns a failure
      -ve size. Also break overly long lines to clean up checkpatch
      warnings.
      
      Addresses-Coverity: ("Unused value")
      Fixes: 1381a511 ("usb: dwc3: debug: purge usage of strcat")
      Reviewed-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      42cd5ffe
    • S
      usb: gadget: serial: fix Tx stall after buffer overflow · e4bfded5
      Sergey Organov 提交于
      Symptom: application opens /dev/ttyGS0 and starts sending (writing) to
      it while either USB cable is not connected, or nobody listens on the
      other side of the cable. If driver circular buffer overflows before
      connection is established, no data will be written to the USB layer
      until/unless /dev/ttyGS0 is closed and re-opened again by the
      application (the latter besides having no means of being notified about
      the event of establishing of the connection.)
      
      Fix: on open and/or connect, kick Tx to flush circular buffer data to
      USB layer.
      Signed-off-by: NSergey Organov <sorganov@gmail.com>
      Reviewed-by: NMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      e4bfded5
    • L
      usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags · 43d56572
      Lars-Peter Clausen 提交于
      ffs_aio_cancel() can be called from both interrupt and thread context. Make
      sure that the current IRQ state is saved and restored by using
      spin_{un,}lock_irq{save,restore}().
      
      Otherwise undefined behavior might occur.
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      43d56572
    • M
      usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows · 9a0d6f7c
      Minas Harutyunyan 提交于
      SET/CLEAR_FEATURE for Remote Wakeup allowance not handled correctly.
      GET_STATUS handling provided not correct data on DATA Stage.
      Issue seen when gadget's dr_mode set to "otg" mode and connected
      to MacOS.
      Both are fixed and tested using USBCV Ch.9 tests.
      Signed-off-by: NMinas Harutyunyan <hminas@synopsys.com>
      Fixes: fa389a6d ("usb: dwc2: gadget: Add remote_wakeup_allowed flag")
      Tested-by: NJack Mitchell <ml@embed.me.uk>
      Cc: stable@vger.kernel.org
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      9a0d6f7c
    • M
      usb: dwc2: Fix in ISOC request length checking · 860ef6cd
      Minas Harutyunyan 提交于
      Moved ISOC request length checking from dwc2_hsotg_start_req() function to
      dwc2_hsotg_ep_queue().
      
      Fixes: 4fca54aa ("usb: gadget: s3c-hsotg: add multi count support")
      Signed-off-by: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      860ef6cd
    • J
      usb: gadget: composite: Support more than 500mA MaxPower · a2035411
      Jack Pham 提交于
      USB 3.x SuperSpeed peripherals can draw up to 900mA of VBUS power
      when in configured state. However, if a configuration wanting to
      take advantage of this is added with MaxPower greater than 500
      (currently possible if using a ConfigFS gadget) the composite
      driver fails to accommodate this for a couple reasons:
      
       - usb_gadget_vbus_draw() when called from set_config() and
         composite_resume() will be passed the MaxPower value without
         regard for the current connection speed, resulting in a
         violation for USB 2.0 since the max is 500mA.
      
       - the bMaxPower of the configuration descriptor would be
         incorrectly encoded, again if the connection speed is only
         at USB 2.0 or below, likely wrapping around U8_MAX since
         the 2mA multiplier corresponds to a maximum of 510mA.
      
      Fix these by adding checks against the current gadget->speed
      when the c->MaxPower value is used (set_config() and
      composite_resume()) and appropriately limit based on whether
      it is currently at a low-/full-/high- or super-speed connection.
      
      Because 900 is not divisible by 8, with the round-up division
      currently used in encode_bMaxPower() a MaxPower of 900mA will
      result in an encoded value of 0x71. When a host stack (including
      Linux and Windows) enumerates this on a single port root hub, it
      reads this value back and decodes (multiplies by 8) to get 904mA
      which is strictly greater than 900mA that is typically budgeted
      for that port, causing it to reject the configuration. Instead,
      we should be using the round-down behavior of normal integral
      division so that 900 / 8 -> 0x70 or 896mA to stay within range.
      And we might as well change it for the high/full/low case as well
      for consistency.
      
      N.B. USB 3.2 Gen N x 2 allows for up to 1500mA but there doesn't
      seem to be any any peripheral controller supported by Linux that
      does two lane operation, so for now keeping the clamp at 900
      should be fine.
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      a2035411
    • J
      usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus · c724417b
      Jack Pham 提交于
      SuperSpeedPlus peripherals must report their bMaxPower of the
      configuration descriptor in units of 8mA as per the USB 3.2
      specification. The current switch statement in encode_bMaxPower()
      only checks for USB_SPEED_SUPER but not USB_SPEED_SUPER_PLUS so
      the latter falls back to USB 2.0 encoding which uses 2mA units.
      Replace the switch with a simple if/else.
      
      Fixes: eae5820b ("usb: gadget: composite: Write SuperSpeedPlus config descriptors")
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      c724417b
    • J
      usb: gadget: u_audio: Fix high-speed max packet size · 904967c6
      John Keeping 提交于
      Prior to commit eb9fecb9 ("usb: gadget: f_uac2: split out audio
      core") the maximum packet size was calculated only from the high-speed
      descriptor but now we use the largest of the full-speed and high-speed
      descriptors.
      
      This is correct, but the full-speed value is likely to be higher than
      that for high-speed and this leads to submitting requests for OUT
      transfers (received by the gadget) which are larger than the endpoint's
      maximum packet size.  These are rightly rejected by the gadget core.
      
      config_ep_by_speed() already sets up the correct maximum packet size for
      the enumerated speed in the usb_ep structure, so we can simply use this
      instead of the overall value that has been used to allocate buffers for
      requests.
      
      Note that the minimum period for ALSA is still set from the largest
      value, and this is unavoidable because it's possible to open the audio
      device before the gadget has been enumerated.
      Tested-by: NPavel Hofman  <pavel.hofman@ivitera.com>
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      904967c6
    • A
      usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields · 5ee85897
      Anurag Kumar Vulisha 提交于
      The current code in dwc3_gadget_ep_reclaim_completed_trb() will
      check for IOC/LST bit in the event->status and returns if
      IOC/LST bit is set. This logic doesn't work if multiple TRBs
      are queued per request and the IOC/LST bit is set on the last
      TRB of that request.
      
      Consider an example where a queued request has multiple queued
      TRBs and IOC/LST bit is set only for the last TRB. In this case,
      the core generates XferComplete/XferInProgress events only for
      the last TRB (since IOC/LST are set only for the last TRB). As
      per the logic in dwc3_gadget_ep_reclaim_completed_trb()
      event->status is checked for IOC/LST bit and returns on the
      first TRB. This leaves the remaining TRBs left unhandled.
      
      Similarly, if the gadget function enqueues an unaligned request
      with sglist already in it, it should fail the same way, since we
      will append another TRB to something that already uses more than
      one TRB.
      
      To aviod this, this patch changes the code to check for IOC/LST
      bits in TRB->ctrl instead.
      
      At a practical level, this patch resolves USB transfer stalls seen
      with adb on dwc3 based HiKey960 after functionfs gadget added
      scatter-gather support around v4.20.
      
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Yang Fei <fei.yang@intel.com>
      Cc: Thinh Nguyen <thinhn@synopsys.com>
      Cc: Tejas Joglekar <tejas.joglekar@synopsys.com>
      Cc: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
      Cc: Jack Pham <jackp@codeaurora.org>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Linux USB List <linux-usb@vger.kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Tested-by: NTejas Joglekar <tejas.joglekar@synopsys.com>
      Reviewed-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
      [jstultz: forward ported to mainline, reworded commit log, reworked
       to only check trb->ctrl as suggested by Felipe]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      5ee85897
    • J
      USB: core: clean up endpoint-descriptor parsing · 7f1b92a6
      Johan Hovold 提交于
      Use the new usb-device pointer instead of back-casting when accessing
      the struct usb_device when parsing endpoints.
      
      Note that this introduces two lines that are longer than 80 chars on
      purpose.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200203153830.26394-4-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f1b92a6
    • J
      USB: quirks: blacklist duplicate ep on Sound Devices USBPre2 · bdd1b147
      Johan Hovold 提交于
      This device has a broken vendor-specific altsetting for interface 1,
      where endpoint 0x85 is declared as an isochronous endpoint despite being
      used by interface 2 for audio capture.
      
      Device Descriptor:
        bLength                18
        bDescriptorType         1
        bcdUSB               2.00
        bDeviceClass          239 Miscellaneous Device
        bDeviceSubClass         2
        bDeviceProtocol         1 Interface Association
        bMaxPacketSize0        64
        idVendor           0x0926
        idProduct          0x0202
        bcdDevice            1.00
        iManufacturer           1 Sound Devices
        iProduct                2 USBPre2
        iSerial                 3 [...]
        bNumConfigurations      1
      
      [...]
      
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        1
            bAlternateSetting       3
            bNumEndpoints           2
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass      0
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x85  EP 5 IN
              bmAttributes            5
                Transfer Type            Isochronous
                Synch Type               Asynchronous
                Usage Type               Data
              wMaxPacketSize     0x0126  1x 294 bytes
              bInterval               1
      
      [...]
      
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        2
            bAlternateSetting       1
            bNumEndpoints           1
            bInterfaceClass         1 Audio
            bInterfaceSubClass      2 Streaming
            bInterfaceProtocol      0
            iInterface              0
            AudioStreaming Interface Descriptor:
              bLength                 7
              bDescriptorType        36
              bDescriptorSubtype      1 (AS_GENERAL)
              bTerminalLink           4
              bDelay                  1 frames
              wFormatTag         0x0001 PCM
            AudioStreaming Interface Descriptor:
              bLength                26
              bDescriptorType        36
              bDescriptorSubtype      2 (FORMAT_TYPE)
              bFormatType             1 (FORMAT_TYPE_I)
              bNrChannels             2
              bSubframeSize           2
              bBitResolution         16
              bSamFreqType            6 Discrete
              tSamFreq[ 0]         8000
              tSamFreq[ 1]        16000
              tSamFreq[ 2]        24000
              tSamFreq[ 3]        32000
              tSamFreq[ 4]        44100
              tSamFreq[ 5]        48000
            Endpoint Descriptor:
              bLength                 9
              bDescriptorType         5
              bEndpointAddress     0x85  EP 5 IN
              bmAttributes            5
                Transfer Type            Isochronous
                Synch Type               Asynchronous
                Usage Type               Data
              wMaxPacketSize     0x0126  1x 294 bytes
              bInterval               4
              bRefresh                0
              bSynchAddress           0
              AudioStreaming Endpoint Descriptor:
                bLength                 7
                bDescriptorType        37
                bDescriptorSubtype      1 (EP_GENERAL)
                bmAttributes         0x01
                  Sampling Frequency
                bLockDelayUnits         2 Decoded PCM samples
                wLockDelay         0x0000
      
      Since commit 3e4f8e21 ("USB: core: fix check for duplicate
      endpoints") USB core ignores any duplicate endpoints found during
      descriptor parsing, but in this case we need to ignore the first
      instance in order to avoid breaking the audio capture interface.
      
      Fixes: 3e4f8e21 ("USB: core: fix check for duplicate endpoints")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: Nedes <edes@gmx.net>
      Tested-by: Nedes <edes@gmx.net>
      Link: https://lore.kernel.org/r/20200201105829.5682c887@acme7.acmenetSigned-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200203153830.26394-3-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bdd1b147
    • J
      USB: core: add endpoint-blacklist quirk · 73f8bda9
      Johan Hovold 提交于
      Add a new device quirk that can be used to blacklist endpoints.
      
      Since commit 3e4f8e21 ("USB: core: fix check for duplicate
      endpoints") USB core ignores any duplicate endpoints found during
      descriptor parsing.
      
      In order to handle devices where the first interfaces with duplicate
      endpoints are the ones that should have their endpoints ignored, we need
      to add a blacklist.
      Tested-by: Nedes <edes@gmx.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200203153830.26394-2-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73f8bda9
    • C
      usb: dwc3: debug: fix string position formatting mixup with ret and len · b32196e3
      Colin Ian King 提交于
      Currently the string formatting is mixing up the offset of ret and
      len. Re-work the code to use just len, remove ret and use scnprintf
      instead of snprintf and len position accumulation where required.
      Remove the -ve return check since scnprintf never returns a failure
      -ve size. Also break overly long lines to clean up checkpatch
      warnings.
      
      Addresses-Coverity: ("Unused value")
      Fixes: 1381a511 ("usb: dwc3: debug: purge usage of strcat")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Reviewed-by: NDan Carpenter <dan.carpenter@oracle.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200210095139.328711-1-colin.king@canonical.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b32196e3
    • D
      usb: phy: tegra: Add clarifying comments about the shared registers · a4a60194
      Dmitry Osipenko 提交于
      Tools like Coccinelle may erroneously recommend to use the
      devm_platform_ioremap_resource() API for the registers mapping because
      these tools are not aware about the implementation details of the driver.
      Let's add a clarifying comments to the code, which should help to stop
      future attempts to break the driver.
      Signed-off-by: NDmitry Osipenko <digetx@gmail.com>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Link: https://lore.kernel.org/r/20200202224259.29187-1-digetx@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4a60194
    • A
      USB: hub: Don't record a connect-change event during reset-resume · 8099f58f
      Alan Stern 提交于
      Paul Zimmerman reports that his USB Bluetooth adapter sometimes
      crashes following system resume, when it receives a
      Get-Device-Descriptor request while it is busy doing something else.
      
      Such a request was added by commit a4f55d8b ("usb: hub: Check
      device descriptor before resusciation").  It gets sent when the hub
      driver's work thread checks whether a connect-change event on an
      enabled port really indicates a new device has been connected, as
      opposed to an old device momentarily disconnecting and then
      reconnecting (which can happen with xHCI host controllers, since they
      automatically enable connected ports).
      
      The same kind of thing occurs when a port's power session is lost
      during system suspend.  When the system wakes up it sees a
      connect-change event on the port, and if the child device's
      persist_enabled flag was set then hub_activate() sets the device's
      reset_resume flag as well as the port's bit in hub->change_bits.  The
      reset-resume code then takes responsibility for checking that the same
      device is still attached to the port, and it does this as part of the
      device's resume pathway.  By the time the hub driver's work thread
      starts up again, the device has already been fully reinitialized and
      is busy doing its own thing.  There's no need for the work thread to
      do the same check a second time, and in fact this unnecessary check is
      what caused the problem that Paul observed.
      
      Note that performing the unnecessary check is not actually a bug.
      Devices are supposed to be able to send descriptors back to the host
      even when they are busy doing something else.  The underlying cause of
      Paul's problem lies in his Bluetooth adapter.  Nevertheless, we
      shouldn't perform the same check twice in a row -- and as a nice side
      benefit, removing the extra check allows the Bluetooth adapter to work
      more reliably.
      
      The work thread performs its check when it sees that the port's bit is
      set in hub->change_bits.  In this situation that bit is interpreted as
      though a connect-change event had occurred on the port _after_ the
      reset-resume, which is not what actually happened.
      
      One possible fix would be to make the reset-resume code clear the
      port's bit in hub->change_bits.  But it seems simpler to just avoid
      setting the bit during hub_activate() in the first place.  That's what
      this patch does.
      
      (Proving that the patch is correct when CONFIG_PM is disabled requires
      a little thought.  In that setting hub_activate() will be called only
      for initialization and resets, since there won't be any resumes or
      reset-resumes.  During initialization and hub resets the hub doesn't
      have any child devices, and so this code path never gets executed.)
      Reported-and-tested-by: NPaul Zimmerman <pauldzim@gmail.com>
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Link: https://marc.info/?t=157949360700001&r=1&w=2
      CC: David Heinzelmann <heinzelmann.david@gmail.com>
      CC: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2001311037460.1577-100000@iolanthe.rowland.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8099f58f
    • E
      usb: uas: fix a plug & unplug racing · 3e99862c
      EJ Hsu 提交于
      When a uas disk is plugged into an external hub, uas_probe()
      will be called by the hub thread to do the probe. It will
      first create a SCSI host and then do the scan for this host.
      During the scan, it will probe the LUN using SCSI INQUERY command
      which will be packed in the URB and submitted to uas disk.
      
      There might be a chance that this external hub with uas disk
      attached is unplugged during the scan. In this case, uas driver
      will fail to submit the URB (due to the NOTATTACHED state of uas
      device) and try to put this SCSI command back to request queue
      waiting for next chance to run.
      
      In normal case, this cycle will terminate when hub thread gets
      disconnection event and calls into uas_disconnect() accordingly.
      But in this case, uas_disconnect() will not be called because
      hub thread of external hub gets stuck waiting for the completion
      of this SCSI command. A deadlock happened.
      
      In this fix, uas will call scsi_scan_host() asynchronously to
      avoid the blocking of hub thread.
      Signed-off-by: NEJ Hsu <ejh@nvidia.com>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200130092506.102760-1-ejh@nvidia.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e99862c
    • H
      USB: hub: Fix the broken detection of USB3 device in SMSC hub · 1208f9e1
      Hardik Gajjar 提交于
      Renesas R-Car H3ULCB + Kingfisher Infotainment Board is either not able
      to detect the USB3.0 mass storage devices or is detecting those as
      USB2.0 high speed devices.
      
      The explanation given by Renesas is that, due to a HW issue, the XHCI
      driver does not wake up after going to sleep on connecting a USB3.0
      device.
      
      In order to mitigate that, disable the auto-suspend feature
      specifically for SMSC hubs from hub_probe() function, as a quirk.
      
      Renesas Kingfisher Infotainment Board has two USB3.0 ports (CN2) which
      are connected via USB5534B 4-port SuperSpeed/Hi-Speed, low-power,
      configurable hub controller.
      
      [1] SanDisk USB 3.0 device detected as USB-2.0 before the patch
       [   74.036390] usb 5-1.1: new high-speed USB device number 4 using xhci-hcd
       [   74.061598] usb 5-1.1: New USB device found, idVendor=0781, idProduct=5581, bcdDevice= 1.00
       [   74.069976] usb 5-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
       [   74.077303] usb 5-1.1: Product: Ultra
       [   74.080980] usb 5-1.1: Manufacturer: SanDisk
       [   74.085263] usb 5-1.1: SerialNumber: 4C530001110208116550
      
      [2] SanDisk USB 3.0 device detected as USB-3.0 after the patch
       [   34.565078] usb 6-1.1: new SuperSpeed Gen 1 USB device number 3 using xhci-hcd
       [   34.588719] usb 6-1.1: New USB device found, idVendor=0781, idProduct=5581, bcdDevice= 1.00
       [   34.597098] usb 6-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
       [   34.604430] usb 6-1.1: Product: Ultra
       [   34.608110] usb 6-1.1: Manufacturer: SanDisk
       [   34.612397] usb 6-1.1: SerialNumber: 4C530001110208116550
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NHardik Gajjar <hgajjar@de.adit-jv.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NEugeniu Rosca <erosca@de.adit-jv.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/1580989763-32291-1-git-send-email-hgajjar@de.adit-jv.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1208f9e1
  6. 10 2月, 2020 4 次提交