From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98908606A31A for ; Tue, 1 Dec 2026 13:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gSnWloug Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E61910E3A2; Tue, 1 Dec 2026 13:23:40 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4953210E3A2 for ; Tue, 1 Dec 2026 13:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796131414; x=1827667414; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=VY06o7otJaXkQERw0siqBns85xjjzPsDoplpLfy/MJE=; b=gSnWlougmMobWS+cAWbZhPWtQpzpKR0qZpuGlHrJCp5GKopfabqtrbnJ wTC8VoMpRSocilzyRPj5ix+jwEB1QJ4dwLT7uUdvuCuv4p45/NkC9pAT7 hFb58GrL0Av01xt/78TpOOULH+koeyH70jFkVt0NeN6NaX0Zc6zzgjQ82 OXGY0Y1cnd2jWlhzsDUBmiyzW6W/JaBIrNj0SOMc12646HwQDqLOM4IsS CRHg7AeCBsJR9iGScTCopZv5BtkRbW+meLqGXvPjmIGpEBZipoSzdvgBj C0llgPjs/OXlcYTyrbljC1PUTj/wF9QnIspaIv+y+3di4ebaxY+gPsBmb g==; X-CSE-ConnectionGUID: nhznwxE7S069m0QxjPOaDw== X-CSE-MsgGUID: ULbd2fi5T+2armY8QEWTqw== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4972710" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="4972710" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 05:23:34 -0800 X-CSE-ConnectionGUID: jn4WjzRTRzytokjXI3cqQw== X-CSE-MsgGUID: o2uf6ruMQ6W+a99xwXWhJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13562611" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa008.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 05:23:31 -0800 Date: Tue, 1 Dec 2026 14:23:29 +0100 From: Raag Jadav To: Riana Tauro Cc: intel-xe@lists.freedesktop.org, anshuman.gupta@intel.com, aravind.iddamsetty@linux.intel.com, badal.nilawar@intel.com, ravi.kishore.koppuravuri@intel.com, mallesh.koujalagi@intel.com, soham.purkait@intel.com, tejas.upadhyay@intel.com Subject: Re: [PATCH v5 4/4] drm/xe/ras: Serialize RAS workers on an ordered workqueue Message-ID: References: <20261201094549.3158286-6-riana.tauro@intel.com> <20261201094549.3158286-10-riana.tauro@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201094549.3158286-10-riana.tauro@intel.com> X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, Dec 01, 2026 at 03:15:54PM +0530, Riana Tauro wrote: > The sysctrl event worker and the per-tile hw error workers are scheduled > on the system workqueue and can run concurrently. > > The page offline flow is not atomic. The soft-offlining in > xe_ttm_vram_handle_addr_fault() and firmware action are separate steps. > Two workers handling the same address can both see the page as not yet > offlined and send a duplicate or out-of-order firmware command. > > Teardown had a similar problem. devres runs ras_fini() before > sysctrl_fini() disables the sysctrl worker, so a worker queued before > the IRQ was uninstalled can store into offlined_pages after > xa_destroy(), leaking XArray nodes. > > Add an ordered RAS workqueue and queue both workers on it, so that RAS > workers do not run concurrently. Destroy the workqueue in ras_fini() > before destroying offlined_pages. By then the IRQ is uninstalled, > so draining the queue guarantees no worker touches RAS state afterwards. > > Also flush the RAS workqueue on suspend, after interrupts are disabled, > so no RAS worker runs across suspend or FLR. > > Suggested-by: Raag Jadav > Signed-off-by: Riana Tauro > --- > drivers/gpu/drm/xe/xe_device.c | 1 + > drivers/gpu/drm/xe/xe_hw_error.c | 7 ++++--- > drivers/gpu/drm/xe/xe_ras.c | 28 +++++++++++++++++++++++----- > drivers/gpu/drm/xe/xe_ras.h | 1 + > drivers/gpu/drm/xe/xe_ras_types.h | 2 ++ > drivers/gpu/drm/xe/xe_sysctrl.c | 2 +- > 6 files changed, 32 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index 36693df65594..b7e0d89e1b04 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -1452,6 +1452,7 @@ int xe_device_suspend(struct xe_device *xe, bool hibernate, bool flr) > } > > xe_irq_suspend(xe); > + xe_ras_suspend(xe); > > if (flr) { > unmap_mapping_range(xe->drm.anon_inode->i_mapping, 0, 0, 1); > diff --git a/drivers/gpu/drm/xe/xe_hw_error.c b/drivers/gpu/drm/xe/xe_hw_error.c > index 86b29f282837..7bf3f5688825 100644 > --- a/drivers/gpu/drm/xe/xe_hw_error.c > +++ b/drivers/gpu/drm/xe/xe_hw_error.c > @@ -227,7 +227,7 @@ static void csc_hw_error_handler(struct xe_tile *tile, const enum hardware_error > hec_uncorrected_fw_errors[err_bit], severity_str, > err_bit); > > - schedule_work(&tile->hw_error_work); > + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work); > } > } > > @@ -461,7 +461,7 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er > */ > if (xe->info.has_sysctrl) { > drm_err_ratelimited(&xe->drm, HW_ERR "Non-fatal %s reported\n", severity_str); > - schedule_work(&tile->hw_error_work); > + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work); > return; > } > > @@ -533,10 +533,11 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er > */ > void xe_hw_error_irq_handler(struct xe_tile *tile, const u32 master_ctl) > { > + struct xe_device *xe = tile_to_xe(tile); > enum hardware_error hw_err; > > if (xe_fault_csc_hw_error()) > - schedule_work(&tile->hw_error_work); > + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work); > > for (hw_err = 0; hw_err < HARDWARE_ERROR_MAX; hw_err++) { > if (master_ctl & ERROR_IRQ(hw_err)) > diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c > index febd151c92f0..4730b0abdbb9 100644 > --- a/drivers/gpu/drm/xe/xe_ras.c > +++ b/drivers/gpu/drm/xe/xe_ras.c > @@ -1448,8 +1448,11 @@ static const struct attribute_group gpu_health_group = { > static void ras_fini(void *arg) > { > struct xe_device *xe = arg; > + struct xe_ras_state *state = &xe->ras.state; > > - xa_destroy(&xe->ras.state.offlined_pages); > + destroy_workqueue(state->ras_wq); > + if (xe->info.has_sysctrl) > + xa_destroy(&state->offlined_pages); Don't complicate things. Split all the page offline stuff into its own init and have its own devm action. > } > > /** > @@ -1494,6 +1497,17 @@ void xe_ras_set_aer_internal_error(struct xe_device *xe) > xe->ras.state.aer_internal_error = true; > } > > +/** > + * xe_ras_suspend() - Flush workqueue > + * @xe: xe device instance > + * > + * Flush the RAS workqueue. > + */ > +void xe_ras_suspend(struct xe_device *xe) > +{ > + flush_workqueue(xe->ras.state.ras_wq); > +} > + > /** > * xe_ras_init - Initialize Xe RAS > * @xe: xe device instance > @@ -1509,6 +1523,14 @@ int xe_ras_init(struct xe_device *xe) > > xe_drm_ras_init(xe); > > + state->ras_wq = alloc_ordered_workqueue("xe-ras-wq", 0); > + if (!state->ras_wq) > + return -ENOMEM; > + > + ret = devm_add_action_or_reset(xe->drm.dev, ras_fini, xe); > + if (ret) > + return ret; > + > if (!xe->info.has_sysctrl) > return 0; > > @@ -1524,10 +1546,6 @@ int xe_ras_init(struct xe_device *xe) > > xa_init(&state->offlined_pages); > > - ret = devm_add_action_or_reset(xe->drm.dev, ras_fini, xe); > - if (ret) > - return ret; > - > /* Fetch the offline list before queue to avoid duplication */ > ret = get_offline_list(xe); > if (ret == -ENOTRECOVERABLE) > diff --git a/drivers/gpu/drm/xe/xe_ras.h b/drivers/gpu/drm/xe/xe_ras.h > index 18531f172695..5ec8eb692efe 100644 > --- a/drivers/gpu/drm/xe/xe_ras.h > +++ b/drivers/gpu/drm/xe/xe_ras.h > @@ -33,4 +33,5 @@ u32 xe_ras_drain_info_queue(struct xe_device *xe, > u8 *dest_buf, u32 dest_size); > bool xe_ras_is_aer_internal_error(struct xe_device *xe); > void xe_ras_set_aer_internal_error(struct xe_device *xe); > +void xe_ras_suspend(struct xe_device *xe); > #endif > diff --git a/drivers/gpu/drm/xe/xe_ras_types.h b/drivers/gpu/drm/xe/xe_ras_types.h > index 80f5d46d2dc2..1e327c9270f8 100644 > --- a/drivers/gpu/drm/xe/xe_ras_types.h > +++ b/drivers/gpu/drm/xe/xe_ras_types.h > @@ -536,5 +536,7 @@ struct xe_ras_state { > u32 max_pages; > /** @offlined_pages: XArray of pages offlined by firmware */ > struct xarray offlined_pages; > + /** @ras_wq: Workqueue for serializing RAS workers */ > + struct workqueue_struct *ras_wq; Nit: It's already part of ras state, just make it 'wq'. Raag > }; > #endif > diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c > index d362e8156fca..e1c057a50e7d 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl.c > +++ b/drivers/gpu/drm/xe/xe_sysctrl.c > @@ -122,7 +122,7 @@ void xe_sysctrl_irq_handler(struct xe_device *xe, u32 master_ctl) > return; > > if (master_ctl & SYSCTRL_IRQ) > - schedule_work(&sc->work); > + queue_work(xe->ras.state.ras_wq, &sc->work); > } > > /** > -- > 2.47.1 >