aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj N. Kumar <manoj@linux.vnet.ibm.com>2016-03-04 16:55:14 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2016-03-08 21:17:33 -0500
commit961487e46a87079a573348896a0d39c1cb10947d (patch)
treec605ca80ba8f4883a8546e64bb73f362b5689527
parente729b50307bfe9c541d08dd591c1dd6aef1999e8 (diff)
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: Manoj N. Kumar <manoj@linux.vnet.ibm.com> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Reviewed-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/cxlflash/main.c54
1 files changed, 1 insertions, 53 deletions
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index f6d90ce8f3b7..3dbb9fa3019e 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -767,7 +767,6 @@ static void cxlflash_remove(struct pci_dev *pdev)
767 cancel_work_sync(&cfg->work_q); 767 cancel_work_sync(&cfg->work_q);
768 term_afu(cfg); 768 term_afu(cfg);
769 case INIT_STATE_PCI: 769 case INIT_STATE_PCI:
770 pci_release_regions(cfg->dev);
771 pci_disable_device(pdev); 770 pci_disable_device(pdev);
772 case INIT_STATE_NONE: 771 case INIT_STATE_NONE:
773 free_mem(cfg); 772 free_mem(cfg);
@@ -840,15 +839,6 @@ static int init_pci(struct cxlflash_cfg *cfg)
840 struct pci_dev *pdev = cfg->dev; 839 struct pci_dev *pdev = cfg->dev;
841 int rc = 0; 840 int rc = 0;
842 841
843 cfg->cxlflash_regs_pci = pci_resource_start(pdev, 0);
844 rc = pci_request_regions(pdev, CXLFLASH_NAME);
845 if (rc < 0) {
846 dev_err(&pdev->dev,
847 "%s: Couldn't register memory range of registers\n",
848 __func__);
849 goto out;
850 }
851
852 rc = pci_enable_device(pdev); 842 rc = pci_enable_device(pdev);
853 if (rc || pci_channel_offline(pdev)) { 843 if (rc || pci_channel_offline(pdev)) {
854 if (pci_channel_offline(pdev)) { 844 if (pci_channel_offline(pdev)) {
@@ -860,55 +850,13 @@ static int init_pci(struct cxlflash_cfg *cfg)
860 dev_err(&pdev->dev, "%s: Cannot enable adapter\n", 850 dev_err(&pdev->dev, "%s: Cannot enable adapter\n",
861 __func__); 851 __func__);
862 cxlflash_wait_for_pci_err_recovery(cfg); 852 cxlflash_wait_for_pci_err_recovery(cfg);
863 goto out_release_regions; 853 goto out;
864 }
865 }
866
867 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
868 if (rc < 0) {
869 dev_dbg(&pdev->dev, "%s: Failed to set 64 bit PCI DMA mask\n",
870 __func__);
871 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
872 }
873
874 if (rc < 0) {
875 dev_err(&pdev->dev, "%s: Failed to set PCI DMA mask\n",
876 __func__);
877 goto out_disable;
878 }
879
880 pci_set_master(pdev);
881
882 if (pci_channel_offline(pdev)) {
883 cxlflash_wait_for_pci_err_recovery(cfg);
884 if (pci_channel_offline(pdev)) {
885 rc = -EIO;
886 goto out_msi_disable;
887 } 854 }
888 } 855 }
889 856
890 rc = pci_save_state(pdev);
891
892 if (rc != PCIBIOS_SUCCESSFUL) {
893 dev_err(&pdev->dev, "%s: Failed to save PCI config space\n",
894 __func__);
895 rc = -EIO;
896 goto cleanup_nolog;
897 }
898
899out: 857out:
900 pr_debug("%s: returning rc=%d\n", __func__, rc); 858 pr_debug("%s: returning rc=%d\n", __func__, rc);
901 return rc; 859 return rc;
902
903cleanup_nolog:
904out_msi_disable:
905 cxlflash_wait_for_pci_err_recovery(cfg);
906out_disable:
907 pci_disable_device(pdev);
908out_release_regions:
909 pci_release_regions(pdev);
910 goto out;
911
912} 860}
913 861
914/** 862/**