All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Vinod Koul" <vkoul@kernel.org>, "Frank Li" <Frank.li@nxp.com>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Christophe Jaillet" <christophe.jaillet@wanadoo.fr>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Kelvin Cao" <kelvin.cao@microchip.com>
Subject: Re: [PATCH v2 1/4] dmaengine: add per-channel sysfs attribute groups via chan_groups
Date: Wed, 19 Aug 2026 10:48:20 -0500	[thread overview]
Message-ID: <aoXQRK4lLm2Ypp5v@SMW015318> (raw)
In-Reply-To: <40941ade-2522-4afd-9b4f-510547833db8@deltatee.com>

On Tue, Aug 18, 2026 at 04:44:30PM -0600, Logan Gunthorpe wrote:
>
>
> On 2026-08-18 14:56, Frank Li wrote:
> > On Mon, Jul 27, 2026 at 12:48:41PM -0600, Logan Gunthorpe wrote:
> >> @@ -1098,6 +1124,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
> >>
> >>  	chan->dev->device.class = &dma_devclass;
> >>  	chan->dev->device.parent = device->dev;
> >> +	chan->dev->device.groups = device->chan_groups;
> >
> > why not call device_add_groups() with const groups, so needn't save
> > "device->chan_groups" at all.
> That would mean each driver looping over dma->channels calling
> device_add_groups() itself, which is what I was pushing back against in
> my previous response, only a bit worse:
>
> Letting the core set dev->groups is also better than adding the groups
> after registration: device_add() applies dev->groups before signalling
> to userspace that the group has been created. If the driver is
> responsible for calling dma_add_groups() after registration, then
> userspace can be signalled before all the groups are added and ready,
> causing subtle issues with udev rules, etc. I'm not sure it can all be
> done correctly without introducing complicated race issues.
>
> I really think setting device.groups before calling device_add() is by
> far the better solution here.
>
> I had to go digging for this, but I was reminded of a (older than I had
> thought) blog post that GKH wrote more than a decade ago to describe
> this exact issue:
>
> http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
>
> The recommendation: just set the groups field in the device object.

Thanks, let me think to how to handle it better.  This field just use once
when register.

Frank

>
> Logan

  reply	other threads:[~2026-08-19 15:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 18:48 [PATCH v2 0/4] Add sysfs interface to switchtec-dma Logan Gunthorpe
2026-07-27 18:48 ` [PATCH v2 1/4] dmaengine: add per-channel sysfs attribute groups via chan_groups Logan Gunthorpe
2026-08-14 20:07   ` Frank Li
2026-08-18 16:40     ` Logan Gunthorpe
2026-08-18 20:56   ` Frank Li
2026-08-18 22:44     ` Logan Gunthorpe
2026-08-19 15:48       ` Frank Li [this message]
2026-07-27 18:48 ` [PATCH v2 2/4] dmaengine: ioatdma: convert per-channel sysfs to chan_groups Logan Gunthorpe
2026-07-27 18:48 ` [PATCH v2 3/4] dmaengine: switchtec-dma: add config sysfs attributes Logan Gunthorpe
2026-07-27 18:48 ` [PATCH v2 4/4] dmaengine: switchtec-dma: add pmon " Logan Gunthorpe

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=aoXQRK4lLm2Ypp5v@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.li@nxp.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=kelvin.cao@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=logang@deltatee.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.