All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com,
	suganath-prabu.subramani@broadcom.com
Cc: MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH 3/3] scsi: mptbase: use 'dma_set_mask_and_coherent()' to simplify code
Date: Sun, 13 Jun 2021 10:23:24 +0200	[thread overview]
Message-ID: <a93e5e750d9d7bbbd873eaa4de2f968341ade7f3.1623571676.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <cover.1623571676.git.christophe.jaillet@wanadoo.fr>

Use 'dma_set_mask_and_coherent()' instead of
'dma_set_mask()/dma_set_coherent_mask()', it is less verbose.

While at it, fix a typo in a comment (s/Reseting/Resetting/).

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
The code about the "1078 errata workaround" (around line 4449) looks
spurious to me. Test, value of 'dma_mask' and message are all about 35 bit
addressing, BUT the code uses DMA_BIT_MASK(32).
Having 35 here would look more logical to me

Just my 2 cents.
---
 drivers/message/fusion/mptbase.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 2add74f92323..ad3f5d8a5f7c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1665,15 +1665,14 @@ mpt_mapresources(MPT_ADAPTER *ioc)
 	if (sizeof(dma_addr_t) > 4) {
 		const uint64_t required_mask = dma_get_required_mask
 		    (&pdev->dev);
-		if (required_mask > DMA_BIT_MASK(32)
-			&& !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))
-			&& !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+		if (required_mask > DMA_BIT_MASK(32) &&
+		    !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 (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))
-			   && !dma_set_coherent_mask(&pdev->dev, 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",
@@ -1684,8 +1683,7 @@ mpt_mapresources(MPT_ADAPTER *ioc)
 			goto out_pci_release_region;
 		}
 	} else {
-		if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))
-			&& !dma_set_coherent_mask(&pdev->dev, 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",
@@ -4451,19 +4449,17 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 		 */
 		if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 &&
 		    ioc->dma_mask > DMA_BIT_MASK(35)) {
-			if (!dma_set_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32))
-			    && !dma_set_coherent_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32))) {
+			if (!dma_set_mask_and_coherent(&ioc->pcidev->dev,
+						       DMA_BIT_MASK(32))) {
 				dma_mask = DMA_BIT_MASK(35);
 				d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 				    "setting 35 bit addressing for "
 				    "Request/Reply/Chain and Sense Buffers\n",
 				    ioc->name));
 			} else {
-				/*Reseting DMA mask to 64 bit*/
-				dma_set_mask(&ioc->pcidev->dev,
-					     DMA_BIT_MASK(64));
-				dma_set_coherent_mask(&ioc->pcidev->dev,
-						      DMA_BIT_MASK(64));
+				/* Resetting DMA mask to 64 bit */
+				dma_set_mask_and_coherent(&ioc->pcidev->dev,
+							  DMA_BIT_MASK(64));
 
 				printk(MYIOC_s_ERR_FMT
 				    "failed setting 35 bit addressing for "
@@ -4599,8 +4595,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 	}
 
 	if (dma_mask == DMA_BIT_MASK(35) &&
-	    !dma_set_mask(&ioc->pcidev->dev, ioc->dma_mask) &&
-	    !dma_set_coherent_mask(&ioc->pcidev->dev, ioc->dma_mask))
+	    !dma_set_mask_and_coherent(&ioc->pcidev->dev, ioc->dma_mask))
 		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 		    "restoring 64 bit addressing\n", ioc->name));
 
@@ -4624,8 +4619,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 	}
 
 	if (dma_mask == DMA_BIT_MASK(35) &&
-	    !dma_set_mask(&ioc->pcidev->dev, DMA_BIT_MASK(64)) &&
-	    !dma_set_coherent_mask(&ioc->pcidev->dev, DMA_BIT_MASK(64)))
+	    !dma_set_mask_and_coherent(&ioc->pcidev->dev, DMA_BIT_MASK(64)))
 		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 		    "restoring 64 bit addressing\n", ioc->name));
 
-- 
2.30.2


      parent reply	other threads:[~2021-06-13  8:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13  8:22 [PATCH 0/3] scsi: mptbase: switch from 'pci_' to 'dma_' API Christophe JAILLET
2021-06-13  8:22 ` [PATCH 1/3] " Christophe JAILLET
2021-06-13  8:23 ` [PATCH 2/3] scsi: mptbase: switch from 'pci_' to 'dma_' API in 'mpt_alloc_fw_memory()' Christophe JAILLET
2021-06-13  8:23 ` Christophe JAILLET [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a93e5e750d9d7bbbd873eaa4de2f968341ade7f3.1623571676.git.christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.