* Re: [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config. [not found] <CAAboHLVgQKzNVU6XDWGZmnxGK0DGvtgyzMsY9V+UiOJVq1JyTg@mail.gmail.com> @ 2022-10-12 1:35 ` Guenter Roeck 2022-10-13 3:42 ` karthik gengan 0 siblings, 1 reply; 3+ messages in thread From: Guenter Roeck @ 2022-10-12 1:35 UTC (permalink / raw) To: karthik gengan, Jean Delvare; +Cc: linux-hwmon, linux-kernel On 10/11/22 16:59, karthik gengan wrote: > Linear mode config calculation is based on the exponent value > derived from vout_mode. So vout_mode value should be valid > for PMBUS_VOUT_MODE command-supported chips. > We can not do this. The operational word is "should". See comment below "Not all chips support the VOUT_MODE command". It is what it is. We can not just refuse to support such chips because they don't support what we expect them to support. Sure, those chips will (likely) report wrong values since the exponent will default to 0. That can be adjusted in user space, or whoever finds such a chip can provide a back-end driver with the appropriate values configured (for example by providing a dummy VOUT_MODE command response). That is better than just rejecting the chip entirely. From a practical perspective, if you know about an affected chip one that would refuse to instantiate after your patch is applied, I would suggest to submit (or improve) a back-end driver with an explanation instead. Thanks, Guenter > Signed-off-by: karthik.gengan <gengankarthik@gmail.com <mailto:gengankarthik@gmail.com>> > --- > drivers/hwmon/pmbus/pmbus_core.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c > index 7ec04934747e..5f80c3b8f245 100644 > --- a/drivers/hwmon/pmbus/pmbus_core.c > +++ b/drivers/hwmon/pmbus/pmbus_core.c > @@ -2507,9 +2507,17 @@ static int pmbus_identify_common(struct i2c_client *client, > { > int vout_mode = -1; > > - if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) > + if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) { > vout_mode = _pmbus_read_byte_data(client, page, > PMBUS_VOUT_MODE); > + /* > + * If the client page supports PMBUS_VOUT_MODE, > + * then the output of the VOUT_MODE command should > + * be a valid value for linear mode calculation. > + */ > + if ((data->info->format[PSC_VOLTAGE_OUT] == linear) && (vout_mode < 0)) > + return -ENODEV; > + } > if (vout_mode >= 0 && vout_mode != 0xff) { > /* > * Not all chips support the VOUT_MODE command, > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config. 2022-10-12 1:35 ` [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config Guenter Roeck @ 2022-10-13 3:42 ` karthik gengan 2022-10-13 4:35 ` Guenter Roeck 0 siblings, 1 reply; 3+ messages in thread From: karthik gengan @ 2022-10-13 3:42 UTC (permalink / raw) To: Guenter Roeck; +Cc: Jean Delvare, linux-hwmon, linux-kernel Hi Guenter, Thanks for your response but I need some more valuable suggestions... In the pmbus_data structure, we are updating the vout_out mode value based on the config ( linear, vid .direct) and this structure is declared in pmbus_core.c .so the low-level driver could not able to access this structure. Guidance required, 1. Move the pumbus_data structure declaration to pmbus.h, so that low-level the driver can check and update the vout_mode if the value is not proper. (or) 2. if the vout_mode attribute value is exposed in the sysfs, the user-level application can modify the value. ( if the value is not proper). (or) 3. if an ioctl call is exposed for the vout_mode then the user-level application can able to update the value. ( if the value is not proper). (or) guide me to a better approach to handle this issue. For reference, UCD90xx vendor claims that vout_mode value should be present if the chip supports PMBUS_VOUT_MODE command. Hence the patch validated the vout_mode value for PMBUS_VOUT_MODE supported chip. Thanks & Regards, Karthik.G On Wed, Oct 12, 2022 at 7:05 AM Guenter Roeck <linux@roeck-us.net> wrote: > > On 10/11/22 16:59, karthik gengan wrote: > > Linear mode config calculation is based on the exponent value > > derived from vout_mode. So vout_mode value should be valid > > for PMBUS_VOUT_MODE command-supported chips. > > > > We can not do this. The operational word is "should". See comment > below "Not all chips support the VOUT_MODE command". It is what it is. > We can not just refuse to support such chips because they don't > support what we expect them to support. > > Sure, those chips will (likely) report wrong values since the > exponent will default to 0. That can be adjusted in user space, > or whoever finds such a chip can provide a back-end driver > with the appropriate values configured (for example by providing > a dummy VOUT_MODE command response). That is better than just > rejecting the chip entirely. > > From a practical perspective, if you know about an affected chip > one that would refuse to instantiate after your patch is applied, > I would suggest to submit (or improve) a back-end driver with > an explanation instead. > > Thanks, > Guenter > > > Signed-off-by: karthik.gengan <gengankarthik@gmail.com <mailto:gengankarthik@gmail.com>> > > --- > > drivers/hwmon/pmbus/pmbus_core.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c > > index 7ec04934747e..5f80c3b8f245 100644 > > --- a/drivers/hwmon/pmbus/pmbus_core.c > > +++ b/drivers/hwmon/pmbus/pmbus_core.c > > @@ -2507,9 +2507,17 @@ static int pmbus_identify_common(struct i2c_client *client, > > { > > int vout_mode = -1; > > > > - if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) > > + if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) { > > vout_mode = _pmbus_read_byte_data(client, page, > > PMBUS_VOUT_MODE); > > + /* > > + * If the client page supports PMBUS_VOUT_MODE, > > + * then the output of the VOUT_MODE command should > > + * be a valid value for linear mode calculation. > > + */ > > + if ((data->info->format[PSC_VOLTAGE_OUT] == linear) && (vout_mode < 0)) > > + return -ENODEV; > > + } > > if (vout_mode >= 0 && vout_mode != 0xff) { > > /* > > * Not all chips support the VOUT_MODE command, > > -- > > 2.25.1 > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config. 2022-10-13 3:42 ` karthik gengan @ 2022-10-13 4:35 ` Guenter Roeck 0 siblings, 0 replies; 3+ messages in thread From: Guenter Roeck @ 2022-10-13 4:35 UTC (permalink / raw) To: karthik gengan; +Cc: Jean Delvare, linux-hwmon, linux-kernel On 10/12/22 20:42, karthik gengan wrote: > Hi Guenter, > > Thanks for your response but I need some more valuable suggestions... > > In the pmbus_data structure, we are updating the vout_out mode > value based on the config ( linear, vid .direct) and this structure is declared > in pmbus_core.c .so the low-level driver could not able to access this > structure. > > Guidance required, > 1. Move the pumbus_data structure declaration to pmbus.h, so that low-level > the driver can check and update the vout_mode if the value > is not proper. (or) > 2. if the vout_mode attribute value is exposed in the sysfs, the > user-level application > can modify the value. ( if the value is not proper). > (or) > 3. if an ioctl call is exposed for the vout_mode then the > user-level application can > able to update the value. ( if the value is not proper). > > (or) guide me to a better approach to handle this issue. > Have a look at drivers/hwmon/pmbus/stpddc60.c. That chip reports a wrong value for PMBUS_VOUT_MODE, and the driver provides the expected value to the PMBus core. Taking that as example, the simple solution is to have the chip driver report the expected value. There is no need to get userspace involved. Actually, involving userspace would be completely wrong. > For reference, > UCD90xx vendor claims that vout_mode value should be present > if the chip > supports PMBUS_VOUT_MODE command. Hence the patch validated the vout_mode > value for PMBUS_VOUT_MODE supported chip. > Not sure if I understand, but if any of the chips supported by the ucd9009 driver does not support the VOUT_MODE command or reports a wrong value, just extend ucd9000_read_byte_data() to report whatever value the command should return. That would need some confirmation, though - I don't recall any such problem, and UCD90xxx Sequencer and System Health Controller PMBUS Command Reference (SLVU352) clearly states that the command is supported. Guenter ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-13 4:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAAboHLVgQKzNVU6XDWGZmnxGK0DGvtgyzMsY9V+UiOJVq1JyTg@mail.gmail.com>
2022-10-12 1:35 ` [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config Guenter Roeck
2022-10-13 3:42 ` karthik gengan
2022-10-13 4:35 ` Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®