Fix stuck UCSI controller on DELL
Subsystems (2)
RFC 1/1 Fix stuck UCSI controller on DELL
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (GET_CONNECTOR_STATUS failed (-110)).
This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
regards Christian
drivers/usb/typec/ucsi/ucsi.c +4 -1
@@ -53,7 +53,10 @@ static int ucsi_acknowledge_connector_change(struct ucsi *ucsi) ctrl =UCSI_ACK_CC_CI ; ctrl |=UCSI_ACK_CONNECTOR_CHANGE ; -return ucsi->ops->sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); +if (ucsi->ops->sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl))) +pr_err ("ACK FAILED\n" ); + +return ucsi_acknowledge_command (ucsi); }static int ucsi_exec_command (struct ucsi *ucsi,u64 command);
Signature · 1 line
2.40.1
Heikki Krogerus
maintainerHi Christian,
Quoted 9 lines · Christian A. Ehrhardt
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (
GET_CONNECTOR_STATUSfailed (-110)).This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Quoted 4 lines
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
We can use DMI quirks. Something like the attached diff (not tested).
thanks,
Signature · 1 line
heikki
drivers/usb/typec/ucsi/ucsi_acpi.c +36 -8
@@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_return 0 ; } -static const struct ucsi_operations ucsi_zenbook_ops = { - .read = ucsi_zenbook_read, - .sync_write = ucsi_acpi_sync_write, - .async_write = ucsi_acpi_async_write -}; +static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset, +const void *val,size_t val_len) +{ +u64 ctrl = *(u64 *)val; +int ret; + + ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); +if (ret && (ctrl & (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE ))) { + ctrl=UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; + +dev_dbg (ucsi->dev->parent,"%s: ACK failed\n" , __func__); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); + } -static const struct dmi_system_id zenbook_dmi_id[] = { +return ret; +} + +static const struct dmi_system_id ucsi_acpi_quirks[] = { { .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ),DMI_MATCH (DMI_PRODUCT_NAME ,"ZenBook UX325UA_UM325UA" ), }, + .driver_data = &(struct ucsi_operations ) { + .read = ucsi_zenbook_read, + .sync_write = ucsi_acpi_sync_write, + .async_write = ucsi_acpi_async_write + }, + }, + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), + }, + .driver_data = &(struct ucsi_operations ) { + .read = ucsi_acpi_read, + .sync_write = ucsi_dell_sync_write, + .async_write = ucsi_acpi_async_write + }, }, { } };
@@ -151,6 +177,7 @@ static int ucsi_acpi_probe(struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);const struct ucsi_operations *ops = &ucsi_acpi_ops; +const struct dmi_system_id *id;struct ucsi_acpi *ua;struct resource *res;acpi_status status;
@@ -180,8 +207,9 @@ static int ucsi_acpi_probe(struct platform_device *pdev)init_completion (&ua->complete); ua->dev = &pdev->dev; -if (dmi_check_system (zenbook_dmi_id)) - ops = &ucsi_zenbook_ops; + id =dmi_first_match (ucsi_acpi_quirks); +if (id) + ops = id->driver_data; ua->ucsi =ucsi_create (&pdev->dev, ops);if (IS_ERR (ua->ucsi))
Hi Heikki,
sorry to bother you again with this but I'm afraid there's a misunderstanding wrt. the nature of the quirk. See below:
Quoted 40 lines · Heikki Krogerus
Hi Christian,
Quoted 9 lines · Christian A. Ehrhardt
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (
GET_CONNECTOR_STATUSfailed (-110)).This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Quoted 4 lines
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
We can use DMI quirks. Something like the attached diff (not tested).
thanks,
Signature · 1 line
heikkidrivers/usb/typec/ucsi/ucsi_acpi.c +3
-5@@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_return 0 ; } -static const struct ucsi_operations ucsi_zenbook_ops = { - .read = ucsi_zenbook_read, - .sync_write = ucsi_acpi_sync_write, - .async_write = ucsi_acpi_async_write -}; +static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset, +const void *val,size_t val_len) +{
drivers/usb/typec/ucsi/ucsi_acpi.c ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_ · line 128
Quoted 10 lines
drivers/usb/typec/ucsi/ucsi_acpi.c +10
-0+u64 ctrl = *(u64 *)val; +int ret; + + ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); +if (ret && (ctrl & (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE ))) { + ctrl=UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; + +dev_dbg (ucsi->dev->parent,"%s: ACK failed\n" , __func__); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); + }
Unfortunately, this has the logic reversed. The quirk (i.e. the additional UCSI_ACK_COMMAND_COMPLETE) is required after a _successful_ UCSI_ACK_CONNECTOR_CHANGE. Otherwise, _subsequent_ commands will timeout (usually the next GET_CONNECTOR_CHANGE).
This means the quirk must be applied _before_ we detect any failure. Consequently, the quirk has the potential to break working systems.
Sorry, if that wasn't clear from my original mail. Please let me know if this changes how you want the quirks handled.
Thanks Christian
Quoted 63 lines · Christian A. Ehrhardt
Hi Heikki,
sorry to bother you again with this but I'm afraid there's a misunderstanding wrt. the nature of the quirk. See below:
Quoted 40 lines · Heikki Krogerus
Hi Christian,
Quoted 9 lines · Christian A. Ehrhardt
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (
GET_CONNECTOR_STATUSfailed (-110)).This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Quoted 4 lines
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
We can use DMI quirks. Something like the attached diff (not tested).
thanks,
Signature · 1 line
heikkidrivers/usb/typec/ucsi/ucsi_acpi.c +3
-5@@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_return 0 ; } -static const struct ucsi_operations ucsi_zenbook_ops = { - .read = ucsi_zenbook_read, - .sync_write = ucsi_acpi_sync_write, - .async_write = ucsi_acpi_async_write -}; +static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset, +const void *val,size_t val_len) +{drivers/usb/typec/ucsi/ucsi_acpi.c ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_ · line 128
Quoted 10 lines
drivers/usb/typec/ucsi/ucsi_acpi.c +10
-0+u64 ctrl = *(u64 *)val; +int ret; + + ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); +if (ret && (ctrl & (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE ))) { + ctrl=UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; + +dev_dbg (ucsi->dev->parent,"%s: ACK failed\n" , __func__); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); + }Unfortunately, this has the logic reversed. The quirk (i.e. the additional
UCSI_ACK_COMMAND_COMPLETE) is required after a _successful_UCSI_ACK_CONNECTOR_CHANGE. Otherwise, _subsequent_ commands will timeout (usually the nextGET_CONNECTOR_CHANGE).
Quoted 8 lines
This means the quirk must be applied _before_ we detect any failure. Consequently, the quirk has the potential to break working systems.
Sorry, if that wasn't clear from my original mail. Please let me know if this changes how you want the quirks handled.
Thanks Christian
For the problematic scenario have you tried to play with it a bit to see if it's too short of a timeout (raise timeout) or to output the response bits to see if anything else surprising is sent?
Does it always fail on the same command, or does it happen to a bunch of them?
Hi Mario,
Quoted 69 lines · Mario Limonciello
Quoted 68 lines · Christian A. Ehrhardt
Hi Heikki,
sorry to bother you again with this but I'm afraid there's a misunderstanding wrt. the nature of the quirk. See below:
Quoted 39 lines · Heikki Krogerus
Hi Christian,
Quoted 9 lines · Christian A. Ehrhardt
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (
GET_CONNECTOR_STATUSfailed (-110)).This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Quoted 4 lines
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
We can use DMI quirks. Something like the attached diff (not tested).
thanks,
Signature · 1 line
heikkidrivers/usb/typec/ucsi/ucsi_acpi.c +3
-5@@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_return 0 ; } -static const struct ucsi_operations ucsi_zenbook_ops = { - .read = ucsi_zenbook_read, - .sync_write = ucsi_acpi_sync_write, - .async_write = ucsi_acpi_async_write -}; +static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset, +const void *val,size_t val_len) +{drivers/usb/typec/ucsi/ucsi_acpi.c ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_ · line 127
Quoted 10 lines
drivers/usb/typec/ucsi/ucsi_acpi.c +10
-0+u64 ctrl = *(u64 *)val; +int ret; + + ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); +if (ret && (ctrl & (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE ))) { + ctrl=UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; + +dev_dbg (ucsi->dev->parent,"%s: ACK failed\n" , __func__); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); + }Unfortunately, this has the logic reversed. The quirk (i.e. the additional
UCSI_ACK_COMMAND_COMPLETE) is required after a _successful_UCSI_ACK_CONNECTOR_CHANGE. Otherwise, _subsequent_ commands will timeout (usually the nextGET_CONNECTOR_CHANGE).This means the quirk must be applied _before_ we detect any failure. Consequently, the quirk has the potential to break working systems.
Sorry, if that wasn't clear from my original mail. Please let me know if this changes how you want the quirks handled.
Quoted 6 lines
Quoted 2 lines
Thanks Christian
For the problematic scenario have you tried to play with it a bit to see if it's too short of a timeout (raise timeout) or to output the response bits to see if anything else surprising is sent?
It is not a problem with the timeout. Waiting forever in this case doesn't help. IMHO this is actually a bug in the PPM, i.e. in Dell's bios.
Sending an ack after the timeout fixes things, though.
Quoted 2 lines
Does it always fail on the same command, or does it happen to a bunch of them?
It always fails on the first command after UCSI_ACK_CC_CI for a connector change. However, there might be no such command if the next event is a notification.
I did play around with it a bit more and came up with a way to probe for the issue:
https://lore.kernel.orgorg/all/[email protected]/
regards Christian
Quoted 76 lines · Christian A. Ehrhardt
Hi Mario,
Quoted 72 lines · Mario Limonciello
Quoted 70 lines · Christian A. Ehrhardt
Hi Heikki,
sorry to bother you again with this but I'm afraid there's a misunderstanding wrt. the nature of the quirk. See below:
Quoted 39 lines · Heikki Krogerus
Hi Christian,
Quoted 9 lines · Christian A. Ehrhardt
I have a DELL Latitude 5431 where typec only works somewhat. After the first plug/unplug event the PPM seems to be stuck and commands end with a timeout (
GET_CONNECTOR_STATUSfailed (-110)).This patch fixes it for me but according to my reading it is in violation of the UCSI spec. On the other hand searching through the net it appears that many DELL models seem to have timeout problems with UCSI.
Quoted 4 lines
Do we want some kind of quirk here? There does not seem to be a quirk framework for this part of the code, yet. Or is it ok to just send the additional ACK in all cases and hope that the PPM will do the right thing?
We can use DMI quirks. Something like the attached diff (not tested).
thanks,
Signature · 1 line
heikkidrivers/usb/typec/ucsi/ucsi_acpi.c +3
-5@@ -113,18 +113,44 @@ ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_return 0 ; } -static const struct ucsi_operations ucsi_zenbook_ops = { - .read = ucsi_zenbook_read, - .sync_write = ucsi_acpi_sync_write, - .async_write = ucsi_acpi_async_write -}; +static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset, +const void *val,size_t val_len) +{drivers/usb/typec/ucsi/ucsi_acpi.c ucsi_zenbook_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_ · line 127
Quoted 10 lines
drivers/usb/typec/ucsi/ucsi_acpi.c +10
-0+u64 ctrl = *(u64 *)val; +int ret; + + ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); +if (ret && (ctrl & (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE ))) { + ctrl=UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; + +dev_dbg (ucsi->dev->parent,"%s: ACK failed\n" , __func__); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ctrl,sizeof (ctrl)); + }Unfortunately, this has the logic reversed. The quirk (i.e. the additional
UCSI_ACK_COMMAND_COMPLETE) is required after a _successful_UCSI_ACK_CONNECTOR_CHANGE. Otherwise, _subsequent_ commands will timeout (usually the nextGET_CONNECTOR_CHANGE).This means the quirk must be applied _before_ we detect any failure. Consequently, the quirk has the potential to break working systems.
Sorry, if that wasn't clear from my original mail. Please let me know if this changes how you want the quirks handled.
Thanks Christian
Quoted 7 lines
Quoted 3 lines
For the problematic scenario have you tried to play with it a bit to see if it's too short of a timeout (raise timeout) or to output the response bits to see if anything else surprising is sent?
It is not a problem with the timeout. Waiting forever in this case doesn't help. IMHO this is actually a bug in the PPM, i.e. in Dell's bios.
"Usually" the PD controller F/W is distributed with the EC, but yes Dell nominally puts everything in a monolithic BIOS package.
Quoted 6 lines
Sending an ack after the timeout fixes things, though.
Quoted 2 lines
Does it always fail on the same command, or does it happen to a bunch of them?
Quoted 8 lines
It always fails on the first command after
UCSI_ACK_CC_CIfor a connector change. However, there might be no such command if the next event is a notification.I did play around with it a bit more and came up with a way to probe for the issue:
https://lore.kernel.orgorg/all/[email protected]/
If some variation of your prob-able workaround is picked up I think it's worth making noise when probed (dev_warn or dev_notice) about this situation that it is being used to workaround a PPM bug.
Quoted 4 lines
regards Christian
+ Dell Client Kernel mailbox
Dell team,
Can you look into this? It sounds like it should be investigated more closely to see where the impedance mismatch against the spec and real behavior actually lies.