27 Oct, 2020

1 commit

  • The error_debugfs label is only used when either
    CONFIG_USB_DWC2_PERIPHERAL or CONFIG_USB_DWC2_DUAL_ROLE is enabled. Add
    the same #if to the error_debugfs label itself as the code which uses
    this label already has.

    This avoids the following compiler warning:
    warning: label ‘error_debugfs’ defined but not used [-Wunused-label]

    Fixes: e1c08cf23172ed ("usb: dwc2: Add missing cleanups when usb_add_gadget_udc() fails")
    Acked-by: Minas Harutyunyan
    Reported-by: kernel test robot
    Reported-by: Jens Axboe
    Signed-off-by: Martin Blumenstingl
    Signed-off-by: Felipe Balbi

    Martin Blumenstingl
     

02 Oct, 2020

5 commits

  • In DDMA mode if INTR OUT transfers mps not multiple of 4 then single packet
    corresponds to single descriptor.

    Descriptor limit set to mps and desc chain limit set to mps *
    MAX_DMA_DESC_NUM_GENERIC. On that descriptors complete, to calculate
    transfer size should be considered correction value for each descriptor.

    In start request function, if "continue" is true then dma buffer address
    should be incremmented by offset for all type of transfers, not only for
    Control DATA_OUT transfers.

    Fixes: cf77b5fb9b394 ("usb: dwc2: gadget: Transfer length limit checking for DDMA")
    Fixes: e02f9aa6119e0 ("usb: dwc2: gadget: EP 0 specific DDMA programming")
    Fixes: aa3e8bc81311e ("usb: dwc2: gadget: DDMA transfer start and complete")

    Signed-off-by: Minas Harutyunyan
    Signed-off-by: Felipe Balbi

    Minas Harutyunyan
     
  • If usb-role-switch is present in the device tree, it means that ID and Vbus
    signals are not connected to the OTG controller but to an external
    component (GPIOs, Type-C controller). In this configuration, usb role
    switch is used to force valid sessions on STM32MP15 SoCs.

    Acked-by: Minas Harutyunyan
    Acked-by: Martin Blumenstingl
    Signed-off-by: Amelie Delaunay
    Signed-off-by: Felipe Balbi

    Amelie Delaunay
     
  • This patch adds support for usb role switch to dwc2, by using overriding
    control of the PHY voltage valid and ID input signals.

    iddig signal (ID) can be overridden:
    - when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1;
    - when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0.

    avalid/bvalid/vbusvalid signals can be overridden respectively with:
    - GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL
    - GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL
    - GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL

    It is possible to determine valid sessions thanks to usb role switch:
    - if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid
    - if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid
    - if USB_ROLE_HOST then avalid && !bvalid && vbusvalid

    Acked-by: Minas Harutyunyan
    Acked-by: Martin Blumenstingl
    Signed-off-by: Amelie Delaunay
    Signed-off-by: Felipe Balbi

    Amelie Delaunay
     
  • If the dwc2 driver fails to probe after having enabled the regulators,
    it ends up being unregistered with regulators enabled, something the
    core regulator code is legitimately upset about:

    dwc2 ff400000.usb: supply vusb_d not found, using dummy regulator
    dwc2 ff400000.usb: supply vusb_a not found, using dummy regulator
    dwc2 ff400000.usb: dwc2_core_reset: HANG! AHB Idle timeout GRSTCTL GRSTCTL_AHBIDLE
    WARNING: CPU: 2 PID: 112 at drivers/regulator/core.c:2074 _regulator_put.part.0+0x16c/0x174
    Modules linked in: dwc2(E+) dwc3(E) udc_core(E) rtc_hym8563(E) dwmac_generic(E) ulpi(E) usbcore(E) dwc3_meson_g12a(E) roles(E) meson_gx_mmc(E+) i2c_meson(E) mdio_mux_meson_g12a(E) mdio_mux(E) dwmac_meson8b(E) stmmac_platform(E) stmmac(E) mdio_xpcs(E) phylink(E) of_mdio(E) fixed_phy(E) libphy(E) pwm_regulator(E) fixed(E)
    CPU: 2 PID: 112 Comm: systemd-udevd Tainted: G E 5.9.0-rc4-00102-g423583bc8cf9 #1840
    Hardware name: amlogic w400/w400, BIOS 2020.04 05/22/2020
    pstate: 80400009 (Nzcv daif +PAN -UAO BTYPE=--)
    pc : _regulator_put.part.0+0x16c/0x174
    lr : regulator_bulk_free+0x6c/0x9c
    sp : ffffffc012353820
    x29: ffffffc012353820 x28: ffffff805a4b7000
    x27: ffffff8059c2eac0 x26: ffffff8059c2e810
    x25: ffffff805a4b7d00 x24: ffffffc008cf3028
    x23: ffffffc011729ef8 x22: ffffff807e2761d8
    x21: ffffffc01171df78 x20: ffffff805a4b7700
    x19: ffffff805a4b7700 x18: 0000000000000030
    x17: 0000000000000000 x16: 0000000000000000
    x15: ffffff807ea8d178 x14: 3935312820435455
    x13: 2038323a36313a37 x12: ffffffffffffffff
    x11: 0000000000000040 x10: 0000000000000007
    x9 : ffffffc0106f77d0 x8 : ffffffffffffffe0
    x7 : ffffffffffffffff x6 : 0000000000017702
    x5 : ffffff805a4b7400 x4 : 0000000000000000
    x3 : ffffffc01171df78 x2 : ffffff807ea8cc40
    x1 : 0000000000000000 x0 : 0000000000000001
    Call trace:
    _regulator_put.part.0+0x16c/0x174
    regulator_bulk_free+0x6c/0x9c
    devm_regulator_bulk_release+0x28/0x3c
    release_nodes+0x1c8/0x2c0
    devres_release_all+0x44/0x6c
    really_probe+0x1ec/0x504
    driver_probe_device+0x100/0x170
    device_driver_attach+0xcc/0xd4
    __driver_attach+0xb0/0x17c
    bus_for_each_dev+0x7c/0xd4
    driver_attach+0x30/0x3c
    bus_add_driver+0x154/0x250
    driver_register+0x84/0x140
    __platform_driver_register+0x54/0x60
    dwc2_platform_driver_init+0x2c/0x1000 [dwc2]
    do_one_initcall+0x54/0x2d0
    do_init_module+0x68/0x29c

    In order to fix this, tie the regulator disabling to the teardown
    process by registering a devm action callback. This makes sure that
    the regulators are disabled at the right time (just before they are
    released).

    Cc: Minas Harutyunyan
    Cc: Greg Kroah-Hartman
    Signed-off-by: Marc Zyngier
    Signed-off-by: Felipe Balbi

    Marc Zyngier
     
  • adds the specific compatible string for the DWC2 IP found in the APM82181
    SoCs. The IP is setup correctly through the auto detection... With the
    exception of the AHB Burst Size. The default of GAHBCFG_HBSTLEN_INCR4 of
    the "snps,dwc2" can cause a system hang when the USB and SATA is used
    concurrently. Because the predecessor (PPC460EX (Canyonlands)) already
    had the same problem, this SoC can make use of the existing
    dwc2_set_amcc_params() function.

    Signed-off-by: Christian Lamparter
    Signed-off-by: Felipe Balbi

    Christian Lamparter
     

24 Sep, 2020

2 commits

  • Call dwc2_debugfs_exit() and dwc2_hcd_remove() (if the HCD was enabled
    earlier) when usb_add_gadget_udc() has failed. This ensures that the
    debugfs entries created by dwc2_debugfs_init() as well as the HCD are
    cleaned up in the error path.

    Fixes: 207324a321a866 ("usb: dwc2: Postponed gadget registration to the udc class driver")
    Acked-by: Minas Harutyunyan
    Signed-off-by: Martin Blumenstingl
    Signed-off-by: Felipe Balbi

    Martin Blumenstingl
     
  • When booting up on a Raspberry Pi 4 with Control Flow Integrity checking
    enabled, the following warning/panic happens:

    [ 1.626435] CFI failure (target: dwc2_set_bcm_params+0x0/0x4):
    [ 1.632408] WARNING: CPU: 0 PID: 32 at kernel/cfi.c:30 __cfi_check_fail+0x54/0x5c
    [ 1.640021] Modules linked in:
    [ 1.643137] CPU: 0 PID: 32 Comm: kworker/0:1 Not tainted 5.8.0-rc6-next-20200724-00051-g89ba619726de #1
    [ 1.652693] Hardware name: Raspberry Pi 4 Model B Rev 1.2 (DT)
    [ 1.658637] Workqueue: events deferred_probe_work_func
    [ 1.663870] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--)
    [ 1.669542] pc : __cfi_check_fail+0x54/0x5c
    [ 1.673798] lr : __cfi_check_fail+0x54/0x5c
    [ 1.678050] sp : ffff8000102bbaa0
    [ 1.681419] x29: ffff8000102bbaa0 x28: ffffab09e21c7000
    [ 1.686829] x27: 0000000000000402 x26: ffff0000f6e7c228
    [ 1.692238] x25: 00000000fb7cdb0d x24: 0000000000000005
    [ 1.697647] x23: ffffab09e2515000 x22: ffffab09e069a000
    [ 1.703055] x21: 4c550309df1cf4c1 x20: ffffab09e2433c60
    [ 1.708462] x19: ffffab09e160dc50 x18: ffff0000f6e8cc78
    [ 1.713870] x17: 0000000000000041 x16: ffffab09e0bce6f8
    [ 1.719278] x15: ffffab09e1c819b7 x14: 0000000000000003
    [ 1.724686] x13: 00000000ffffefff x12: 0000000000000000
    [ 1.730094] x11: 0000000000000000 x10: 00000000ffffffff
    [ 1.735501] x9 : c932f7abfc4bc600 x8 : c932f7abfc4bc600
    [ 1.740910] x7 : 077207610770075f x6 : ffff0000f6c38f00
    [ 1.746317] x5 : 0000000000000000 x4 : 0000000000000000
    [ 1.751723] x3 : 0000000000000000 x2 : 0000000000000000
    [ 1.757129] x1 : ffff8000102bb7d8 x0 : 0000000000000032
    [ 1.762539] Call trace:
    [ 1.765030] __cfi_check_fail+0x54/0x5c
    [ 1.768938] __cfi_check+0x5fa6c/0x66afc
    [ 1.772932] dwc2_init_params+0xd74/0xd78
    [ 1.777012] dwc2_driver_probe+0x484/0x6ec
    [ 1.781180] platform_drv_probe+0xb4/0x100
    [ 1.785350] really_probe+0x228/0x63c
    [ 1.789076] driver_probe_device+0x80/0xc0
    [ 1.793247] __device_attach_driver+0x114/0x160
    [ 1.797857] bus_for_each_drv+0xa8/0x128
    [ 1.801851] __device_attach.llvm.14901095709067289134+0xc0/0x170
    [ 1.808050] bus_probe_device+0x44/0x100
    [ 1.812044] deferred_probe_work_func+0x78/0xb8
    [ 1.816656] process_one_work+0x204/0x3c4
    [ 1.820736] worker_thread+0x2f0/0x4c4
    [ 1.824552] kthread+0x174/0x184
    [ 1.827837] ret_from_fork+0x10/0x18

    CFI validates that all indirect calls go to a function with the same
    exact function pointer prototype. In this case, dwc2_set_bcm_params
    is the target, which has a parameter of type 'struct dwc2_hsotg *',
    but it is being implicitly cast to have a parameter of type 'void *'
    because that is the set_params function pointer prototype. Make the
    function pointer protoype match the definitions so that there is no
    more violation.

    Fixes: 7de1debcd2de ("usb: dwc2: Remove platform static params")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1107
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Felipe Balbi

    Nathan Chancellor
     

27 Jul, 2020

2 commits


24 Jul, 2020

1 commit

  • When gadget registration fails, one should not call usb_del_gadget_udc().
    Ensure this by setting gadget->udc to NULL. Also in case of a failure
    there is no need to disable low-level hardware, so return immiedetly
    instead of jumping to error_init label.

    This fixes the following kernel NULL ptr dereference on gadget failure
    (can be easily triggered with g_mass_storage without any module
    parameters):

    dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter besl=1
    dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter g_np_tx_fifo_size=1024
    dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM
    Mass Storage Function, version: 2009/09/11
    LUN: removable file: (no medium)
    no file given for LUN0
    g_mass_storage 12480000.hsotg: failed to start g_mass_storage: -22
    8] (usb_del_gadget_udc) from [] (dwc2_hsotg_remove+0x10/0x20)
    [] (dwc2_hsotg_remove) from [] (dwc2_driver_probe+0x57c/0x69c)
    [] (dwc2_driver_probe) from [] (platform_drv_probe+0x6c/0xa4)
    [] (platform_drv_probe) from [] (really_probe+0x200/0x48c)
    [] (really_probe) from [] (driver_probe_device+0x78/0x1fc)
    [] (driver_probe_device) from [] (bus_for_each_drv+0x74/0xb8)
    [] (bus_for_each_drv) from [] (__device_attach+0xd4/0x16c)
    [] (__device_attach) from [] (bus_probe_device+0x88/0x90)
    [] (bus_probe_device) from [] (deferred_probe_work_func+0x3c/0xd0)
    [] (deferred_probe_work_func) from [] (process_one_work+0x234/0x7dc)
    [] (process_one_work) from [] (worker_thread+0x44/0x51c)
    [] (worker_thread) from [] (kthread+0x158/0x1a0)
    [] (kthread) from [] (ret_from_fork+0x14/0x20)
    Exception stack(0xef121fb0 to 0xef121ff8)
    ...
    ---[ end trace 9724c2fc7cc9c982 ]---

    While fixing this also fix the double call to dwc2_lowlevel_hw_disable()
    if dr_mode is set to USB_DR_MODE_PERIPHERAL. In such case low-level
    hardware is already disabled before calling usb_add_gadget_udc(). That
    function correctly preserves low-level hardware state, there is no need
    for the second unconditional dwc2_lowlevel_hw_disable() call.

    Fixes: 207324a321a8 ("usb: dwc2: Postponed gadget registration to the udc class driver")
    Acked-by: Minas Harutyunyan
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Felipe Balbi

    Marek Szyprowski
     

