1. 26 11月, 2022 1 次提交
  2. 18 10月, 2022 1 次提交
  3. 18 5月, 2022 1 次提交
  4. 14 1月, 2022 1 次提交
  5. 15 11月, 2021 2 次提交
  6. 15 10月, 2021 2 次提交
  7. 03 6月, 2021 1 次提交
  8. 09 3月, 2021 1 次提交
    • H
      usb: dwc2: Fix endpoint direction check in ep_from_windex · 531f212b
      Heiko Stuebner 提交于
      stable inclusion
      from stable-5.10.15
      commit 750829e1931a495d6889752811584a23ddad9db5
      bugzilla: 48167
      
      --------------------------------
      
      commit f670e9f9 upstream.
      
      dwc2_hsotg_process_req_status uses ep_from_windex() to retrieve
      the endpoint for the index provided in the wIndex request param.
      
      In a test-case with a rndis gadget running and sending a malformed
      packet to it like:
          dev.ctrl_transfer(
              0x82,      # bmRequestType
              0x00,       # bRequest
              0x0000,     # wValue
              0x0001,     # wIndex
              0x00       # wLength
          )
      it is possible to cause a crash:
      
      [  217.533022] dwc2 ff300000.usb: dwc2_hsotg_process_req_status: USB_REQ_GET_STATUS
      [  217.559003] Unable to handle kernel read from unreadable memory at virtual address 0000000000000088
      ...
      [  218.313189] Call trace:
      [  218.330217]  ep_from_windex+0x3c/0x54
      [  218.348565]  usb_gadget_giveback_request+0x10/0x20
      [  218.368056]  dwc2_hsotg_complete_request+0x144/0x184
      
      This happens because ep_from_windex wants to compare the endpoint
      direction even if index_to_ep() didn't return an endpoint due to
      the direction not matching.
      
      The fix is easy insofar that the actual direction check is already
      happening when calling index_to_ep() which will return NULL if there
      is no endpoint for the targeted direction, so the offending check
      can go away completely.
      
      Fixes: c6f5c050 ("usb: dwc2: gadget: add bi-directional endpoint support")
      Cc: stable@vger.kernel.org
      Reported-by: NGerhard Klostermeier <gerhard.klostermeier@syss.de>
      Signed-off-by: NHeiko Stuebner <heiko.stuebner@theobroma-systems.com>
      Link: https://lore.kernel.org/r/20210127103919.58215-1-heiko@sntech.deSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      531f212b
  9. 02 10月, 2020 2 次提交
    • M
      usb: dwc2: Fix INTR OUT transfers in DDMA mode. · b2c586eb
      Minas Harutyunyan 提交于
      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: cf77b5fb ("usb: dwc2: gadget: Transfer length limit checking for DDMA")
      Fixes: e02f9aa6 ("usb: dwc2: gadget: EP 0 specific DDMA programming")
      Fixes: aa3e8bc8 ("usb: dwc2: gadget: DDMA transfer start and complete")
      Signed-off-by: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      b2c586eb
    • A
      usb: dwc2: override PHY input signals with usb role switch support · 17f93402
      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: NMinas Harutyunyan <hminas@synopsys.com>
      Acked-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NAmelie Delaunay <amelie.delaunay@st.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      17f93402
  10. 27 7月, 2020 1 次提交
  11. 23 7月, 2020 1 次提交
    • A
      usb: dwc2: override PHY input signals with usb role switch support · bc0f0d4a
      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: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NAmelie Delaunay <amelie.delaunay@st.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      bc0f0d4a
  12. 15 7月, 2020 2 次提交
  13. 03 7月, 2020 1 次提交
  14. 24 6月, 2020 1 次提交
  15. 18 6月, 2020 1 次提交
  16. 15 3月, 2020 1 次提交
  17. 11 2月, 2020 2 次提交
  18. 15 1月, 2020 2 次提交
    • J
      usb: dwc2: Fix IN FIFO allocation · 644139f8
      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: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      644139f8
    • M
      usb: dwc2: Fix Stalling a Non-Isochronous OUT EP · 6070636c
      Minas Harutyunyan 提交于
      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: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6070636c
  19. 09 8月, 2019 1 次提交
    • J
      usb: dwc2: gadget: Fix kill_all_requests race · 37bea42f
      John Keeping 提交于
      When a gadget is disabled, kill_all_requests() can be called
      simultaneously from both a user process via dwc2_hsotg_pullup() and from
      the interrupt handler if the hardware detects disconnection.
      
      Since we drop the lock in dwc2_hsotg_complete_request() in order to call
      the completion handler, this means that the list is modified
      concurrently and leads to an infinite loop in kill_all_requests().
      
      Replace the foreach loop with a while-not-empty loop in order to remove
      the danger of this concurrent modification.
      
      Note: I observed this with threadirqs, I'm not sure if it can be
      triggered without threaded interrupts.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      37bea42f
  20. 06 6月, 2019 2 次提交
  21. 03 5月, 2019 8 次提交
  22. 07 2月, 2019 2 次提交
  23. 17 1月, 2019 1 次提交
  24. 11 12月, 2018 1 次提交
    • M
      usb: dwc2: Fix disable all EP's on disconnect · 4fe4f9fe
      Minas Harutyunyan 提交于
      Disabling all EP's allow to reset EP's to initial state.
      Introduced new function dwc2_hsotg_ep_disable_lock() which
      before calling dwc2_hsotg_ep_disable() function acquire
      hsotg->lock and release on exiting.
      From dwc2_hsotg_ep_disable() function removed acquiring
      hsotg->lock.
      In dwc2_hsotg_core_init_disconnected() function when USB
      reset interrupt asserted disabling all ep’s by
      dwc2_hsotg_ep_disable() function.
      This updates eliminating sparse imbalance warnings.
      
      Reverted changes in dwc2_hostg_disconnect() function.
      Introduced new function dwc2_hsotg_ep_disable_lock().
      Changed dwc2_hsotg_ep_ops. Now disable point to
      dwc2_hsotg_ep_disable_lock() function.
      In functions dwc2_hsotg_udc_stop() and dwc2_hsotg_suspend()
      dwc2_hsotg_ep_disable() function replaced by
      dwc2_hsotg_ep_disable_lock() function.
      In dwc2_hsotg_ep_disable() function removed acquiring
      of hsotg->lock.
      
      Fixes: dccf1bad ("usb: dwc2: Disable all EP's on disconnect")
      Signed-off-by: NMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      4fe4f9fe
  25. 26 11月, 2018 1 次提交