* [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after it's freed
@ 2023-12-14 8:25 joakim.zhang
2023-12-15 11:32 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: joakim.zhang @ 2023-12-14 8:25 UTC (permalink / raw)
To: hch, m.szyprowski, robin.murphy
Cc: iommu, linux-kernel, cix-kernel-upstream, Joakim Zhang
From: Joakim Zhang <joakim.zhang@cixtech.com>
Reproduced with below sequence:
dma_declare_coherent_memory()->dma_release_coherent_memory()
->dma_declare_coherent_memory()->"return -EBUSY" error
It will return -EBUSY from the dma_assign_coherent_memory()
in dma_declare_coherent_memory(), the reason is that dev->dma_mem
pointer has not been set to NULL after it's freed.
Fixes: cf65a0f6f6ff ("dma-mapping: move all DMA mapping code to kernel/dma")
Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>
---
ChangeLogs:
V1->V2:
* remove _dma_release_coherent_memory() from
rmem_dma_device_release()
* update commit message
---
kernel/dma/coherent.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index c21abc77c53e..ff5683a57f77 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -132,8 +132,10 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
void dma_release_coherent_memory(struct device *dev)
{
- if (dev)
+ if (dev) {
_dma_release_coherent_memory(dev->dma_mem);
+ dev->dma_mem = NULL;
+ }
}
static void *__dma_alloc_from_coherent(struct device *dev,
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after it's freed
2023-12-14 8:25 [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after it's freed joakim.zhang
@ 2023-12-15 11:32 ` Christoph Hellwig
2023-12-15 14:24 ` Joakim Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2023-12-15 11:32 UTC (permalink / raw)
To: joakim.zhang
Cc: hch, m.szyprowski, robin.murphy, iommu, linux-kernel,
cix-kernel-upstream
I've applied this after fixing the whitespace errors.
But we really need to get remoteporc off messing with the reserved
regions itself and retire this API entirely.
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after it's freed
2023-12-15 11:32 ` Christoph Hellwig
@ 2023-12-15 14:24 ` Joakim Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Joakim Zhang @ 2023-12-15 14:24 UTC (permalink / raw)
To: Christoph Hellwig
Cc: m.szyprowski@samsung.com, robin.murphy@arm.com,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
cix-kernel-upstream
Hi Christoph Hellwig,
> -----Original Message-----
> From: Christoph Hellwig <hch@lst.de>
> Sent: Friday, December 15, 2023 7:32 PM
> To: Joakim Zhang <joakim.zhang@cixtech.com>
> Cc: hch@lst.de; m.szyprowski@samsung.com; robin.murphy@arm.com;
> iommu@lists.linux.dev; linux-kernel@vger.kernel.org; cix-kernel-upstream
> <cix-kernel-upstream@cixtech.com>
> Subject: Re: [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after
> it's freed
>
> I've applied this after fixing the whitespace errors.
>
> But we really need to get remoteporc off messing with the reserved regions
> itself and retire this API entirely.
Indeed, I met this issue when debugging remoteproc, this API maybe useful since some system would not support device tree, but still want to reserve memory in the driver.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-15 14:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 8:25 [PATCH V2] dma-mapping: Set dma_mem pointer as NULL after it's freed joakim.zhang
2023-12-15 11:32 ` Christoph Hellwig
2023-12-15 14:24 ` Joakim Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox