[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZsYAlG_4MOUagcGk@ashyti-mobl2.lan>
Date: Wed, 21 Aug 2024 16:58:28 +0200
From: Andi Shyti <andi.shyti@...ux.intel.com>
To: Raag Jadav <raag.jadav@...el.com>
Cc: Andi Shyti <andi.shyti@...ux.intel.com>, jani.nikula@...ux.intel.com,
joonas.lahtinen@...ux.intel.com, rodrigo.vivi@...el.com,
tursulin@...ulin.net, airlied@...il.com, daniel@...ll.ch,
linux@...ck-us.net, andriy.shevchenko@...ux.intel.com,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
anshuman.gupta@...el.com, badal.nilawar@...el.com,
riana.tauro@...el.com, ashutosh.dixit@...el.com,
karthik.poosa@...el.com
Subject: Re: [PATCH v5] drm/i915/hwmon: expose fan speed
> > > + /*
> > > + * HW register value is accumulated count of pulses from
> > > + * PWM fan with the scale of 2 pulses per rotation.
> > > + */
> > > + rotations = pulses / 2;
> > > +
> > > + time = jiffies_delta_to_msecs(time_now - fi->time_prev);
> > > + if (unlikely(!time)) {
> > > + ret = -EAGAIN;
> > > + goto exit;
> > > + }
> >
> > Can you please add a comment describing how you obtain the speed
> > calculation?
>
> That's what I initially tried but ended up dropping it in favour of RPM
> formula below, which I found to be doing a better job of explaining than
> a few lines of description.
>
> > Basically at every read you store the values. Is it possible that
> > we don't have reads for a long time and the register resets more
> > than once?
>
> Considering a fan continuously running at higher speeds (for example 4000 RPM
> which is quite optimistic), with the scale of 2 pulses per rotation, a 32 bit
> register will take around a year to overflow, which is more than most usecases
> I could think of.
Which can be considered as a worse case scenario. I would have
preferred here a runtime calculation, which means read now, wait
a bit, read again and calculate. The read might be slow, but
efficient.
Anyway, your argument makes sense, so that I'm not going to push
on this, I already r-b'ed it.
Thanks,
Andi
Powered by blists - more mailing lists