s390/pci: add recover sysfs knob
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Thu, 29 Aug 2013 17:35:19 +0000 (19:35 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 30 Aug 2013 06:57:12 +0000 (08:57 +0200)
Add an arch specific attribute to recover a pci function from an
error state or config space blockage.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/pci/pci.c
arch/s390/pci/pci_sysfs.c
drivers/pci/hotplug/s390_pci_hpc.c

index 61167b1209a33a471cd1c4f535271530dacced9a..b0ccd424308a692832f81883fdad13be58848ee4 100644 (file)
@@ -791,6 +791,8 @@ int zpci_enable_device(struct zpci_dev *zdev)
        rc = zpci_dma_init_device(zdev);
        if (rc)
                goto out_dma;
+
+       zdev->state = ZPCI_FN_STATE_ONLINE;
        return 0;
 
 out_dma:
@@ -819,8 +821,6 @@ int zpci_create_device(struct zpci_dev *zdev)
                rc = zpci_enable_device(zdev);
                if (rc)
                        goto out_free;
-
-               zdev->state = ZPCI_FN_STATE_ONLINE;
        }
        rc = zpci_scan_bus(zdev);
        if (rc)
index e99a2557f1865f5c50e246b1e52b08227d2f83f5..cf8a12ff733b3883c6b8f32d626e14a47a173f92 100644 (file)
@@ -48,11 +48,38 @@ static ssize_t show_pfgid(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL);
 
+static void recover_callback(struct device *dev)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct zpci_dev *zdev = get_zdev(pdev);
+       int ret;
+
+       pci_stop_and_remove_bus_device(pdev);
+       ret = zpci_disable_device(zdev);
+       if (ret)
+               return;
+
+       ret = zpci_enable_device(zdev);
+       if (ret)
+               return;
+
+       pci_rescan_bus(zdev->bus);
+}
+
+static ssize_t store_recover(struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
+{
+       int rc = device_schedule_callback(dev, recover_callback);
+       return rc ? rc : count;
+}
+static DEVICE_ATTR(recover, S_IWUSR, NULL, store_recover);
+
 static struct device_attribute *zpci_dev_attrs[] = {
        &dev_attr_function_id,
        &dev_attr_function_handle,
        &dev_attr_pchid,
        &dev_attr_pfgid,
+       &dev_attr_recover,
        NULL,
 };
 
index 0d9c12fbcb3ab1a17db89d5efae0cae5845ed851..66e505ca24ef418a250219789faeb8bd1de8a9be 100644 (file)
@@ -79,8 +79,6 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
        if (rc)
                goto out_deconfigure;
 
-       slot->zdev->state = ZPCI_FN_STATE_ONLINE;
-
        pci_scan_slot(slot->zdev->bus, ZPCI_DEVFN);
        pci_bus_add_devices(slot->zdev->bus);