Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Frank.Li@oss.nxp.com
Cc: "Jacky Huang" <ychuang3@nuvoton.com>,
	"Shan-Chun Hung" <schung@nuvoton.com>,
	"Vinod Koul" <vkoul@kernel.org>, "Frank Li" <Frank.Li@kernel.org>,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Eugeniy Paltsev" <Eugeniy.Paltsev@synopsys.com>,
	"Binbin Zhou" <zhoubinbin@loongson.cn>,
	"Patrice Chotard" <patrice.chotard@foss.st.com>,
	"Amélie Delaunay" <amelie.delaunay@foss.st.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Thierry Reding" <thierry.reding@kernel.org>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Ludovic Desroches" <ludovic.desroches@microchip.com>,
	"Viresh Kumar" <vireshk@kernel.org>,
	"Keguang Zhang" <keguang.zhang@gmail.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Daniel Mack" <daniel@zonque.org>,
	"Haojian Zhuang" <haojian.zhuang@gmail.com>,
	"Robert Jarzmik" <robert.jarzmik@free.fr>,
	"Chen-Yu Tsai" <wens@kernel.org>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Samuel Holland" <samuel@sholland.org>,
	"Kelvin Cao" <kelvin.cao@microchip.com>,
	"Logan Gunthorpe" <logang@deltatee.com>,
	"Laxman Dewangan" <ldewangan@nvidia.com>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-trace-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-actions@lists.infradead.org, linux-sunxi@lists.linux.dev,
	imx@lists.linux.dev, "Frank Li" <Frank.Li@nxp.com>
Subject: Re: [PATCH v2 3/3] dmaengine: add union chan_dev for dma_chan::dev for clarity
Date: Fri, 4 Sep 2026 12:19:08 +0300	[thread overview]
Message-ID: <apqNDHoNt09QYJe7@ashevche-desk.local> (raw)
In-Reply-To: <20260903-dma-chan_dev-rename-v2-3-0db305b6c716@nxp.com>

On Thu, Sep 03, 2026 at 04:53:13PM -0400, Frank.Li@oss.nxp.com wrote:

> The current dma_chan structure contains both "device" and "dev". So
> 
> chan->device->dev refers to the DMA engine device.
> chan->dev->device refers to the per-channel device instance.
> 
> Their similar naming makes the distinction unclear and increases reader
> confusion.
> 
> Add union dma_chan::chan_dev to make its purpose explicit and clearly
> identify it as the per-channel device. After all user switch to chan_dev,
> union and dma_chan::dev will be removed.
> 
> Update the kernel-doc accordingly. Besides its sysfs usage, the per-channel
> device is also used by some DMA engine drivers for IOMMU mapping and
> therefore deserves a more accurate description.
> 
> No functional change intended.

...

>  static inline struct device *chan2dev(struct axi_dma_chan *chan)
>  {
> -	return &chan->vc.chan.dev->device;
> +	return &chan->vc.chan.chan_dev->device;
>  }

Looking at this and below I think we need a common helper(s)

>  static struct device *chan2dev(struct loongson2_cmc_dma_chan *lchan)
>  {
> -	return &lchan->vchan.chan.dev->device;
> +	return &lchan->vchan.chan.chan_dev->device;
>  }

