* [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree
@ 2025-12-03 12:11 Robert Marko
2025-12-16 15:18 ` Vinod Koul
2026-01-01 17:41 ` Vinod Koul
0 siblings, 2 replies; 4+ messages in thread
From: Robert Marko @ 2025-12-03 12:11 UTC (permalink / raw)
To: ludovic.desroches, vkoul, linux-arm-kernel, dmaengine,
linux-kernel, daniel.machon
Cc: luka.perkov, Tony Han, Robert Marko
From: Tony Han <tony.han@microchip.com>
In case of kernel runs in non-secure mode, the number of DMA channels can
be got from device tree since the value read from GTYPE register is "0" as
it's always secured.
As the number of channels can never be negative, update them to the type
"unsigned".
This is required for LAN969x.
Signed-off-by: Tony Han <tony.han@microchip.com>
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
drivers/dma/at_xdmac.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 3fbc74710a13..acabf82e293c 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -2257,12 +2257,29 @@ static int __maybe_unused atmel_xdmac_runtime_resume(struct device *dev)
return clk_enable(atxdmac->clk);
}
+static inline int at_xdmac_get_channel_number(struct platform_device *pdev,
+ u32 reg, u32 *pchannels)
+{
+ int ret;
+
+ if (reg) {
+ *pchannels = AT_XDMAC_NB_CH(reg);
+ return 0;
+ }
+
+ ret = of_property_read_u32(pdev->dev.of_node, "dma-channels", pchannels);
+ if (ret)
+ dev_err(&pdev->dev, "can't get number of channels\n");
+
+ return ret;
+}
+
static int at_xdmac_probe(struct platform_device *pdev)
{
struct at_xdmac *atxdmac;
- int irq, nr_channels, i, ret;
+ int irq, ret;
void __iomem *base;
- u32 reg;
+ u32 nr_channels, i, reg;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
@@ -2278,7 +2295,10 @@ static int at_xdmac_probe(struct platform_device *pdev)
* of channels to do the allocation.
*/
reg = readl_relaxed(base + AT_XDMAC_GTYPE);
- nr_channels = AT_XDMAC_NB_CH(reg);
+ ret = at_xdmac_get_channel_number(pdev, reg, &nr_channels);
+ if (ret)
+ return ret;
+
if (nr_channels > AT_XDMAC_MAX_CHAN) {
dev_err(&pdev->dev, "invalid number of channels (%u)\n",
nr_channels);
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree
2025-12-03 12:11 [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree Robert Marko
@ 2025-12-16 15:18 ` Vinod Koul
2025-12-30 13:19 ` Robert Marko
2026-01-01 17:41 ` Vinod Koul
1 sibling, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2025-12-16 15:18 UTC (permalink / raw)
To: Robert Marko
Cc: ludovic.desroches, linux-arm-kernel, dmaengine, linux-kernel,
daniel.machon, luka.perkov, Tony Han
On 03-12-25, 13:11, Robert Marko wrote:
> From: Tony Han <tony.han@microchip.com>
>
> In case of kernel runs in non-secure mode, the number of DMA channels can
> be got from device tree since the value read from GTYPE register is "0" as
> it's always secured.
>
> As the number of channels can never be negative, update them to the type
> "unsigned".
>
> This is required for LAN969x.
You updated the changelog, but tagged it as resend. It should be v2!
>
> Signed-off-by: Tony Han <tony.han@microchip.com>
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
> ---
> drivers/dma/at_xdmac.c | 26 +++++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 3fbc74710a13..acabf82e293c 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -2257,12 +2257,29 @@ static int __maybe_unused atmel_xdmac_runtime_resume(struct device *dev)
> return clk_enable(atxdmac->clk);
> }
>
> +static inline int at_xdmac_get_channel_number(struct platform_device *pdev,
> + u32 reg, u32 *pchannels)
> +{
> + int ret;
> +
> + if (reg) {
> + *pchannels = AT_XDMAC_NB_CH(reg);
> + return 0;
> + }
> +
> + ret = of_property_read_u32(pdev->dev.of_node, "dma-channels", pchannels);
> + if (ret)
> + dev_err(&pdev->dev, "can't get number of channels\n");
Do we need to log error, I thought the API did that...
> +
> + return ret;
> +}
> +
> static int at_xdmac_probe(struct platform_device *pdev)
> {
> struct at_xdmac *atxdmac;
> - int irq, nr_channels, i, ret;
> + int irq, ret;
> void __iomem *base;
> - u32 reg;
> + u32 nr_channels, i, reg;
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0)
> @@ -2278,7 +2295,10 @@ static int at_xdmac_probe(struct platform_device *pdev)
> * of channels to do the allocation.
> */
> reg = readl_relaxed(base + AT_XDMAC_GTYPE);
> - nr_channels = AT_XDMAC_NB_CH(reg);
> + ret = at_xdmac_get_channel_number(pdev, reg, &nr_channels);
> + if (ret)
> + return ret;
> +
> if (nr_channels > AT_XDMAC_MAX_CHAN) {
> dev_err(&pdev->dev, "invalid number of channels (%u)\n",
> nr_channels);
> --
> 2.52.0
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree
2025-12-16 15:18 ` Vinod Koul
@ 2025-12-30 13:19 ` Robert Marko
0 siblings, 0 replies; 4+ messages in thread
From: Robert Marko @ 2025-12-30 13:19 UTC (permalink / raw)
To: Vinod Koul
Cc: ludovic.desroches, linux-arm-kernel, dmaengine, linux-kernel,
daniel.machon, luka.perkov, Tony Han
On Tue, Dec 16, 2025 at 4:18 PM Vinod Koul <vkoul@kernel.org> wrote:
>
> On 03-12-25, 13:11, Robert Marko wrote:
> > From: Tony Han <tony.han@microchip.com>
> >
> > In case of kernel runs in non-secure mode, the number of DMA channels can
> > be got from device tree since the value read from GTYPE register is "0" as
> > it's always secured.
> >
> > As the number of channels can never be negative, update them to the type
> > "unsigned".
> >
> > This is required for LAN969x.
>
> You updated the changelog, but tagged it as resend. It should be v2!
Hi,
Sorry for this, I sent the wrong patch and though quickly resending
the right one would be better.
>
> >
> > Signed-off-by: Tony Han <tony.han@microchip.com>
> > Signed-off-by: Robert Marko <robert.marko@sartura.hr>
> > ---
> > drivers/dma/at_xdmac.c | 26 +++++++++++++++++++++++---
> > 1 file changed, 23 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> > index 3fbc74710a13..acabf82e293c 100644
> > --- a/drivers/dma/at_xdmac.c
> > +++ b/drivers/dma/at_xdmac.c
> > @@ -2257,12 +2257,29 @@ static int __maybe_unused atmel_xdmac_runtime_resume(struct device *dev)
> > return clk_enable(atxdmac->clk);
> > }
> >
> > +static inline int at_xdmac_get_channel_number(struct platform_device *pdev,
> > + u32 reg, u32 *pchannels)
> > +{
> > + int ret;
> > +
> > + if (reg) {
> > + *pchannels = AT_XDMAC_NB_CH(reg);
> > + return 0;
> > + }
> > +
> > + ret = of_property_read_u32(pdev->dev.of_node, "dma-channels", pchannels);
> > + if (ret)
> > + dev_err(&pdev->dev, "can't get number of channels\n");
>
> Do we need to log error, I thought the API did that...
I dont think API helps here, we would just be left with the error
code, which can be hard
to trace back but I am flexible.
Regards,
Robert
>
> > +
> > + return ret;
> > +}
> > +
> > static int at_xdmac_probe(struct platform_device *pdev)
> > {
> > struct at_xdmac *atxdmac;
> > - int irq, nr_channels, i, ret;
> > + int irq, ret;
> > void __iomem *base;
> > - u32 reg;
> > + u32 nr_channels, i, reg;
> >
> > irq = platform_get_irq(pdev, 0);
> > if (irq < 0)
> > @@ -2278,7 +2295,10 @@ static int at_xdmac_probe(struct platform_device *pdev)
> > * of channels to do the allocation.
> > */
> > reg = readl_relaxed(base + AT_XDMAC_GTYPE);
> > - nr_channels = AT_XDMAC_NB_CH(reg);
> > + ret = at_xdmac_get_channel_number(pdev, reg, &nr_channels);
> > + if (ret)
> > + return ret;
> > +
> > if (nr_channels > AT_XDMAC_MAX_CHAN) {
> > dev_err(&pdev->dev, "invalid number of channels (%u)\n",
> > nr_channels);
> > --
> > 2.52.0
>
> --
> ~Vinod
--
Robert Marko
Staff Embedded Linux Engineer
Sartura d.d.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: robert.marko@sartura.hr
Web: www.sartura.hr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree
2025-12-03 12:11 [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree Robert Marko
2025-12-16 15:18 ` Vinod Koul
@ 2026-01-01 17:41 ` Vinod Koul
1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2026-01-01 17:41 UTC (permalink / raw)
To: ludovic.desroches, linux-arm-kernel, dmaengine, linux-kernel,
daniel.machon, Robert Marko
Cc: luka.perkov, Tony Han
On Wed, 03 Dec 2025 13:11:43 +0100, Robert Marko wrote:
> In case of kernel runs in non-secure mode, the number of DMA channels can
> be got from device tree since the value read from GTYPE register is "0" as
> it's always secured.
>
> As the number of channels can never be negative, update them to the type
> "unsigned".
>
> [...]
Applied, thanks!
[1/1] dmaengine: at_xdmac: get the number of DMA channels from device tree
commit: d3824968dbd9056844bbd5041020a3e28c748558
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-01 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 12:11 [PATCH RESEND] dmaengine: at_xdmac: get the number of DMA channels from device tree Robert Marko
2025-12-16 15:18 ` Vinod Koul
2025-12-30 13:19 ` Robert Marko
2026-01-01 17:41 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).