From: Frank Li <Frank.li@nxp.com>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: Vinod Koul <vkoul@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Jiada Wang <jiada_wang@mentor.com>,
dmaengine@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 02/10] dmaengine: imx-sdma: fix spba-bus handling for i.MX8M
Date: Fri, 12 Sep 2025 12:57:52 -0400 [thread overview]
Message-ID: <aMRRECxBqzRqGYwf@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250912152748.gn66fmmrqyqlqdrb@pengutronix.de>
On Fri, Sep 12, 2025 at 05:27:48PM +0200, Marco Felsch wrote:
> On 25-09-12, Frank Li wrote:
> > On Thu, Sep 11, 2025 at 11:56:43PM +0200, Marco Felsch wrote:
> > > Starting with i.MX8M* devices there are multiple spba-busses so we can't
> > > just search the whole DT for the first spba-bus match and take it.
> > > Instead we need to check for each device to which bus it belongs and
> > > setup the spba_{start,end}_addr accordingly per sdma_channel.
> > >
> > > While on it, don't ignore errors from of_address_to_resource() if they
> > > are valid.
> > >
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> >
> > I think the below method should be better.
> >
> > of_translate_address(per_address) == OF_BAD_ADDR to check if belong spba-bus
>
> The SDMA engine doesn't have to be part of the SPBA bus, please see the
> i.MX8MM for example.
which one, can you point me?
spba_bus = of_get_parent(chan->slave->of_node);
Actaully you get dma consumers' spba-bus, not dmaengine one.
And I also confused
+ if (sdmac->per_address2 >= sdmac->spba_start_addr &&
+ sdmac->per_address2 <= sdmac->spba_end_addr)
sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_SP;
- if (sdmac->per_address >= sdma->spba_start_addr &&
- sdmac->per_address <= sdma->spba_end_addr)
+ if (sdmac->per_address >= sdmac->spba_start_addr &&
+ sdmac->per_address <= sdmac->spba_end_addr)
sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_DP;
what's purpsoe of this code, check if dma target address in spba_bus ?
And only here use spba_start_addr!
Frank
>
> Regards,
> Marco
>
> > aips3: bus@30800000 {
> > ...
> > ranges = <0x30800000 0x30800000 0x400000>,
> > <0x8000000 0x8000000 0x10000000>;
> >
> > spba1: spba-bus@30800000 {
> > compatible = "fsl,spba-bus", "simple-bus";
> > #address-cells = <1>;
> > #size-cells = <1>;
> > reg = <0x30800000 0x100000>;
> > ranges;
> >
> > ...
> > sdma1:
> >
> > };
> >
> > of_translate_address() will 1:1 map at spba-bus@30800000 spba1.
> > then
> > reach ranges = <0x30800000 0x30800000 0x400000> of aips3
> >
> > if per_address is not in this range, it should return OF_BAD_ADDR. So
> > needn't parse reg of bus@30800000 at all.
> >
> > Frank
> >
> > > ---
> > > drivers/dma/imx-sdma.c | 58 ++++++++++++++++++++++++++++++++++----------------
> > > 1 file changed, 40 insertions(+), 18 deletions(-)
> > >
> > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> > > index 3ecb917214b1268b148a29df697b780bc462afa4..56daaeb7df03986850c9c74273d0816700581dc0 100644
> > > --- a/drivers/dma/imx-sdma.c
> > > +++ b/drivers/dma/imx-sdma.c
> > > @@ -429,6 +429,8 @@ struct sdma_desc {
> > > * @event_mask: event mask used in p_2_p script
> > > * @watermark_level: value for gReg[7], some script will extend it from
> > > * basic watermark such as p_2_p
> > > + * @spba_start_addr: SDMA controller SPBA bus start address
> > > + * @spba_end_addr: SDMA controller SPBA bus end address
> > > * @shp_addr: value for gReg[6]
> > > * @per_addr: value for gReg[2]
> > > * @status: status of dma channel
> > > @@ -461,6 +463,8 @@ struct sdma_channel {
> > > dma_addr_t per_address, per_address2;
> > > unsigned long event_mask[2];
> > > unsigned long watermark_level;
> > > + u32 spba_start_addr;
> > > + u32 spba_end_addr;
> > > u32 shp_addr, per_addr;
> > > enum dma_status status;
> > > struct imx_dma_data data;
> > > @@ -534,8 +538,6 @@ struct sdma_engine {
> > > u32 script_number;
> > > struct sdma_script_start_addrs *script_addrs;
> > > const struct sdma_driver_data *drvdata;
> > > - u32 spba_start_addr;
> > > - u32 spba_end_addr;
> > > unsigned int irq;
> > > dma_addr_t bd0_phys;
> > > struct sdma_buffer_descriptor *bd0;
> > > @@ -1236,8 +1238,6 @@ static void sdma_channel_synchronize(struct dma_chan *chan)
> > >
> > > static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
> > > {
> > > - struct sdma_engine *sdma = sdmac->sdma;
> > > -
> > > int lwml = sdmac->watermark_level & SDMA_WATERMARK_LEVEL_LWML;
> > > int hwml = (sdmac->watermark_level & SDMA_WATERMARK_LEVEL_HWML) >> 16;
> > >
> > > @@ -1263,12 +1263,12 @@ static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
> > > swap(sdmac->event_mask[0], sdmac->event_mask[1]);
> > > }
> > >
> > > - if (sdmac->per_address2 >= sdma->spba_start_addr &&
> > > - sdmac->per_address2 <= sdma->spba_end_addr)
> > > + if (sdmac->per_address2 >= sdmac->spba_start_addr &&
> > > + sdmac->per_address2 <= sdmac->spba_end_addr)
> > > sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_SP;
> > >
> > > - if (sdmac->per_address >= sdma->spba_start_addr &&
> > > - sdmac->per_address <= sdma->spba_end_addr)
> > > + if (sdmac->per_address >= sdmac->spba_start_addr &&
> > > + sdmac->per_address <= sdmac->spba_end_addr)
> > > sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_DP;
> > >
> > > sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_CONT;
> > > @@ -1447,6 +1447,31 @@ static void sdma_desc_free(struct virt_dma_desc *vd)
> > > kfree(desc);
> > > }
> > >
> > > +static int sdma_config_spba_slave(struct dma_chan *chan)
> > > +{
> > > + struct sdma_channel *sdmac = to_sdma_chan(chan);
> > > + struct device_node *spba_bus;
> > > + struct resource spba_res;
> > > + int ret;
> > > +
> > > + spba_bus = of_get_parent(chan->slave->of_node);
> > > + /* Device doesn't belong to the spba-bus */
> > > + if (!of_device_is_compatible(spba_bus, "fsl,spba-bus"))
> > > + return 0;
> > > +
> > > + ret = of_address_to_resource(spba_bus, 0, &spba_res);
> > > + of_node_put(spba_bus);
> > > + if (ret) {
> > > + dev_err(sdmac->sdma->dev, "Failed to get spba-bus resources\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + sdmac->spba_start_addr = spba_res.start;
> > > + sdmac->spba_end_addr = spba_res.end;
> > > +
> > > + return 0;
> > > +}
> > > +
> > > static int sdma_alloc_chan_resources(struct dma_chan *chan)
> > > {
> > > struct sdma_channel *sdmac = to_sdma_chan(chan);
> > > @@ -1527,6 +1552,8 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
> > >
> > > sdmac->event_id0 = 0;
> > > sdmac->event_id1 = 0;
> > > + sdmac->spba_start_addr = 0;
> > > + sdmac->spba_end_addr = 0;
> > >
> > > sdma_set_channel_priority(sdmac, 0);
> > >
> > > @@ -1837,6 +1864,7 @@ static int sdma_config(struct dma_chan *chan,
> > > {
> > > struct sdma_channel *sdmac = to_sdma_chan(chan);
> > > struct sdma_engine *sdma = sdmac->sdma;
> > > + int ret;
> > >
> > > memcpy(&sdmac->slave_config, dmaengine_cfg, sizeof(*dmaengine_cfg));
> > >
> > > @@ -1867,6 +1895,10 @@ static int sdma_config(struct dma_chan *chan,
> > > sdma_event_enable(sdmac, sdmac->event_id1);
> > > }
> > >
> > > + ret = sdma_config_spba_slave(chan);
> > > + if (ret)
> > > + return ret;
> > > +
> > > return 0;
> > > }
> > >
> > > @@ -2235,11 +2267,9 @@ static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec,
> > > static int sdma_probe(struct platform_device *pdev)
> > > {
> > > struct device_node *np = pdev->dev.of_node;
> > > - struct device_node *spba_bus;
> > > const char *fw_name;
> > > int ret;
> > > int irq;
> > > - struct resource spba_res;
> > > int i;
> > > struct sdma_engine *sdma;
> > > s32 *saddr_arr;
> > > @@ -2375,14 +2405,6 @@ static int sdma_probe(struct platform_device *pdev)
> > > dev_err(&pdev->dev, "failed to register controller\n");
> > > goto err_register;
> > > }
> > > -
> > > - spba_bus = of_find_compatible_node(NULL, NULL, "fsl,spba-bus");
> > > - ret = of_address_to_resource(spba_bus, 0, &spba_res);
> > > - if (!ret) {
> > > - sdma->spba_start_addr = spba_res.start;
> > > - sdma->spba_end_addr = spba_res.end;
> > > - }
> > > - of_node_put(spba_bus);
> > > }
> > >
> > > /*
> > >
> > > --
> > > 2.47.3
> > >
> >
next prev parent reply other threads:[~2025-09-12 16:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 21:56 [PATCH v2 00/10] i.MX SDMA cleanups and fixes Marco Felsch
2025-09-11 21:56 ` [PATCH v2 01/10] dmaengine: imx-sdma: fix missing of_dma_controller_free() Marco Felsch
2025-09-12 2:59 ` Peng Fan
2025-09-12 14:39 ` Frank Li
2025-09-11 21:56 ` [PATCH v2 02/10] dmaengine: imx-sdma: fix spba-bus handling for i.MX8M Marco Felsch
2025-09-12 3:02 ` Peng Fan
2025-09-12 8:48 ` Marco Felsch
2025-09-12 15:18 ` Frank Li
2025-09-12 15:27 ` Marco Felsch
2025-09-12 16:57 ` Frank Li [this message]
2025-10-01 10:31 ` Marco Felsch
2025-09-16 2:01 ` Peng Fan
2026-04-02 3:33 ` Shengjiu Wang
2025-09-11 21:56 ` [PATCH v2 03/10] dmaengine: imx-sdma: drop legacy device_node np check Marco Felsch
2025-09-12 3:04 ` Peng Fan
2025-09-11 21:56 ` [PATCH v2 04/10] dmaengine: imx-sdma: sdma_remove minor cleanups Marco Felsch
2025-09-12 3:06 ` Peng Fan
2025-09-11 21:56 ` [PATCH v2 05/10] dmaengine: imx-sdma: cosmetic cleanup Marco Felsch
2025-09-12 3:09 ` Peng Fan
2025-09-11 21:56 ` [PATCH v2 06/10] dmaengine: imx-sdma: make use of devm_kzalloc for script_addrs Marco Felsch
2025-09-12 4:00 ` Peng Fan
2025-09-11 21:56 ` [PATCH v2 07/10] dmaengine: imx-sdma: make use of devm_clk_get_prepared() Marco Felsch
2025-09-12 4:02 ` Peng Fan
2025-09-11 21:56 ` [PATCH v2 08/10] dmaengine: imx-sdma: make use of devm_add_action_or_reset to unregiser the dma_device Marco Felsch
2025-09-12 4:02 ` Peng Fan
2025-09-12 14:49 ` Frank Li
2025-09-12 15:25 ` Marco Felsch
2025-09-12 16:37 ` Frank Li
2025-09-12 16:49 ` Marco Felsch
2025-09-11 21:56 ` [PATCH v2 09/10] dmaengine: imx-sdma: make use of devm_add_action_or_reset to unregiser the dma-controller Marco Felsch
2025-09-12 4:06 ` Peng Fan
2025-09-12 14:50 ` Frank Li
2025-09-12 15:28 ` Marco Felsch
2025-09-12 16:39 ` Frank Li
2025-09-11 21:56 ` [PATCH v2 10/10] dmaengine: imx-sdma: make use of dev_err_probe() Marco Felsch
2025-09-12 4:07 ` Peng Fan
2026-02-25 15:59 ` [PATCH v2 00/10] i.MX SDMA cleanups and fixes Frank Li
2026-02-25 17:05 ` Marco Felsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aMRRECxBqzRqGYwf@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=dmaengine@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jiada_wang@mentor.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox