kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs.
@ 2020-07-11 12:58 Suraj Upadhyay
  2020-07-13  4:59 ` Benjamin Poirier
  0 siblings, 1 reply; 4+ messages in thread
From: Suraj Upadhyay @ 2020-07-11 12:58 UTC (permalink / raw)
  To: manishrc, GR-Linux-NIC-Dev, gregkh
  Cc: devel, netdev, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3839 bytes --]

The legacy API wrappers in include/linux/pci-dma-compat.h
should go away as it creates unnecessary midlayering
for include/linux/dma-mapping.h APIs, instead use dma-mapping.h
APIs directly.

The patch has been generated with the coccinelle script below
and 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_ATOMIC)

@@ expression E1, E2, E3; @@
- pci_zalloc_consistent(E1, E2, E3)
+ dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC)

@@ 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, (enum dma_data_direction)E4)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_single(E1, E2, E3, E4)
+ dma_unmap_single(&E1->dev, E2, E3, (enum dma_data_direction)E4)

@@ expression E1, E2, E3, E4, E5; @@
- pci_map_page(E1, E2, E3, E4, E5)
+ dma_map_page(&E1->dev, E2, E3, E4, (enum dma_data_direction)E5)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_page(E1, E2, E3, E4)
+ dma_unmap_page(&E1->dev, E2, E3, (enum dma_data_direction)E4)

@@ expression E1, E2, E3, E4; @@
- pci_map_sg(E1, E2, E3, E4)
+ dma_map_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_sg(E1, E2, E3, E4)
+ dma_unmap_sg(&E1->dev, E2, E3, (enum dma_data_direction)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, (enum dma_data_direction)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, (enum dma_data_direction)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, (enum dma_data_direction)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, (enum dma_data_direction)E4)

@@ expression E1, E2; @@
- pci_dma_mapping_error(E1, E2)
+ dma_mapping_error(&E1->dev, E2)

@@ expression E1, E2; @@
- pci_set_consistent_dma_mask(E1, E2)
+ dma_set_coherent_mask(&E1->dev, E2)

@@ expression E1, E2; @@
- pci_set_dma_mask(E1, E2)
+ dma_set_mask(&E1->dev, E2)

Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
---
	This change is proposed by Christoph Hellwig <hch@infradead.org>
        in the post https://marc.info/?l=kernel-janitors&m=158745678307186&w=4
        on kernel-janitors Mailing List.

 drivers/staging/qlge/qlge_mpi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index fa178fc642a6..16a9bf818346 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -788,8 +788,9 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
 	char *my_buf;
 	dma_addr_t buf_dma;
 
-	my_buf = pci_alloc_consistent(qdev->pdev, word_count * sizeof(u32),
-				      &buf_dma);
+	my_buf = dma_alloc_coherent(&qdev->pdev->dev,
+				    word_count * sizeof(u32), &buf_dma,
+				    GFP_ATOMIC);
 	if (!my_buf)
 		return -EIO;
 
@@ -797,8 +798,8 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
 	if (!status)
 		memcpy(buf, my_buf, word_count * sizeof(u32));
 
-	pci_free_consistent(qdev->pdev, word_count * sizeof(u32), my_buf,
-			    buf_dma);
+	dma_free_coherent(&qdev->pdev->dev, word_count * sizeof(u32), my_buf,
+			  buf_dma);
 	return status;
 }
 
-- 
2.17.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs.
  2020-07-11 12:58 [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs Suraj Upadhyay
@ 2020-07-13  4:59 ` Benjamin Poirier
  2020-07-13  5:56   ` Suraj Upadhyay
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Poirier @ 2020-07-13  4:59 UTC (permalink / raw)
  To: Suraj Upadhyay
  Cc: devel, GR-Linux-NIC-Dev, gregkh, manishrc, kernel-janitors,
	linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 1936 bytes --]

On 2020-07-11 18:16 +0530, Suraj Upadhyay wrote:
> The legacy API wrappers in include/linux/pci-dma-compat.h
> should go away as it creates unnecessary midlayering
> for include/linux/dma-mapping.h APIs, instead use dma-mapping.h
> APIs directly.
> 
> The patch has been generated with the coccinelle script below
> and compile-tested.
> 
[...]
> 
> @@ expression E1, E2, E3, E4; @@
> - pci_dma_sync_single_for_device(E1, E2, E3, E4)
> + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4)

The qlge driver contains more usages of the deprecated pci_dma_* api
than what this diff addresses. In particular, there are some calls to
pci_dma_sync_single_for_cpu() which were not changed despite this
expression being in the semantic patch.

Dunno what happened but it should be reviewed. After converting away
from all of the old api, the TODO file should also be updated.

[...]

> 
> diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
> index fa178fc642a6..16a9bf818346 100644
> --- a/drivers/staging/qlge/qlge_mpi.c
> +++ b/drivers/staging/qlge/qlge_mpi.c
> @@ -788,8 +788,9 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
>  	char *my_buf;
>  	dma_addr_t buf_dma;
>  
> -	my_buf = pci_alloc_consistent(qdev->pdev, word_count * sizeof(u32),
> -				      &buf_dma);
> +	my_buf = dma_alloc_coherent(&qdev->pdev->dev,
> +				    word_count * sizeof(u32), &buf_dma,
> +				    GFP_ATOMIC);
>  	if (!my_buf)
>  		return -EIO;
>  
> @@ -797,8 +798,8 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
>  	if (!status)
>  		memcpy(buf, my_buf, word_count * sizeof(u32));
>  
> -	pci_free_consistent(qdev->pdev, word_count * sizeof(u32), my_buf,
> -			    buf_dma);
> +	dma_free_coherent(&qdev->pdev->dev, word_count * sizeof(u32), my_buf,
> +			  buf_dma);
>  	return status;
>  }
>  
> -- 
> 2.17.1
> 



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs.
  2020-07-13  4:59 ` Benjamin Poirier
@ 2020-07-13  5:56   ` Suraj Upadhyay
  2020-07-13  6:48     ` Benjamin Poirier
  0 siblings, 1 reply; 4+ messages in thread
From: Suraj Upadhyay @ 2020-07-13  5:56 UTC (permalink / raw)
  To: Benjamin Poirier; +Cc: devel, netdev, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2608 bytes --]

On Mon, Jul 13, 2020 at 01:59:59PM +0900, Benjamin Poirier wrote:
> On 2020-07-11 18:16 +0530, Suraj Upadhyay wrote:
> > The legacy API wrappers in include/linux/pci-dma-compat.h
> > should go away as it creates unnecessary midlayering
> > for include/linux/dma-mapping.h APIs, instead use dma-mapping.h
> > APIs directly.
> > 
> > The patch has been generated with the coccinelle script below
> > and compile-tested.
> > 
> [...]
> > 
> > @@ expression E1, E2, E3, E4; @@
> > - pci_dma_sync_single_for_device(E1, E2, E3, E4)
> > + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4)
> 
> The qlge driver contains more usages of the deprecated pci_dma_* api
> than what this diff addresses. In particular, there are some calls to
> pci_dma_sync_single_for_cpu() which were not changed despite this
> expression being in the semantic patch.

Hii Ben,
        I couldn't find any instances of pci_dma_sync_single_for_cpu in
the drivers/staging/qlge/ driver, I ran a simple `git grep pci_dma_sync_single_for_cpu/device`
and got nothing.
If I am wrong, please send the line number of the usages.

> Dunno what happened but it should be reviewed. After converting away
> from all of the old api, the TODO file should also be updated.

Thanks for reminding me this, I would send a follow up patch to remove
"pci_dma_*" from "avoid legacy/deprecated apis (ex. replace pci_dma_*, replace pci_enable_msi,
  use pci_iomap)".


Thanks and Cheers,

Suraj Upadhyay.
> [...]
> 
> > 
> > diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
> > index fa178fc642a6..16a9bf818346 100644
> > --- a/drivers/staging/qlge/qlge_mpi.c
> > +++ b/drivers/staging/qlge/qlge_mpi.c
> > @@ -788,8 +788,9 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
> >  	char *my_buf;
> >  	dma_addr_t buf_dma;
> >  
> > -	my_buf = pci_alloc_consistent(qdev->pdev, word_count * sizeof(u32),
> > -				      &buf_dma);
> > +	my_buf = dma_alloc_coherent(&qdev->pdev->dev,
> > +				    word_count * sizeof(u32), &buf_dma,
> > +				    GFP_ATOMIC);
> >  	if (!my_buf)
> >  		return -EIO;
> >  
> > @@ -797,8 +798,8 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
> >  	if (!status)
> >  		memcpy(buf, my_buf, word_count * sizeof(u32));
> >  
> > -	pci_free_consistent(qdev->pdev, word_count * sizeof(u32), my_buf,
> > -			    buf_dma);
> > +	dma_free_coherent(&qdev->pdev->dev, word_count * sizeof(u32), my_buf,
> > +			  buf_dma);
> >  	return status;
> >  }
> >  
> > -- 
> > 2.17.1
> > 
> 
> 



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs.
  2020-07-13  5:56   ` Suraj Upadhyay
@ 2020-07-13  6:48     ` Benjamin Poirier
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Poirier @ 2020-07-13  6:48 UTC (permalink / raw)
  To: Suraj Upadhyay; +Cc: devel, netdev, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On 2020-07-13 11:14 +0530, Suraj Upadhyay wrote:
> On Mon, Jul 13, 2020 at 01:59:59PM +0900, Benjamin Poirier wrote:
> > On 2020-07-11 18:16 +0530, Suraj Upadhyay wrote:
> > > The legacy API wrappers in include/linux/pci-dma-compat.h
> > > should go away as it creates unnecessary midlayering
> > > for include/linux/dma-mapping.h APIs, instead use dma-mapping.h
> > > APIs directly.
> > > 
> > > The patch has been generated with the coccinelle script below
> > > and compile-tested.
> > > 
> > [...]
> > > 
> > > @@ expression E1, E2, E3, E4; @@
> > > - pci_dma_sync_single_for_device(E1, E2, E3, E4)
> > > + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4)
> > 
> > The qlge driver contains more usages of the deprecated pci_dma_* api
> > than what this diff addresses. In particular, there are some calls to
> > pci_dma_sync_single_for_cpu() which were not changed despite this
> > expression being in the semantic patch.
> 
> Hii Ben,
>         I couldn't find any instances of pci_dma_sync_single_for_cpu in
> the drivers/staging/qlge/ driver, I ran a simple `git grep pci_dma_sync_single_for_cpu/device`
> and got nothing.
> If I am wrong, please send the line number of the usages.

You're right, sorry. I was missing commit e955a071b9b3 ("staging: qlge:
replace deprecated apis pci_dma_*") in my tree.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-07-13  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-11 12:58 [PATCH] staging: qlge: Remove pci-dma-compat wrapper APIs Suraj Upadhyay
2020-07-13  4:59 ` Benjamin Poirier
2020-07-13  5:56   ` Suraj Upadhyay
2020-07-13  6:48     ` Benjamin Poirier

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).