]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/scsi/cxlflash/main.c
cxlflash: Unmap problem state area before detaching master context
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / cxlflash / main.c
index f6d90ce8f3b7eaa64b09e03aa515333323d1870e..ca702d855c314a04615ba5814c50b2360fff9a1c 100644 (file)
@@ -726,11 +726,11 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level)
  */
 static void term_afu(struct cxlflash_cfg *cfg)
 {
-       term_mc(cfg, UNDO_START);
-
        if (cfg->afu)
                stop_afu(cfg);
 
+       term_mc(cfg, UNDO_START);
+
        pr_debug("%s: returning\n", __func__);
 }
 
@@ -767,7 +767,6 @@ static void cxlflash_remove(struct pci_dev *pdev)
                cancel_work_sync(&cfg->work_q);
                term_afu(cfg);
        case INIT_STATE_PCI:
-               pci_release_regions(cfg->dev);
                pci_disable_device(pdev);
        case INIT_STATE_NONE:
                free_mem(cfg);
@@ -840,15 +839,6 @@ static int init_pci(struct cxlflash_cfg *cfg)
        struct pci_dev *pdev = cfg->dev;
        int rc = 0;
 
-       cfg->cxlflash_regs_pci = pci_resource_start(pdev, 0);
-       rc = pci_request_regions(pdev, CXLFLASH_NAME);
-       if (rc < 0) {
-               dev_err(&pdev->dev,
-                       "%s: Couldn't register memory range of registers\n",
-                       __func__);
-               goto out;
-       }
-
        rc = pci_enable_device(pdev);
        if (rc || pci_channel_offline(pdev)) {
                if (pci_channel_offline(pdev)) {
@@ -860,55 +850,13 @@ static int init_pci(struct cxlflash_cfg *cfg)
                        dev_err(&pdev->dev, "%s: Cannot enable adapter\n",
                                __func__);
                        cxlflash_wait_for_pci_err_recovery(cfg);
-                       goto out_release_regions;
-               }
-       }
-
-       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
-       if (rc < 0) {
-               dev_dbg(&pdev->dev, "%s: Failed to set 64 bit PCI DMA mask\n",
-                       __func__);
-               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
-       }
-
-       if (rc < 0) {
-               dev_err(&pdev->dev, "%s: Failed to set PCI DMA mask\n",
-                       __func__);
-               goto out_disable;
-       }
-
-       pci_set_master(pdev);
-
-       if (pci_channel_offline(pdev)) {
-               cxlflash_wait_for_pci_err_recovery(cfg);
-               if (pci_channel_offline(pdev)) {
-                       rc = -EIO;
-                       goto out_msi_disable;
+                       goto out;
                }
        }
 
-       rc = pci_save_state(pdev);
-
-       if (rc != PCIBIOS_SUCCESSFUL) {
-               dev_err(&pdev->dev, "%s: Failed to save PCI config space\n",
-                       __func__);
-               rc = -EIO;
-               goto cleanup_nolog;
-       }
-
 out:
        pr_debug("%s: returning rc=%d\n", __func__, rc);
        return rc;
-
-cleanup_nolog:
-out_msi_disable:
-       cxlflash_wait_for_pci_err_recovery(cfg);
-out_disable:
-       pci_disable_device(pdev);
-out_release_regions:
-       pci_release_regions(pdev);
-       goto out;
-
 }
 
 /**
@@ -2544,8 +2492,8 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev,
                if (unlikely(rc))
                        dev_err(dev, "%s: Failed to mark user contexts!(%d)\n",
                                __func__, rc);
-               term_mc(cfg, UNDO_START);
                stop_afu(cfg);
+               term_mc(cfg, UNDO_START);
                return PCI_ERS_RESULT_NEED_RESET;
        case pci_channel_io_perm_failure:
                cfg->state = STATE_FAILTERM;