* [PATCH RFT 1/2] ARM: mmu: take DMA offset into account for coherent memory
@ 2025-12-01 21:18 Ahmad Fatoum
2025-12-01 21:18 ` [PATCH RFT 2/2] usb: xhci: pass hardware device to dma_alloc_coherent Ahmad Fatoum
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-12-01 21:18 UTC (permalink / raw)
To: barebox; +Cc: chalianis1, Ahmad Fatoum
Now that dma_alloc_coherent and dma_alloc_writecombine take an optional
device parameter, let's take the dma_offset of the device into account
if a device has been supplied.
This will allow supporting systems, where the CPU and other DMA masters,
see the SDRAM at different addresses (i.e. has a dma-ranges in the DT).
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
Result of a discussion with Anis. Needs to be tested.
---
arch/arm/cpu/mmu-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c
index dd4c8f7de7d4..30a9dfbcb9c0 100644
--- a/arch/arm/cpu/mmu-common.c
+++ b/arch/arm/cpu/mmu-common.c
@@ -47,7 +47,7 @@ void *dma_alloc_map(struct device *dev,
size = PAGE_ALIGN(size);
ret = xmemalign(PAGE_SIZE, size);
if (dma_handle)
- *dma_handle = (dma_addr_t)ret;
+ *dma_handle = cpu_to_dma(ret);
memset(ret, 0, size);
dma_flush_range(ret, size);
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH RFT 2/2] usb: xhci: pass hardware device to dma_alloc_coherent
2025-12-01 21:18 [PATCH RFT 1/2] ARM: mmu: take DMA offset into account for coherent memory Ahmad Fatoum
@ 2025-12-01 21:18 ` Ahmad Fatoum
0 siblings, 0 replies; 2+ messages in thread
From: Ahmad Fatoum @ 2025-12-01 21:18 UTC (permalink / raw)
To: barebox; +Cc: chalianis1, Ahmad Fatoum
We already pass the hardware device to dma_map_single in xhci-ring.c, do
the same for the coherent allocation, so dma-ranges is taken into
account.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/usb/host/xhci-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index aca3920427f4..6324bab730ad 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -86,7 +86,7 @@ static void *xhci_malloc(struct xhci_ctrl *ctrl, unsigned int size, dma_addr_t *
{
void *ptr;
- ptr = dma_alloc_coherent(DMA_DEVICE_BROKEN, size, dma_addr);
+ ptr = dma_alloc_coherent(ctrl->host.hw_dev, size, dma_addr);
if (!ptr)
return NULL;
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-01 21:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 21:18 [PATCH RFT 1/2] ARM: mmu: take DMA offset into account for coherent memory Ahmad Fatoum
2025-12-01 21:18 ` [PATCH RFT 2/2] usb: xhci: pass hardware device to dma_alloc_coherent Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox