* [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast @ 2024-07-24 9:47 Ahmad Fatoum 2024-07-24 9:47 ` [PATCH master 2/2] usb: gadget: fsl_udc: dma_map buffers instead of using dma_sync Ahmad Fatoum 2024-07-30 8:13 ` [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Sascha Hauer 0 siblings, 2 replies; 3+ messages in thread From: Ahmad Fatoum @ 2024-07-24 9:47 UTC (permalink / raw) To: barebox; +Cc: ske, Ahmad Fatoum All other prints in the file use the DMA address except for this single print inside debug_dma_map(). Let's use the DMA address there as well to fix the warning about casting a 32-bit pointer to a 64 bit integer and to align error messages in case of non-1:1 mapped DMA addresses. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/dma/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/debug.c b/drivers/dma/debug.c index 32a417504479..befe837d6cd8 100644 --- a/drivers/dma/debug.c +++ b/drivers/dma/debug.c @@ -131,7 +131,7 @@ void debug_dma_map(struct device *dev, void *addr, if (!IS_ALIGNED(dev_addr, DMA_ALIGNMENT)) dma_dev_warn(dev, "Mapping insufficiently aligned %s buffer 0x%llx+0x%zx: %u bytes required!\n", - dir2name[direction], (u64)addr, size, DMA_ALIGNMENT); + dir2name[direction], (u64)dev_addr, size, DMA_ALIGNMENT); } void debug_dma_unmap(struct device *dev, dma_addr_t addr, -- 2.39.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH master 2/2] usb: gadget: fsl_udc: dma_map buffers instead of using dma_sync 2024-07-24 9:47 [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Ahmad Fatoum @ 2024-07-24 9:47 ` Ahmad Fatoum 2024-07-30 8:13 ` [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Sascha Hauer 1 sibling, 0 replies; 3+ messages in thread From: Ahmad Fatoum @ 2024-07-24 9:47 UTC (permalink / raw) To: barebox; +Cc: ske, Ahmad Fatoum CONFIG_DMA_API_DEBUG depends on DMA buffers being mapped with dma_map_single before ownership is switched with dma_sync_single. As this is currently not done, CONFIG_DMA_API_DEBUG reports a lot of false positives when the driver is enabled. Fix it by using usb_gadget_map_request which internally calls dma_map_single. This fixes the false positives, aligns us with what the Linux driver is doing and reduces overhead when unmapping the buffer for an IN target endpoint: Previously with DMA_BIDIRECTIONAL, we always invalidated buffers when taking back ownership for the CPU. This is unnecessary when unmapping a buffer for an IN endpoint as the direction is DMA_TO_DEVICE and we won't be reading back the result. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/usb/gadget/udc/fsl_udc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/udc/fsl_udc.c b/drivers/usb/gadget/udc/fsl_udc.c index 41de44b30d12..e1d0d0b48272 100644 --- a/drivers/usb/gadget/udc/fsl_udc.c +++ b/drivers/usb/gadget/udc/fsl_udc.c @@ -197,8 +197,7 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status) dma_free_coherent(curr_td, 0, sizeof(struct ep_td_struct)); } - dma_sync_single_for_cpu(udc->gadget.dev.parent, (unsigned long)req->req.buf, - req->req.length, DMA_BIDIRECTIONAL); + usb_gadget_unmap_request(&udc->gadget, &req->req, ep_is_in(ep)); if (status && (status != -ESHUTDOWN)) VDBG("complete %s req %p stat %d len %u/%u", @@ -861,7 +860,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req) struct fsl_ep *ep = container_of(_ep, struct fsl_ep, ep); struct fsl_req *req = container_of(_req, struct fsl_req, req); struct fsl_udc *udc; - int is_iso = 0; + int ret, is_iso = 0; /* catch various bogus parameters */ if (!_req || !req->req.complete || !req->req.buf @@ -885,8 +884,9 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req) req->ep = ep; - dma_sync_single_for_device(udc->gadget.dev.parent, (unsigned long)req->req.buf, - req->req.length, DMA_BIDIRECTIONAL); + ret = usb_gadget_map_request(&ep->udc->gadget, &req->req, ep_is_in(ep)); + if (ret) + return ret; req->req.status = -EINPROGRESS; req->req.actual = 0; -- 2.39.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast 2024-07-24 9:47 [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Ahmad Fatoum 2024-07-24 9:47 ` [PATCH master 2/2] usb: gadget: fsl_udc: dma_map buffers instead of using dma_sync Ahmad Fatoum @ 2024-07-30 8:13 ` Sascha Hauer 1 sibling, 0 replies; 3+ messages in thread From: Sascha Hauer @ 2024-07-30 8:13 UTC (permalink / raw) To: barebox, Ahmad Fatoum; +Cc: ske On Wed, 24 Jul 2024 11:47:31 +0200, Ahmad Fatoum wrote: > All other prints in the file use the DMA address except for this single > print inside debug_dma_map(). Let's use the DMA address there as well to > fix the warning about casting a 32-bit pointer to a 64 bit integer and > to align error messages in case of non-1:1 mapped DMA addresses. > > Applied, thanks! [1/2] dma: debug: fix compiler warning about pointer u64 cast https://git.pengutronix.de/cgit/barebox/commit/?id=4cd2dbea7bda (link may not be stable) [2/2] usb: gadget: fsl_udc: dma_map buffers instead of using dma_sync https://git.pengutronix.de/cgit/barebox/commit/?id=c825a35f0f35 (link may not be stable) Best regards, -- Sascha Hauer <s.hauer@pengutronix.de> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-30 8:13 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-07-24 9:47 [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Ahmad Fatoum 2024-07-24 9:47 ` [PATCH master 2/2] usb: gadget: fsl_udc: dma_map buffers instead of using dma_sync Ahmad Fatoum 2024-07-30 8:13 ` [PATCH master 1/2] dma: debug: fix compiler warning about pointer u64 cast Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox