DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Zhou" <zhoubinbin@loongson.cn>
Cc: vkoul@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org, Frank.Li@kernel.org,
	dmaengine@vger.kernel.org
Subject: Re: [PATCH 1/3] dt-bindings: dma: loongson: Add Loongson-2 DMA mux request IDs
Date: Tue, 22 Sep 2026 09:34:01 +0000	[thread overview]
Message-ID: <20260922093402.6C62C1F00893@smtp.kernel.org> (raw)
In-Reply-To: <d8762c697fee7c2184f26968109162d59aef1514.1790068409.git.zhoubinbin@loongson.cn>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dma: loongson: hardcoding physical DMA channel in device tree
- [Low] dma: loongson: expose LS2K0300_DMA_REQ_MAX in binding header
--

commit e4e9feb04bfe5cf0cae531423dc7021c3d20e99c
Author: Binbin Zhou <zhoubinbin@loongson.cn>

dt-bindings: dma: loongson: Add Loongson-2 DMA mux request IDs

Add DT binding constants for the Loongson-2 DMA mux. It covers UART,
I2C, SPI, I2S, ADC, and CAN peripherals for Loongson-2K0300. It also
documents channel-pair semantics for peripherals using paired channels.

> diff --git a/include/dt-bindings/dma/loongson,ls2k-dmamux.h b/include/dt-bindings/dma/loongson,ls2k-dmamux.h
> new file mode 100644
> index 0000000000000..dcc8df86befbb
> --- /dev/null
> +++ b/include/dt-bindings/dma/loongson,ls2k-dmamux.h
> @@ -0,0 +1,56 @@
> +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
> +/*
> + * Loongson-2 SoC DMA Mux dt-bindings
> + *
> + * DMA specifier format:
> + *   dmas = <&dma_mux <request> <channel> <flags>>;
> + *
> + * The <channel> cell selects a physical CMC DMA channel (0-7)

[Severity: Medium]
Does this design hardcode software resource allocation policy into the hardware
description?

Device trees should describe immutable hardware wiring rather than software
policy. Since the Loongson DMA mux is flexible (e.g., UART0 can be mapped to
one of 4 channel pairs via a 2-bit register field), shouldn't the OS DMA
engine dynamically allocate an available channel from a pool and program the
mux accordingly?

Statically assigning the channel in the DT shifts this policy to the hardware
description, preventing dynamic allocation and risking runtime resource
conflicts if multiple peripherals concurrently request the same statically
assigned channel.

> + * For peripherals using channel pairs (UART, I2C, SPI2/3, I2S),
> + * the channel number selects the pair: 0/1 -> pair 0, 2/3 -> pair 1,
> + * 4/5 -> pair 2, 6/7 -> pair 3.
> + *
> + * Copyright (C) 2026 Loongson Technology Corporation Limited
> + */

[ ... ]

> +/* CAN-FD controllers */
> +#define LS2K0300_DMA_CAN0		18
> +#define LS2K0300_DMA_CAN1		19
> +#define LS2K0300_DMA_CAN2		20
> +#define LS2K0300_DMA_CAN3		21
> +
> +/* Total number of 2K0300 DMA requests */
> +#define LS2K0300_DMA_REQ_MAX		22

[Severity: Low]
Is it safe to expose LS2K0300_DMA_REQ_MAX in a device tree binding header?

Device tree binding headers define the stable ABI between the hardware
description and the operating system. Exposing a _MAX macro is a known DT
anti-pattern.

If future hardware revisions or bindings add new request IDs, updating the _MAX
macro breaks backward compatibility with older compiled device trees or drivers
that rely on the previous value, potentially leading to out-of-bounds accesses
or ABI mismatches.

Should this macro be removed from the ABI header to prevent misuse?

> +
> +#endif /* _DT_BINDINGS_DMA_LOONGSON_LS2K_DMAMUX_H */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790068409.git.zhoubinbin@loongson.cn?part=1

  reply	other threads:[~2026-09-22  9:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  9:25 [PATCH 0/3] Add Loongson-2K0300 APB DMA mux support Binbin Zhou
2026-09-22  9:25 ` [PATCH 1/3] dt-bindings: dma: loongson: Add Loongson-2 DMA mux request IDs Binbin Zhou
2026-09-22  9:34   ` sashiko-bot [this message]
2026-09-30 21:52   ` Frank Li
2026-09-22  9:25 ` [PATCH 2/3] dt-bindings: dma: loongson: Add Loongson-2K0300 DMA mux support Binbin Zhou
2026-09-30 21:44   ` Frank Li
2026-10-02 14:00     ` Binbin Zhou
2026-10-02 14:47       ` Frank Li
2026-10-04  6:27         ` Binbin Zhou
2026-09-22  9:25 ` [PATCH 3/3] dmaengine: loongson: Add Loongson-2K0300 APB DMA mux driver Binbin Zhou
2026-09-22  9:36   ` sashiko-bot
2026-09-23  4:17   ` Huacai Chen
2026-09-30 21:56   ` Frank Li
2026-09-22 16:45 ` [PATCH 0/3] Add Loongson-2K0300 APB DMA mux support Frank Li
2026-09-23  5:53   ` Binbin Zhou

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=20260922093402.6C62C1F00893@smtp.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=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=zhoubinbin@loongson.cn \
    /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