23 Jul, 2020

2 commits

  • If usb-role-switch is present in the device tree, it means that ID and Vbus
    signals are not connected to the OTG controller but to an external
    component (GPIOs, Type-C controller). In this configuration, usb role
    switch is used to force valid sessions on STM32MP15 SoCs.

    Acked-by: Minas Harutyunyan
    Signed-off-by: Amelie Delaunay
    Signed-off-by: Felipe Balbi

    Amelie Delaunay
     
  • This patch adds support for usb role switch to dwc2, by using overriding
    control of the PHY voltage valid and ID input signals.

    iddig signal (ID) can be overridden:
    - when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1;
    - when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0.

    avalid/bvalid/vbusvalid signals can be overridden respectively with:
    - GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL
    - GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL
    - GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL

    It is possible to determine valid sessions thanks to usb role switch:
    - if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid
    - if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid
    - if USB_ROLE_HOST then avalid && !bvalid && vbusvalid

    Acked-by: Minas Harutyunyan
    Signed-off-by: Amelie Delaunay
    Signed-off-by: Felipe Balbi

    Amelie Delaunay
     

20 Jul, 2020

1 commit


15 Jul, 2020

2 commits

  • Commit ec1f9d9f01384 ("usb: dwc2: gadget: parity fix in isochronous mode") moved
    these checks to dwc2_hsotg_change_ep_iso_parity() back in 2015. The assigned
    value hasn't been read back since. Let's remove the unnecessary H/W read.

    Fixes the following W=1 warning:

    drivers/usb/dwc2/gadget.c: In function ‘dwc2_hsotg_epint’:
    drivers/usb/dwc2/gadget.c:2981:6: warning: variable ‘ctrl’ set but not used [-Wunused-but-set-variable]
    2981 | u32 ctrl;
    | ^~~~

    Cc: Ben Dooks
    Signed-off-by: Lee Jones
    Acked-by: Minas Harutyunyan
    Link: https://lore.kernel.org/r/20200715093209.3165641-3-lee.jones@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Lee Jones
     
  • The value obtained from GINTSTS2 should be masked with the GINTMSK2
    value. Looks like this has been broken since
    dwc2_gadget_wkup_alert_handler() was added back in 2018.

    Also fixes the following W=1 warning:

    drivers/usb/dwc2/gadget.c: In function ‘dwc2_gadget_wkup_alert_handler’:
    drivers/usb/dwc2/gadget.c:259:6: warning: variable ‘gintmsk2’ set but not used [-Wunused-but-set-variable]
    259 | u32 gintmsk2;
    | ^~~~~~~~

    Cc: Ben Dooks
    Fixes: 187c5298a1229 ("usb: dwc2: gadget: Add handler for WkupAlert interrupt")
    Signed-off-by: Lee Jones
    Acked-by: Minas Harutyunyan
    Link: https://lore.kernel.org/r/20200715093209.3165641-2-lee.jones@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Lee Jones
     

