kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mei: switch from 'pci_' to 'dma_' API
@ 2021-08-22 20:02 Christophe JAILLET
  2021-08-24 13:43 ` Greg KH
  2021-08-27 20:36 ` Kari Argillander
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-08-22 20:02 UTC (permalink / raw)
  To: tomas.winkler, arnd, gregkh
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.

It has been compile tested.


@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
If needed, see post from Christoph Hellwig on the kernel-janitors ML:
   https://marc.info/?l=kernel-janitors&m=158745678307186&w=4
---
 drivers/misc/mei/pci-txe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
index aec0483b8e72..fa20d9a27813 100644
--- a/drivers/misc/mei/pci-txe.c
+++ b/drivers/misc/mei/pci-txe.c
@@ -69,9 +69,9 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto end;
 	}
 
-	err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
+	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(36));
 	if (err) {
-		err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
 		if (err) {
 			dev_err(&pdev->dev, "No suitable DMA available.\n");
 			goto end;
-- 
2.30.2


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

* Re: [PATCH] mei: switch from 'pci_' to 'dma_' API
  2021-08-22 20:02 [PATCH] mei: switch from 'pci_' to 'dma_' API Christophe JAILLET
@ 2021-08-24 13:43 ` Greg KH
  2021-08-27 20:12   ` Christophe JAILLET
  2021-08-27 20:36 ` Kari Argillander
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-08-24 13:43 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: tomas.winkler, arnd, linux-kernel, kernel-janitors

On Sun, Aug 22, 2021 at 10:02:59PM +0200, Christophe JAILLET wrote:
> The wrappers in include/linux/pci-dma-compat.h should go away.
> 
> The patch has been generated with the coccinelle script below.
> 
> It has been compile tested.
> 
> 
> @@
> @@
> -    PCI_DMA_BIDIRECTIONAL
> +    DMA_BIDIRECTIONAL
> 
> @@
> @@
> -    PCI_DMA_TODEVICE
> +    DMA_TO_DEVICE
> 
> @@
> @@
> -    PCI_DMA_FROMDEVICE
> +    DMA_FROM_DEVICE
> 
> @@
> @@
> -    PCI_DMA_NONE
> +    DMA_NONE
> 
> @@
> expression e1, e2, e3;
> @@
> -    pci_alloc_consistent(e1, e2, e3)
> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
> 
> @@
> expression e1, e2, e3;
> @@
> -    pci_zalloc_consistent(e1, e2, e3)
> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_free_consistent(e1, e2, e3, e4)
> +    dma_free_coherent(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_map_single(e1, e2, e3, e4)
> +    dma_map_single(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_single(e1, e2, e3, e4)
> +    dma_unmap_single(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4, e5;
> @@
> -    pci_map_page(e1, e2, e3, e4, e5)
> +    dma_map_page(&e1->dev, e2, e3, e4, e5)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_page(e1, e2, e3, e4)
> +    dma_unmap_page(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_map_sg(e1, e2, e3, e4)
> +    dma_map_sg(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_sg(e1, e2, e3, e4)
> +    dma_unmap_sg(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
> +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
> +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
> +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
> +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2;
> @@
> -    pci_dma_mapping_error(e1, e2)
> +    dma_mapping_error(&e1->dev, e2)
> 
> @@
> expression e1, e2;
> @@
> -    pci_set_dma_mask(e1, e2)
> +    dma_set_mask(&e1->dev, e2)
> 
> @@
> expression e1, e2;
> @@
> -    pci_set_consistent_dma_mask(e1, e2)
> +    dma_set_coherent_mask(&e1->dev, e2)
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

That is a lot of different things in one changelog text, yet you really
only did a replacement for pci_set_dma_mask here.  Please clean up the
changelog to reflect what you did, and most importantly, _WHY_ you are
doing it.

thanks,

greg k-h

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

* Re: [PATCH] mei: switch from 'pci_' to 'dma_' API
  2021-08-24 13:43 ` Greg KH
@ 2021-08-27 20:12   ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-08-27 20:12 UTC (permalink / raw)
  To: Greg KH; +Cc: tomas.winkler, arnd, linux-kernel, kernel-janitors

Le 24/08/2021 à 15:43, Greg KH a écrit :
> On Sun, Aug 22, 2021 at 10:02:59PM +0200, Christophe JAILLET wrote:
>> The wrappers in include/linux/pci-dma-compat.h should go away.
>>
>> The patch has been generated with the coccinelle script below.
>>
>> It has been compile tested.
>>
>>
>> @@
>> @@
>> -    PCI_DMA_BIDIRECTIONAL
>> +    DMA_BIDIRECTIONAL
>>
>> @@
>> @@
>> -    PCI_DMA_TODEVICE
>> +    DMA_TO_DEVICE
>>
>> @@
>> @@
>> -    PCI_DMA_FROMDEVICE
>> +    DMA_FROM_DEVICE
>>
>> @@
>> @@
>> -    PCI_DMA_NONE
>> +    DMA_NONE
>>
>> @@
>> expression e1, e2, e3;
>> @@
>> -    pci_alloc_consistent(e1, e2, e3)
>> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
>>
>> @@
>> expression e1, e2, e3;
>> @@
>> -    pci_zalloc_consistent(e1, e2, e3)
>> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_free_consistent(e1, e2, e3, e4)
>> +    dma_free_coherent(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_map_single(e1, e2, e3, e4)
>> +    dma_map_single(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_unmap_single(e1, e2, e3, e4)
>> +    dma_unmap_single(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4, e5;
>> @@
>> -    pci_map_page(e1, e2, e3, e4, e5)
>> +    dma_map_page(&e1->dev, e2, e3, e4, e5)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_unmap_page(e1, e2, e3, e4)
>> +    dma_unmap_page(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_map_sg(e1, e2, e3, e4)
>> +    dma_map_sg(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_unmap_sg(e1, e2, e3, e4)
>> +    dma_unmap_sg(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
>> +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
>> +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
>> +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2, e3, e4;
>> @@
>> -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
>> +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
>>
>> @@
>> expression e1, e2;
>> @@
>> -    pci_dma_mapping_error(e1, e2)
>> +    dma_mapping_error(&e1->dev, e2)
>>
>> @@
>> expression e1, e2;
>> @@
>> -    pci_set_dma_mask(e1, e2)
>> +    dma_set_mask(&e1->dev, e2)
>>
>> @@
>> expression e1, e2;
>> @@
>> -    pci_set_consistent_dma_mask(e1, e2)
>> +    dma_set_coherent_mask(&e1->dev, e2)
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> That is a lot of different things in one changelog text, yet you really
> only did a replacement for pci_set_dma_mask here.  Please clean up the
> changelog to reflect what you did, and most importantly, _WHY_ you are
> doing it.
> 
> thanks,
> 
> greg k-h
> 

Hi,

thx for the feed-back.

I've continued my serie and just sent "[PATCH] niu: switch from 'pci_' 
to 'dma_' API" where you are also in copy.

I've tried to improve the log message in it, giving references of why 
these clean-ups are done (proposed by Christoph Hellwig) and some 
reasons of why it is a good idea (argumentation from Julia Lawall)

The long coccinelle script has been reduced to only relevant parts.

I hope that this new version is good enough.


Comments on the "niu" drivers will also be taken into account when I 
will send a v2 for patches you have commented on.

CJ

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

* Re: [PATCH] mei: switch from 'pci_' to 'dma_' API
  2021-08-22 20:02 [PATCH] mei: switch from 'pci_' to 'dma_' API Christophe JAILLET
  2021-08-24 13:43 ` Greg KH
@ 2021-08-27 20:36 ` Kari Argillander
  1 sibling, 0 replies; 4+ messages in thread
From: Kari Argillander @ 2021-08-27 20:36 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: tomas.winkler, arnd, gregkh, linux-kernel, kernel-janitors

On Sun, Aug 22, 2021 at 10:02:59PM +0200, Christophe JAILLET wrote:
> The wrappers in include/linux/pci-dma-compat.h should go away.
> 
> The patch has been generated with the coccinelle script below.
> 
> It has been compile tested.

This should not be in commit message. It is unrelevant after this patch
is merged. It should be between
---
<here>
---

It is still good info to give.

Argillander

> 
> 
> @@
> @@
> -    PCI_DMA_BIDIRECTIONAL
> +    DMA_BIDIRECTIONAL
> 
> @@
> @@
> -    PCI_DMA_TODEVICE
> +    DMA_TO_DEVICE
> 
> @@
> @@
> -    PCI_DMA_FROMDEVICE
> +    DMA_FROM_DEVICE
> 
> @@
> @@
> -    PCI_DMA_NONE
> +    DMA_NONE
> 
> @@
> expression e1, e2, e3;
> @@
> -    pci_alloc_consistent(e1, e2, e3)
> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
> 
> @@
> expression e1, e2, e3;
> @@
> -    pci_zalloc_consistent(e1, e2, e3)
> +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_free_consistent(e1, e2, e3, e4)
> +    dma_free_coherent(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_map_single(e1, e2, e3, e4)
> +    dma_map_single(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_single(e1, e2, e3, e4)
> +    dma_unmap_single(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4, e5;
> @@
> -    pci_map_page(e1, e2, e3, e4, e5)
> +    dma_map_page(&e1->dev, e2, e3, e4, e5)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_page(e1, e2, e3, e4)
> +    dma_unmap_page(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_map_sg(e1, e2, e3, e4)
> +    dma_map_sg(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_unmap_sg(e1, e2, e3, e4)
> +    dma_unmap_sg(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
> +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
> +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
> +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2, e3, e4;
> @@
> -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
> +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
> 
> @@
> expression e1, e2;
> @@
> -    pci_dma_mapping_error(e1, e2)
> +    dma_mapping_error(&e1->dev, e2)
> 
> @@
> expression e1, e2;
> @@
> -    pci_set_dma_mask(e1, e2)
> +    dma_set_mask(&e1->dev, e2)
> 
> @@
> expression e1, e2;
> @@
> -    pci_set_consistent_dma_mask(e1, e2)
> +    dma_set_coherent_mask(&e1->dev, e2)
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> If needed, see post from Christoph Hellwig on the kernel-janitors ML:
>    https://marc.info/?l=kernel-janitors&m=158745678307186&w=4
> ---
>  drivers/misc/mei/pci-txe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
> index aec0483b8e72..fa20d9a27813 100644
> --- a/drivers/misc/mei/pci-txe.c
> +++ b/drivers/misc/mei/pci-txe.c
> @@ -69,9 +69,9 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		goto end;
>  	}
>  
> -	err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
> +	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(36));
>  	if (err) {
> -		err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> +		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
>  		if (err) {
>  			dev_err(&pdev->dev, "No suitable DMA available.\n");
>  			goto end;
> -- 
> 2.30.2
> 

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

end of thread, other threads:[~2021-08-27 20:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-22 20:02 [PATCH] mei: switch from 'pci_' to 'dma_' API Christophe JAILLET
2021-08-24 13:43 ` Greg KH
2021-08-27 20:12   ` Christophe JAILLET
2021-08-27 20:36 ` Kari Argillander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).