mbox series

[v2,0/2] usb: typec: ucsi: add workaround for several Qualcomm platforms

Message ID 20231025115620.905538-1-dmitry.baryshkov@linaro.org (mailing list archive)
Headers show
Series usb: typec: ucsi: add workaround for several Qualcomm platforms | expand

Message

Dmitry Baryshkov Oct. 25, 2023, 11:49 a.m. UTC
The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
Submitting UCSI_GET_PDOS command for partners which do not actually
support PD and do not have PDOs causes firmware to crash, preventing
further UCSI activity. Firmware on newer platforms have fixed this
issue. In order to still be able to use UCSI functionality on the
mentioned platforms (e.g. to be able to handle USB role switching),
apply a workaround that completely shortcuts UCSI_GET_PDOS command for
the USB-C partner.

This has been tested on sm8350 only, but should apply to other
platforms. I did not enable UCSI for sc8180x yet, it has slightly
different implementation, which I'd like to get tested first.

Note: patch 2 depends on patch 1, otherwise people might end up with the
broken kernel and crashed firmware. The easiest way to handle this
dependency is to merge both patches through the USB tree.

Changes since v1:
- Check parent's compatible in the UCSI driver instead of using
  different AUX device names in the PMIC GLINK driver (Bjorn).

Dmitry Baryshkov (2):
  usb: typec: ucsi: fix UCSI on buggy Qualcomm devices
  soc: qcom: pmic_glink: enable UCSI by default

 drivers/soc/qcom/pmic_glink.c       | 19 +++++++++----------
 drivers/usb/typec/ucsi/ucsi.c       |  3 +++
 drivers/usb/typec/ucsi/ucsi.h       |  3 +++
 drivers/usb/typec/ucsi/ucsi_glink.c | 13 +++++++++++++
 4 files changed, 28 insertions(+), 10 deletions(-)

Comments

Johan Hovold Dec. 8, 2023, 8:40 a.m. UTC | #1
On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> Submitting UCSI_GET_PDOS command for partners which do not actually
> support PD and do not have PDOs causes firmware to crash, preventing
> further UCSI activity. Firmware on newer platforms have fixed this
> issue. In order to still be able to use UCSI functionality on the
> mentioned platforms (e.g. to be able to handle USB role switching),
> apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> the USB-C partner.
> 
> This has been tested on sm8350 only, but should apply to other
> platforms. I did not enable UCSI for sc8180x yet, it has slightly
> different implementation, which I'd like to get tested first.

Has no one tested this on sc8280xp/x13s before merging?

I see a bunch of errors with this series applied to 6.7-rc4:

