Message ID | 20241024-tps25990-v3-4-b6a6e9d4b506@baylibre.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | hwmon: pmbus: add tps25990 efuse support | expand |
On Thu, Oct 24, 2024 at 08:10:38PM +0200, Jerome Brunet wrote: > pmbus_write_smbalert_mask() ignores the errors if the chip can't set > smbalert mask the standard way. It is not necessarily a problem for the irq > support if the chip is otherwise properly setup but it may leave an > uncleared fault behind. > > pmbus_core will pick the fault on the next register_check(). The register > check will fails regardless of the actual register support by the chip. > > This leads to missing attributes or debugfs entries for chips that should > provide them. > > We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only. > > Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to > avoid the problem. > > Suggested-by: Guenter Roeck <linux@roeck-us.net> > Fixes: 221819ca4c36 ("hwmon: (pmbus/core) Add interrupt support") > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> > --- > drivers/hwmon/pmbus/pmbus_core.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c > index ce697ca03de01c0e5a352f8f6b72671137721868..a0a397d571caa1a6620ef095f9cf63d94e8bda1d 100644 > --- a/drivers/hwmon/pmbus/pmbus_core.c > +++ b/drivers/hwmon/pmbus/pmbus_core.c > @@ -3346,7 +3346,12 @@ static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) > > static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) > { > - return _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); > + int ret; > + > + ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); > + pmbus_clear_fault_page(client, -1); Why -1 and not page ? Guenter
On Fri 01 Nov 2024 at 08:10, Guenter Roeck <linux@roeck-us.net> wrote: > On Thu, Oct 24, 2024 at 08:10:38PM +0200, Jerome Brunet wrote: >> pmbus_write_smbalert_mask() ignores the errors if the chip can't set >> smbalert mask the standard way. It is not necessarily a problem for the irq >> support if the chip is otherwise properly setup but it may leave an >> uncleared fault behind. >> >> pmbus_core will pick the fault on the next register_check(). The register >> check will fails regardless of the actual register support by the chip. >> >> This leads to missing attributes or debugfs entries for chips that should >> provide them. >> >> We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only. >> >> Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to >> avoid the problem. >> >> Suggested-by: Guenter Roeck <linux@roeck-us.net> >> Fixes: 221819ca4c36 ("hwmon: (pmbus/core) Add interrupt support") >> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> >> --- >> drivers/hwmon/pmbus/pmbus_core.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c >> index ce697ca03de01c0e5a352f8f6b72671137721868..a0a397d571caa1a6620ef095f9cf63d94e8bda1d 100644 >> --- a/drivers/hwmon/pmbus/pmbus_core.c >> +++ b/drivers/hwmon/pmbus/pmbus_core.c >> @@ -3346,7 +3346,12 @@ static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) >> >> static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) >> { >> - return _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); >> + int ret; >> + >> + ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); >> + pmbus_clear_fault_page(client, -1); > > Why -1 and not page ? The idea was to clear the fault on the page we are on, basically just skipping setting the page again. I'll change to 'page' > > Guenter
On 11/4/24 00:28, Jerome Brunet wrote: > On Fri 01 Nov 2024 at 08:10, Guenter Roeck <linux@roeck-us.net> wrote: > >> On Thu, Oct 24, 2024 at 08:10:38PM +0200, Jerome Brunet wrote: >>> pmbus_write_smbalert_mask() ignores the errors if the chip can't set >>> smbalert mask the standard way. It is not necessarily a problem for the irq >>> support if the chip is otherwise properly setup but it may leave an >>> uncleared fault behind. >>> >>> pmbus_core will pick the fault on the next register_check(). The register >>> check will fails regardless of the actual register support by the chip. >>> >>> This leads to missing attributes or debugfs entries for chips that should >>> provide them. >>> >>> We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only. >>> >>> Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to >>> avoid the problem. >>> >>> Suggested-by: Guenter Roeck <linux@roeck-us.net> >>> Fixes: 221819ca4c36 ("hwmon: (pmbus/core) Add interrupt support") >>> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> >>> --- >>> drivers/hwmon/pmbus/pmbus_core.c | 7 ++++++- >>> 1 file changed, 6 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c >>> index ce697ca03de01c0e5a352f8f6b72671137721868..a0a397d571caa1a6620ef095f9cf63d94e8bda1d 100644 >>> --- a/drivers/hwmon/pmbus/pmbus_core.c >>> +++ b/drivers/hwmon/pmbus/pmbus_core.c >>> @@ -3346,7 +3346,12 @@ static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) >>> >>> static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) >>> { >>> - return _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); >>> + int ret; >>> + >>> + ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); >>> + pmbus_clear_fault_page(client, -1); >> >> Why -1 and not page ? > > The idea was to clear the fault on the page we are on, basically just skipping > setting the page again. > > I'll change to 'page' > Or just add a comment explaining the '-1'. Thanks, Guenter
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index ce697ca03de01c0e5a352f8f6b72671137721868..a0a397d571caa1a6620ef095f9cf63d94e8bda1d 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3346,7 +3346,12 @@ static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) { - return _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); + int ret; + + ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); + pmbus_clear_fault_page(client, -1); + + return ret; } static irqreturn_t pmbus_fault_handler(int irq, void *pdata)
pmbus_write_smbalert_mask() ignores the errors if the chip can't set smbalert mask the standard way. It is not necessarily a problem for the irq support if the chip is otherwise properly setup but it may leave an uncleared fault behind. pmbus_core will pick the fault on the next register_check(). The register check will fails regardless of the actual register support by the chip. This leads to missing attributes or debugfs entries for chips that should provide them. We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only. Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to avoid the problem. Suggested-by: Guenter Roeck <linux@roeck-us.net> Fixes: 221819ca4c36 ("hwmon: (pmbus/core) Add interrupt support") Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> --- drivers/hwmon/pmbus/pmbus_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)