DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: imx@lists.linux.dev, dmaengine@vger.kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v4 6/7] dmaengine: fsl-edma: support per-channel DT child nodes
Date: Tue, 03 Nov 2026 15:34:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-195623@kernel.org> (raw)
In-Reply-To: <20261103-edma-iommu-v3-v4-6-470415d418c5@Example.Com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dmaengine: fsl-edma: 64-bit modulo in fsl_edma_child_to_chan_id()
--

commit 76cf0654e1725c0e3aaa1017f35c2a7303b2f234
Author: Peng Fan <peng.fan@nxp.com>

dmaengine: fsl-edma: support per-channel DT child nodes

This commit adds support for parsing per-channel devicetree child nodes in
the fsl-edma driver to configure per-channel interrupts and IOMMU mappings.
It introduces helpers to derive the channel index from the child MMIO
address, obtain child interrupts before IRQ setup, and configure per-channel
IOMMUs after device registration.

> diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
> index 30d548a723462..8691676b3b692 100644
> --- a/drivers/dma/fsl-edma-main.c
> +++ b/drivers/dma/fsl-edma-main.c

[ ... ]

> @@ -703,6 +720,184 @@ static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_eng
>  	return -EINVAL;
>  }
>  
> +static int fsl_edma_child_to_chan_id(struct fsl_edma_engine *fsl_edma,
> +				     struct device_node *child,
> +				     struct resource *parent_res)
> +{
> +	const struct fsl_edma_drvdata *drvdata = fsl_edma->drvdata;
> +	struct resource child_res;
> +	u64 offset, ch_id;
> +	int ret;
> +
> +	ret = of_address_to_resource(child, 0, &child_res);
> +	if (ret)
> +		return ret;
> +
> +	if (!resource_contains(parent_res, &child_res))
> +		return -EINVAL;
> +
> +	if (child_res.start < parent_res->start + drvdata->chreg_off)
> +		return -EINVAL;
> +
> +	offset = child_res.start - parent_res->start - drvdata->chreg_off;
> +	if (offset % drvdata->chreg_space_sz)
> +		return -EINVAL;
> +
> +	ch_id = div_u64(offset, drvdata->chreg_space_sz);

[Severity: Medium]
As reported by kernel test robot on v3 [1], in fsl_edma_child_to_chan_id() in
drivers/dma/fsl-edma-main.c, offset is a u64 and drvdata->chreg_space_sz is a
u32. While the division uses div_u64(), evaluating offset %
drvdata->chreg_space_sz directly above it promotes drvdata->chreg_space_sz to
u64 and emits a 64-bit modulo library call (__umoddi3 or __aeabi_uldivmod),
which fails to link on 32-bit architectures when CONFIG_FSL_EDMA is enabled.

Could this use div_u64_rem(offset, drvdata->chreg_space_sz, &rem) to compute
both the alignment remainder and the channel ID quotient in a single step?

[1] https://lore.kernel.org/r/202611031650.EONIRpF4-lkp@intel.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-edma-iommu-v3-v4-0-470415d418c5@Example.Com?part=6

  reply	other threads:[~2026-11-03 15:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 15:18 [PATCH v4 0/7] dmaengine: add DMA channel bus and fsl-edma per-channel IOMMU support Peng Fan (OSS)
2026-11-03 15:18 ` [PATCH v4 1/7] dmaengine: fsl-edma: unregister channels before vchan cleanup Peng Fan (OSS)
2026-11-03 15:18 ` [PATCH v4 2/7] dmaengine: add a bus for DMA channel devices Peng Fan (OSS)
2026-11-03 15:30   ` sashiko-bot
2026-11-03 15:19 ` [PATCH v4 3/7] iommu: register the DMA channel bus for IOMMU notifications Peng Fan (OSS)
2026-11-03 15:19 ` [PATCH v4 4/7] dmaengine: move channel devices to the DMA channel bus Peng Fan (OSS)
2026-11-03 15:19 ` [PATCH v4 5/7] dt-bindings: dma: fsl,edma: add per-channel child node support Peng Fan (OSS)
2026-11-03 15:19 ` [PATCH v4 6/7] dmaengine: fsl-edma: support per-channel DT child nodes Peng Fan (OSS)
2026-11-03 15:34   ` sashiko-bot [this message]
2026-11-03 15:19 ` [PATCH v4 7/7] arm64: dts: imx95: convert eDMA to per-channel " Peng Fan (OSS)

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=sashiko-outbox-195623@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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