[   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
[   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
[   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
[   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
[   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
[   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)

Is it just broken or am I missing some undocumented dependency that is
only in linux-next?

Johan
Dmitry Baryshkov Dec. 8, 2023, 10:58 a.m. UTC | #2
On Fri, 8 Dec 2023 at 10:39, Johan Hovold <johan@kernel.org> wrote:
>
> On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> > The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> > Submitting UCSI_GET_PDOS command for partners which do not actually
> > support PD and do not have PDOs causes firmware to crash, preventing
> > further UCSI activity. Firmware on newer platforms have fixed this
> > issue. In order to still be able to use UCSI functionality on the
> > mentioned platforms (e.g. to be able to handle USB role switching),
> > apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> > the USB-C partner.
> >
> > This has been tested on sm8350 only, but should apply to other
> > platforms. I did not enable UCSI for sc8180x yet, it has slightly
> > different implementation, which I'd like to get tested first.
>
> Has no one tested this on sc8280xp/x13s before merging?
>
> I see a bunch of errors with this series applied to 6.7-rc4:
>
> [   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> [   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
> [   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> [   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> [   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> [   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)

Can you please post previous messages or is the first timeout the
first error from ucsi?

>
> Is it just broken or am I missing some undocumented dependency that is
> only in linux-next?
>
> Johan
Johan Hovold Dec. 8, 2023, 11:10 a.m. UTC | #3
On Fri, Dec 08, 2023 at 12:58:29PM +0200, Dmitry Baryshkov wrote:
> On Fri, 8 Dec 2023 at 10:39, Johan Hovold <johan@kernel.org> wrote:
> >
> > On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> > > The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> > > Submitting UCSI_GET_PDOS command for partners which do not actually
> > > support PD and do not have PDOs causes firmware to crash, preventing
> > > further UCSI activity. Firmware on newer platforms have fixed this
> > > issue. In order to still be able to use UCSI functionality on the
> > > mentioned platforms (e.g. to be able to handle USB role switching),
> > > apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> > > the USB-C partner.
> > >
> > > This has been tested on sm8350 only, but should apply to other
> > > platforms. I did not enable UCSI for sc8180x yet, it has slightly
> > > different implementation, which I'd like to get tested first.
> >
> > Has no one tested this on sc8280xp/x13s before merging?
> >
> > I see a bunch of errors with this series applied to 6.7-rc4:
> >
> > [   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > [   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
> > [   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > [   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > [   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > [   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> 
> Can you please post previous messages or is the first timeout the
> first error from ucsi?

These are all the ucsi messages in the log (dmesg | grep ucsi).

The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:

[    9.012421] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-95)
[   14.047379] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
[   14.050708] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
[   20.192382] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
[   20.192542] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)

I see that one if I boot with only the charger connected, the later -110
timeouts go away if I disconnect my r8152 ethernet adapter.

Johan
Dmitry Baryshkov Dec. 8, 2023, 11:10 a.m. UTC | #4
On Fri, 8 Dec 2023 at 13:09, Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Dec 08, 2023 at 12:58:29PM +0200, Dmitry Baryshkov wrote:
> > On Fri, 8 Dec 2023 at 10:39, Johan Hovold <johan@kernel.org> wrote:
> > >
> > > On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> > > > The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> > > > Submitting UCSI_GET_PDOS command for partners which do not actually
> > > > support PD and do not have PDOs causes firmware to crash, preventing
> > > > further UCSI activity. Firmware on newer platforms have fixed this
> > > > issue. In order to still be able to use UCSI functionality on the
> > > > mentioned platforms (e.g. to be able to handle USB role switching),
> > > > apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> > > > the USB-C partner.
> > > >
> > > > This has been tested on sm8350 only, but should apply to other
> > > > platforms. I did not enable UCSI for sc8180x yet, it has slightly
> > > > different implementation, which I'd like to get tested first.
> > >
> > > Has no one tested this on sc8280xp/x13s before merging?
> > >
> > > I see a bunch of errors with this series applied to 6.7-rc4:
> > >
> > > [   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > [   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
> > > [   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > [   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > > [   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > [   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> >
> > Can you please post previous messages or is the first timeout the
> > first error from ucsi?
>
> These are all the ucsi messages in the log (dmesg | grep ucsi).
>
> The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:

Ack, thank you. This is pending on my side together with the UCSI
glink / altmode rework. I hope to have patches for that closer to the
NY.

>
> [    9.012421] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-95)
> [   14.047379] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> [   14.050708] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> [   20.192382] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> [   20.192542] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
>
> I see that one if I boot with only the charger connected, the later -110
> timeouts go away if I disconnect my r8152 ethernet adapter.
>
> Johan
Johan Hovold Dec. 8, 2023, 11:48 a.m. UTC | #5
On Fri, Dec 08, 2023 at 01:10:59PM +0200, Dmitry Baryshkov wrote:
> On Fri, 8 Dec 2023 at 13:09, Johan Hovold <johan@kernel.org> wrote:
> > On Fri, Dec 08, 2023 at 12:58:29PM +0200, Dmitry Baryshkov wrote:
> > > On Fri, 8 Dec 2023 at 10:39, Johan Hovold <johan@kernel.org> wrote:
> > > > On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> > > > > The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> > > > > Submitting UCSI_GET_PDOS command for partners which do not actually
> > > > > support PD and do not have PDOs causes firmware to crash, preventing
> > > > > further UCSI activity. Firmware on newer platforms have fixed this
> > > > > issue. In order to still be able to use UCSI functionality on the
> > > > > mentioned platforms (e.g. to be able to handle USB role switching),
> > > > > apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> > > > > the USB-C partner.
> > > > >
> > > > > This has been tested on sm8350 only, but should apply to other
> > > > > platforms. I did not enable UCSI for sc8180x yet, it has slightly
> > > > > different implementation, which I'd like to get tested first.
> > > >
> > > > Has no one tested this on sc8280xp/x13s before merging?
> > > >
> > > > I see a bunch of errors with this series applied to 6.7-rc4:
> > > >
> > > > [   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > [   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
> > > > [   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > [   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > > > [   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > [   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > >
> > > Can you please post previous messages or is the first timeout the
> > > first error from ucsi?
> >
> > These are all the ucsi messages in the log (dmesg | grep ucsi).
> >
> > The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:
> 
> Ack, thank you. This is pending on my side together with the UCSI
> glink / altmode rework. I hope to have patches for that closer to the
> NY.

What does that mean? That we shall revert these patches until that work
is finished? I don't want to have these errors littering the logs,
scaring users and possibly slowing down boot (those are five second
timeouts).

Also, if this was known issue, why wasn't it mentioned the cover letter
or commit messages?

Johan
Dmitry Baryshkov Dec. 8, 2023, 12:16 p.m. UTC | #6
On Fri, 8 Dec 2023 at 13:47, Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Dec 08, 2023 at 01:10:59PM +0200, Dmitry Baryshkov wrote:
> > On Fri, 8 Dec 2023 at 13:09, Johan Hovold <johan@kernel.org> wrote:
> > > On Fri, Dec 08, 2023 at 12:58:29PM +0200, Dmitry Baryshkov wrote:
> > > > On Fri, 8 Dec 2023 at 10:39, Johan Hovold <johan@kernel.org> wrote:
> > > > > On Wed, Oct 25, 2023 at 02:49:28PM +0300, Dmitry Baryshkov wrote:
> > > > > > The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> > > > > > Submitting UCSI_GET_PDOS command for partners which do not actually
> > > > > > support PD and do not have PDOs causes firmware to crash, preventing
> > > > > > further UCSI activity. Firmware on newer platforms have fixed this
> > > > > > issue. In order to still be able to use UCSI functionality on the
> > > > > > mentioned platforms (e.g. to be able to handle USB role switching),
> > > > > > apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> > > > > > the USB-C partner.
> > > > > >
> > > > > > This has been tested on sm8350 only, but should apply to other
> > > > > > platforms. I did not enable UCSI for sc8180x yet, it has slightly
> > > > > > different implementation, which I'd like to get tested first.
> > > > >
> > > > > Has no one tested this on sc8280xp/x13s before merging?
> > > > >
> > > > > I see a bunch of errors with this series applied to 6.7-rc4:
> > > > >
> > > > > [   11.999960] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > > [   12.000430] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
> > > > > [   17.120515] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > > [   17.124204] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > > > > [   23.264792] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: timeout waiting for UCSI sync write response
> > > > > [   23.264953] ucsi_glink.pmic_glink_ucsi pmic_glink.ucsi.0: GET_CONNECTOR_STATUS failed (-110)
> > > >
> > > > Can you please post previous messages or is the first timeout the
> > > > first error from ucsi?
> > >
> > > These are all the ucsi messages in the log (dmesg | grep ucsi).
> > >
> > > The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:
> >
> > Ack, thank you. This is pending on my side together with the UCSI
> > glink / altmode rework. I hope to have patches for that closer to the
> > NY.
>
> What does that mean? That we shall revert these patches until that work
> is finished? I don't want to have these errors littering the logs,
> scaring users and possibly slowing down boot (those are five second
> timeouts).

Just send a patch disabling ucsi for sc8280xp.

>
> Also, if this was known issue, why wasn't it mentioned the cover letter
> or commit messages?

Surely it was not the known issue, otherwise I would not have sent the series.
Johan Hovold Dec. 8, 2023, 12:26 p.m. UTC | #7
On Fri, Dec 08, 2023 at 02:16:27PM +0200, Dmitry Baryshkov wrote:
> On Fri, 8 Dec 2023 at 13:47, Johan Hovold <johan@kernel.org> wrote:
> > On Fri, Dec 08, 2023 at 01:10:59PM +0200, Dmitry Baryshkov wrote:
> > > On Fri, 8 Dec 2023 at 13:09, Johan Hovold <johan@kernel.org> wrote:

> > > > The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:
> > >
> > > Ack, thank you. This is pending on my side together with the UCSI
> > > glink / altmode rework. I hope to have patches for that closer to the
> > > NY.
> >
> > What does that mean? That we shall revert these patches until that work
> > is finished? I don't want to have these errors littering the logs,
> > scaring users and possibly slowing down boot (those are five second
> > timeouts).
> 
> Just send a patch disabling ucsi for sc8280xp.

Ok, will do.

Looks like that is indeed the only platform besides sc8180x which had
not yet been tested.

> > Also, if this was known issue, why wasn't it mentioned the cover letter
> > or commit messages?
> 
> Surely it was not the known issue, otherwise I would not have sent the series.

Ah, sorry, I misunderstood you then.

Johan
Dmitry Baryshkov Dec. 8, 2023, 12:27 p.m. UTC | #8
On Fri, 8 Dec 2023 at 14:25, Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Dec 08, 2023 at 02:16:27PM +0200, Dmitry Baryshkov wrote:
> > On Fri, 8 Dec 2023 at 13:47, Johan Hovold <johan@kernel.org> wrote:
> > > On Fri, Dec 08, 2023 at 01:10:59PM +0200, Dmitry Baryshkov wrote:
> > > > On Fri, 8 Dec 2023 at 13:09, Johan Hovold <johan@kernel.org> wrote:
>
> > > > > The first error is sometimes GET_CONNECTOR_STATUS failed (-95) instead:
> > > >
> > > > Ack, thank you. This is pending on my side together with the UCSI
> > > > glink / altmode rework. I hope to have patches for that closer to the
> > > > NY.
> > >
> > > What does that mean? That we shall revert these patches until that work
> > > is finished? I don't want to have these errors littering the logs,
> > > scaring users and possibly slowing down boot (those are five second
> > > timeouts).
> >
> > Just send a patch disabling ucsi for sc8280xp.
>
> Ok, will do.
>
> Looks like that is indeed the only platform besides sc8180x which had
> not yet been tested.

And it has its own peculiarities which I didn't observe on other platforms.

>
> > > Also, if this was known issue, why wasn't it mentioned the cover letter
> > > or commit messages?
> >
> > Surely it was not the known issue, otherwise I would not have sent the series.
>
> Ah, sorry, I misunderstood you then.

No problem :-)
Bjorn Andersson Dec. 8, 2023, 2:55 p.m. UTC | #9
On Wed, 25 Oct 2023 14:49:28 +0300, Dmitry Baryshkov wrote:
> The UCSI firmware on Qualcomm SC8180X, SC8280XP and SM8350 are buggy.
> Submitting UCSI_GET_PDOS command for partners which do not actually
> support PD and do not have PDOs causes firmware to crash, preventing
> further UCSI activity. Firmware on newer platforms have fixed this
> issue. In order to still be able to use UCSI functionality on the
> mentioned platforms (e.g. to be able to handle USB role switching),
> apply a workaround that completely shortcuts UCSI_GET_PDOS command for
> the USB-C partner.
> 
> [...]

Applied, thanks!

[1/2] usb: typec: ucsi: fix UCSI on buggy Qualcomm devices
      commit: 1d103d6af241dbfc7e11eb9a46dff65db257a37f
[2/2] soc: qcom: pmic_glink: enable UCSI by default
      commit: 4db09e7b967b905ba3036a4d96e81c06b896b1bf

Best regards,