[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <01af44b5-8a07-4ebc-b58b-13672b545c8b@roeck-us.net>
Date: Mon, 12 Jan 2026 08:35:31 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Tinsae Tadesse <tinsaetadesse2015@...il.com>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] hwmon: spd5118: Retry temperature reads after
temporary I2C errors
On 1/10/26 09:19, Tinsae Tadesse wrote:
> After suspend/resume, the SPD5118 hub or the underlying I2C adapter
> may not be immediately available, causing register reads to fail.
>
> Attempt a single regcache re-synchronization and retry the read to
> allow recovery.
>
> Signed-off-by: Tinsae Tadesse <tinsaetadesse2015@...il.com>
> ---
> drivers/hwmon/spd5118.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
> index ec9f14f6e0df..63f798991363 100644
> --- a/drivers/hwmon/spd5118.c
> +++ b/drivers/hwmon/spd5118.c
> @@ -101,6 +101,7 @@ static int spd5118_read_temp(struct regmap *regmap, u32 attr, long *val)
> int reg, err;
> u8 regval[2];
> u16 temp;
> + bool retried = false;
>
> switch (attr) {
> case hwmon_temp_input:
> @@ -122,9 +123,17 @@ static int spd5118_read_temp(struct regmap *regmap, u32 attr, long *val)
> return -EOPNOTSUPP;
> }
>
> +retry:
> err = regmap_bulk_read(regmap, reg, regval, 2);
> - if (err)
> + if (err) {
> + if (!retried && (err == -ENXIO || err == -EIO)) {
> + retried = true;
> + regcache_mark_dirty(regmap);
> + if (!regcache_sync(regmap))
> + goto retry;
> + }
> return err;
> + }
>
> temp = (regval[1] << 8) | regval[0];
>
Wrong solution. This affects all accesses, not just the first access after
resume. regmap_bulk_read() can fail for any reason, not just because the
system just returned from resume. The above code just assumes that the failure
is due to a bad resume based on the returned error code. That may be the case
for the i801 controller driver, but even that would be just by chance.
Guenter
Powered by blists - more mailing lists