Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: add zpci_event_hard_deconfigured()

Extract the handling of PEC 0x0304 into a function and make sure we only
attempt to disable the function if it is enabled. Also check for errors
returned by zpci_disable_device() and leave the function alone if there
are any.

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>

authored by

Niklas Schnelle and committed by
Heiko Carstens
dee60c0d a9045c22

+24 -15
+24 -15
arch/s390/pci/pci_event.c
··· 73 73 __zpci_event_error(data); 74 74 } 75 75 76 + static void zpci_event_hard_deconfigured(struct zpci_dev *zdev, u32 fh) 77 + { 78 + enum zpci_state state; 79 + int rc; 80 + 81 + zdev->fh = fh; 82 + /* Give the driver a hint that the function is 83 + * already unusable. 84 + */ 85 + zpci_remove_device(zdev, true); 86 + if (zdev_enabled(zdev)) { 87 + rc = zpci_disable_device(zdev); 88 + if (rc) 89 + return; 90 + } 91 + zdev->state = ZPCI_FN_STATE_STANDBY; 92 + if (!clp_get_state(zdev->fid, &state) && 93 + state == ZPCI_FN_STATE_RESERVED) { 94 + zpci_zdev_put(zdev); 95 + } 96 + } 97 + 76 98 static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) 77 99 { 78 100 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 79 - enum zpci_state state; 80 101 struct pci_dev *pdev; 81 102 int ret; 82 103 ··· 155 134 156 135 break; 157 136 case 0x0304: /* Configured -> Standby|Reserved */ 158 - if (!zdev) 159 - break; 160 - /* Give the driver a hint that the function is 161 - * already unusable. 162 - */ 163 - zpci_remove_device(zdev, true); 164 - 165 - zdev->fh = ccdf->fh; 166 - zpci_disable_device(zdev); 167 - zdev->state = ZPCI_FN_STATE_STANDBY; 168 - if (!clp_get_state(ccdf->fid, &state) && 169 - state == ZPCI_FN_STATE_RESERVED) { 170 - zpci_zdev_put(zdev); 171 - } 137 + if (zdev) 138 + zpci_event_hard_deconfigured(zdev, ccdf->fh); 172 139 break; 173 140 case 0x0306: /* 0x308 or 0x302 for multiple devices */ 174 141 zpci_remove_reserved_devices();