All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: add channel device name to channel registration
@ 2023-12-13 17:40 Amelie Delaunay
  2023-12-21 16:13 ` Vinod Koul
  0 siblings, 1 reply; 4+ messages in thread
From: Amelie Delaunay @ 2023-12-13 17:40 UTC (permalink / raw)
  To: Vinod Koul, Fenghua Yu, Dave Jiang
  Cc: linux-stm32, Amelie Delaunay, dmaengine, linux-kernel

Channel device name is used for sysfs, but also by dmatest filter function.

With dynamic channel registration, channels can be registered after dma
controller registration. Users may want to have specific channel names.

If name is NULL, the channel name relies on previous implementation,
dma<controller_device_id>chan<channel_device_id>.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 drivers/dma/dmaengine.c   | 16 ++++++++++------
 drivers/dma/idxd/dma.c    |  2 +-
 include/linux/dmaengine.h |  3 ++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index b7388ae62d7f..7848428da2d6 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1037,7 +1037,8 @@ static int get_dma_id(struct dma_device *device)
 }
 
 static int __dma_async_device_channel_register(struct dma_device *device,
-					       struct dma_chan *chan)
+					       struct dma_chan *chan,
+					       const char *name)
 {
 	int rc;
 
@@ -1066,8 +1067,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 	chan->dev->device.parent = device->dev;
 	chan->dev->chan = chan;
 	chan->dev->dev_id = device->dev_id;
-	dev_set_name(&chan->dev->device, "dma%dchan%d",
-		     device->dev_id, chan->chan_id);
+	if (!name)
+		dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
+	else
+		dev_set_name(&chan->dev->device, name);
 	rc = device_register(&chan->dev->device);
 	if (rc)
 		goto err_out_ida;
@@ -1087,11 +1090,12 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 }
 
 int dma_async_device_channel_register(struct dma_device *device,
-				      struct dma_chan *chan)
+				      struct dma_chan *chan,
+				      const char *name)
 {
 	int rc;
 
-	rc = __dma_async_device_channel_register(device, chan);
+	rc = __dma_async_device_channel_register(device, chan, name);
 	if (rc < 0)
 		return rc;
 
@@ -1200,7 +1204,7 @@ int dma_async_device_register(struct dma_device *device)
 
 	/* represent channels in sysfs. Probably want devs too */
 	list_for_each_entry(chan, &device->channels, device_node) {
-		rc = __dma_async_device_channel_register(device, chan);
+		rc = __dma_async_device_channel_register(device, chan, NULL);
 		if (rc < 0)
 			goto err_out;
 	}
diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
index 47a01893cfdb..101a265567a9 100644
--- a/drivers/dma/idxd/dma.c
+++ b/drivers/dma/idxd/dma.c
@@ -269,7 +269,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
 		desc->txd.tx_submit = idxd_dma_tx_submit;
 	}
 
-	rc = dma_async_device_channel_register(dma, chan);
+	rc = dma_async_device_channel_register(dma, chan, NULL);
 	if (rc < 0) {
 		kfree(idxd_chan);
 		return rc;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 3df70d6131c8..cbad92cc3e0b 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1574,7 +1574,8 @@ int dma_async_device_register(struct dma_device *device);
 int dmaenginem_async_device_register(struct dma_device *device);
 void dma_async_device_unregister(struct dma_device *device);
 int dma_async_device_channel_register(struct dma_device *device,
-				      struct dma_chan *chan);
+				      struct dma_chan *chan,
+				      const char *name);
 void dma_async_device_channel_unregister(struct dma_device *device,
 					 struct dma_chan *chan);
 void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: add channel device name to channel registration
  2023-12-13 17:40 [PATCH] dmaengine: add channel device name to channel registration Amelie Delaunay
@ 2023-12-21 16:13 ` Vinod Koul
  2023-12-21 17:11   ` Amelie Delaunay
  0 siblings, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2023-12-21 16:13 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Fenghua Yu, Dave Jiang, linux-stm32, dmaengine, linux-kernel

On 13-12-23, 18:40, Amelie Delaunay wrote:
> Channel device name is used for sysfs, but also by dmatest filter function.
> 
> With dynamic channel registration, channels can be registered after dma
> controller registration. Users may want to have specific channel names.
> 
> If name is NULL, the channel name relies on previous implementation,
> dma<controller_device_id>chan<channel_device_id>.

lgtm, where is the user for this..?

> 
> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
> ---
>  drivers/dma/dmaengine.c   | 16 ++++++++++------
>  drivers/dma/idxd/dma.c    |  2 +-
>  include/linux/dmaengine.h |  3 ++-
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index b7388ae62d7f..7848428da2d6 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -1037,7 +1037,8 @@ static int get_dma_id(struct dma_device *device)
>  }
>  
>  static int __dma_async_device_channel_register(struct dma_device *device,
> -					       struct dma_chan *chan)
> +					       struct dma_chan *chan,
> +					       const char *name)
>  {
>  	int rc;
>  
> @@ -1066,8 +1067,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	chan->dev->device.parent = device->dev;
>  	chan->dev->chan = chan;
>  	chan->dev->dev_id = device->dev_id;
> -	dev_set_name(&chan->dev->device, "dma%dchan%d",
> -		     device->dev_id, chan->chan_id);
> +	if (!name)
> +		dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
> +	else
> +		dev_set_name(&chan->dev->device, name);
>  	rc = device_register(&chan->dev->device);
>  	if (rc)
>  		goto err_out_ida;
> @@ -1087,11 +1090,12 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  }
>  
>  int dma_async_device_channel_register(struct dma_device *device,
> -				      struct dma_chan *chan)
> +				      struct dma_chan *chan,
> +				      const char *name)
>  {
>  	int rc;
>  
> -	rc = __dma_async_device_channel_register(device, chan);
> +	rc = __dma_async_device_channel_register(device, chan, name);
>  	if (rc < 0)
>  		return rc;
>  
> @@ -1200,7 +1204,7 @@ int dma_async_device_register(struct dma_device *device)
>  
>  	/* represent channels in sysfs. Probably want devs too */
>  	list_for_each_entry(chan, &device->channels, device_node) {
> -		rc = __dma_async_device_channel_register(device, chan);
> +		rc = __dma_async_device_channel_register(device, chan, NULL);
>  		if (rc < 0)
>  			goto err_out;
>  	}
> diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
> index 47a01893cfdb..101a265567a9 100644
> --- a/drivers/dma/idxd/dma.c
> +++ b/drivers/dma/idxd/dma.c
> @@ -269,7 +269,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
>  		desc->txd.tx_submit = idxd_dma_tx_submit;
>  	}
>  
> -	rc = dma_async_device_channel_register(dma, chan);
> +	rc = dma_async_device_channel_register(dma, chan, NULL);
>  	if (rc < 0) {
>  		kfree(idxd_chan);
>  		return rc;
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 3df70d6131c8..cbad92cc3e0b 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -1574,7 +1574,8 @@ int dma_async_device_register(struct dma_device *device);
>  int dmaenginem_async_device_register(struct dma_device *device);
>  void dma_async_device_unregister(struct dma_device *device);
>  int dma_async_device_channel_register(struct dma_device *device,
> -				      struct dma_chan *chan);
> +				      struct dma_chan *chan,
> +				      const char *name);
>  void dma_async_device_channel_unregister(struct dma_device *device,
>  					 struct dma_chan *chan);
>  void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
> -- 
> 2.25.1

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: add channel device name to channel registration
  2023-12-21 16:13 ` Vinod Koul
@ 2023-12-21 17:11   ` Amelie Delaunay
  2023-12-21 17:18     ` Vinod Koul
  0 siblings, 1 reply; 4+ messages in thread
From: Amelie Delaunay @ 2023-12-21 17:11 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Fenghua Yu, Dave Jiang, linux-stm32, dmaengine, linux-kernel

Hi Vinod,

On 12/21/23 17:13, Vinod Koul wrote:
> On 13-12-23, 18:40, Amelie Delaunay wrote:
>> Channel device name is used for sysfs, but also by dmatest filter function.
>>
>> With dynamic channel registration, channels can be registered after dma
>> controller registration. Users may want to have specific channel names.
>>
>> If name is NULL, the channel name relies on previous implementation,
>> dma<controller_device_id>chan<channel_device_id>.
> 
> lgtm, where is the user for this..?
> 

I'll send beginning of next year a DMA controller driver for STM32MP25 
SoC family. It relies on the dynamic channel registration. It will be a 
user of this dma_async_device_channel_register(struct dma_device 
*device, struct dma_chan *chan, const char *name).

Regards,
Amelie

>>
>> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
>> ---
>>   drivers/dma/dmaengine.c   | 16 ++++++++++------
>>   drivers/dma/idxd/dma.c    |  2 +-
>>   include/linux/dmaengine.h |  3 ++-
>>   3 files changed, 13 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
>> index b7388ae62d7f..7848428da2d6 100644
>> --- a/drivers/dma/dmaengine.c
>> +++ b/drivers/dma/dmaengine.c
>> @@ -1037,7 +1037,8 @@ static int get_dma_id(struct dma_device *device)
>>   }
>>   
>>   static int __dma_async_device_channel_register(struct dma_device *device,
>> -					       struct dma_chan *chan)
>> +					       struct dma_chan *chan,
>> +					       const char *name)
>>   {
>>   	int rc;
>>   
>> @@ -1066,8 +1067,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>>   	chan->dev->device.parent = device->dev;
>>   	chan->dev->chan = chan;
>>   	chan->dev->dev_id = device->dev_id;
>> -	dev_set_name(&chan->dev->device, "dma%dchan%d",
>> -		     device->dev_id, chan->chan_id);
>> +	if (!name)
>> +		dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
>> +	else
>> +		dev_set_name(&chan->dev->device, name);
>>   	rc = device_register(&chan->dev->device);
>>   	if (rc)
>>   		goto err_out_ida;
>> @@ -1087,11 +1090,12 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>>   }
>>   
>>   int dma_async_device_channel_register(struct dma_device *device,
>> -				      struct dma_chan *chan)
>> +				      struct dma_chan *chan,
>> +				      const char *name)
>>   {
>>   	int rc;
>>   
>> -	rc = __dma_async_device_channel_register(device, chan);
>> +	rc = __dma_async_device_channel_register(device, chan, name);
>>   	if (rc < 0)
>>   		return rc;
>>   
>> @@ -1200,7 +1204,7 @@ int dma_async_device_register(struct dma_device *device)
>>   
>>   	/* represent channels in sysfs. Probably want devs too */
>>   	list_for_each_entry(chan, &device->channels, device_node) {
>> -		rc = __dma_async_device_channel_register(device, chan);
>> +		rc = __dma_async_device_channel_register(device, chan, NULL);
>>   		if (rc < 0)
>>   			goto err_out;
>>   	}
>> diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
>> index 47a01893cfdb..101a265567a9 100644
>> --- a/drivers/dma/idxd/dma.c
>> +++ b/drivers/dma/idxd/dma.c
>> @@ -269,7 +269,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
>>   		desc->txd.tx_submit = idxd_dma_tx_submit;
>>   	}
>>   
>> -	rc = dma_async_device_channel_register(dma, chan);
>> +	rc = dma_async_device_channel_register(dma, chan, NULL);
>>   	if (rc < 0) {
>>   		kfree(idxd_chan);
>>   		return rc;
>> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
>> index 3df70d6131c8..cbad92cc3e0b 100644
>> --- a/include/linux/dmaengine.h
>> +++ b/include/linux/dmaengine.h
>> @@ -1574,7 +1574,8 @@ int dma_async_device_register(struct dma_device *device);
>>   int dmaenginem_async_device_register(struct dma_device *device);
>>   void dma_async_device_unregister(struct dma_device *device);
>>   int dma_async_device_channel_register(struct dma_device *device,
>> -				      struct dma_chan *chan);
>> +				      struct dma_chan *chan,
>> +				      const char *name);
>>   void dma_async_device_channel_unregister(struct dma_device *device,
>>   					 struct dma_chan *chan);
>>   void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
>> -- 
>> 2.25.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: add channel device name to channel registration
  2023-12-21 17:11   ` Amelie Delaunay
@ 2023-12-21 17:18     ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2023-12-21 17:18 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Fenghua Yu, Dave Jiang, linux-stm32, dmaengine, linux-kernel

On 21-12-23, 18:11, Amelie Delaunay wrote:
> Hi Vinod,
> 
> On 12/21/23 17:13, Vinod Koul wrote:
> > On 13-12-23, 18:40, Amelie Delaunay wrote:
> > > Channel device name is used for sysfs, but also by dmatest filter function.
> > > 
> > > With dynamic channel registration, channels can be registered after dma
> > > controller registration. Users may want to have specific channel names.
> > > 
> > > If name is NULL, the channel name relies on previous implementation,
> > > dma<controller_device_id>chan<channel_device_id>.
> > 
> > lgtm, where is the user for this..?
> > 
> 
> I'll send beginning of next year a DMA controller driver for STM32MP25 SoC
> family. It relies on the dynamic channel registration. It will be a user of
> this dma_async_device_channel_register(struct dma_device *device, struct
> dma_chan *chan, const char *name).

Okay, I prefer to add a API with the user.

Thnx

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-21 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 17:40 [PATCH] dmaengine: add channel device name to channel registration Amelie Delaunay
2023-12-21 16:13 ` Vinod Koul
2023-12-21 17:11   ` Amelie Delaunay
2023-12-21 17:18     ` Vinod Koul

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.