RE: [PATCH RESEND 2/4] thermal: imx8mm: Add support for i.MX8MM thermal monitoring unit

From: Anson Huang
Date: Fri Feb 28 2020 - 22:37:53 EST


Hi, Daniel

> Subject: Re: [PATCH RESEND 2/4] thermal: imx8mm: Add support for
> i.MX8MM thermal monitoring unit
>
> On 28/02/2020 02:12, Anson Huang wrote:
> > Hi, Daniel
>
> [ ... ]
>
> >>> +static int tmu_get_temp(void *data, int *temp) {
> >>> + struct imx8mm_tmu *tmu = data;
> >>> + u32 val;
> >>> +
> >>> + /* the temp sensor need about 1ms to finish the measurement */
> >>> + usleep_range(1000, 2000);
> >>
> >> Why do yo need to force a delay here? If the sensor can not be read
> >> more than one time every 1ms, then specify that in the DT switching
> >> the polling to the right value, no?
> >
> > The polling time(2 seconds) is OK for this case, adding this sleep is
> > to prevent user from reading temperature from sysfs interface very
> frequently like less than 1ms, does it make sense?
>
> Not really, well except if the user is able to press the keys in less than 1ms :)
>
> If the userspace writes a polling script reading the temperature in a busy loop,
> there is nothing we can do against silly programming :/

Make senseð

>
> However, it could interesting to add a <min polling interval> in the thermal
> structure and handle that from the core framework by caching the last value
> and return it in case get_temp is called too fast.

OK, I will resend V2 patch set to remove the sleep in this driver and see if there is
real issue of such corner case, if any issue observed, I will try summit a patch to core
framework later.

Thanks,
Anson