From: Samuel Holland <samuel.holland@sifive.com>
To: shravan chippa <shravan.chippa@microchip.com>,
green.wan@sifive.com, vkoul@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com,
paul.walmsley@sifive.com, conor+dt@kernel.org
Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
nagasuresh.relli@microchip.com, praveen.kumar@microchip.com
Subject: Re: [PATCH v2 1/4] dmaengine: sf-pdma: Support of_dma_controller_register()
Date: Tue, 17 Oct 2023 13:33:27 -0500 [thread overview]
Message-ID: <e5d2e96b-9b16-4aaf-9291-76d1d2222c44@sifive.com> (raw)
In-Reply-To: <20231003042215.142678-2-shravan.chippa@microchip.com>
Hi,
On 2023-10-02 11:22 PM, shravan chippa wrote:
> From: Shravan Chippa <shravan.chippa@microchip.com>
>
> Update sf-pdma driver to adopt generic DMA device tree bindings.
> It calls of_dma_controller_register() with sf-pdma specific
> of_dma_xlate to get the generic DMA device tree helper support
> and the DMA clients can look up the sf-pdma controller using
> standard APIs.
>
> Signed-off-by: Shravan Chippa <shravan.chippa@microchip.com>
> ---
> drivers/dma/sf-pdma/sf-pdma.c | 44 +++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/dma/sf-pdma/sf-pdma.c b/drivers/dma/sf-pdma/sf-pdma.c
> index d1c6956af452..06a0912a12a1 100644
> --- a/drivers/dma/sf-pdma/sf-pdma.c
> +++ b/drivers/dma/sf-pdma/sf-pdma.c
> @@ -20,6 +20,7 @@
> #include <linux/mod_devicetable.h>
> #include <linux/dma-mapping.h>
> #include <linux/of.h>
> +#include <linux/of_dma.h>
> #include <linux/slab.h>
>
> #include "sf-pdma.h"
> @@ -490,6 +491,33 @@ static void sf_pdma_setup_chans(struct sf_pdma *pdma)
> }
> }
>
> +static struct dma_chan *sf_pdma_of_xlate(struct of_phandle_args *dma_spec,
> + struct of_dma *ofdma)
> +{
> + struct sf_pdma *pdma = ofdma->of_dma_data;
> + struct device *dev = pdma->dma_dev.dev;
> + struct sf_pdma_chan *chan;
> + struct dma_chan *c;
> + u32 channel_id;
> +
> + if (dma_spec->args_count != 1) {
> + dev_err(dev, "Bad number of cells\n");
> + return NULL;
> + }
> +
> + channel_id = dma_spec->args[0];
> +
> + chan = &pdma->chans[channel_id];
> +
> + c = dma_get_slave_channel(&chan->vchan.chan);
This does not look right to me. All of the channels in the controller are
identical and support arbitrary addresses, so there is no need to use a specific
physical channel. And unless Microchip has added something on top, the only way
to trigger a transfer is through the MMIO interface, so there is no request ID
to differentiate virtual channels either.
So it seems to me that #dma-cells should really be 0, and this function should
just call dma_get_any_slave_channel().
Regards,
Samuel
> + if (!c) {
> + dev_err(dev, "No more channels available\n");
> + return NULL;
> + }
> +
> + return c;
> +}
> +
> static int sf_pdma_probe(struct platform_device *pdev)
> {
> struct sf_pdma *pdma;
> @@ -563,7 +591,20 @@ static int sf_pdma_probe(struct platform_device *pdev)
> return ret;
> }
>
> + ret = of_dma_controller_register(pdev->dev.of_node,
> + sf_pdma_of_xlate, pdma);
> + if (ret < 0) {
> + dev_err(&pdev->dev,
> + "Can't register SiFive Platform OF_DMA. (%d)\n", ret);
> + goto err_unregister;
> + }
> +
> return 0;
> +
> +err_unregister:
> + dma_async_device_unregister(&pdma->dma_dev);
> +
> + return ret;
> }
>
> static int sf_pdma_remove(struct platform_device *pdev)
> @@ -583,6 +624,9 @@ static int sf_pdma_remove(struct platform_device *pdev)
> tasklet_kill(&ch->err_tasklet);
> }
>
> + if (pdev->dev.of_node)
> + of_dma_controller_free(pdev->dev.of_node);
> +
> dma_async_device_unregister(&pdma->dma_dev);
>
> return 0;
next prev parent reply other threads:[~2023-10-17 18:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 4:22 [PATCH v2 0/4] dma: sf-pdma: various sf-pdma updates for the mpfs platform shravan chippa
2023-10-03 4:22 ` [PATCH v2 1/4] dmaengine: sf-pdma: Support of_dma_controller_register() shravan chippa
2023-10-03 7:36 ` Emil Renner Berthing
2023-10-17 18:33 ` Samuel Holland [this message]
2023-10-18 9:16 ` Shravan.Chippa
2023-10-03 4:22 ` [PATCH v2 2/4] dt-bindings: dma: sf-pdma: add new compatible name shravan chippa
2023-10-04 13:30 ` Rob Herring
2023-10-05 10:54 ` Conor Dooley
2023-10-12 9:22 ` Shravan.Chippa
2023-10-12 9:35 ` Conor Dooley
2023-10-17 17:42 ` Samuel Holland
2023-10-03 4:22 ` [PATCH v2 3/4] dmaengine: sf-pdma: add mpfs-pdma " shravan chippa
2023-10-03 7:35 ` Emil Renner Berthing
2023-10-04 3:47 ` Shravan.Chippa
2023-10-04 13:22 ` Rob Herring
2023-10-03 4:22 ` [PATCH v2 4/4] riscv: dts: microchip: add specific compatible for mpfs' pdma shravan chippa
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=e5d2e96b-9b16-4aaf-9291-76d1d2222c44@sifive.com \
--to=samuel.holland@sifive.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=green.wan@sifive.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=nagasuresh.relli@microchip.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=praveen.kumar@microchip.com \
--cc=robh+dt@kernel.org \
--cc=shravan.chippa@microchip.com \
--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