1. 29 Oct, 2019 3 commits
  2. 23 Oct, 2019 3 commits
    • Chunfeng Yun's avatar
      usb: mtu3: fix race condition about delayed_status · f3088e6a
      Chunfeng Yun authored
      usb_composite_setup_continue() may be called before composite_setup()
      return USB_GADGET_DELAYED_STATUS, then the controller driver will
      delay status stage after composite_setup() finish, but the class driver
      don't ask the controller to continue delayed status anymore, this will
      cause control transfer timeout.
      
      happens when use mass storage (also enabled other class driver):
      
      cpu1:                               cpu2
      handle_setup(SET_CONFIG) //gadget driver
        unlock (g->lock)
        gadget_driver->setup()
          composite_setup()
            lock(cdev->lock)
              set_config()
                fsg_set_alt() // maybe some times due to many class are enabled
                  raise FSG_STATE_CONFIG_CHANGE
                  return USB_GADGET_DELAYED_STATUS
                                          handle_exception()
                                          usb_composite_setup_continue()
            unlock(cdev->lock)
                                            lock(cdev->lock)
                                              ep0_queue()
                                                lock (g->lock)
                                                //no delayed status, nothing todo
                                                unlock (g->lock)
                                            unlock(cdev->lock)
          return USB_GADGET_DELAYED_STATUS // composite_setup
        lock (g->lock)
      get USB_GADGET_DELAYED_STATUS //handle_setup [1]
      
      Try to fix the race condition as following:
      After the driver gets USB_GADGET_DELAYED_STATUS at [1], if we find
      there is a usb_request in ep0 request list, it means composite already
      asked us to continue delayed status by usb_composite_setup_continue(),
      so we skip request about delayed_status by composite_setup() and still
      do status stage.
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      f3088e6a
    • Nagarjuna Kristam's avatar
      usb: gadget: Add UDC driver for tegra XUSB device mode controller · 49db4272
      Nagarjuna Kristam authored
      This patch adds UDC driver for tegra XUSB 3.0 device mode controller.
      XUSB device mode controller supports SS, HS and FS modes
      
      Based on work by:
        Mark Kuo <mkuo@nvidia.com>
        Hui Fu <hfu@nvidia.com>
        Andrew Bresticker <abrestic@chromium.org>
      Signed-off-by: default avatarNagarjuna Kristam <nkristam@nvidia.com>
      Acked-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      49db4272
    • Thinh Nguyen's avatar
      usb: dwc3: debug: Remove newline printout · 038761ce
      Thinh Nguyen authored
      The newline from the unknown link state tracepoint doesn't follow the
      other tracepoints, and it looks unsightly. Let's remove it.
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      038761ce
  3. 22 Oct, 2019 34 commits
    • Mathias Kresin's avatar
      usb: dwc2: use a longer core rest timeout in dwc2_core_reset() · 6689f0f4
      Mathias Kresin authored
      Testing on different generations of Lantiq MIPS SoC based boards, showed
      that it takes up to 1500 us until the core reset bit is cleared.
      
      The driver from the vendor SDK (ifxhcd) uses a 1 second timeout. Use the
      same timeout to fix wrong hang detections and make the driver work for
      Lantiq MIPS SoCs.
      
      At least till kernel 4.14 the hanging reset only caused a warning but
      the driver was probed successful. With kernel 4.19 errors out with
      EBUSY.
      
      Cc: linux-stable <stable@vger.kernel.org> # 4.19+
      Signed-off-by: default avatarMathias Kresin <dev@kresin.me>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      6689f0f4
    • Markus Elfring's avatar
      usb: gadget: udc: lpc32xx: Use devm_platform_ioremap_resource() in lpc32xx_udc_probe() · a9a367d0
      Markus Elfring authored
      Simplify this function implementation by using a known wrapper function.
      
      This issue was detected by using the Coccinelle software.
      Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      a9a367d0
    • Colin Ian King's avatar
      USB: gadget: udc: clean up an indentation issue · 5a150077
      Colin Ian King authored
      There is a statement that is indented too deeply, remove
      the extraneous tabs.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      5a150077
    • Joel Stanley's avatar
      usb: gadget: Quieten gadget config message · 1cbfb8c4
      Joel Stanley authored
      On a system that often re-configures a USB gadget device the kernel log
      is filled with:
      
        configfs-gadget gadget: high-speed config #1: c
      
      Reduce the verbosity of this print to debug.
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      1cbfb8c4
    • Geert Uytterhoeven's avatar
      phy: renesas: rcar-gen3-usb2: Use platform_get_irq_optional() for optional irq · b049e03c
      Geert Uytterhoeven authored
      As platform_get_irq() now prints an error when the interrupt does not
      exist, a scary warning may be printed for an optional interrupt:
      
          phy_rcar_gen3_usb2 ee0a0200.usb-phy: IRQ index 0 not found
      
      Fix this by calling platform_get_irq_optional() instead.
      
      Fixes: 7723f4c5 ("driver core: platform: Add an error message to platform_get_irq*()")
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      b049e03c
    • zhengbin's avatar
      usb: gadget: Remove set but not used variable 'opts' in msg_do_config · e804cd46
      zhengbin authored
      Fixes gcc '-Wunused-but-set-variable' warning:
      
      drivers/usb/gadget/legacy/mass_storage.c: In function msg_do_config:
      drivers/usb/gadget/legacy/mass_storage.c:108:19: warning: variable opts set but not used [-Wunused-but-set-variable]
      
      It is not used since commit f78bbcae ("usb: f_mass_storage:
      test whether thread is running before starting another")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarzhengbin <zhengbin13@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      e804cd46
    • zhengbin's avatar
      usb: gadget: Remove set but not used variable 'opts' in acm_ms_do_config · 6973dbdd
      zhengbin authored
      Fixes gcc '-Wunused-but-set-variable' warning:
      
      drivers/usb/gadget/legacy/acm_ms.c: In function acm_ms_do_config:
      drivers/usb/gadget/legacy/acm_ms.c:108:19: warning: variable opts set but not used [-Wunused-but-set-variable]
      
      It is not used since commit f78bbcae ("usb: f_mass_storage:
      test whether thread is running before starting another")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarzhengbin <zhengbin13@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      6973dbdd
    • Chunfeng Yun's avatar
      usb: mtu3: add a new function to do status stage · e6fda6e6
      Chunfeng Yun authored
      Exact a new static function to do status stage
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      e6fda6e6
    • Peter Chen's avatar
      usb: gadget: configfs: fix concurrent issue between composite APIs · 3654aaa9
      Peter Chen authored
      We meet several NULL pointer issues if configfs_composite_unbind
      and composite_setup (or composite_disconnect) are running together.
      These issues occur when do the function switch stress test, the
      configfs_compsoite_unbind is called from user mode by
      echo "" to /sys/../UDC entry, and meanwhile, the setup interrupt
      or disconnect interrupt occurs by hardware. The composite_setup
      will get the cdev from get_gadget_data, but configfs_composite_unbind
      will set gadget data as NULL, so the NULL pointer issue occurs.
      This concurrent is hard to reproduce by native kernel, but can be
      reproduced by android kernel.
      
      In this commit, we introduce one spinlock belongs to structure
      gadget_info since we can't use the same spinlock in usb_composite_dev
      due to exclusive running together between composite_setup and
      configfs_composite_unbind. And one bit flag 'unbind' to indicate the
      code is at unbind routine, this bit is needed due to we release the
      lock at during configfs_composite_unbind sometimes, and composite_setup
      may be run at that time.
      
      Several oops:
      
      oops 1:
      android_work: sent uevent USB_STATE=CONNECTED
      configfs-gadget gadget: super-speed config #1: b
      android_work: sent uevent USB_STATE=CONFIGURED
      init: Received control message 'start' for 'adbd' from pid: 3515 (system_server)
      Unable to handle kernel NULL pointer dereference at virtual address 0000002a
      init: Received control message 'stop' for 'adbd' from pid: 3375 (/vendor/bin/hw/android.hardware.usb@1.1-servic)
      Mem abort info:
        Exception class = DABT (current EL), IL = 32 bits
        SET = 0, FnV = 0
        EA = 0, S1PTW = 0
      Data abort info:
        ISV = 0, ISS = 0x00000004
        CM = 0, WnR = 0
      user pgtable: 4k pages, 48-bit VAs, pgd = ffff8008f1b7f000
      [000000000000002a] *pgd=0000000000000000
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 4 PID: 2457 Comm: irq/125-5b11000 Not tainted 4.14.98-07846-g0b40a9b-dirty #16
      Hardware name: Freescale i.MX8QM MEK (DT)
      task: ffff8008f2a98000 task.stack: ffff00000b7b8000
      PC is at composite_setup+0x44/0x1508
      LR is at android_setup+0xb8/0x13c
      pc : [<ffff0000089ffb3c>] lr : [<ffff000008a032fc>] pstate: 800001c5
      sp : ffff00000b7bbb80
      x29: ffff00000b7bbb80 x28: ffff8008f2a3c010
      x27: 0000000000000001 x26: 0000000000000000                                                          [1232/1897]
      audit: audit_lost=25791 audit_rate_limit=5 audit_backlog_limit=64
      x25: 00000000ffffffa1 x24: ffff8008f2a3c010
      audit: rate limit exceeded
      x23: 0000000000000409 x22: ffff000009c8e000
      x21: ffff8008f7a8b428 x20: ffff00000afae000
      x19: ffff0000089ff000 x18: 0000000000000000
      x17: 0000000000000000 x16: ffff0000082b7c9c
      x15: 0000000000000000 x14: f1866f5b952aca46
      x13: e35502e30d44349c x12: 0000000000000008
      x11: 0000000000000008 x10: 0000000000000a30
      x9 : ffff00000b7bbd00 x8 : ffff8008f2a98a90
      x7 : ffff8008f27a9c90 x6 : 0000000000000001
      x5 : 0000000000000000 x4 : 0000000000000001
      x3 : 0000000000000000 x2 : 0000000000000006
      x1 : ffff0000089ff8d0 x0 : 732a010310b9ed00
      
      X7: 0xffff8008f27a9c10:
      9c10  00000002 00000000 00000001 00000000 13110000 ffff0000 00000002 00208040
      9c30  00000000 00000000 00000000 00000000 00000000 00000005 00000029 00000000
      9c50  00051778 00000001 f27a8e00 ffff8008 00000005 00000000 00000078 00000078
      9c70  00000078 00000000 09031d48 ffff0000 00100000 00000000 00400000 00000000
      9c90  00000001 00000000 00000000 00000000 00000000 00000000 ffefb1a0 ffff8008
      9cb0  f27a9ca8 ffff8008 00000000 00000000 b9d88037 00000173 1618a3eb 00000001
      9cd0  870a792a 0000002e 16188fe6 00000001 0000242b 00000000 00000000 00000000
      using random self ethernet address
      9cf0  019a4646 00000000 000547f3 00000000 ecfd6c33 00000002 00000000
      using random host ethernet address
       00000000
      
      X8: 0xffff8008f2a98a10:
      8a10  00000000 00000000 f7788d00 ffff8008 00000001 00000000 00000000 00000000
      8a30  eb218000 ffff8008 f2a98000 ffff8008 f2a98000 ffff8008 09885000 ffff0000
      8a50  f34df480 ffff8008 00000000 00000000 f2a98648 ffff8008 09c8e000 ffff0000
      8a70  fff2c800 ffff8008 09031d48 ffff0000 0b7bbd00 ffff0000 0b7bbd00 ffff0000
      8a90  080861bc ffff0000 00000000 00000000 00000000 00000000 00000000 00000000
      8ab0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      8ad0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      8af0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      
      X21: 0xffff8008f7a8b3a8:
      b3a8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      b3c8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      b3e8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      b408  00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000000
      b428  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      b448  0053004d 00540046 00300031 00010030 eb07b520 ffff8008 20011201 00000003
      b468  e418d109 0104404e 00010302 00000000 eb07b558 ffff8008 eb07b558 ffff8008
      b488  f7a8b488 ffff8008 f7a8b488 ffff8008 f7a8b300 ffff8008 00000000 00000000
      
      X24: 0xffff8008f2a3bf90:
      bf90  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfb0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bff0  00000000 00000000 00000000 00000000 f76c8010 ffff8008 f76c8010 ffff8008
      c010  00000000 00000000 f2a3c018 ffff8008 f2a3c018 ffff8008 08a067dc ffff0000
      c030  f2a5a000 ffff8008 091c3650 ffff0000 f716fd18 ffff8008 f716fe30 ffff8008
      c050  f2ce4a30 ffff8008 00000000 00000005 00000000 00000000 095d1568 ffff0000
      c070  f76c8010 ffff8008 f2ce4b00 ffff8008 095cac68 ffff0000 f2a5a028 ffff8008
      
      X28: 0xffff8008f2a3bf90:
      bf90  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfb0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bff0  00000000 00000000 00000000 00000000 f76c8010 ffff8008 f76c8010 ffff8008
      c010  00000000 00000000 f2a3c018 ffff8008 f2a3c018 ffff8008 08a067dc ffff0000
      c030  f2a5a000 ffff8008 091c3650 ffff0000 f716fd18 ffff8008 f716fe30 ffff8008
      c050  f2ce4a30 ffff8008 00000000 00000005 00000000 00000000 095d1568 ffff0000
      c070  f76c8010 ffff8008 f2ce4b00 ffff8008 095cac68 ffff0000 f2a5a028 ffff8008
      
      Process irq/125-5b11000 (pid: 2457, stack limit = 0xffff00000b7b8000)
      Call trace:
      Exception stack(0xffff00000b7bba40 to 0xffff00000b7bbb80)
      ba40: 732a010310b9ed00 ffff0000089ff8d0 0000000000000006 0000000000000000
      ba60: 0000000000000001 0000000000000000 0000000000000001 ffff8008f27a9c90
      ba80: ffff8008f2a98a90 ffff00000b7bbd00 0000000000000a30 0000000000000008
      baa0: 0000000000000008 e35502e30d44349c f1866f5b952aca46 0000000000000000
      bac0: ffff0000082b7c9c 0000000000000000 0000000000000000 ffff0000089ff000
      bae0: ffff00000afae000 ffff8008f7a8b428 ffff000009c8e000 0000000000000409
      bb00: ffff8008f2a3c010 00000000ffffffa1 0000000000000000 0000000000000001
      bb20: ffff8008f2a3c010 ffff00000b7bbb80 ffff000008a032fc ffff00000b7bbb80
      bb40: ffff0000089ffb3c 00000000800001c5 ffff00000b7bbb80 732a010310b9ed00
      bb60: ffffffffffffffff ffff0000080f777c ffff00000b7bbb80 ffff0000089ffb3c
      [<ffff0000089ffb3c>] composite_setup+0x44/0x1508
      [<ffff000008a032fc>] android_setup+0xb8/0x13c
      [<ffff0000089bd9a8>] cdns3_ep0_delegate_req+0x44/0x70
      [<ffff0000089bdff4>] cdns3_check_ep0_interrupt_proceed+0x33c/0x654
      [<ffff0000089bca44>] cdns3_device_thread_irq_handler+0x4b0/0x4bc
      [<ffff0000089b77b4>] cdns3_thread_irq+0x48/0x68
      [<ffff000008145bf0>] irq_thread_fn+0x28/0x88
      [<ffff000008145e38>] irq_thread+0x13c/0x228
      [<ffff0000080fed70>] kthread+0x104/0x130
      [<ffff000008085064>] ret_from_fork+0x10/0x18
      
      oops2:
      composite_disconnect: Calling disconnect on a Gadget that is                      not connected
      android_work: did not send uevent (0 0           (null))
      init: Received control message 'stop' for 'adbd' from pid: 3359 (/vendor/bin/hw/android.hardware.usb@1.1-service.imx)
      init: Sending signal 9 to service 'adbd' (pid 22343) process group...
      ------------[ cut here ]------------
      audit: audit_lost=180038 audit_rate_limit=5 audit_backlog_limit=64
      audit: rate limit exceeded
      WARNING: CPU: 0 PID: 3468 at kernel_imx/drivers/usb/gadget/composite.c:2009 composite_disconnect+0x80/0x88
      Modules linked in:
      CPU: 0 PID: 3468 Comm: HWC-UEvent-Thre Not tainted 4.14.98-07846-g0b40a9b-dirty #16
      Hardware name: Freescale i.MX8QM MEK (DT)
      task: ffff8008f2349c00 task.stack: ffff00000b0a8000
      PC is at composite_disconnect+0x80/0x88
      LR is at composite_disconnect+0x80/0x88
      pc : [<ffff0000089ff9b0>] lr : [<ffff0000089ff9b0>] pstate: 600001c5
      sp : ffff000008003dd0
      x29: ffff000008003dd0 x28: ffff8008f2349c00
      x27: ffff000009885018 x26: ffff000008004000
      Timeout for IPC response!
      x25: ffff000009885018 x24: ffff000009c8e280
      x23: ffff8008f2d98010 x22: 00000000000001c0
      x21: ffff8008f2d98394 x20: ffff8008f2d98010
      x19: 0000000000000000 x18: 0000e3956f4f075a
      fxos8700 4-001e: i2c block read acc failed
      x17: 0000e395735727e8 x16: ffff00000829f4d4
      x15: ffffffffffffffff x14: 7463656e6e6f6320
      x13: 746f6e2009090920 x12: 7369207461687420
      x11: 7465676461472061 x10: 206e6f207463656e
      x9 : 6e6f637369642067 x8 : ffff000009c8e280
      x7 : ffff0000086ca6cc x6 : ffff000009f15e78
      x5 : 0000000000000000 x4 : 0000000000000000
      x3 : ffffffffffffffff x2 : c3f28b86000c3900
      x1 : c3f28b86000c3900 x0 : 000000000000004e
      
      X20: 0xffff8008f2d97f90:
      7f90  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      7fb0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      libprocessgroup: Failed to kill process cgroup uid 0 pid 22343 in 215ms, 1 processes remain
      7fd0
      Timeout for IPC response!
       00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      using random self ethernet address
      7ff0  00000000 00000000 00000000 00000000 f76c8010 ffff8008 f76c8010 ffff8008
      8010  00000100 00000000 f2d98018 ffff8008 f2d98018 ffff8008 08a067dc
      using random host ethernet address
       ffff0000
      8030  f206d800 ffff8008 091c3650 ffff0000 f7957b18 ffff8008 f7957730 ffff8008
      8050  f716a630 ffff8008 00000000 00000005 00000000 00000000 095d1568 ffff0000
      8070  f76c8010 ffff8008 f716a800 ffff8008 095cac68 ffff0000 f206d828 ffff8008
      
      X21: 0xffff8008f2d98314:
      8314  ffff8008 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      8334  00000000 00000000 00000000 00000000 00000000 08a04cf4 ffff0000 00000000
      8354  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      8374  00000000 00000000 00000000 00001001 00000000 00000000 00000000 00000000
      8394  e4bbe4bb 0f230000 ffff0000 0afae000 ffff0000 ae001000 00000000 f206d400
      Timeout for IPC response!
      83b4  ffff8008 00000000 00000000 f7957b18 ffff8008 f7957718 ffff8008 f7957018
      83d4  ffff8008 f7957118 ffff8008 f7957618 ffff8008 f7957818 ffff8008 f7957918
      83f4  ffff8008 f7957d18 ffff8008 00000000 00000000 00000000 00000000 00000000
      
      X23: 0xffff8008f2d97f90:
      7f90  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      7fb0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      7fd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      7ff0  00000000 00000000 00000000 00000000 f76c8010 ffff8008 f76c8010 ffff8008
      8010  00000100 00000000 f2d98018 ffff8008 f2d98018 ffff8008 08a067dc ffff0000
      8030  f206d800 ffff8008 091c3650 ffff0000 f7957b18 ffff8008 f7957730 ffff8008
      8050  f716a630 ffff8008 00000000 00000005 00000000 00000000 095d1568 ffff0000
      8070  f76c8010 ffff8008 f716a800 ffff8008 095cac68 ffff0000 f206d828 ffff8008
      
      X28: 0xffff8008f2349b80:
      9b80  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      9ba0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      9bc0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      9be0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      9c00  00000022 00000000 ffffffff ffffffff 00010001 00000000 00000000 00000000
      9c20  0b0a8000 ffff0000 00000002 00404040 00000000 00000000 00000000 00000000
      9c40  00000001 00000000 00000001 00000000 001ebd44 00000001 f390b800 ffff8008
      9c60  00000000 00000001 00000070 00000070 00000070 00000000 09031d48 ffff0000
      
      Call trace:
      Exception stack(0xffff000008003c90 to 0xffff000008003dd0)
      3c80:                                   000000000000004e c3f28b86000c3900
      3ca0: c3f28b86000c3900 ffffffffffffffff 0000000000000000 0000000000000000
      3cc0: ffff000009f15e78 ffff0000086ca6cc ffff000009c8e280 6e6f637369642067
      3ce0: 206e6f207463656e 7465676461472061 7369207461687420 746f6e2009090920
      3d00: 7463656e6e6f6320 ffffffffffffffff ffff00000829f4d4 0000e395735727e8
      3d20: 0000e3956f4f075a 0000000000000000 ffff8008f2d98010 ffff8008f2d98394
      3d40: 00000000000001c0 ffff8008f2d98010 ffff000009c8e280 ffff000009885018
      3d60: ffff000008004000 ffff000009885018 ffff8008f2349c00 ffff000008003dd0
      3d80: ffff0000089ff9b0 ffff000008003dd0 ffff0000089ff9b0 00000000600001c5
      3da0: ffff8008f33f2cd8 0000000000000000 0000ffffffffffff 0000000000000000
      init: Received control message 'start' for 'adbd' from pid: 3359 (/vendor/bin/hw/android.hardware.usb@1.1-service.imx)
      3dc0: ffff000008003dd0 ffff0000089ff9b0
      [<ffff0000089ff9b0>] composite_disconnect+0x80/0x88
      [<ffff000008a044d4>] android_disconnect+0x3c/0x68
      [<ffff0000089ba9f8>] cdns3_device_irq_handler+0xfc/0x2c8
      [<ffff0000089b84c0>] cdns3_irq+0x44/0x94
      [<ffff00000814494c>] __handle_irq_event_percpu+0x60/0x24c
      [<ffff000008144c0c>] handle_irq_event+0x58/0xc0
      [<ffff00000814873c>] handle_fasteoi_irq+0x98/0x180
      [<ffff000008143a10>] generic_handle_irq+0x24/0x38
      [<ffff000008144170>] __handle_domain_irq+0x60/0xac
      [<ffff0000080819c4>] gic_handle_irq+0xd4/0x17c
      
      Cc: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      3654aaa9
    • Jayshri Pawar's avatar
      usb: gadget: f_tcm: Provide support to get alternate setting in tcm function · 0b8b1a1f
      Jayshri Pawar authored
      Providing tcm_get_alt in tcm function to support Bulk only protocol and
      USB Attached SCSI protocol
      Signed-off-by: default avatarJayshri Pawar <jpawar@cadence.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      0b8b1a1f
    • Nikhil Badola's avatar
      usb: gadget: Correct NULL pointer checking in fsl gadget · 75eaa498
      Nikhil Badola authored
      Correct NULL pointer checking for endpoint descriptor
      before it gets dereferenced
      Signed-off-by: default avatarNikhil Badola <nikhil.badola@freescale.com>
      Signed-off-by: default avatarRan Wang <ran.wang_1@nxp.com>
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      75eaa498
    • Nikhil Badola's avatar
      usb: fsl: Remove unused variable · eb23c8b4
      Nikhil Badola authored
      Remove unused variable td_complete
      Signed-off-by: default avatarNikhil Badola <nikhil.badola@freescale.com>
      Reviewed-by: default avatarRan Wang <ran.wang_1@nxp.com>
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      eb23c8b4
    • Andrey Konovalov's avatar
      USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein · 15ac1d99
      Andrey Konovalov authored
      Commit fea34091 ("USB: add direction bit to urb->transfer_flags") has
      added a usb_urb_dir_in() helper function that can be used to determine
      the direction of the URB. With that patch USB_DIR_IN control requests with
      wLength == 0 are considered out requests by real USB HCDs. This patch
      changes dummy-hcd to use the usb_urb_dir_in() helper to match that
      behavior.
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      15ac1d99
    • Andrey Konovalov's avatar
      USB: dummy-hcd: increase max number of devices to 32 · 1bff4a4e
      Andrey Konovalov authored
      When fuzzing the USB subsystem with syzkaller, we currently use 8 testing
      processes within one VM. To isolate testing processes from one another it
      is desirable to assign a dedicated USB bus to each of those, which means
      we need at least 8 Dummy UDC/HCD devices.
      
      This patch increases the maximum number of Dummy UDC/HCD devices to 32
      (more than 8 in case we need more of them in the future).
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      1bff4a4e
    • Veeraiyan Chidambaram's avatar
      usb: renesas_usbhs: add suspend event support in gadget mode · f2b06c95
      Veeraiyan Chidambaram authored
      When R-Car Gen3 USB 2.0 is in Gadget mode, if host is detached an interrupt
      will be generated and Suspended state bit is set in interrupt status
      register. Interrupt handler will call driver->suspend(composite_suspend)
      if suspended state bit is set. composite_suspend will call
      ffs_func_suspend which will post FUNCTIONFS_SUSPEND and will be consumed
      by user space application via /dev/ep0.
      
      To be able to detect host detach, extend the DVSQ_MASK to cover the
      Suspended bit of the DVSQ[2:0] bitfield from the Interrupt Status
      Register 0 (INTSTS0) register and perform appropriate action in the
      DVST interrupt handler (usbhsg_irq_dev_state).
      
      Without this commit, disconnection of the phone from R-Car H3 ES2.0
      Salvator-X CN9 port is not recognized and reverse role switch does
      not not happen. If phone is connected again it does not enumerate.
      
      With this commit, disconnection will be recognized and reverse role
      switch will happen by a user space application. If phone is connected
      again it will enumerate properly and will become visible in the output
      of 'lsusb'.
      Signed-off-by: default avatarVeeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      f2b06c95
    • Eugeniu Rosca's avatar
      usb: renesas_usbhs: simplify usbhs_status_get_device_state() · d2802865
      Eugeniu Rosca authored
      Similar to usbhs_status_get_ctrl_stage(), *_get_device_state() is not
      supposed to return any error code since its return value is the DVSQ
      bitfield of the INTSTS0 register. According to SoC HW manual rev1.00,
      every single value of DVSQ[2:0] is valid and none is an error:
      
      ----8<----
      Device State
      000: Powered state
      001: Default state
      010: Address state
      011: Configuration state
      1xx: Suspended state
      ----8<----
      
      Hence, simplify the function body. The motivation behind dropping the
      switch/case construct is being able to implement reading the suspended
      state. The latter (based on the above DVSQ[2:0] description) doesn't
      have a unique value, but is rather a list of states (which makes
      switch/case less suitable for reading/validating it):
      
      100: (Suspended) Powered state
      101: (Suspended) Default state
      110: (Suspended) Address state
      111: (Suspended) Configuration state
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarVeeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      d2802865
    • Eugeniu Rosca's avatar
      usb: renesas_usbhs: enable DVSE interrupt · 8b20d00f
      Eugeniu Rosca authored
      Commit [1] enabled the possibility of checking the DVST (Device State
      Transition) bit of INTSTS0 (Interrupt Status Register 0) and calling
      the irq_dev_state() handler if the DVST bit is set. But neither
      commit [1] nor commit [2] actually enabled the DVSE (Device State
      Transition Interrupt Enable) bit in the INTENB0 (Interrupt Enable
      Register 0). As a consequence, irq_dev_state() handler is getting
      called as a side effect of other (non-DVSE) interrupts being fired,
      which definitely can't be relied upon, if DVST notifications are of
      any value.
      
      Why this doesn't hurt is because usbhsg_irq_dev_state() currently
      doesn't do much except of a dev_dbg(). Once more work is added to
      the handler (e.g. detecting device "Suspended" state and notifying
      other USB gadget components about it), enabling DVSE becomes a hard
      requirement. Do it in a standalone commit for better visibility and
      clear explanation.
      
      [1] f1407d5c ("usb: renesas_usbhs: Add Renesas USBHS common code")
      [2] 2f98382d ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarVeeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      8b20d00f
    • Veeraiyan Chidambaram's avatar
      usb: gadget: udc: renesas_usb3: add suspend event support · e961c47e
      Veeraiyan Chidambaram authored
      In R-Car Gen3 USB 3.0 Function, if host is detached an interrupt
      will be generated and Suspended state bit is set in interrupt status
      register. Interrupt handler will call driver->suspend(composite_suspend)
      if suspended state bit is set. composite_suspend will call
      ffs_func_suspend which will post FUNCTIONFS_SUSPEND and will be consumed
      by user space application via /dev/ep0.
      
      To be able to detect the host detach, USB_INT_1_B2_SPND to cover the
      Suspended bit of the B2_SPND_OUT[9] from the USB Status Register
      (USB_STA) register and perform appropriate action in the
      usb3_irq_epc_int_1 function.
      
      Without this commit, disconnection of the phone from R-Car H3 ES2.0
      Salvator-X CN11 port is not recognized and reverse role switch does
      not happen. If phone is connected again it does not enumerate.
      
      With this commit, disconnection will be recognized and reverse role
      switch will happen by a user space application. If phone is connected
      again it will enumerate properly and will become visible in the
      output of 'lsusb'.
      Reviewed-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarVeeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      e961c47e
    • YueHaibing's avatar
      usb: gadget: s3c-hsudc: use devm_platform_ioremap_resource() to simplify code · 6a3893bf
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      6a3893bf
    • YueHaibing's avatar
      usb: gadget: renesas_usb3: use devm_platform_ioremap_resource() to simplify code · e17d8766
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      e17d8766
    • YueHaibing's avatar
      usb: gadget: r8a66597-udc: use devm_platform_ioremap_resource() to simplify code · 195ad9c3
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      195ad9c3
    • YueHaibing's avatar
      usb: gadget: pxa27x_udc: use devm_platform_ioremap_resource() to simplify code · e7705d26
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      e7705d26
    • YueHaibing's avatar
      usb: gadget: pxa25x_udc: use devm_platform_ioremap_resource() to simplify code · 62312807
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      62312807
    • YueHaibing's avatar
      usb: gadget: gr_udc: use devm_platform_ioremap_resource() to simplify code · 60b6465b
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      60b6465b
    • YueHaibing's avatar
      usb: bdc: use devm_platform_ioremap_resource() to simplify code · 586a5fd6
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      586a5fd6
    • YueHaibing's avatar
      usb: gadget: bcm63xx_udc: use devm_platform_ioremap_resource() to simplify code · 4496bf25
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      4496bf25
    • YueHaibing's avatar
      usb: gadget: at91_udc: use devm_platform_ioremap_resource() to simplify code · 2e78dd51
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      2e78dd51
    • YueHaibing's avatar
      usb: renesas_usbhs: use devm_platform_ioremap_resource() to simplify code · 836283dd
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      836283dd
    • YueHaibing's avatar
      usb: phy: mxs: use devm_platform_ioremap_resource() to simplify code · 53490989
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      53490989
    • YueHaibing's avatar
      usb: phy: keystone: use devm_platform_ioremap_resource() to simplify code · b45ca31a
      YueHaibing authored
      Use devm_platform_ioremap_resource() to simplify the code a bit.
      This is detected by coccinelle.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      b45ca31a
    • Michał Mirosław's avatar
      usb: gadget: u_serial: use mutex for serialising open()s · c6561082
      Michał Mirosław authored
      Remove home-made waiting mechanism from gs_open() and rely on
      portmaster's mutex to do the job.
      
      Note: This releases thread waiting on close() when another thread
      open()s simultaneously.
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      c6561082
    • Michał Mirosław's avatar
      usb: gadget: u_serial: diagnose missed console messages · ef9b457d
      Michał Mirosław authored
      Insert markers in console stream marking places where data
      is missing. This makes the hole in the data stand out clearly
      instead of glueing together unrelated messages.
      
      Example output as seen from USB host side:
      
      [    0.064078] pinctrl core: registered pin 16 (UART3_RTS_N PC0) on 70000868.pinmux
      [    0.064130] pinctrl
      [missed 114987 bytes]
      [    4.302299] udevd[134]: starting version 3.2.5
      [    4.306845] random: udevd: uninitialized urandom read (16 bytes read)
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      ef9b457d
    • Michał Mirosław's avatar
      usb: gadget: legacy/serial: allow dynamic removal · bd25a14e
      Michał Mirosław authored
      Legacy serial USB gadget is still useful as an early console,
      before userspace is up. Later it could be replaced with proper
      configfs-configured composite gadget - that use case is enabled
      by this patch.
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      bd25a14e
    • Michał Mirosław's avatar
      usb: gadget: u_serial: allow more console gadget ports · d7cb8fb7
      Michał Mirosław authored
      Allow configuring more than one console using USB serial or ACM gadget.
      
      By default, only first (ttyGS0) is a console, but this may be changed
      using function's new "console" attribute.
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      d7cb8fb7