From: Raag Jadav <raag.jadav@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tursulin@ursulin.net, airlied@gmail.com,
daniel@ffwll.ch, linux@roeck-us.net, andi.shyti@linux.intel.com,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
anshuman.gupta@intel.com, badal.nilawar@intel.com,
riana.tauro@intel.com, ashutosh.dixit@intel.com,
karthik.poosa@intel.com
Subject: Re: [PATCH v5] drm/i915/hwmon: expose fan speed
Date: Tue, 13 Aug 2024 13:03:01 +0300 [thread overview]
Message-ID: <ZrsvVSu8rdNYfsSo@black.fi.intel.com> (raw)
In-Reply-To: <ZrsY6tMts81T-uFa@smile.fi.intel.com>
On Tue, Aug 13, 2024 at 11:27:22AM +0300, Andy Shevchenko wrote:
> On Tue, Aug 13, 2024 at 08:45:19AM +0300, Raag Jadav wrote:
> > On Mon, Aug 12, 2024 at 04:15:14PM +0300, Andy Shevchenko wrote:
> > > On Mon, Aug 12, 2024 at 01:45:38PM +0530, Raag Jadav wrote:
>
> ...
>
> > > > +static int
> > > > +hwm_fan_read(struct hwm_drvdata *ddat, u32 attr, long *val)
> > > > +{
> > > > + struct i915_hwmon *hwmon = ddat->hwmon;
> > > > + struct hwm_fan_info *fi = &ddat->fi;
> > > > + u64 rotations, time_now, time;
> > > > + intel_wakeref_t wakeref;
> > > > + u32 reg_val, pulses;
> > > > + int ret = 0;
> > > > +
> > > > + if (attr != hwmon_fan_input)
> > > > + return -EOPNOTSUPP;
> > > > +
> > > > + wakeref = intel_runtime_pm_get(ddat->uncore->rpm);
> > > > + mutex_lock(&hwmon->hwmon_lock);
> > > > +
> > > > + reg_val = intel_uncore_read(ddat->uncore, hwmon->rg.fan_speed);
> > > > + time_now = get_jiffies_64();
> > >
> > > > + /* Handle HW register overflow */
> > > > + if (reg_val >= fi->reg_val_prev)
> > > > + pulses = reg_val - fi->reg_val_prev;
> > > > + else
> > > > + pulses = UINT_MAX - fi->reg_val_prev + reg_val;
> > >
> > > Isn't it the abs_diff() reimplementation?
> >
> > Not exactly. This is specific to 32 bit register overflow, so we count
> > from max value.
>
> I see. But since you have the both variables of u32, why:
> 1) UINT_MAX?
> 2) Not simply using
>
> pulses = reg_val - fi->reg_val_prev;
>
> which will wrap over correctly?
Agree. Will update.
Raag
next prev parent reply other threads:[~2024-08-13 10:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 8:15 [PATCH v5] drm/i915/hwmon: expose fan speed Raag Jadav
2024-08-12 10:14 ` ✓ Fi.CI.BAT: success for drm/i915/hwmon: expose fan speed (rev5) Patchwork
2024-08-12 13:15 ` [PATCH v5] drm/i915/hwmon: expose fan speed Andy Shevchenko
2024-08-13 5:45 ` Raag Jadav
2024-08-13 8:27 ` Andy Shevchenko
2024-08-13 10:03 ` Raag Jadav [this message]
2024-08-12 13:50 ` Andi Shyti
2024-08-13 6:30 ` Raag Jadav
2024-08-21 14:58 ` Andi Shyti
2024-08-12 21:36 ` kernel test robot
2024-08-12 22:43 ` ✓ Fi.CI.IGT: success for drm/i915/hwmon: expose fan speed (rev5) Patchwork
2024-08-13 0:38 ` [PATCH v5] drm/i915/hwmon: expose fan speed kernel test robot
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=ZrsvVSu8rdNYfsSo@black.fi.intel.com \
--to=raag.jadav@intel.com \
--cc=airlied@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anshuman.gupta@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=badal.nilawar@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=karthik.poosa@intel.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=tursulin@ursulin.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.