Re: [PATCH RESEND 1/2] scsi: megaraid: Remove pci-dma-compat wrapper APIs.

2020-07-29 Thread Suraj Upadhyay
On Tue, Jul 28, 2020 at 11:40:12PM -0400, Martin K. Petersen wrote:
> 
> Hello Suraj!
> 
> > 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.
> 
> Instead of all these individual patches, please submit a combined patch
> series for the changes under SCSI.
> 
> Each patch should fix a single driver. Please don't mix changes to
> completely different drivers such as hpsa and dc395x in a single
> commit. And please don't split semantically identical changes to the
> same driver into multiple commits (megaraid [2/2]).
> 
> Thank you!
> 
Hii Martin,
Thanks for your response.
I sent a patch series for the above changes.

Thanks,

Suraj Upadhyay
> -- 
> Martin K. PetersenOracle Linux Engineering


Re: [PATCH RESEND 1/2] scsi: megaraid: Remove pci-dma-compat wrapper APIs.

2020-07-28 Thread Martin K. Petersen


Hello Suraj!

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

Instead of all these individual patches, please submit a combined patch
series for the changes under SCSI.

Each patch should fix a single driver. Please don't mix changes to
completely different drivers such as hpsa and dc395x in a single
commit. And please don't split semantically identical changes to the
same driver into multiple commits (megaraid [2/2]).

Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH RESEND 1/2] scsi: megaraid: Remove pci-dma-compat wrapper APIs.

2020-07-27 Thread Suraj Upadhyay
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 has
been hand modified to replace GFP_ with correct flags based on the
context.

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(>dev, E2, E3, GFP_)

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

@@ expression E1, E2, E3, E4; @@
- pci_free_consistent(E1, E2, E3, E4)
+ dma_free_coherent(>dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_map_single(E1, E2, E3, E4)
+ dma_map_single(>dev, E2, E3, E4)

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

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

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

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

@@ expression E1, E2, E3, E4; @@
- pci_unmap_sg(E1, E2, E3, E4)
+ dma_unmap_sg(>dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_single_for_cpu(E1, E2, E3, E4)
+ dma_sync_single_for_cpu(>dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_single_for_device(E1, E2, E3, E4)
+ dma_sync_single_for_device(>dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_sg_for_cpu(E1, E2, E3, E4)
+ dma_sync_sg_for_cpu(>dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_sg_for_device(E1, E2, E3, E4)
+ dma_sync_sg_for_device(>dev, E2, E3, E4)

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

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

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

Signed-off-by: Suraj Upadhyay 
---
 drivers/scsi/megaraid.c | 66 ++---
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 0484ee52ae80..16bcdffeab37 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -133,8 +133,10 @@ mega_setup_mailbox(adapter_t *adapter)
 {
unsigned long   align;
 
-   adapter->una_mbox64 = pci_alloc_consistent(adapter->dev,
-   sizeof(mbox64_t), >una_mbox64_dma);
+   adapter->una_mbox64 = dma_alloc_coherent(>dev->dev,
+sizeof(mbox64_t),
+>una_mbox64_dma,
+GFP_KERNEL);
 
if( !adapter->una_mbox64 ) return -1;

@@ -222,8 +224,9 @@ mega_query_adapter(adapter_t *adapter)
mraid_inquiry   *inq;
dma_addr_t  dma_handle;
 
-   ext_inq = pci_alloc_consistent(adapter->dev,
-   sizeof(mraid_ext_inquiry), _handle);
+   ext_inq = dma_alloc_coherent(>dev->dev,
+sizeof(mraid_ext_inquiry),
+_handle, GFP_KERNEL);
 
if( ext_inq == NULL ) return -1;
 
@@ -243,8 +246,9 @@ mega_query_adapter(adapter_t *adapter)
mega_8_to_40ld(inq, inquiry3,
(mega_product_info *)>product_info);
 
-   pci_free_consistent(adapter->dev, sizeof(mraid_ext_inquiry),
-   ext_inq, dma_handle);
+   dma_free_coherent(>dev->dev,
+ sizeof(mraid_ext_inquiry), ext_inq,
+ dma_handle);
 
} else {/*adapter supports 40ld */
adapter->flag |= BOARD_40LD;
@@ -253,9 +257,9 @@ mega_query_adapter(adapter_t *adapter)
 * get product_info, which is static information and will be
 * unchanged
 */
-   prod_info_dma_handle = pci_map_single(adapter->dev, (void *)
-   >product_info,
-   sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
+   prod_info_dma_handle = dma_map_single(>dev->dev,
+ (void 
*)>product_info,
+ 
sizeof(mega_product_info), DMA_FROM_DEVICE);
 
mbox->m_out.xferaddr = prod_info_dma_handle;
 
@@ -267,8 +271,8 @@ mega_query_adapter(adapter_t *adapter)
"Product_info cmd