kernel_samsung_a53x/drivers/usb/dwc2
Peng Hongchi 3050eda410 usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled
[ Upstream commit 1134289b6b93d73721340b66c310fd985385e8fa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-15 16:29:40 +01:00
..
core.c
core.h usb: dwc2: gadget: LPM flow fix 2024-11-19 09:22:43 +01:00
core_intr.c usb: dwc2: gadget: LPM flow fix 2024-11-19 09:22:43 +01:00
debug.h
debugfs.c
drd.c
gadget.c usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled 2025-01-15 16:29:40 +01:00
hcd.c usb: dwc2: hcd: Fix GetPortStatus & SetPortFeature 2025-01-02 17:00:49 +01:00
hcd.h
hcd_ddma.c usb: dwc2: host: Fix dereference issue in DDMA completion flow. 2024-11-19 11:32:23 +01:00
hcd_intr.c
hcd_queue.c
hw.h usb: dwc2: host: Fix ISOC flow in DDMA mode 2024-11-19 09:22:43 +01:00
Kconfig
Makefile
params.c
pci.c
platform.c Revert "usb: dwc2: Adjust the timing of USB Driver Interrupt Registration in the Crashkernel Scenario" 2024-11-24 00:22:58 +01:00