>  	({								\
>  		u32 _v;							\
>  		_v = readl_relaxed((phy)->base + _reg((phy)->idx));	\
> -		dev_vdbg(&phy->vchan->vc.chan.dev->device,		\
> +		dev_vdbg(&phy->vchan->vc.chan.chan_dev->device,		\
>  			 "%s(): readl(%s): 0x%08x\n", __func__, #_reg,	\
>  			  _v);						\
>  		_v;							\

>  #define phy_writel(phy, val, _reg)					\
>  	do {								\
>  		writel((val), (phy)->base + _reg((phy)->idx));		\
> -		dev_vdbg(&phy->vchan->vc.chan.dev->device,		\
> +		dev_vdbg(&phy->vchan->vc.chan.chan_dev->device,		\
>  			 "%s(): writel(0x%08x, %s)\n",			\
>  			 __func__, (u32)(val), #_reg);			\
>  	} while (0)
>  #define phy_writel_relaxed(phy, val, _reg)				\
>  	do {								\
>  		writel_relaxed((val), (phy)->base + _reg((phy)->idx));	\
> -		dev_vdbg(&phy->vchan->vc.chan.dev->device,		\
> +		dev_vdbg(&phy->vchan->vc.chan.chan_dev->device,		\
>  			 "%s(): writel_relaxed(0x%08x, %s)\n",		\
>  			 __func__, (u32)(val), #_reg);			\
>  	} while (0)

>  out_unlock:
>  	spin_unlock_irqrestore(&pdev->phy_lock, flags);
> -	dev_dbg(&pchan->vc.chan.dev->device,
> +	dev_dbg(&pchan->vc.chan.chan_dev->device,
>  		"%s(): phy=%p(%d)\n", __func__, found,
>  		found ? found->idx : -1);
>  

> -	dev_dbg(&chan->vc.chan.dev->device,
> +	dev_dbg(&chan->vc.chan.chan_dev->device,
>  		"%s(): freeing\n", __func__);

> -	dev_dbg(&phy->vchan->vc.chan.dev->device,
> +	dev_dbg(&phy->vchan->vc.chan.chan_dev->device,
>  		"%s(); phy=%p(%d) misaligned=%d\n", __func__,
>  		phy, phy->idx, misaligned);

> -	dev_dbg(&phy->vchan->vc.chan.dev->device,
> +	dev_dbg(&phy->vchan->vc.chan.chan_dev->device,
>  		"%s(): phy=%p(%d)\n", __func__, phy, phy->idx);

> -	dev_dbg(&chan->vc.chan.dev->device,
> +	dev_dbg(&chan->vc.chan.chan_dev->device,
>  		"%s(): desc=%p\n", __func__, desc);
>  	if (!chan->phy) {
>  		chan->phy = lookup_phy(chan);
>  		if (!chan->phy) {
> -			dev_dbg(&chan->vc.chan.dev->device,
> +			dev_dbg(&chan->vc.chan.chan_dev->device,
>  				"%s(): no free dma channel\n", __func__);
>  			return;

(and so on in this PXA driver)

Besides that we should drop __func__ from all _dbg() messages, that can be
enabled run-time with help of Dynamic Debug.

So I think this driver requires more prerequisite work.

>  static struct device *chan2dev(struct stm32_dma_chan *chan)
>  {
> -	return &chan->vchan.chan.dev->device;
> +	return &chan->vchan.chan.chan_dev->device;
>  }

>  static struct device *chan2dev(struct stm32_dma3_chan *chan)
>  {
> -	return &chan->vchan.chan.dev->device;
> +	return &chan->vchan.chan.chan_dev->device;
>  }

>  static struct device *chan2dev(struct stm32_mdma_chan *chan)
>  {
> -	return &chan->vchan.chan.dev->device;
> +	return &chan->vchan.chan.chan_dev->device;
>  }

...

Something like

vchan_to_device(vchan)
{
	return &vchan->chan.chan_dev->device;
}



-- 
With Best Regards,
Andy Shevchenko




      reply	other threads:[~2026-09-04  9:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 20:53 [PATCH v2 0/3] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
2026-09-03 20:53 ` [PATCH v2 1/3] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
2026-09-03 22:30   ` Logan Gunthorpe
2026-09-04  8:35   ` Amelie Delaunay
2026-09-04  9:10     ` [Linux-stm32] " Amelie Delaunay
2026-09-04 14:21       ` Frank Li
2026-09-04  9:08   ` Andy Shevchenko
2026-09-04  9:26     ` Amelie Delaunay
2026-09-04 11:38       ` Andy Shevchenko
2026-09-03 20:53 ` [PATCH v2 2/3] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
2026-09-03 20:53 ` [PATCH v2 3/3] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
2026-09-04  9:19   ` Andy Shevchenko [this message]

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=apqNDHoNt09QYJe7@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=Frank.Li@oss.nxp.com \
    --cc=afaerber@suse.de \
    --cc=alexandre.torgue@foss.st.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=daniel@zonque.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=keguang.zhang@gmail.com \
    --cc=kelvin.cao@microchip.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-actions@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=ludovic.desroches@microchip.com \
    --cc=mani@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=paul@crapouillou.net \
    --cc=robert.jarzmik@free.fr \
    --cc=rostedt@goodmis.org \
    --cc=samuel@sholland.org \
    --cc=schung@nuvoton.com \
    --cc=thierry.reding@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=vireshk@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=wens@kernel.org \
    --cc=ychuang3@nuvoton.com \
    --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