]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
scsi: aacraid: Fix DMAR issues with iommu=pt
authorRaghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Wed, 10 May 2017 16:39:36 +0000 (09:39 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Jun 2017 00:47:59 +0000 (20:47 -0400)
The driver changed the DMA consistent map after consistent memory was
allocated, this invalidated the IOMMU identity mapping. The fix was to
make sure that we set the DMA consistent mask setting once depending on
the controller card.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/commsup.c
drivers/scsi/aacraid/linit.c

index 43d88389e899fb2f992fbf9b1868204437f1c0da..707ee2f5954d0ac0890c6f05967f7acd24157704 100644 (file)
@@ -2071,20 +2071,15 @@ int aac_get_adapter_info(struct aac_dev* dev)
                expose_physicals = 0;
        }
 
-       if(dev->dac_support != 0) {
-               if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64)) &&
-                       !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(64))) {
+       if (dev->dac_support) {
+               if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64))) {
                        if (!dev->in_reset)
-                               printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n",
-                                       dev->name, dev->id);
-               } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32)) &&
-                       !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(32))) {
-                       printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
-                               dev->name, dev->id);
+                               dev_info(&dev->pdev->dev, "64 Bit DAC enabled\n");
+               } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32))) {
+                       dev_info(&dev->pdev->dev, "DMA mask set failed, 64 Bit DAC disabled\n");
                        dev->dac_support = 0;
                } else {
-                       printk(KERN_WARNING"%s%d: No suitable DMA available.\n",
-                               dev->name, dev->id);
+                       dev_info(&dev->pdev->dev, "No suitable DMA available\n");
                        rcode = -ENOMEM;
                }
        }
index 7a1b8a2ce6583dc581a6819426deb2563bd14420..45de9b5cc42dc02435eceb9633c12f6d0c272c14 100644 (file)
@@ -1513,6 +1513,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
        struct scsi_cmnd *command_list;
        int jafo = 0;
        int bled;
+       u64 dmamask;
 
        /*
         * Assumptions:
@@ -1580,21 +1581,27 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
        aac_free_irq(aac);
        kfree(aac->fsa_dev);
        aac->fsa_dev = NULL;
+
+       dmamask = DMA_BIT_MASK(32);
        quirks = aac_get_driver_ident(index)->quirks;
-       if (quirks & AAC_QUIRK_31BIT) {
-               if (((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(31)))) ||
-                 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_BIT_MASK(31)))))
-                       goto out;
-       } else {
-               if (((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32)))) ||
-                 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_BIT_MASK(32)))))
-                       goto out;
+       if (quirks & AAC_QUIRK_31BIT)
+               retval = pci_set_dma_mask(aac->pdev, dmamask);
+       else if (!(quirks & AAC_QUIRK_SRC))
+               retval = pci_set_dma_mask(aac->pdev, dmamask);
+       else
+               retval = pci_set_consistent_dma_mask(aac->pdev, dmamask);
+
+       if (quirks & AAC_QUIRK_31BIT && !retval) {
+               dmamask = DMA_BIT_MASK(31);
+               retval = pci_set_consistent_dma_mask(aac->pdev, dmamask);
        }
+
+       if (retval)
+               goto out;
+
        if ((retval = (*(aac_get_driver_ident(index)->init))(aac)))
                goto out;
-       if (quirks & AAC_QUIRK_31BIT)
-               if ((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32))))
-                       goto out;
+
        if (jafo) {
                aac->thread = kthread_run(aac_command_thread, aac, "%s",
                                          aac->name);
index 372a075330263ab0d0d289b3583d72823e29f597..5a201da932509ef8501be8b23320dadab4146982 100644 (file)
@@ -1403,6 +1403,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        int error = -ENODEV;
        int unique_id = 0;
        u64 dmamask;
+       int mask_bits = 0;
        extern int aac_sync_mode;
 
        /*
@@ -1426,18 +1427,32 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
                goto out;
        error = -ENODEV;
 
+       if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) {
+               error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+               if (error) {
+                       dev_err(&pdev->dev, "PCI 32 BIT dma mask set failed");
+                       goto out_disable_pdev;
+               }
+       }
+
        /*
         * If the quirk31 bit is set, the adapter needs adapter
         * to driver communication memory to be allocated below 2gig
         */
-       if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
+       if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) {
                dmamask = DMA_BIT_MASK(31);
-       else
+               mask_bits = 31;
+       } else {
                dmamask = DMA_BIT_MASK(32);
+               mask_bits = 32;
+       }
 
-       if (pci_set_dma_mask(pdev, dmamask) ||
-                       pci_set_consistent_dma_mask(pdev, dmamask))
+       error = pci_set_consistent_dma_mask(pdev, dmamask);
+       if (error) {
+               dev_err(&pdev->dev, "PCI %d B consistent dma mask set failed\n"
+                               , mask_bits);
                goto out_disable_pdev;
+       }
 
        pci_set_master(pdev);
 
@@ -1501,15 +1516,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
                goto out_deinit;
        }
 
-       /*
-        * If we had set a smaller DMA mask earlier, set it to 4gig
-        * now since the adapter can dma data to at least a 4gig
-        * address space.
-        */
-       if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
-               if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
-                       goto out_deinit;
-
        aac->maximum_num_channels = aac_drivers[index].channels;
        error = aac_get_adapter_info(aac);
        if (error < 0)