usb: typec: tcpci: clear the fault status bit
Subsystems (4)
PATCH v3 1/1 usb: typec: tcpci: clear the fault status bit
From: Marco Felsch <[email protected]>
According the "USB Type-C Port Controller Interface Specification v2.0" the TCPC sets the fault status register bit-7 (AllRegistersResetToDefault) once the registers have been reset to their default values.
This triggers an alert(-irq) on PTN5110 devices albeit we do mask the fault-irq, which may cause a kernel hang. Fix this generically by writing a one to the corresponding bit-7.
---
Changes since v2:
- Submitted it as a standalone patch.
- Explain that it may cause a kernel hang.
- Fixed typos in the commit log. (Guenter)
- Check the tcpci_write16() return value. (Guenter)
- Write to TCPC_FAULT_STATUS unconditionally. (Guenter)
- Added Fixes, Reported-by and Closes tags.
- CCed stable
drivers/usb/typec/tcpm/tcpci.c | 4 ++++ include/linux/usb/tcpci.h | 1 + 2 files changed, 5 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +4 -0
@@ -602,6 +602,10 @@ static int tcpci_init(struct tcpc_dev *tcpc)if (time_after (jiffies, timeout))return -ETIMEDOUT ; + ret =tcpci_write16 (tcpci,TCPC_FAULT_STATUS ,TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT ); +if (ret <0 ) +return ret; +/* Handle vendor init */ if (tcpci->data->init) { ret = tcpci->data->init (tcpci, tcpci->data);
include/linux/usb/tcpci.h +1 -0
@@ -103,6 +103,7 @@#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)#define TCPC_FAULT_STATUS 0x1f +#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)#define TCPC_ALERT_EXTENDED 0x21
Signature · 1 line
2.34.1
Quoted 11 lines · Fabio Estevam
From: Marco Felsch <[email protected]>
According the "USB Type-C Port Controller Interface Specification v2.0" the TCPC sets the fault status register bit-7 (AllRegistersResetToDefault) once the registers have been reset to their default values.
This triggers an alert(-irq) on PTN5110 devices albeit we do mask the fault-irq, which may cause a kernel hang. Fix this generically by writing a one to the corresponding bit-7.
Quoted 8 lines
Fixes 74e656d6b055 ("staging: typec: Type-C Port Controller Interface driver (tcpci)")Reported-by Angus Ainslie (Purism) <[email protected]>Reported-by Christian Bach <[email protected]>Closes https://lore.kernel.org/regressions/ZR0P278MB07737E5F1D48632897D51AC3EB329@ZR0P278MB0773.CHEP278.PROD.OUTLOOK.COM/t/ open hereSigned-off-by Marco Felsch <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
Quoted 44 lines
---
Changes since v2:
- Submitted it as a standalone patch.
- Explain that it may cause a kernel hang.
- Fixed typos in the commit log. (Guenter)
- Check thetcpci_write16()return value. (Guenter)
- Write toTCPC_FAULT_STATUSunconditionally. (Guenter)
- Added Fixes, Reported-by and Closes tags.
- CCed stabledrivers/usb/typec/tcpm/tcpci.c | 4 ++++ include/linux/usb/tcpci.h | 1 + 2 files changed, 5 insertions(+)drivers/usb/typec/tcpm/tcpci.c +4
-0@@ -602,6 +602,10 @@ static int tcpci_init(struct tcpc_dev *tcpc)if (time_after (jiffies, timeout))return -ETIMEDOUT ; + ret =tcpci_write16 (tcpci,TCPC_FAULT_STATUS ,TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT ); +if (ret <0 ) +return ret; +/* Handle vendor init */ if (tcpci->data->init) { ret = tcpci->data->init (tcpci, tcpci->data);include/linux/usb/tcpci.h +1
-0@@ -103,6 +103,7 @@#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)#define TCPC_FAULT_STATUS 0x1f +#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)#define TCPC_ALERT_EXTENDED 0x21Signature · 1 line
2.34.1
Quoted 19 lines · Fabio Estevam
From: Marco Felsch <[email protected]>
According the "USB Type-C Port Controller Interface Specification v2.0" the TCPC sets the fault status register bit-7 (AllRegistersResetToDefault) once the registers have been reset to their default values.
This triggers an alert(-irq) on PTN5110 devices albeit we do mask the fault-irq, which may cause a kernel hang. Fix this generically by writing a one to the corresponding bit-7.
Fixes 74e656d6b055 ("staging: typec: Type-C Port Controller Interface driver (tcpci)")Reported-by Angus Ainslie (Purism) <[email protected]>Reported-by Christian Bach <[email protected]>Closes https://lore.kernel.org/regressions/ZR0P278MB07737E5F1D48632897D51AC3EB329@ZR0P278MB0773.CHEP278.PROD.OUTLOOK.COM/t/ open hereSigned-off-by Marco Felsch <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
Quoted 9 lines
---
Changes since v2:
- Submitted it as a standalone patch.
- Explain that it may cause a kernel hang.
- Fixed typos in the commit log. (Guenter)
- Check thetcpci_write16()return value. (Guenter)
- Write toTCPC_FAULT_STATUSunconditionally. (Guenter)
- Added Fixes, Reported-by and Closes tags.
- CCed stable
thanks for the work Fabio :)
Regards,
Marco
Quoted 36 lines
drivers/usb/typec/tcpm/tcpci.c | 4 ++++ include/linux/usb/tcpci.h | 1 + 2 files changed, 5 insertions(+)drivers/usb/typec/tcpm/tcpci.c +4
-0@@ -602,6 +602,10 @@ static int tcpci_init(struct tcpc_dev *tcpc)if (time_after (jiffies, timeout))return -ETIMEDOUT ; + ret =tcpci_write16 (tcpci,TCPC_FAULT_STATUS ,TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT ); +if (ret <0 ) +return ret; +/* Handle vendor init */ if (tcpci->data->init) { ret = tcpci->data->init (tcpci, tcpci->data);include/linux/usb/tcpci.h +1
-0@@ -103,6 +103,7 @@#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)#define TCPC_FAULT_STATUS 0x1f +#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)#define TCPC_ALERT_EXTENDED 0x21Signature · 1 line
2.34.1
Quoted 11 lines · Fabio Estevam
From: Marco Felsch <[email protected]>
According the "USB Type-C Port Controller Interface Specification v2.0" the TCPC sets the fault status register bit-7 (AllRegistersResetToDefault) once the registers have been reset to their default values.
This triggers an alert(-irq) on PTN5110 devices albeit we do mask the fault-irq, which may cause a kernel hang. Fix this generically by writing a one to the corresponding bit-7.
Quoted 8 lines
Fixes 74e656d6b055 ("staging: typec: Type-C Port Controller Interface driver (tcpci)")Reported-by Angus Ainslie (Purism) <[email protected]>Reported-by Christian Bach <[email protected]>Closes https://lore.kernel.org/regressions/ZR0P278MB07737E5F1D48632897D51AC3EB329@ZR0P278MB0773.CHEP278.PROD.OUTLOOK.COM/t/ open hereSigned-off-by Marco Felsch <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
Quoted 43 lines
---
Changes since v2:
- Submitted it as a standalone patch.
- Explain that it may cause a kernel hang.
- Fixed typos in the commit log. (Guenter)
- Check thetcpci_write16()return value. (Guenter)
- Write toTCPC_FAULT_STATUSunconditionally. (Guenter)
- Added Fixes, Reported-by and Closes tags.
- CCed stabledrivers/usb/typec/tcpm/tcpci.c | 4 ++++ include/linux/usb/tcpci.h | 1 + 2 files changed, 5 insertions(+)drivers/usb/typec/tcpm/tcpci.c +4
-0@@ -602,6 +602,10 @@ static int tcpci_init(struct tcpc_dev *tcpc)if (time_after (jiffies, timeout))return -ETIMEDOUT ; + ret =tcpci_write16 (tcpci,TCPC_FAULT_STATUS ,TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT ); +if (ret <0 ) +return ret; +/* Handle vendor init */ if (tcpci->data->init) { ret = tcpci->data->init (tcpci, tcpci->data);include/linux/usb/tcpci.h +1
-0@@ -103,6 +103,7 @@#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)#define TCPC_FAULT_STATUS 0x1f +#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)#define TCPC_ALERT_EXTENDED 0x21Signature · 1 line
2.34.1
Signature · 1 line
heikki