Commit 961487e4 authored by Manoj N. Kumar's avatar Manoj N. Kumar Committed by Martin K. Petersen

cxlflash: Simplify PCI registration

The calls to pci_request_regions(), pci_resource_start(),
pci_set_dma_mask(), pci_set_master() and pci_save_state() are all
unnecessary for the IBM CXL flash adapter since data buffers
are not required to be mapped to the device's memory.

The use of services such as pci_set_dma_mask() are problematic on
hypervisor managed systems as the IBM CXL flash adapter is operating
under a virtual PCI Host Bridge (virtual PHB) which does not support
these services.

cxlflash 0001:00:00.0: init_pci: Failed to set PCI DMA mask rc=-5

The resolution is to simplify init_pci(), to a point where it does the
bare minimum (pci_enable_device). Similarly, remove the call the
pci_release_regions() from cxlflash_remove().
Signed-off-by: default avatarManoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: default avatarUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent e729b503
...@@ -767,7 +767,6 @@ static void cxlflash_remove(struct pci_dev *pdev) ...@@ -767,7 +767,6 @@ static void cxlflash_remove(struct pci_dev *pdev)
cancel_work_sync(&cfg->work_q); cancel_work_sync(&cfg->work_q);
term_afu(cfg); term_afu(cfg);
case INIT_STATE_PCI: case INIT_STATE_PCI:
pci_release_regions(cfg->dev);
pci_disable_device(pdev); pci_disable_device(pdev);
case INIT_STATE_NONE: case INIT_STATE_NONE:
free_mem(cfg); free_mem(cfg);
...@@ -840,15 +839,6 @@ static int init_pci(struct cxlflash_cfg *cfg) ...@@ -840,15 +839,6 @@ static int init_pci(struct cxlflash_cfg *cfg)
struct pci_dev *pdev = cfg->dev; struct pci_dev *pdev = cfg->dev;
int rc = 0; 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); rc = pci_enable_device(pdev);
if (rc || pci_channel_offline(pdev)) { if (rc || pci_channel_offline(pdev)) {
if (pci_channel_offline(pdev)) { if (pci_channel_offline(pdev)) {
...@@ -860,55 +850,13 @@ static int init_pci(struct cxlflash_cfg *cfg) ...@@ -860,55 +850,13 @@ static int init_pci(struct cxlflash_cfg *cfg)
dev_err(&pdev->dev, "%s: Cannot enable adapter\n", dev_err(&pdev->dev, "%s: Cannot enable adapter\n",
__func__); __func__);
cxlflash_wait_for_pci_err_recovery(cfg); cxlflash_wait_for_pci_err_recovery(cfg);
goto out_release_regions; goto out;
}
}
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;
}
} }
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: out:
pr_debug("%s: returning rc=%d\n", __func__, rc); pr_debug("%s: returning rc=%d\n", __func__, rc);
return 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;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment