All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] message: fusion: switch from 'pci_' to 'dma_' API
@ 2021-09-28  3:42 Qing Wang
  2021-11-02 19:43 ` Christophe JAILLET
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-09-28  3:42 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux.pdl, linux-scsi, linux-kernel
  Cc: Qing Wang

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

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

While at it, some 'dma_set_mask()/dma_set_coherent_mask()' have been
updated to a much less verbose 'dma_set_mask_and_coherent()'.

Signed-off-by: Qing Wang <wangqing@vivo.com>
---
 drivers/message/fusion/mptbase.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 7f7abc9..c255d8a
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1666,16 +1666,12 @@ mpt_mapresources(MPT_ADAPTER *ioc)
 		const uint64_t required_mask = dma_get_required_mask
 		    (&pdev->dev);
 		if (required_mask > DMA_BIT_MASK(32)
-			&& !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
-			&& !pci_set_consistent_dma_mask(pdev,
-						 DMA_BIT_MASK(64))) {
+			&& dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
 			ioc->dma_mask = DMA_BIT_MASK(64);
 			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
 				": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
 				ioc->name));
-		} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
-			&& !pci_set_consistent_dma_mask(pdev,
-						DMA_BIT_MASK(32))) {
+		} else if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
 			ioc->dma_mask = DMA_BIT_MASK(32);
 			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
 				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
@@ -1686,9 +1682,7 @@ mpt_mapresources(MPT_ADAPTER *ioc)
 			goto out_pci_release_region;
 		}
 	} else {
-		if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
-			&& !pci_set_consistent_dma_mask(pdev,
-						DMA_BIT_MASK(32))) {
+		if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
 			ioc->dma_mask = DMA_BIT_MASK(32);
 			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
 				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
@@ -4452,9 +4446,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 		 */
 		if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 &&
 		    ioc->dma_mask > DMA_BIT_MASK(35)) {
-			if (!pci_set_dma_mask(ioc->pcidev, DMA_BIT_MASK(32))
-			    && !pci_set_consistent_dma_mask(ioc->pcidev,
-			    DMA_BIT_MASK(32))) {
+			if (!dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(32))) {
 				dma_mask = DMA_BIT_MASK(35);
 				d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 				    "setting 35 bit addressing for "
@@ -4462,10 +4454,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 				    ioc->name));
 			} else {
 				/*Reseting DMA mask to 64 bit*/
-				pci_set_dma_mask(ioc->pcidev,
-					DMA_BIT_MASK(64));
-				pci_set_consistent_dma_mask(ioc->pcidev,
-					DMA_BIT_MASK(64));
+				dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64));
 
 				printk(MYIOC_s_ERR_FMT
 				    "failed setting 35 bit addressing for "
@@ -4600,9 +4589,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 		alloc_dma += ioc->reply_sz;
 	}
 
-	if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
-	    ioc->dma_mask) && !pci_set_consistent_dma_mask(ioc->pcidev,
-	    ioc->dma_mask))
+	if (dma_mask == DMA_BIT_MASK(35) &&
+	    !dma_set_mask_and_coherent(&ioc->pcidev, ioc->dma_mask))
 		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 		    "restoring 64 bit addressing\n", ioc->name));
 
@@ -4625,9 +4613,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 		ioc->sense_buf_pool = NULL;
 	}
 
-	if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
-	    DMA_BIT_MASK(64)) && !pci_set_consistent_dma_mask(ioc->pcidev,
-	    DMA_BIT_MASK(64)))
+	if (dma_mask == DMA_BIT_MASK(35) &&
+	    !dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64)))
 		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 		    "restoring 64 bit addressing\n", ioc->name));
 
-- 
2.7.4


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

* Re: [PATCH V2] message: fusion: switch from 'pci_' to 'dma_' API
  2021-09-28  3:42 [PATCH V2] message: fusion: switch from 'pci_' to 'dma_' API Qing Wang
@ 2021-11-02 19:43 ` Christophe JAILLET
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-02 19:43 UTC (permalink / raw)
  To: Qing Wang, Sathya Prakash, Sreekanth Reddy,
	Suganath Prabu Subramani, MPT-FusionLinux.pdl, linux-scsi,
	linux-kernel, Kernel Janitors

Hi,

Le 28/09/2021 à 05:42, Qing Wang a écrit :
> The wrappers in include/linux/pci-dma-compat.h should go away.
> 
> The patch has been generated with the coccinelle script below.
> 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)
> 
> While at it, some 'dma_set_mask()/dma_set_coherent_mask()' have been
> updated to a much less verbose 'dma_set_mask_and_coherent()'.
> 
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
>   drivers/message/fusion/mptbase.c | 31 +++++++++----------------------
>   1 file changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index 7f7abc9..c255d8a
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -1666,16 +1666,12 @@ mpt_mapresources(MPT_ADAPTER *ioc)
>   		const uint64_t required_mask = dma_get_required_mask
>   		    (&pdev->dev);
>   		if (required_mask > DMA_BIT_MASK(32)
> -			&& !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
> -			&& !pci_set_consistent_dma_mask(pdev,
> -						 DMA_BIT_MASK(64))) {
> +			&& dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {

The logic is reversed here. We used to have a !, but it is now missing.

CJ

>   			ioc->dma_mask = DMA_BIT_MASK(64);
>   			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
>   				": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
>   				ioc->name));
> -		} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
> -			&& !pci_set_consistent_dma_mask(pdev,
> -						DMA_BIT_MASK(32))) {
> +		} else if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
>   			ioc->dma_mask = DMA_BIT_MASK(32);
>   			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
>   				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
> @@ -1686,9 +1682,7 @@ mpt_mapresources(MPT_ADAPTER *ioc)
>   			goto out_pci_release_region;
>   		}
>   	} else {
> -		if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
> -			&& !pci_set_consistent_dma_mask(pdev,
> -						DMA_BIT_MASK(32))) {
> +		if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
>   			ioc->dma_mask = DMA_BIT_MASK(32);
>   			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
>   				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
> @@ -4452,9 +4446,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
>   		 */
>   		if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 &&
>   		    ioc->dma_mask > DMA_BIT_MASK(35)) {
> -			if (!pci_set_dma_mask(ioc->pcidev, DMA_BIT_MASK(32))
> -			    && !pci_set_consistent_dma_mask(ioc->pcidev,
> -			    DMA_BIT_MASK(32))) {
> +			if (!dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(32))) {
>   				dma_mask = DMA_BIT_MASK(35);
>   				d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
>   				    "setting 35 bit addressing for "
> @@ -4462,10 +4454,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
>   				    ioc->name));
>   			} else {
>   				/*Reseting DMA mask to 64 bit*/
> -				pci_set_dma_mask(ioc->pcidev,
> -					DMA_BIT_MASK(64));
> -				pci_set_consistent_dma_mask(ioc->pcidev,
> -					DMA_BIT_MASK(64));
> +				dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64));
>   
>   				printk(MYIOC_s_ERR_FMT
>   				    "failed setting 35 bit addressing for "
> @@ -4600,9 +4589,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
>   		alloc_dma += ioc->reply_sz;
>   	}
>   
> -	if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
> -	    ioc->dma_mask) && !pci_set_consistent_dma_mask(ioc->pcidev,
> -	    ioc->dma_mask))
> +	if (dma_mask == DMA_BIT_MASK(35) &&
> +	    !dma_set_mask_and_coherent(&ioc->pcidev, ioc->dma_mask))
>   		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
>   		    "restoring 64 bit addressing\n", ioc->name));
>   
> @@ -4625,9 +4613,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
>   		ioc->sense_buf_pool = NULL;
>   	}
>   
> -	if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
> -	    DMA_BIT_MASK(64)) && !pci_set_consistent_dma_mask(ioc->pcidev,
> -	    DMA_BIT_MASK(64)))
> +	if (dma_mask == DMA_BIT_MASK(35) &&
> +	    !dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64)))
>   		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
>   		    "restoring 64 bit addressing\n", ioc->name));
>   
> 


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

end of thread, other threads:[~2021-11-02 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  3:42 [PATCH V2] message: fusion: switch from 'pci_' to 'dma_' API Qing Wang
2021-11-02 19:43 ` Christophe JAILLET

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.