Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] drm/xe: hardware forcewake drop outside IO protection in send_tlb_inval_ggtt() --
commit e9f023cf84d9700d7a5ded726d95cff381241557 Author: Arvind Yadav <[email protected]> drm/xe: Protect device I/O with DRM device SRCU This commit introduces wrappers around DRM device SRCU to protect device I/O operations. It blocks new access during PCI recovery or when the device is wedged, and drains existing hardware users to safely isolate the device. > diff --git a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c > b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c > --- a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c > +++ b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c [ ... ] > @@ -86,8 +84,13 @@ static int send_tlb_inval_ggtt(struct xe_tlb_inval > *tlb_inval, u32 seqno) > } else if (xe_device_uc_enabled(xe)) { > struct xe_mmio *mmio = >->mmio; > > - if (IS_SRIOV_VF(xe)) > + if (xe_device_io_get(xe, &io_idx)) > + return -ECANCELED; > + > + if (IS_SRIOV_VF(xe)) { > + xe_device_io_put(io_idx); > return -ECANCELED; > + } > > CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GT); > if (xe->info.platform == XE_PVC || GRAPHICS_VER(xe) >= 20) { > @@ -99,6 +102,8 @@ static int send_tlb_inval_ggtt(struct xe_tlb_inval > *tlb_inval, u32 seqno) > xe_mmio_write32(mmio, GUC_TLB_INV_CR, > GUC_TLB_INV_CR_INVALIDATE); > } > + > + xe_device_io_put(io_idx); [Severity: High] Does this code drop the I/O protection before the scoped forcewake destructor runs? The CLASS(xe_force_wake, fw_ref) macro creates a scoped guard whose destructor executes when leaving the block. Because xe_device_io_put(io_idx) is called explicitly right before the closing brace, the I/O protection is released before the forcewake destructor runs. If PCI error recovery or wedge isolation disables the device immediately after xe_device_io_put() returns, the automatically executing fw_ref destructor will perform MMIO writes on a disabled device. This could trigger a PCI Advanced Error Reporting (AER) fault and crash the system. > } > > return -ECANCELED; -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4
