From: lyude@redhat.com
To: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>,
linux-kernel@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org,
Danilo Krummrich <dakr@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Mary Guillemard <mary@mary.zone>,
Milos Tijanic <mtijanic@nvidia.com>,
nouveau@lists.freedesktop.org
Subject: Re: [PATCH 3/6] drm/nouveau: add GSP hwmon support
Date: Tue, 21 Jul 2026 14:36:11 -0400 [thread overview]
Message-ID: <78ca5c308ce81465956e839c82e1bba46a9f0686.camel@redhat.com> (raw)
In-Reply-To: <20260714211429.238355-4-mohamedahmedegypt2001@gmail.com>
On Wed, 2026-07-15 at 01:14 +0400, Mohamed Ahmed wrote:
> +static int
> +nouveau_power_read(struct device *dev, u32 attr, int channel, long
> *val)
> +{
> + struct drm_device *drm_dev = dev_get_drvdata(dev);
> + struct nouveau_drm *drm = nouveau_drm(drm_dev);
> + struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
> + struct nvkm_device *device = drm->nvkm;
> + struct nvkm_gsp *gsp = device->gsp;
> +
> + if (nvkm_gsp_rusd(gsp))
> + return nouveau_rusd_power_read(drm_dev, gsp, attr,
> channel, val);
IMO - let's add braces to this conditional
> + else {
> + if (!iccsense)
> + return -EOPNOTSUPP;
> +
> + switch (attr) {
> + case hwmon_power_input:
> + if (drm_dev->switch_power_state !=
> DRM_SWITCH_POWER_ON)
> + return -EINVAL;
> + *val = nvkm_iccsense_read_all(iccsense);
> + break;
> + case hwmon_power_max:
> + *val = iccsense->power_w_max;
> + break;
> + case hwmon_power_crit:
> + *val = iccsense->power_w_crit;
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + return 0;
> + }
> +}
> +
...
> static int
> nouveau_temp_write(struct device *dev, u32 attr, int channel, long
> val)
> {
> @@ -667,13 +854,39 @@ nouveau_hwmon_init(struct drm_device *dev)
> struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
> struct nvkm_therm *therm = nvxx_therm(drm);
> struct nvkm_volt *volt = nvxx_volt(drm);
> + struct nvkm_device *device = drm->nvkm;
> + struct nvkm_gsp *gsp = device->gsp;
> const struct attribute_group *special_groups[N_ATTR_GROUPS];
> struct nouveau_hwmon *hwmon;
> struct device *hwmon_dev;
> + bool rusd_active = false;
> int ret = 0;
> int i = 0;
>
> - if (!iccsense && !therm && !volt) {
> + if (nvkm_gsp_rusd(gsp)) {
> + /* Per-channel visibility is latched below from live
> RUSD
> + * section validity, so wait for GSP-RM's first poll
> of both
> + * requested groups (thermal, power). It is normally
> completed
> + * long before we get here and this is a last
> resort.
> + */
> + unsigned long timeout = jiffies +
> + msecs_to_jiffies(2 * gsp->rusd.poll_ms);
> + bool thermal, power;
> +
> + for (;;) {
> + thermal = nouveau_rusd_ok(gsp,
> NVKM_GSP_RUSD_TEMP_GPU);
> + power = nouveau_rusd_ok(gsp,
> NVKM_GSP_RUSD_POWER_GPU) ||
> + nouveau_rusd_ok(gsp,
> NVKM_GSP_RUSD_POWER_GPU_AVG) ||
> + nouveau_rusd_ok(gsp,
> NVKM_GSP_RUSD_POWER_CAP);
> + if ((thermal && power) ||
> !time_before(jiffies, timeout))
> + break;
> + msleep(20);
> + }
Is it possible to use nvif_msec() here?
> +
> + rusd_active = thermal || power;
> + }
> +
> + if (!iccsense && !therm && !volt && !rusd_active) {
> NV_DEBUG(drm, "Skipping hwmon registration\n");
> return 0;
> }
next prev parent reply other threads:[~2026-07-21 18:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 21:14 [PATCH 0/6] drm/nouveau: GSP telemetry via RUSD, and fdinfo telemetry exposure Mohamed Ahmed
2026-07-14 21:14 ` [PATCH 1/6] drm/nouveau/gsp: vendor the RUSD header Mohamed Ahmed
2026-07-14 21:14 ` [PATCH 2/6] drm/nouveau/gsp: add RUSD telemetry support Mohamed Ahmed
2026-07-21 18:23 ` lyude
2026-07-14 21:14 ` [PATCH 3/6] drm/nouveau: add GSP hwmon support Mohamed Ahmed
2026-07-21 18:36 ` lyude [this message]
2026-07-21 19:36 ` Mohamed Ahmed
2026-07-21 20:36 ` lyude
2026-07-14 21:14 ` [PATCH 4/6] drm/nouveau: expose RUSD telemetry via sysfs Mohamed Ahmed
2026-07-14 21:14 ` [PATCH 5/6] drm/nouveau: expose global VRAM size and usage " Mohamed Ahmed
2026-07-14 21:14 ` [PATCH 6/6] drm/nouveau: expose per-client GPU usage via fdinfo Mohamed Ahmed
2026-07-20 22:16 ` [PATCH 0/6] drm/nouveau: GSP telemetry via RUSD, and fdinfo telemetry exposure lyude
2026-07-21 10:39 ` Milos Tijanic
2026-07-21 15:11 ` Mohamed Ahmed
2026-07-21 20:40 ` lyude
2026-07-21 20:46 ` Mohamed Ahmed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=78ca5c308ce81465956e839c82e1bba46a9f0686.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mary@mary.zone \
--cc=mohamedahmedegypt2001@gmail.com \
--cc=mripard@kernel.org \
--cc=mtijanic@nvidia.com \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®