[PATCH 1/1] rapidio/tsi721: move dma_device from rio_mport to tsi721_device
From: Frank . Li
Date: Fri Nov 06 2026 - 16:43:21 EST
From: Frank Li <Frank.Li@xxxxxxx>
The embedded struct dma_device in struct rio_mport is only used by the
tsi721 driver. Move it into struct tsi721_device where it belongs, and
replace it with a pointer in struct rio_mport so that the generic RapidIO
code (rio_chan_filter) can still compare channel ownership without a
driver-specific container_of.
Prepare move struct dma_device to private.
Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
---
build test only
combine with other on going reviewed rio patches. drivers/rapidio can
build with allyesconfig after move struct dma_device to
drivers/dmaengine.h
---
drivers/rapidio/devices/tsi721.h | 1 +
drivers/rapidio/devices/tsi721_dma.c | 44 ++++++++++++++--------------
drivers/rapidio/rio.c | 2 +-
include/linux/rio.h | 8 ++---
4 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h
index 4f996ce627254..2df3955581af3 100644
--- a/drivers/rapidio/devices/tsi721.h
+++ b/drivers/rapidio/devices/tsi721.h
@@ -886,6 +886,7 @@ struct tsi721_device {
u32 pw_discard_count;
/* BDMA Engine */
+ struct dma_device dma;
struct tsi721_bdma_maint mdma; /* Maintenance rd/wr request channel */
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
index 52749f1d2a11a..09faaf2f334cc 100644
--- a/drivers/rapidio/devices/tsi721_dma.c
+++ b/drivers/rapidio/devices/tsi721_dma.c
@@ -51,7 +51,7 @@ static inline struct tsi721_bdma_chan *to_tsi721_chan(struct dma_chan *chan)
static inline struct tsi721_device *to_tsi721(struct dma_device *ddev)
{
- return container_of(ddev, struct rio_mport, dma)->priv;
+ return container_of(ddev, struct tsi721_device, dma);
}
static inline
@@ -437,7 +437,7 @@ static int tsi721_submit_sg(struct tsi721_tx_desc *desc)
rio_addr = desc->rio_addr;
next_addr = -1;
bcount = 0;
- sys_size = dma_to_mport(dchan->device)->sys_size;
+ sys_size = to_tsi721(dchan->device)->mport.sys_size;
rd_idx = ioread32(bdma_chan->regs + TSI721_DMAC_DRDCNT);
rd_idx %= (bdma_chan->bd_num + 1);
@@ -965,9 +965,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
int i;
int nr_channels = 0;
int err;
- struct rio_mport *mport = &priv->mport;
-
- INIT_LIST_HEAD(&mport->dma.channels);
+ INIT_LIST_HEAD(&priv->dma.channels);
for (i = 0; i < TSI721_DMA_MAXCH; i++) {
struct tsi721_bdma_chan *bdma_chan = &priv->bdma[i];
@@ -977,7 +975,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
bdma_chan->regs = priv->regs + TSI721_DMAC_BASE(i);
- bdma_chan->dchan.device = &mport->dma;
+ bdma_chan->dchan.device = &priv->dma;
bdma_chan->dchan.cookie = 1;
bdma_chan->dchan.chan_id = i;
bdma_chan->id = i;
@@ -992,40 +990,42 @@ int tsi721_register_dma(struct tsi721_device *priv)
tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet,
(unsigned long)bdma_chan);
list_add_tail(&bdma_chan->dchan.device_node,
- &mport->dma.channels);
+ &priv->dma.channels);
nr_channels++;
}
- mport->dma.chancnt = nr_channels;
- dma_cap_zero(mport->dma.cap_mask);
- dma_cap_set(DMA_PRIVATE, mport->dma.cap_mask);
- dma_cap_set(DMA_SLAVE, mport->dma.cap_mask);
+ priv->dma.chancnt = nr_channels;
+ dma_cap_zero(priv->dma.cap_mask);
+ dma_cap_set(DMA_PRIVATE, priv->dma.cap_mask);
+ dma_cap_set(DMA_SLAVE, priv->dma.cap_mask);
- mport->dma.dev = &priv->pdev->dev;
- mport->dma.device_alloc_chan_resources = tsi721_alloc_chan_resources;
- mport->dma.device_free_chan_resources = tsi721_free_chan_resources;
- mport->dma.device_tx_status = tsi721_tx_status;
- mport->dma.device_issue_pending = tsi721_issue_pending;
- mport->dma.device_prep_slave_sg = tsi721_prep_rio_sg;
- mport->dma.device_terminate_all = tsi721_terminate_all;
+ priv->dma.dev = &priv->pdev->dev;
+ priv->dma.device_alloc_chan_resources = tsi721_alloc_chan_resources;
+ priv->dma.device_free_chan_resources = tsi721_free_chan_resources;
+ priv->dma.device_tx_status = tsi721_tx_status;
+ priv->dma.device_issue_pending = tsi721_issue_pending;
+ priv->dma.device_prep_slave_sg = tsi721_prep_rio_sg;
+ priv->dma.device_terminate_all = tsi721_terminate_all;
- err = dma_async_device_register(&mport->dma);
+ err = dma_async_device_register(&priv->dma);
if (err)
tsi_err(&priv->pdev->dev, "Failed to register DMA device");
+ else
+ priv->mport.dma = &priv->dma;
return err;
}
void tsi721_unregister_dma(struct tsi721_device *priv)
{
- struct rio_mport *mport = &priv->mport;
struct dma_chan *chan, *_c;
struct tsi721_bdma_chan *bdma_chan;
tsi721_dma_stop_all(priv);
- dma_async_device_unregister(&mport->dma);
+ priv->mport.dma = NULL;
+ dma_async_device_unregister(&priv->dma);
- list_for_each_entry_safe(chan, _c, &mport->dma.channels,
+ list_for_each_entry_safe(chan, _c, &priv->dma.channels,
device_node) {
bdma_chan = to_tsi721_chan(chan);
if (bdma_chan->active) {
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 3ac83721c0e94..d2dbc9d94cc51 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -1754,7 +1754,7 @@ static bool rio_chan_filter(struct dma_chan *chan, void *arg)
struct rio_mport *mport = arg;
/* Check that DMA device belongs to the right MPORT */
- return mport == container_of(chan->device, struct rio_mport, dma);
+ return mport->dma == chan->device;
}
/**
diff --git a/include/linux/rio.h b/include/linux/rio.h
index f42379775ce8f..98ded5db5a2a1 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -257,7 +257,7 @@ struct rio_dbell {
* @name: Port name string
* @dev: device structure associated with an mport
* @priv: Master port private data
- * @dma: DMA device associated with mport
+ * @dma: DMA device pointer associated with mport
* @nscan: RapidIO network enumeration/discovery operations
* @state: mport device state
* @pwe_refcnt: port-write enable ref counter to track enable/disable requests
@@ -288,7 +288,7 @@ struct rio_mport {
struct device dev;
void *priv; /* Master port private data */
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
- struct dma_device dma;
+ struct dma_device *dma; /* associated DMA device, if any */
#endif
struct rio_scan *nscan;
atomic_t state;
@@ -513,10 +513,6 @@ struct rio_dma_data {
enum rio_write_type wr_type; /* preferred RIO write operation type */
};
-static inline struct rio_mport *dma_to_mport(struct dma_device *ddev)
-{
- return container_of(ddev, struct rio_mport, dma);
-}
#endif /* CONFIG_RAPIDIO_DMA_ENGINE */
/**
--
2.43.0