aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/pci/pci.c
diff options
context:
space:
mode:
authorNiklas Schnelle <schnelle@linux.ibm.com>2021-07-22 11:44:08 +0200
committerHeiko Carstens <hca@linux.ibm.com>2021-08-25 11:03:33 +0200
commitcc049eecfb7adc4bfecd05eb25e425d8def96fce (patch)
tree9a5b659a0fbef8b3615b0ec61fa0a4b9d3527e60 /arch/s390/pci/pci.c
parents390/pci: handle FH state mismatch only on disable (diff)
downloadlinux-dev-cc049eecfb7adc4bfecd05eb25e425d8def96fce.tar.xz
linux-dev-cc049eecfb7adc4bfecd05eb25e425d8def96fce.zip
s390/pci: simplify CLP List PCI handling
Currently clp_get_state() and clp_refresh_fh() awkwardly use the clp_list_pci() callback mechanism to find the entry for a specific FID and update its zdev, respectively return its state. This is both needlessly complex and means we are always going through the entire PCI function list even if the FID has already been found. Instead lets introduce a clp_find_pci() function to find a specific entry and share the CLP List PCI request handling code with clp_list_pci(). With that in place we can also easily make the function handle a simple out parameter instead of directly altering the zdev allowing easier access to the updated function handle by the caller. Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/pci/pci.c')
-rw-r--r--arch/s390/pci/pci.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 6be5ee320194..b05b86e2d2c0 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -653,12 +653,14 @@ void zpci_free_domain(int domain)
int zpci_enable_device(struct zpci_dev *zdev)
{
+ u32 fh = zdev->fh;
int rc;
- if (clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES)) {
+ if (clp_enable_fh(zdev, &fh, ZPCI_NR_DMA_SPACES)) {
rc = -EIO;
goto out;
}
+ zdev->fh = fh;
rc = zpci_dma_init_device(zdev);
if (rc)
@@ -667,29 +669,33 @@ int zpci_enable_device(struct zpci_dev *zdev)
return 0;
out_dma:
- clp_disable_fh(zdev);
+ clp_disable_fh(zdev, &fh);
out:
+ zdev->fh = fh;
return rc;
}
int zpci_disable_device(struct zpci_dev *zdev)
{
+ u32 fh = zdev->fh;
int cc, rc = 0;
zpci_dma_exit_device(zdev);
- /*
- * The zPCI function may already be disabled by the platform, this is
- * detected in clp_disable_fh() which becomes a no-op.
- */
- cc = clp_disable_fh(zdev);
- if (cc == CLP_RC_SETPCIFN_ALRDY) {
+ if (!zdev_enabled(zdev))
+ return 0;
+ cc = clp_disable_fh(zdev, &fh);
+ if (!cc) {
+ zdev->fh = fh;
+ } else if (cc == CLP_RC_SETPCIFN_ALRDY) {
pr_info("Disabling PCI function %08x had no effect as it was already disabled\n",
zdev->fid);
/* Function is already disabled - update handle */
- rc = clp_refresh_fh(zdev->fid);
- if (!rc)
+ rc = clp_refresh_fh(zdev->fid, &fh);
+ if (!rc) {
+ zdev->fh = fh;
rc = -EINVAL;
- } else if (cc) {
+ }
+ } else {
rc = -EIO;
}
return rc;