From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382020; b=zTNu3KchWzrE7AcyEnBNGebPsY4ZB432B+HwnfiuErca1j3ZP+Jznfms8novHnXO0Z0d iXqeOQovbp23aBfNkbqNwJfPfdR2if2A7uc0fdOxKrepzmvlzNmJiWGO+C4RMteE+oVw7 3gG0Mq0jkzxHGLmE/VwNeIB5EhCFjIxPCLr5xs2ZkJRJhyuPKgPzJwvpFbFOoiEYbGq/P kuXNT3s3PuesswNhXb1WR4YzbubDYPlld40d/76fq1l4sILQJGFSaTGQyQcl9DFMfOxBH qC6P7p772sd8XRVi1hJa/u4QN4fSMlaWgPcT+OlmnPeCP2fq7DX/fRxNGO4fLDdNuLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382020; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=egu73xr7vfd/4Lzv8qfADdooUf1ZP07W0sUpNYRem7c=; b=m+geYaTgmGZAyBc59dv9Pdq7rBzb0mBWl24f7uORHleaK69gb6qMoR9LGeq4gTqqF4iS hs5QcK5+65c1uzILdMFKWjhABThLcS9aH1DKyVdBh+mVgB+flRHefad0C2UKBsjUqhTOw kTy9dSKjshn8tF4xIjcdZ+UXGTDzf4pmjnDXrqtCBjoCXu/SsN2CBaH41ylBz6DOuUt8z g6ZJ8lnGwDG6TF9PyYUgBAshQG6/uauZ+gAL0+osn/y6UCqj3WzRJWbS7nDsPLLpaQAPp EEFREQ/UNu+oqhubynJadAe9n07vm2HAb6JFbESEF5V7Rg2YHpTi3CqzDozJEkR4vtw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=o7Cs9yc+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 246B0606A335; Fri, 4 Dec 2026 11:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=o7Cs9yc+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 570091F000C2; Fri, 4 Dec 2026 11:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382019; bh=egu73xr7vfd/4Lzv8qfADdooUf1ZP07W0sUpNYRem7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o7Cs9yc+Qhxkiv++kKz0YFB1QcSodOhNSIu8xov1II6RxaGYiDggdV5vChw1Zerpg IUscD0Mq/yIJKbC+kd1G7Ih3LyVkWOY/rawuOJrphuwHm+6Q0OVyJnGUaaU9tT+Wyi d6feMWxkgMlFN1Ym7lkPWVMaF5KGrybnzEO7Rilc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karthik Poosa , "Michael J. Ruhl" , Rodrigo Vivi , Matthew Brost , Sasha Levin Subject: [PATCH 6.18 271/703] drm/xe/hwmon: Unregister hwmon before the device is unplugged Date: Fri, 4 Dec 2026 19:02:50 +0900 Message-ID: <20261204100634.989547650@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rodrigo Vivi [ Upstream commit 72296e02b46a34e52c8b97c5ebf95c2a970373fd ] hwmon was registered with devm, so its sysfs attributes stayed reachable after drm_dev_unplug() until devres teardown. A reader in that window accesses an unplugged device, e.g. the PMT energy read on BMG. Unregister it explicitly in xe_device_remove() and in the probe error path, before the device is unplugged. Removing the attributes waits for in-flight reads, so none can run afterwards. Cc: Karthik Poosa Cc: Michael J. Ruhl Reviewed-by: Michael J. Ruhl Fixes: fb1b70607f73 ("drm/xe/hwmon: Expose power attributes") Link: https://patch.msgid.link/20261120152753.1346010-2-rodrigo.vivi@intel.com Signed-off-by: Rodrigo Vivi (cherry picked from commit 6bae3d8f569445db5e3385b61efa5f9ba9eed3d3) Signed-off-by: Matthew Brost Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_device.c | 9 ++++++--- drivers/gpu/drm/xe/xe_hwmon.c | 22 +++++++++++++++++++--- drivers/gpu/drm/xe/xe_hwmon.h | 2 ++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 1d5deb149137a..4c5a87c682a0c 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -951,7 +951,7 @@ int xe_device_probe(struct xe_device *xe) err = xe_i2c_probe(xe); if (err) - goto err_unregister_display; + goto err_unregister_hwmon; for_each_gt(gt, xe, id) xe_gt_sanitize_freq(gt); @@ -960,14 +960,16 @@ int xe_device_probe(struct xe_device *xe) err = xe_sriov_init_late(xe); if (err) - goto err_unregister_display; + goto err_unregister_hwmon; err = devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe); if (err) - goto err_unregister_display; + goto err_unregister_hwmon; return 0; +err_unregister_hwmon: + xe_hwmon_unregister(xe); err_unregister_display: xe_display_unregister(xe); drm_dev_unregister(&xe->drm); @@ -977,6 +979,7 @@ int xe_device_probe(struct xe_device *xe) void xe_device_remove(struct xe_device *xe) { + xe_hwmon_unregister(xe); xe_display_unregister(xe); drm_dev_unplug(&xe->drm); diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c index 65621775878b6..a1a78ecd2f554 100644 --- a/drivers/gpu/drm/xe/xe_hwmon.c +++ b/drivers/gpu/drm/xe/xe_hwmon.c @@ -1328,9 +1328,9 @@ int xe_hwmon_register(struct xe_device *xe) drm_dbg(&xe->drm, "Register xe hwmon interface\n"); /* hwmon_dev points to device hwmon */ - hwmon->hwmon_dev = devm_hwmon_device_register_with_info(dev, "xe", hwmon, - &hwmon_chip_info, - hwmon_groups); + hwmon->hwmon_dev = hwmon_device_register_with_info(dev, "xe", hwmon, + &hwmon_chip_info, + hwmon_groups); if (IS_ERR(hwmon->hwmon_dev)) { drm_err(&xe->drm, "Failed to register xe hwmon (%pe)\n", hwmon->hwmon_dev); xe->hwmon = NULL; @@ -1339,4 +1339,20 @@ int xe_hwmon_register(struct xe_device *xe) return 0; } + +/** + * xe_hwmon_unregister - Remove the hwmon interface + * @xe: xe device + * + * Called before the device is unplugged, so that no hwmon attribute can + * be accessed afterwards. + */ +void xe_hwmon_unregister(struct xe_device *xe) +{ + if (!xe->hwmon) + return; + + hwmon_device_unregister(xe->hwmon->hwmon_dev); + xe->hwmon = NULL; +} MODULE_IMPORT_NS("INTEL_PMT_TELEMETRY"); diff --git a/drivers/gpu/drm/xe/xe_hwmon.h b/drivers/gpu/drm/xe/xe_hwmon.h index d02c1bfe8c0a0..e67e0134f02a5 100644 --- a/drivers/gpu/drm/xe/xe_hwmon.h +++ b/drivers/gpu/drm/xe/xe_hwmon.h @@ -12,8 +12,10 @@ struct xe_device; #if IS_REACHABLE(CONFIG_HWMON) int xe_hwmon_register(struct xe_device *xe); +void xe_hwmon_unregister(struct xe_device *xe); #else static inline int xe_hwmon_register(struct xe_device *xe) { return 0; }; +static inline void xe_hwmon_unregister(struct xe_device *xe) { } #endif #endif /* _XE_HWMON_H_ */ -- 2.53.0