linux/drivers/usb/dwc2
Peng Hongchi 1134289b6b usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled
When using dma_map_sg() to map the scatterlist with iommu enabled,
the entries in the scatterlist can be mergerd into less but longer
entries in the function __finalise_sg(). So that the number of
valid mapped entries is actually smaller than ureq->num_reqs,and
there are still some invalid entries in the scatterlist with
dma_addr=0xffffffff and len=0. Writing these invalid sg entries
into the dma_desc can cause a data transmission error.

The function dma_map_sg() returns the number of valid map entries
and the return value is assigned to usb_request::num_mapped_sgs in
function usb_gadget_map_request_by_dev(). So that just write valid
mapped entries into dma_desc according to the usb_request::num_mapped_sgs,
and set the IOC bit if it's the last valid mapped entry.

This patch poses no risk to no-iommu situation, cause
ureq->num_mapped_sgs equals ureq->num_sgs while using dma_direct_map_sg()
to map the scatterlist whith iommu disabled.

Signed-off-by: Peng Hongchi <hongchi.peng@siengine.com>
Link: https://lore.kernel.org/r/20240523100315.7226-1-hongchi.peng@siengine.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-04 15:41:26 +02:00
..
core_intr.c Merge 6.9-rc2 into usb-next 2024-04-01 17:02:18 +02:00
core.c usb: dwc2: New bitfield definition and programming in GRSTCTL 2024-03-26 10:44:53 +01:00
core.h Merge 6.9-rc2 into usb-next 2024-04-01 17:02:18 +02:00
debug.h USB: dwc2: Use the correct style for SPDX License Identifier 2020-05-05 10:58:50 +03:00
debugfs.c usb: dwc2: Add new parameter eusb2_disc 2024-03-26 10:44:53 +01:00
drd.c usb: dwc2: drd: fix inconsistent mode if role-switch-default-mode="host" 2023-03-09 15:38:24 +01:00
gadget.c usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled 2024-06-04 15:41:26 +02:00
hcd_ddma.c usb: dwc2: host: Fix dereference issue in DDMA completion flow. 2024-04-09 17:29:38 +02:00
hcd_intr.c USB: dwc2: write HCINT with INTMASK applied 2023-11-21 15:30:27 +01:00
hcd_queue.c usb: dwc2: Remove cat_printf() 2024-03-26 10:43:45 +01:00
hcd.c Merge 6.9-rc2 into usb-next 2024-04-01 17:02:18 +02:00
hcd.h usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hw.h Merge 6.9-rc2 into usb-next 2024-04-01 17:02:18 +02:00
Kconfig usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
Makefile usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
params.c usb: dwc2: add support for Sophgo CV18XX/SG200X series SoC 2024-03-27 07:57:15 +01:00
pci.c usb: dwc2: add pci_device_id driver_data parse support 2023-08-22 14:49:12 +02:00
platform.c usb: dwc2: gadget: Fix exiting from clock gating 2024-03-26 14:56:25 +01:00