@@ -106,6 +106,10 @@ static pci_ers_result_t zpci_event_do_error_state_clear(struct pci_dev *pdev,
106106 struct zpci_dev * zdev = to_zpci (pdev );
107107 int rc ;
108108
109+ /* The underlying device may have been disabled by the event */
110+ if (!zdev_enabled (zdev ))
111+ return PCI_ERS_RESULT_NEED_RESET ;
112+
109113 pr_info ("%s: Unblocking device access for examination\n" , pci_name (pdev ));
110114 rc = zpci_reset_load_store_blocked (zdev );
111115 if (rc ) {
@@ -273,6 +277,8 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
273277 struct zpci_dev * zdev = get_zdev_by_fid (ccdf -> fid );
274278 struct pci_dev * pdev = NULL ;
275279 pci_ers_result_t ers_res ;
280+ u32 fh = 0 ;
281+ int rc ;
276282
277283 zpci_dbg (3 , "err fid:%x, fh:%x, pec:%x\n" ,
278284 ccdf -> fid , ccdf -> fh , ccdf -> pec );
@@ -281,6 +287,15 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
281287
282288 if (zdev ) {
283289 mutex_lock (& zdev -> state_lock );
290+ rc = clp_refresh_fh (zdev -> fid , & fh );
291+ if (rc )
292+ goto no_pdev ;
293+ if (!fh || ccdf -> fh != fh ) {
294+ /* Ignore events with stale handles */
295+ zpci_dbg (3 , "err fid:%x, fh:%x (stale %x)\n" ,
296+ ccdf -> fid , fh , ccdf -> fh );
297+ goto no_pdev ;
298+ }
284299 zpci_update_fh (zdev , ccdf -> fh );
285300 if (zdev -> zbus -> bus )
286301 pdev = pci_get_slot (zdev -> zbus -> bus , zdev -> devfn );
0 commit comments