1. 22 Oct, 2019 34 commits
    • 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
    • Michał Mirosław's avatar
      usb: gadget: u_serial: make OBEX port not a console · b417343c
      Michał Mirosław authored
      Prevent OBEX serial port from ever becoming a console. Console messages
      will definitely break the protocol, and since you have to instantiate
      the port making it explicitly for OBEX, there is no point in allowing
      console to break it by mistake.
      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>
      b417343c
    • Michał Mirosław's avatar
      usb: gadget: u_serial: reimplement console support · fe1ea63a
      Michał Mirosław authored
      Rewrite console support to fix a few shortcomings of the old code
      preventing its use with multiple ports. This removes some duplicated
      code and replaces a custom kthread with simpler workqueue item.
      
      Only port ttyGS0 gets to be a console for now.
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: default avatarLadislav Michl <ladis@linux-mips.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      fe1ea63a
    • Michał Mirosław's avatar
      usb: gadget: u_serial: add missing port entry locking · daf82bd2
      Michał Mirosław authored
      gserial_alloc_line() misses locking (for a release barrier) while
      resetting port entry on TTY allocation failure. Fix this.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: default avatarLadislav Michl <ladis@linux-mips.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      daf82bd2
    • Thinh Nguyen's avatar
      usb: dwc3: Disable phy suspend after power-on reset · 9ba3aca8
      Thinh Nguyen authored
      For DRD controllers, the programming guide recommended that
      GUSB3PIPECTL.SUSPENDABLE and GUSB2PHYCFG.SUSPHY to be cleared after
      power-on reset and only set after the controller initialization is
      completed. This can be done after device soft-reset in dwc3_core_init().
      This patch makes sure to clear GUSB3PIPECTL.SUSPENDABLE and
      GUSB2PHYCFG.SUSPHY before core initialization and only set them after
      the device soft-reset is completed.
      
      Reference: DWC_usb3 3.30a and DWC_usb31 1.90a programming guide section
      1.2.49 and 1.2.45
      Signed-off-by: default avatarThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      9ba3aca8
  2. 20 Oct, 2019 6 commits