Skip to contentSkip to conversation

FAILED: patch "[PATCH] usb: typec: tcpci: clear the fault status bit" failed to apply to 5.15-stable tree

PATCH New [email protected] 3 participants 5 messages Sep 3, 2023 – Sep 4, 2023

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 23e60c8daf5ec2ab1b731310761b668745fcf6ed
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023090314-headroom-doorbell-3ac8@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..

Possible dependencies:

23e60c8daf5e ("usb: typec: tcpci: clear the fault status bit")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 23e60c8daf5ec2ab1b731310761b668745fcf6ed Mon Sep 17 00:00:00 2001
From: Marco Felsch <[email protected]>
Date: Wed, 16 Aug 2023 14:25:02 -0300
Subject: [PATCH] usb: typec: tcpci: clear the fault status bit

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.

drivers/usb/typec/tcpm/tcpci.c +4 -0
index fc708c289a73..0ee3e6e29bb1 100644
@@ -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
index 85e95a3251d3..83376473ac76 100644
@@ -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
 
#1 lore raw

PATCH 1/2 usb: typec: tcpci: move tcpci.h to include/linux/usb/

From: Xin Ji <[email protected]>

[ Upstream commit 7963d4d710112bc457f99bdb56608211e561190e ]

USB PD controllers which consisting of a microcontroller (acting as the TCPM) and a port controller (TCPC) - may require that the driver for the PD controller accesses directly also the on-chip port controller in some cases.

Move tcpci.h to include/linux/usb/ is convenience access TCPC registers.

Stable-dep-of: 23e60c8daf5e ("usb: typec: tcpci: clear the fault status bit")

---
 drivers/usb/typec/tcpm/tcpci.c                        | 3 +--
 drivers/usb/typec/tcpm/tcpci_maxim.c                  | 3 +--
 drivers/usb/typec/tcpm/tcpci_mt6360.c                 | 3 +--
 drivers/usb/typec/tcpm/tcpci_rt1711h.c                | 2 +-
 {drivers/usb/typec/tcpm => include/linux/usb}/tcpci.h | 1 +
 5 files changed, 5 insertions(+), 7 deletions(-)
 rename {drivers/usb/typec/tcpm => include/linux/usb}/tcpci.h (99%)
drivers/usb/typec/tcpm/tcpci.c +1 -2
index 5340a3a3a81b..1a6aea9edc78 100644
@@ -13,11 +13,10 @@
 #include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/usb/pd.h>
+#include <linux/usb/tcpci.h>
 #include <linux/usb/tcpm.h>
 #include <linux/usb/typec.h>
 
-#include "tcpci.h"
-
 #define	PD_RETRY_COUNT_DEFAULT			3
 #define	PD_RETRY_COUNT_3_0_OR_HIGHER		2
 #define	AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV	3500
drivers/usb/typec/tcpm/tcpci_maxim.c +1 -2
index df2505570f07..4b6705f3d7b7 100644
@@ -11,11 +11,10 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/usb/pd.h>
+#include <linux/usb/tcpci.h>
 #include <linux/usb/tcpm.h>
 #include <linux/usb/typec.h>
 
-#include "tcpci.h"
-
 #define PD_ACTIVITY_TIMEOUT_MS				10000
 
 #define TCPC_VENDOR_ALERT				0x80
drivers/usb/typec/tcpm/tcpci_mt6360.c +1 -2
index 8a952eaf9016..1b7c31278ebb 100644
@@ -11,10 +11,9 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/usb/tcpci.h>
 #include <linux/usb/tcpm.h>
 
-#include "tcpci.h"
-
 #define MT6360_REG_PHYCTRL1	0x80
 #define MT6360_REG_PHYCTRL3	0x82
 #define MT6360_REG_PHYCTRL7	0x86
drivers/usb/typec/tcpm/tcpci_rt1711h.c +1 -1
index b56a0880a044..3291ca4948da 100644
@@ -10,9 +10,9 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/gpio/consumer.h>
+#include <linux/usb/tcpci.h>
 #include <linux/usb/tcpm.h>
 #include <linux/regmap.h>
-#include "tcpci.h"
 
 #define RT1711H_VID		0x29CF
 #define RT1711H_PID		0x1711
include/linux/usb/tcpci.h renamed from drivers/usb/typec/tcpm/tcpci.h +1 -0
similarity index 99%
rename from drivers/usb/typec/tcpm/tcpci.h
rename to include/linux/usb/tcpci.h
index b2edd45f13c6..20c0bedb8ec8 100644
@@ -9,6 +9,7 @@
 #define __LINUX_USB_TCPCI_H
 
 #include <linux/usb/typec.h>
+#include <linux/usb/tcpm.h>
 
 #define TCPC_VENDOR_ID			0x0
 #define TCPC_PRODUCT_ID			0x2
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 usb: typec: tcpci: clear the fault status bit

From: Marco Felsch <[email protected]>

[ Upstream commit 23e60c8daf5ec2ab1b731310761b668745fcf6ed ]

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.

---
 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
index 1a6aea9edc78..a7b0134d382b 100644
@@ -615,6 +615,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
index 20c0bedb8ec8..f7c01ce879a2 100644
@@ -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
#3 lore raw
In reply to [email protected]
Quoted 4 lines · On 03/09/2023 13:57, [email protected] wrote:

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

The reason that it fails to apply against 5.15 is due to the missing commit:

7963d4d71011 ("usb: typec: tcpci: move tcpci.h to include/linux/usb/")

I have submitted it as part of a series that applies cleanly against 5.15.

Thanks

author maintainer
#4 lore raw
Quoted 11 lines · Fabio Estevam
Quoted 4 lines · On 03/09/2023 13:57, [email protected] wrote:

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

The reason that it fails to apply against 5.15 is due to the missing commit:

7963d4d71011 ("usb: typec: tcpci: move tcpci.h to include/linux/usb/")

I have submitted it as part of a series that applies cleanly against 5.15.

Thanks all now queued up.

greg k-h