[PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error

Mark Pearson posted 1 patch 1 year, 8 months ago
drivers/usb/typec/ucsi/ucsi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error
Posted by Mark Pearson 1 year, 8 months ago
On systems where the UCSI PDOs are not supported, the UCSI driver is
giving an error message. This can cause users to believe there is a HW
issue with their system when in fact it is working as designed.

Downgrade message to dev_info for EOPNOTSUPP condition.

Tested on Lenovo L14 G5 AMD and confirmed with Lenovo FW team that PDOs
are not supported on this platform.

Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
---
 drivers/usb/typec/ucsi/ucsi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index cb52e7b0a2c5..090be87d5485 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -632,8 +632,12 @@ static int ucsi_read_pdos(struct ucsi_connector *con,
 	command |= is_source(role) ? UCSI_GET_PDOS_SRC_PDOS : 0;
 	ret = ucsi_send_command(ucsi, command, pdos + offset,
 				num_pdos * sizeof(u32));
-	if (ret < 0 && ret != -ETIMEDOUT)
-		dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
+	if (ret < 0 && ret != -ETIMEDOUT) {
+		if (ret == -EOPNOTSUPP)
+			dev_info(ucsi->dev, "UCSI_GET_PDOS not supported on this hardware\n");
+		else
+			dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
+	}
 
 	return ret;
 }
-- 
2.45.1
Re: [PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error
Posted by Diogo Ivo 1 year, 8 months ago
Just realized Dmitry said literally the same thing as me. Sorry for the
extra noise, please ignore my comment.

Best regards,
Diogo
Re: [PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error
Posted by Mark Pearson 1 year, 8 months ago
Hi Diogo,

On Wed, Jun 5, 2024, at 11:29 AM, Diogo Ivo wrote:
> Just realized Dmitry said literally the same thing as me. Sorry for the
> extra noise, please ignore my comment.
>
All good - it's a good suggestion and I appreciate the reviews from both you and Dmitry.

I'm looking into it, to see if it works out. Will update to the thread in a bit.

Thanks
Mark
Re: [PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error
Posted by Diogo Ivo 1 year, 8 months ago
Hi Mark,

Do these devices report GET_PDOS support as a response to GET_CAPABILITY?
If they don't I think the best way of addressing this would be to guard
against executing this command for devices without "PDO details supported"
(in ucsi_get_pdos() for example).

Best regards,
Diogo
Re: [PATCH] usb: typec: ucsi: treat get_pdos not supported condition as info instead of error
Posted by Dmitry Baryshkov 1 year, 8 months ago
On Tue, Jun 04, 2024 at 03:40:44PM -0400, Mark Pearson wrote:
> On systems where the UCSI PDOs are not supported, the UCSI driver is
> giving an error message. This can cause users to believe there is a HW
> issue with their system when in fact it is working as designed.
> 
> Downgrade message to dev_info for EOPNOTSUPP condition.
> 
> Tested on Lenovo L14 G5 AMD and confirmed with Lenovo FW team that PDOs
> are not supported on this platform.
> 
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index cb52e7b0a2c5..090be87d5485 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -632,8 +632,12 @@ static int ucsi_read_pdos(struct ucsi_connector *con,
>  	command |= is_source(role) ? UCSI_GET_PDOS_SRC_PDOS : 0;
>  	ret = ucsi_send_command(ucsi, command, pdos + offset,
>  				num_pdos * sizeof(u32));
> -	if (ret < 0 && ret != -ETIMEDOUT)
> -		dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
> +	if (ret < 0 && ret != -ETIMEDOUT) {
> +		if (ret == -EOPNOTSUPP)
> +			dev_info(ucsi->dev, "UCSI_GET_PDOS not supported on this hardware\n");

Maybe it would be enough to guard GET_PDOS commands with the
UCSI_CAP_PDO_DETAILS check? Is it cleared on affected platforms?

> +		else
> +			dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
> +	}
>  
>  	return ret;
>  }
> -- 
> 2.45.1
> 

-- 
With best wishes
Dmitry