09 Jul, 2020

1 commit

  • To avoid lot of interrupts from dwc2 core, which can be asserted in
    specific conditions need to disable interrupts on HW level instead of
    disable IRQs on Kernel level, because of IRQ can be shared between
    drivers.

    Cc: stable@vger.kernel.org
    Fixes: a40a00318c7fc ("usb: dwc2: add shutdown callback to platform variant")
    Tested-by: Frank Mori Hess
    Reviewed-by: Alan Stern
    Reviewed-by: Doug Anderson
    Reviewed-by: Frank Mori Hess
    Signed-off-by: Minas Harutyunyan
    Signed-off-by: Felipe Balbi

    Minas Harutyunyan
     

03 Jul, 2020

1 commit

  • The value of 'maxsize' has not been checked since commit 729cac693eecf
    ("usb: dwc2: Change ISOC DDMA flow") back in 2018, so remove the set but
    unused variable, which fixes the following W=1 kernel build warning:

    drivers/usb/dwc2/gadget.c: In function ‘dwc2_gadget_fill_isoc_desc’:
    drivers/usb/dwc2/gadget.c:885:6: warning: variable ‘maxsize’ set but not used [-Wunused-but-set-variable]
    885 | u32 maxsize = 0;
    | ^~~~~~~

    Cc: Minas Harutyunyan
    Cc: Ben Dooks
    Signed-off-by: Lee Jones
    Link: https://lore.kernel.org/r/20200702144625.2533530-11-lee.jones@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Lee Jones
     

01 Jul, 2020

1 commit

  • USB is a HOST/DEVICE protocol, as per the specification and all
    documentation. Fix up terms that are not applicable to make things
    match up with the terms used through the rest of the USB stack.

    Signed-off-by: Greg Kroah-Hartman
    Acked-by: Felipe Balbi
    Link: https://lore.kernel.org/r/20200630174123.GA1906678@kroah.com
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

29 Jun, 2020

1 commit


24 Jun, 2020

1 commit

  • For some reason, the TEST_ defines in the usb/ch9.h files did not have
    the USB_ prefix on it, making it a bit confusing when reading the file,
    as well as not the nicest thing to do in a uapi file.

    So fix that up and add the USB_ prefix on to them, and fix up all
    in-kernel usages. This included deleting the duplicate copy in the
    net2272.h file.

    Cc: Felipe Balbi
    Cc: Michal Simek
    Cc: Mathias Nyman
    Cc: Pawel Laszczak
    Cc: YueHaibing
    Cc: Nathan Chancellor
    Cc: Jason Yan
    Cc: Jia-Ju Bai
    Cc: Stephen Boyd
    Cc: Christophe JAILLET
    Cc: Arnd Bergmann
    Cc: Jules Irenge
    Cc: Alan Stern
    Cc: Thinh Nguyen
    Cc: Rob Gill
    Cc: Macpaul Lin
    Acked-by: Minas Harutyunyan
    Acked-by: Bin Liu
    Acked-by: Chunfeng Yun
    Acked-by: Peter Chen
    Link: https://lore.kernel.org/r/20200618144206.2655890-1-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 Jun, 2020

