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 27AD1606A31A for ; Wed, 2 Dec 2026 13:19:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SU/va/Ki Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E160310E3F0; Wed, 2 Dec 2026 13:19:35 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD8441121A9 for ; Wed, 2 Dec 2026 13:19:29 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 31B57625C0; Wed, 2 Dec 2026 13:19:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BABE51F00893; Wed, 2 Dec 2026 13:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796217568; bh=ShX4LIULR2nVC6Kc/B74wjtGLj/zYvLwRzBMhdsvBd8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=SU/va/KihWnxOltjLvJkmkLMd6bXxVUF6usv7IhtMnJCB8Cq4Qv7br1NhuqLvUMu4 N/bfQqPbNThmueY0Na2/x40cWkfL8mpGFzQY62/O46XlIFsabT/kXDyPR2rmZgeP7E QcGtwYIT2eSUft6r8DJI3mHSRlRzUxNAjkzeUTVu03EFjEKZDoPOIxqEwYeAQHMe8j wBHpRemUaoyqMeY0dkdiTNUVE7uFlUILlvQGnENSzo8WI5wcTjyllZNZYdiYBbYuYm eiQK51bjFfhGBFbWXh6dgtR65FW68W0Kh3ajNiB3+kAF8w90Isa1R6s6ufLrUYsvBR eX4EEbMAFnDlQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7 09/10] drm/xe/hwmon: Refresh fan data after late binding To: "Karthik Poosa" , intel-xe@lists.freedesktop.org In-Reply-To: <20261202125637.1581881-10-karthik.poosa@intel.com> References: <20261202125637.1581881-1-karthik.poosa@intel.com> <20261202125637.1581881-10-karthik.poosa@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 13:19:28 +0000 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: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] drm/xe/hwmon: fan_late_bind_work aborts on runtime resume in xe_hwmon_resume() - [Medium] drm/xe/hwmon: xe_hwmon_resume() fails to restart fan_late_bind_work after D3hot - [Medium] drm/xe/hwmon: missing cancel_delayed_work_sync() in xe_hwmon_suspend() - [Medium] drm/xe/hwmon: fan_late_bind_work runs on platforms without fan late binding - [Low] drm/xe/hwmon: stale comment in xe_hwmon_register() references removed function -- commit 0eda84b4dad26ab42bb697e17e7063f6bb7ab964 Author: Karthik Poosa drm/xe/hwmon: Refresh fan data after late binding This commit adds a delayed work item in hwmon to poll for fan-control firmware late-binding provisioning after registration and resume, refreshing cached stock fan tables and maximum RPM and re-programming active user fan tables. > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index 2fd6c2c50f2c1..a3ec319e857f2 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c [ ... ] > @@ -2897,13 +2920,20 @@ int xe_hwmon_register(struct xe_device *xe) > for (fan =3D 0; fan < FAN_MAX; fan++) > hwmon->fi[fan].pwm_enable_mode =3D XE_FAN_PWM_UNINITIALIZED; > =20 > - ret =3D devm_mutex_init(dev, &hwmon->hwmon_lock); > + ret =3D drmm_mutex_init(&xe->drm, &hwmon->hwmon_lock); > + if (ret) > + return ret; > + > + ret =3D drmm_mutex_init(&xe->drm, &hwmon->registration_lock); > if (ret) > return ret; > =20 > + guard(mutex)(&hwmon->registration_lock); > + > /* There's only one instance of hwmon per device */ > hwmon->xe =3D xe; > - xe->hwmon =3D hwmon; > + /* Pair with the acquire load in xe_hwmon_fan_late_binding_update(). */ > + smp_store_release(&xe->hwmon, hwmon); [Severity: Low] This isn't a bug, but the comment above smp_store_release() refers to xe_hwmon_fan_late_binding_update(), which was removed in v6, and the remain= ing loads of xe->hwmon use READ_ONCE() rather than smp_load_acquire(). > @@ -2926,11 +2956,15 @@ int xe_hwmon_register(struct xe_device *xe) > xe_log_err(xe, HWMON, ret, "Failed to register xe hwmon\n"); > goto err_null_hwmon; > } > + if (xe->info.has_fan_control) { > + hwmon->fan_late_bind_poll_count =3D 0; > + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work, 0); > + } [Severity: Medium] Should this and xe_hwmon_resume() also check xe->info.late_bind_mask & BIT(XE_LB_FW_FAN_CONTROL) before queuing fan_late_bind_work? Platforms like DG2 set has_fan_control =3D true with late_bind_mask =3D 0. = On those platforms, PCODE_LATE_BINDING fails with an illegal command error in xe_pcode_read(), and because ret is non-zero, xe_hwmon_fan_late_bind_work() falls through and retries 30 times, logging 30 PCODE errors on probe and on every resume. [ ... ] > @@ -3035,6 +3085,13 @@ void xe_hwmon_resume(struct xe_device *xe, bool ru= ntime) > return; > } > =20 > + mutex_lock(&hwmon->registration_lock); > + if (READ_ONCE(xe->hwmon) =3D=3D hwmon) { > + hwmon->fan_late_bind_poll_count =3D 0; > + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work, 0); > + } > + mutex_unlock(&hwmon->registration_lock); [Severity: Medium] If the device enters D3hot runtime suspend (!xe->d3cold.allowed) during the 1-second polling window before V1_FAN_PROVISIONED is seen, will fan_late_bind_work stop without ever being restarted? When suspended in D3hot, xe_hwmon_fan_late_bind_work() sees !xe_pm_runtime_get_if_active(xe) and returns without rescheduling. On the subsequent runtime resume from D3hot, xe_hwmon_resume() returns early at the if (runtime && !xe->d3cold.allowed) check right above this hunk, leaving the stock fan tables and max_rps unrefreshed and active user fan tables un-reprogrammed. [ ... ] > +static void xe_hwmon_fan_late_bind_work(struct work_struct *work) > +{ > + struct xe_hwmon *hwmon =3D container_of(to_delayed_work(work), > + struct xe_hwmon, fan_late_bind_work); > + struct xe_device *xe =3D hwmon->xe; > + u32 status =3D 0; > + int ret; > + > + if (!xe_pm_runtime_get_if_active(xe)) > + return; [Severity: Medium] Can fan_late_bind_work abort permanently on runtime resume from D3cold? xe_pm_runtime_resume() calls xe_hwmon_resume(xe, true) from inside the driv= er runtime_resume callback while dev->power.runtime_status is still RPM_RESUMI= NG. xe_hwmon_resume() queues fan_late_bind_work with delay 0 and then performs synchronous PCODE mailbox writes before returning to rpm_resume(): CPU0 CPU1 (system_wq) rpm_resume() runtime_status =3D RPM_RESUMING xe_pci_runtime_resume() xe_pm_runtime_resume() xe_hwmon_resume() mod_delayed_work(..., 0) xe_hwmon_fan_late_bind_work() xe_pm_runtime_get_if_active(xe) /* runtime_status !=3D RPM_ACTIVE= */ return; <-- polling stops xe_pcode_write(...) runtime_status =3D RPM_ACTIVE Because pm_runtime_get_if_active() requires runtime_status =3D=3D RPM_ACTIV= E, the worker exits without polling or rescheduling, so the fan tables and max_rps are not refreshed after the late-binding firmware reload finishes. > + > + ret =3D xe_pcode_read(xe_device_get_root_tile(xe), > + PCODE_MBOX(PCODE_LATE_BINDING, GET_CAPABILITY_STATUS, 0), > + &status, NULL); > + if (!ret && !(status & V1_FAN_SUPPORTED)) > + goto out; > + > + if (!ret && (status & V1_FAN_PROVISIONED)) { > + xe_hwmon_refresh_fan_data(hwmon); > + goto out; > + } > + > + mutex_lock(&hwmon->registration_lock); > + if (READ_ONCE(xe->hwmon) =3D=3D hwmon && > + ++hwmon->fan_late_bind_poll_count < XE_FAN_LATE_BIND_POLL_RETRIES) > + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work, > + XE_FAN_LATE_BIND_POLL_INTERVAL); > + else if (READ_ONCE(xe->hwmon) =3D=3D hwmon) > + xe_dbg(xe, "timed out waiting for fan firmware provisioning\n"); > + mutex_unlock(&hwmon->registration_lock); > +out: > + xe_pm_runtime_put(xe); > +} [Severity: Medium] Should xe_hwmon_suspend() cancel fan_late_bind_work synchronously, the way xe_late_bind_pm_suspend() flushes late-binding work? During system suspend (throughout dpm_suspend, where __xe_pci_suspend() disables the PCI device and puts it in PCI_D3cold before dpm_suspend_late disables runtime PM) and during PCIe FLR (xe_pci_reset_prepare() -> xe_device_suspend()), dev->power.runtime_status remains RPM_ACTIVE with disable_depth =3D=3D 0. If a pending fan_late_bind_work fires after xe_hwmon_suspend(), xe_pm_runtime_get_if_active(xe) returns true and the worker issues PCODE MMIO accesses to a disabled or resetting PCI device, an= d a failed xe_hwmon_activate_user_fan_table() will fall back to xe_hwmon_fan_set_auto() and overwrite the saved fi->pwm_enable_mode before xe_hwmon_resume(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202125637.1581= 881-1-karthik.poosa@intel.com?part=3D9