diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index c454dfb9fc4b34d3d0b0490da4e3bef0325c44fa..35dec33c28017d5047790f9828c6c72e530abc69 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -201,7 +201,6 @@ extern unsigned int s390_pci_no_rid; ----------------------------------------------------------------------------- */ /* Base stuff */ int zpci_create_device(u32 fid, u32 fh, enum zpci_state state); -void zpci_remove_device(struct zpci_dev *zdev, bool set_error); int zpci_enable_device(struct zpci_dev *); int zpci_disable_device(struct zpci_dev *); int zpci_configure_device(struct zpci_dev *zdev, u32 fh); diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 6d84ec8f1dd6001333c43a7172e114b02b231d65..dd14641b2d20bfdf46b5504ea45e449deeed1cd8 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -679,39 +679,6 @@ int zpci_disable_device(struct zpci_dev *zdev) return clp_disable_fh(zdev); } -/* zpci_remove_device - Removes the given zdev from the PCI core - * @zdev: the zdev to be removed from the PCI core - * @set_error: if true the device's error state is set to permanent failure - * - * Sets a zPCI device to a configured but offline state; the zPCI - * device is still accessible through its hotplug slot and the zPCI - * API but is removed from the common code PCI bus, making it - * no longer available to drivers. - */ -void zpci_remove_device(struct zpci_dev *zdev, bool set_error) -{ - struct zpci_bus *zbus = zdev->zbus; - struct pci_dev *pdev; - - if (!zdev->zbus->bus) - return; - - pdev = pci_get_slot(zbus->bus, zdev->devfn); - if (pdev) { - if (set_error) - pdev->error_state = pci_channel_io_perm_failure; - if (pdev->is_virtfn) { - zpci_iov_remove_virtfn(pdev, zdev->vfn); - /* balance pci_get_slot */ - pci_dev_put(pdev); - return; - } - pci_stop_and_remove_bus_device_locked(pdev); - /* balance pci_get_slot */ - pci_dev_put(pdev); - } -} - /** * zpci_create_device() - Create a new zpci_dev and add it to the zbus * @fid: Function ID of the device to be created @@ -847,7 +814,7 @@ int zpci_deconfigure_device(struct zpci_dev *zdev) int rc; if (zdev->zbus->bus) - zpci_remove_device(zdev, false); + zpci_bus_remove_device(zdev, false); if (zdev_enabled(zdev)) { rc = zpci_disable_device(zdev); @@ -870,7 +837,7 @@ void zpci_release_device(struct kref *kref) int ret; if (zdev->zbus->bus) - zpci_remove_device(zdev, false); + zpci_bus_remove_device(zdev, false); if (zdev_enabled(zdev)) zpci_disable_device(zdev); diff --git a/arch/s390/pci/pci_bus.c b/arch/s390/pci/pci_bus.c index 755b46f4c5954cde51148496be6e745fd23dab8c..ace9dbbe3bc1487f7239456a45a86a2e4525ab89 100644 --- a/arch/s390/pci/pci_bus.c +++ b/arch/s390/pci/pci_bus.c @@ -30,6 +30,39 @@ static LIST_HEAD(zbus_list); static DEFINE_SPINLOCK(zbus_list_lock); static int zpci_nb_devices; +/* zpci_bus_remove_device - Removes the given zdev from the PCI core + * @zdev: the zdev to be removed from the PCI core + * @set_error: if true the device's error state is set to permanent failure + * + * Sets a zPCI device to a configured but offline state; the zPCI + * device is still accessible through its hotplug slot and the zPCI + * API but is removed from the common code PCI bus, making it + * no longer available to drivers. + */ +void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error) +{ + struct zpci_bus *zbus = zdev->zbus; + struct pci_dev *pdev; + + if (!zdev->zbus->bus) + return; + + pdev = pci_get_slot(zbus->bus, zdev->devfn); + if (pdev) { + if (set_error) + pdev->error_state = pci_channel_io_perm_failure; + if (pdev->is_virtfn) { + zpci_iov_remove_virtfn(pdev, zdev->vfn); + /* balance pci_get_slot */ + pci_dev_put(pdev); + return; + } + pci_stop_and_remove_bus_device_locked(pdev); + /* balance pci_get_slot */ + pci_dev_put(pdev); + } +} + /* zpci_bus_scan * @zbus: the zbus holding the zdevices * @ops: the pci operations diff --git a/arch/s390/pci/pci_bus.h b/arch/s390/pci/pci_bus.h index f8dfac0b5b7134227e6707c0ec7ec2bf15e1218b..e04ca06a71b646ae0a17fe983e0d108988ecfdcd 100644 --- a/arch/s390/pci/pci_bus.h +++ b/arch/s390/pci/pci_bus.h @@ -10,6 +10,8 @@ int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops); void zpci_bus_device_unregister(struct zpci_dev *zdev); +void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error); + void zpci_release_device(struct kref *kref); static inline void zpci_zdev_put(struct zpci_dev *zdev) { diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index 2676df9816f005669da66398c7198c203eacf334..9455c5be88200e511da6ec45512bedf8590700b3 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -82,7 +82,7 @@ static void zpci_event_hard_deconfigured(struct zpci_dev *zdev, u32 fh) /* Give the driver a hint that the function is * already unusable. */ - zpci_remove_device(zdev, true); + zpci_bus_remove_device(zdev, true); if (zdev_enabled(zdev)) { rc = zpci_disable_device(zdev); if (rc)