2 commits

  • During dwc2 driver probe, after gadget registration to the udc class
    driver, if exist any builtin function driver it immediately bound to
    dwc2 and after init host side (dwc2_hcd_init()) stucked in host mode.
    Patch postpone gadget registration after host side initialization done.

    Fixes: 117777b2c3bb9 ("usb: dwc2: Move gadget probe function into platform code")
    Reported-by: kbuild test robot
    Tested-by: Marek Vasut
    Cc: stable
    Signed-off-by: Minas Harutyunyan
    Link: https://lore.kernel.org/r/f21cb38fecc72a230b86155d94c7e60c9cb66f58.1591690938.git.hminas@synopsys.com
    Signed-off-by: Greg Kroah-Hartman

    Minas Harutyunyan
     
  • Use the well defined macros such as DWC2_POWER_DOWN_PARAM_NONE,
    DWC2_POWER_DOWN_PARAM_PARTIAL and DWC2_POWER_DOWN_PARAM_HIBERNATION
    to make code more readable.

    Signed-off-by: Jisheng Zhang
    Acked-by: Minas Harutyunyan
    Link: https://lore.kernel.org/r/20200616162617.38365cc8@xhacker.debian
    Signed-off-by: Greg Kroah-Hartman

    Jisheng Zhang
     

25 May, 2020

2 commits

  • Starting from core version 4.20a Core Reset flow is changed.
    Introduced new bit in GRSTCTL register - GRSTCTL_CSFTRST_DONE.
    Core Reset new programming flow steps are follow:
    1. Set GRSTCTL_CSFTRST bit.
    2. Wait for bit GRSTCTL_CSFTRST_DONE is set.
    3. Clear GRSTCTL_CSFTRST and GRSTCTL_CSFTRST_DONE bits.

    Check core version functionality separated from dwc2_get_hwparams() to
    new dwc2_check_core_version() function because Core Reset flow depend
    on SNPSID.

    Signed-off-by: Minas Harutyunyan
    Signed-off-by: Felipe Balbi

    Minas Harutyunyan
     
  • When the remote wakeup interrupt is triggered, lx_state is resumed from L2
    to L0 state. But when the gadget resume is called, lx_state is still L2.
    This prevents the resume callback to queue any request. Any attempt
    to queue a request from resume callback will result in:
    - "submit request only in active state" debug message to be issued
    - dwc2_hsotg_ep_queue() returns -EAGAIN

    Call the gadget resume routine after the core is in L0 state.

    Fixes: f81f46e1f530 ("usb: dwc2: implement hibernation during bus suspend/resume")

    Acked-by: Minas Harutyunyan
    Signed-off-by: Fabrice Gasnier
    Signed-off-by: Felipe Balbi

    Fabrice Gasnier
     

05 May, 2020

1 commit

  • This patch corrects the SPDX License Identifier style in
    header files related to DesignWare USB2 DRD Core Support.
    For C header files Documentation/process/license-rules.rst
    mandates C-like comments (opposed to C source files where
    C++ style should be used).

    Changes made by using a script provided by Joe Perches here:
    https://lkml.org/lkml/2019/2/7/46.

    Suggested-by: Joe Perches
    Signed-off-by: Nishad Kamdar
    Signed-off-by: Felipe Balbi

    Nishad Kamdar
     

24 Mar, 2020

1 commit

  • Use devm_platform_get_and_ioremap_resource() to simplify code, which
    contains platform_get_resource() and devm_ioremap_resource(), it also
    get the resource for use by the following code.

    Reviewed-by: Geert Uytterhoeven
    Acked-by: Minas Harutyunyan
    Signed-off-by: Dejin Zheng
    Link: https://lore.kernel.org/r/20200323160612.17277-5-zhengdejin5@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Dejin Zheng
     

16 Mar, 2020

1 commit

  • Felipe writes:

    USB: changes for v5.7 merge window

    Lots of changes on dwc3 this time, most of them from Thinh fixing a
    bunch of really old mishaps on the driver.

    DWC2 got support for STM32MP15 and a couple RockChip SoCs while DWC3
    learned about Amlogic A1 family.

    Apart from these, we have a few spelling fixes and other minor
    non-critical fixes all over the place.

    Signed-off-by: Felipe Balbi

    * tag 'usb-for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (41 commits)
    dt-bindings: usb: add documentation for aspeed usb-vhub
    ARM: dts: aspeed-g4: add vhub port and endpoint properties
    ARM: dts: aspeed-g5: add vhub port and endpoint properties
    ARM: dts: aspeed-g6: add usb functions
    usb: gadget: aspeed: add ast2600 vhub support
    usb: gadget: aspeed: read vhub properties from device tree
    usb: gadget: aspeed: support per-vhub usb descriptors
    usb: gadget: f_phonet: Replace zero-length array with flexible-array member
    usb: gadget: composite: Inform controller driver of self-powered
    usb: gadget: amd5536udc: fix spelling mistake "reserverd" -> "reserved"
    udc: s3c-hsudc: Silence warning about supplies during deferred probe
    usb: dwc2: Silence warning about supplies during deferred probe
    dt-bindings: usb: dwc2: add compatible property for rk3368 usb
    dt-bindings: usb: dwc2: add compatible property for rk3328 usb
    usb: gadget: add raw-gadget interface
    usb: dwc2: Implement set_selfpowered()
    usb: dwc3: qcom: Replace by
    usb: dwc3: core: don't do suspend for device mode if already suspended
    usb: dwc3: Rework resets initialization to be more flexible
    usb: dwc3: Rework clock initialization to be more flexible
    ...

    Greg Kroah-Hartman
     

15 Mar, 2020

3 commits

  • Don't confuse user with meaningless warning about the failure in getting
    supplies in case of deferred probe.

    Acked-by: Minas Harutyunyan
    Reviewed-by: Krzysztof Kozlowski
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Felipe Balbi

    Marek Szyprowski
     
  • dwc2 always reports as self-powered in response to a device status
    request. Implement the set_selfpowered() operations so that the gadget
    can report as bus-powered when appropriate.

    This is modelled on the dwc3 implementation.

    Acked-by: Minas Harutyunyan
    Signed-off-by: John Keeping
    Signed-off-by: Felipe Balbi

    John Keeping
     
  • This patch introduces a new parameter to activate external ID pin and valid
    vbus level detection, required on STM32MP15 SoC to support dual role,
    either in HS or FS.
    The STM32MP15 SoC uses the GGPIO register to enable the level detection.
    The level detector requires to be powered.
    Also adds the params structures for STM32MP15 OTG HS and STM32MP1 OTG FS.

    Acked-by: Minas Harutyunyan
    Signed-off-by: Amelie Delaunay
    Signed-off-by: Felipe Balbi

    Amelie Delaunay
     

24 Feb, 2020

2 commits

  • We need the USB fixes in here as well.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Link: https://lore.kernel.org/r/20200220132017.GA29262@embeddedor
    Signed-off-by: Greg Kroah-Hartman

    Gustavo A. R. Silva
     

11 Feb, 2020

2 commits

  • 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: Minas Harutyunyan
    Fixes: fa389a6d7726 ("usb: dwc2: gadget: Add remote_wakeup_allowed flag")
    Tested-by: Jack Mitchell
    Cc: stable@vger.kernel.org
    Signed-off-by: Felipe Balbi

    Minas Harutyunyan
     
  • Moved ISOC request length checking from dwc2_hsotg_start_req() function to
    dwc2_hsotg_ep_queue().

    Fixes: 4fca54aa58293 ("usb: gadget: s3c-hsotg: add multi count support")
    Signed-off-by: Minas Harutyunyan
    Signed-off-by: Felipe Balbi

    Minas Harutyunyan
     

15 Jan, 2020

5 commits

  • The original dwc_otg driver used a DWC_WORKQ_SCHEDULE() wrapper to queue
    work items. Because that wrapper acquired the driver's global spinlock,
    an unlock/lock dance was necessary whenever a work item was queued up
    while the global spinlock was already held.

    The dwc2 driver dropped DWC_WORKQ_SCHEDULE() in favor of a direct call
    to queue_work(), but retained the (now gratuitous) unlock/lock dance in
    dwc2_handle_conn_id_status_change_intr(). Drop it.

    Signed-off-by: Lukas Wunner
    Acked-by: Minas Harutyunyan
    Acked-by: Felipe Balbi
    Link: https://lore.kernel.org/r/77c07f00a6a9d94323c4a060a3c72817b0703b97.1574244795.git.lukas@wunner.de
    Signed-off-by: Greg Kroah-Hartman

    Lukas Wunner
     
  • The number of FIFOs may be lower than the number of endpoints. Use the
    correct total when printing FIFO details in debugfs.

    Acked-by: Minas Harutyunyan
    Signed-off-by: John Keeping
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    John Keeping
     
  • On chips with fewer FIFOs than endpoints (for example RK3288 which has 9
    endpoints, but only 6 which are cabable of input), the DPTXFSIZN
    registers above the FIFO count may return invalid values.

    With logging added on startup, I see:

    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=1 sz=256
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=2 sz=128
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=3 sz=128
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=4 sz=64
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=5 sz=64
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=6 sz=32
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=7 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=8 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=9 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=10 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=11 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=12 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=13 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=14 sz=0
    dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=15 sz=0

    but:

    # cat /sys/kernel/debug/ff580000.usb/fifo
    Non-periodic FIFOs:
    RXFIFO: Size 275
    NPTXFIFO: Size 16, Start 0x00000113

    Periodic TXFIFOs:
    DPTXFIFO 1: Size 256, Start 0x00000123
    DPTXFIFO 2: Size 128, Start 0x00000223
    DPTXFIFO 3: Size 128, Start 0x000002a3
    DPTXFIFO 4: Size 64, Start 0x00000323
    DPTXFIFO 5: Size 64, Start 0x00000363
    DPTXFIFO 6: Size 32, Start 0x000003a3
    DPTXFIFO 7: Size 0, Start 0x000003e3
    DPTXFIFO 8: Size 0, Start 0x000003a3
    DPTXFIFO 9: Size 256, Start 0x00000123

    so it seems that FIFO 9 is mirroring FIFO 1.

    Fix the allocation by using the FIFO count instead of the endpoint count
    when selecting a FIFO for an endpoint.

    Acked-by: Minas Harutyunyan
    Signed-off-by: John Keeping
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    John Keeping
     
  • When a usb device disconnects in a certain way, dwc2_queue_transaction
    still gets called after dwc2_hcd_cleanup_channels.

    dwc2_hcd_cleanup_channels does "channel->qh = NULL;" but
    dwc2_queue_transaction still wants to dereference qh.
    This adds a check for a null qh.

    Acked-by: Minas Harutyunyan
    Signed-off-by: Alexandru M Stan
    [dianders: rebased to mainline]
    Signed-off-by: Douglas Anderson
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    Alexandru M Stan
     
  • Stalling a Non-Isochronous OUT Endpoint flow changed according
    programming guide.
    In dwc2_hsotg_ep_sethalt() function for OUT EP should not be set STALL bit.
    Instead should set SGOUTNAK in DCTL register. Set STALL bit should be
    set only after GOUTNAKEFF interrupt asserted.

    Signed-off-by: Minas Harutyunyan
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    Minas Harutyunyan