lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210513222302.GA915998@roeck-us.net>
Date:   Thu, 13 May 2021 15:23:02 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Václav Kubernát <kubernat@...net.cz>
Cc:     Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E VOUT

On Thu, May 13, 2021 at 10:11:10PM +0200, Václav Kubernát wrote:
> After testing new YH-5151E devices, we found out that not all YH-5151E
> work the same. The newly tested devices actually report vout correctly
> in linear16 (even though they're still YH-5151E). We suspect that it is
> because these new devices have a different firmware version, but that is
> unconfirmed. The version cannot be queried through PMBus.
> 
> The compliant versions of YH-5151E report VOUT_MODE normally, so we turn
> on the linear11 workaround only if VOUT_MODE doesn't report anything.
> 
What a mess. But thanks for keeping on top of this, and for the fix.
Applied.

Thanks,
Guenter

> Signed-off-by: Václav Kubernát <kubernat@...net.cz>
> ---
>  drivers/hwmon/pmbus/fsp-3y.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/fsp-3y.c b/drivers/hwmon/pmbus/fsp-3y.c
> index 46252b17c008..073d960a0af5 100644
> --- a/drivers/hwmon/pmbus/fsp-3y.c
> +++ b/drivers/hwmon/pmbus/fsp-3y.c
> @@ -37,6 +37,8 @@ struct fsp3y_data {
>  	struct pmbus_driver_info info;
>  	int chip;
>  	int page;
> +
> +	bool vout_linear_11;
>  };
>  
>  #define to_fsp3y_data(x) container_of(x, struct fsp3y_data, info)
> @@ -108,11 +110,9 @@ static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
>  	int rv;
>  
>  	/*
> -	 * YH5151-E outputs vout in linear11. The conversion is done when
> -	 * reading. Here, we have to inject pmbus_core with the correct
> -	 * exponent (it is -6).
> +	 * Inject an exponent for non-compliant YH5151-E.
>  	 */
> -	if (data->chip == yh5151e && reg == PMBUS_VOUT_MODE)
> +	if (data->vout_linear_11 && reg == PMBUS_VOUT_MODE)
>  		return 0x1A;
>  
>  	rv = set_page(client, page);
> @@ -161,10 +161,9 @@ static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase,
>  		return rv;
>  
>  	/*
> -	 * YH-5151E is non-compliant and outputs output voltages in linear11
> -	 * instead of linear16.
> +	 * Handle YH-5151E non-compliant linear11 vout voltage.
>  	 */
> -	if (data->chip == yh5151e && reg == PMBUS_READ_VOUT)
> +	if (data->vout_linear_11 && reg == PMBUS_READ_VOUT)
>  		rv = sign_extend32(rv, 10) & 0xffff;
>  
>  	return rv;
> @@ -256,6 +255,25 @@ static int fsp3y_probe(struct i2c_client *client)
>  
>  	data->info = fsp3y_info[data->chip];
>  
> +	/*
> +	 * YH-5151E sometimes reports vout in linear11 and sometimes in
> +	 * linear16. This depends on the exact individual piece of hardware. One
> +	 * YH-5151E can use linear16 and another might use linear11 instead.
> +	 *
> +	 * The format can be recognized by reading VOUT_MODE - if it doesn't
> +	 * report a valid exponent, then vout uses linear11. Otherwise, the
> +	 * device is compliant and uses linear16.
> +	 */
> +	data->vout_linear_11 = false;
> +	if (data->chip == yh5151e) {
> +		rv = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE);
> +		if (rv < 0)
> +			return rv;
> +
> +		if (rv == 0xFF)
> +			data->vout_linear_11 = true;
> +	}
> +
>  	return pmbus_do_probe(client, &data->info);
>  }
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