* [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
@ 2024-09-17 16:17 Lizhi Hou
2024-09-18 5:22 ` Christoph Hellwig
2024-09-18 12:13 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Lizhi Hou @ 2024-09-17 16:17 UTC (permalink / raw)
To: vkol, hch; +Cc: Lizhi Hou, dmaengine, linux-kernel, nishads
The get_dma_ops and set_dma_ops APIs were never for driver to use. Remove
these calls from QDMA driver. Instead, pass the DMA device pointer from the
qdma_platdata structure.
Fixes: 73d5fc92a11c ("dmaengine: amd: qdma: Add AMD QDMA driver")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/dma/amd/qdma/qdma.c | 20 +++++++-------------
include/linux/platform_data/amd_qdma.h | 2 ++
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/dma/amd/qdma/qdma.c b/drivers/dma/amd/qdma/qdma.c
index b0a1f3ad851b..ded79352550b 100644
--- a/drivers/dma/amd/qdma/qdma.c
+++ b/drivers/dma/amd/qdma/qdma.c
@@ -492,18 +492,9 @@ static int qdma_device_verify(struct qdma_device *qdev)
static int qdma_device_setup(struct qdma_device *qdev)
{
- struct device *dev = &qdev->pdev->dev;
u32 ring_sz = QDMA_DEFAULT_RING_SIZE;
int ret = 0;
- while (dev && get_dma_ops(dev))
- dev = dev->parent;
- if (!dev) {
- qdma_err(qdev, "dma device not found");
- return -EINVAL;
- }
- set_dma_ops(&qdev->pdev->dev, get_dma_ops(dev));
-
ret = qdma_setup_fmap_context(qdev);
if (ret) {
qdma_err(qdev, "Failed setup fmap context");
@@ -548,11 +539,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan)
{
struct qdma_queue *queue = to_qdma_queue(chan);
struct qdma_device *qdev = queue->qdev;
- struct device *dev = qdev->dma_dev.dev;
+ struct qdma_platdata *pdata;
qdma_clear_queue_context(queue);
vchan_free_chan_resources(&queue->vchan);
- dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE,
+ pdata = dev_get_platdata(&qdev->pdev->dev);
+ dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE,
queue->desc_base, queue->dma_desc_base);
}
@@ -565,6 +557,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
struct qdma_queue *queue = to_qdma_queue(chan);
struct qdma_device *qdev = queue->qdev;
struct qdma_ctxt_sw_desc desc;
+ struct qdma_platdata *pdata;
size_t size;
int ret;
@@ -572,8 +565,9 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
if (ret)
return ret;
+ pdata = dev_get_platdata(&qdev->pdev->dev);
size = queue->ring_size * QDMA_MM_DESC_SIZE;
- queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size,
+ queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size,
&queue->dma_desc_base,
GFP_KERNEL);
if (!queue->desc_base) {
@@ -588,7 +582,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
if (ret) {
qdma_err(qdev, "Failed to setup SW desc ctxt for %s",
chan->name);
- dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base,
+ dma_free_coherent(pdata->dma_dev, size, queue->desc_base,
queue->dma_desc_base);
return ret;
}
diff --git a/include/linux/platform_data/amd_qdma.h b/include/linux/platform_data/amd_qdma.h
index 576d952f97ed..967a6ef31cf9 100644
--- a/include/linux/platform_data/amd_qdma.h
+++ b/include/linux/platform_data/amd_qdma.h
@@ -26,11 +26,13 @@ struct dma_slave_map;
* @max_mm_channels: Maximum number of MM DMA channels in each direction
* @device_map: DMA slave map
* @irq_index: The index of first IRQ
+ * @dma_dev: The device pointer for dma operations
*/
struct qdma_platdata {
u32 max_mm_channels;
u32 irq_index;
struct dma_slave_map *device_map;
+ struct device *dma_dev;
};
#endif /* _PLATDATA_AMD_QDMA_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
2024-09-17 16:17 [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs Lizhi Hou
@ 2024-09-18 5:22 ` Christoph Hellwig
2024-09-18 12:13 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-09-18 5:22 UTC (permalink / raw)
To: Lizhi Hou; +Cc: vkol, hch, dmaengine, linux-kernel, nishads
On Tue, Sep 17, 2024 at 09:17:40AM -0700, Lizhi Hou wrote:
> The get_dma_ops and set_dma_ops APIs were never for driver to use. Remove
> these calls from QDMA driver. Instead, pass the DMA device pointer from the
> qdma_platdata structure.
>
> Fixes: 73d5fc92a11c ("dmaengine: amd: qdma: Add AMD QDMA driver")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
From the DMA point of view this looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
2024-09-17 16:17 [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs Lizhi Hou
2024-09-18 5:22 ` Christoph Hellwig
@ 2024-09-18 12:13 ` Christoph Hellwig
2024-09-18 17:37 ` Lizhi Hou
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2024-09-18 12:13 UTC (permalink / raw)
To: Lizhi Hou; +Cc: vkol, hch, dmaengine, linux-kernel, nishads
On Tue, Sep 17, 2024 at 09:17:40AM -0700, Lizhi Hou wrote:
> The get_dma_ops and set_dma_ops APIs were never for driver to use. Remove
> these calls from QDMA driver. Instead, pass the DMA device pointer from the
> qdma_platdata structure.
Btw, this file should also drop the include of <linux/dma-map-ops.h>,
which is clearly marked as not for driver use.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
2024-09-18 12:13 ` Christoph Hellwig
@ 2024-09-18 17:37 ` Lizhi Hou
0 siblings, 0 replies; 4+ messages in thread
From: Lizhi Hou @ 2024-09-18 17:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: vkol, dmaengine, linux-kernel, nishads
On 9/18/24 05:13, Christoph Hellwig wrote:
> On Tue, Sep 17, 2024 at 09:17:40AM -0700, Lizhi Hou wrote:
>> The get_dma_ops and set_dma_ops APIs were never for driver to use. Remove
>> these calls from QDMA driver. Instead, pass the DMA device pointer from the
>> qdma_platdata structure.
> Btw, this file should also drop the include of <linux/dma-map-ops.h>,
> which is clearly marked as not for driver use.
>
>
Thanks. I will remove this header and re-spin a new patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-18 17:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 16:17 [PATCH 1/1] dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs Lizhi Hou
2024-09-18 5:22 ` Christoph Hellwig
2024-09-18 12:13 ` Christoph Hellwig
2024-09-18 17:37 ` Lizhi Hou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox