Re: [PATCH 05/12] hisi_sas: use dma_set_mask_and_coherent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/10/2018 14:10, Christoph Hellwig wrote:
The driver currently uses pci_set_dma_mask despite otherwise using
the generic DMA API.  Switch it over to the better generic DMA API.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index bd4ce38b98d2..73bf45e52a0a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2201,14 +2201,11 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		goto err_out_disable_device;

-	if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) ||
-	    (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)) {
-		if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) ||
-		   (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) {
-			dev_err(dev, "No usable DMA addressing method\n");
-			rc = -EIO;
-			goto err_out_regions;
-		}
+	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
+	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+		dev_err(dev, "No usable DMA addressing method\n");
+		rc = -EIO;
+		goto err_out_regions;
 	}


We already do the same thing as your change for the platform driver probe, here: static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, ...)
{
    struct resource *res;
    struct Scsi_Host *shost;
    struct hisi_hba *hisi_hba;
    struct device *dev = &pdev->dev;
...

    if (hisi_sas_get_fw_info(hisi_hba) < 0)
        goto err_out;

    if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
        dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
        dev_err(dev, "No usable DMA addressing method\n");
        goto err_out;
    }

...
}

So I could make a common helper function in the driver to factor this out, but prob not worth it. Having said that, I think lots of drivers have this same pattern...

Acked-by: John Garry <john.garry@xxxxxxxxxx>

 	shost = hisi_sas_shost_alloc_pci(pdev);






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux