Re: [PATCH v4 1/4] dmaengine: add per-channel sysfs attribute groups via chan_groups
From: Logan Gunthorpe
Date: Tue Nov 17 2026 - 13:28:18 EST
On 2026-11-17 11:59, Frank Li wrote:
> On Tue, Nov 10, 2026 at 11:31:33AM -0600, Logan Gunthorpe wrote:
>> static ssize_t memcpy_count_show(struct device *dev,
>> struct device_attribute *attr, char *buf)
>> {
>> @@ -1117,6 +1143,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>>
>> dmaengine_chan_dev(chan)->class = &dma_devclass;
>> dmaengine_chan_dev(chan)->parent = device->dev;
>> + dmaengine_chan_dev(chan)->groups = device->chan_groups;
>
> if echo channel have same groups, why need copy it to dma_chan?
The groups pointer belong to each channel, so each dma_chan must set its
groups to the chan_groups pointer stored in the device. The only way to
add these groups is to set dma_chan->groups to something and the pointer
stored chan_groups is exactly what it is there for. I can't see any
other way to accomplish this. It makes no sense for each channel to have
different groups.
>> +/*
>> + * dmaengine_chan_from_dev_lock() / dmaengine_chan_from_dev_unlock() bracket
>> + * a critical section across which a channel's struct device can be safely
>> + * converted back to its struct dma_chan: dmaengine_chan_from_dev_lock()
>> + * returns NULL if the channel has already been unregistered, and the lock
>
> where return NULL when already been unregistered
>
> static struct dma_chan *dev_to_dma_chan(struct device *dev)
> {
> struct dma_chan_dev *chan_dev;
>
> chan_dev = container_of(dev, typeof(*chan_dev), device);
> return chan_dev->chan;
> }
__dma_async_device_channel_unregister() will set chan_dev->chan to NULL
while holding the dma_list_mutex lock.
Thanks for reviewing this,
Logan