Skip to contentSkip to conversation

usb: typec: tcpci_rt1711h: avoid screaming irq causing boot hangs

PATCH Superseded [email protected] 3 participants 3 messages Jun 3, 2020 – Jun 4, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: typec: tcpci_rt1711h: avoid screaming irq causing boot hangs

From: Li Jun <[email protected]>

John reported screaming irq caused by rt1711h when system boot[1], this is because irq request is done before tcpci_register_port(), so the chip->tcpci has not been setup, irq handler is entered but can't do anything, this patch is to address this by moving the irq request after tcpci_register_port().

[1] https://lore.kernel.org/linux-usb/[email protected]

Fixes ce08eaeb6388 ("staging: typec: rt1711h typec chip driver")
Cc John Stultz <[email protected]>

---
changes for v2:
- Add fix tag.
- Use lore.kernel.org link.
- Add Guenter's R-b tag.

 drivers/usb/typec/tcpm/tcpci_rt1711h.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/usb/typec/tcpm/tcpci_rt1711h.c +10 -21
index 0173890..b56a088 100644
@@ -179,26 +179,6 @@ static irqreturn_t rt1711h_irq(int irq, void *dev_id)
 	return tcpci_irq(chip->tcpci);
 }
 
-static int rt1711h_init_alert(struct rt1711h_chip *chip,
-			      struct i2c_client *client)
-{
-	int ret;
-
-	/* Disable chip interrupts before requesting irq */
-	ret = rt1711h_write16(chip, TCPC_ALERT_MASK, 0);
-	if (ret < 0)
-		return ret;
-
-	ret = devm_request_threaded_irq(chip->dev, client->irq, NULL,
-					rt1711h_irq,
-					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
-					dev_name(chip->dev), chip);
-	if (ret < 0)
-		return ret;
-	enable_irq_wake(client->irq);
-	return 0;
-}
-
 static int rt1711h_sw_reset(struct rt1711h_chip *chip)
 {
 	int ret;
@@ -260,7 +240,8 @@ static int rt1711h_probe(struct i2c_client *client,
 	if (ret < 0)
 		return ret;
 
-	ret = rt1711h_init_alert(chip, client);
+	/* Disable chip interrupts before requesting irq */
+	ret = rt1711h_write16(chip, TCPC_ALERT_MASK, 0);
 	if (ret < 0)
 		return ret;
 
@@ -271,6 +252,14 @@ static int rt1711h_probe(struct i2c_client *client,
 	if (IS_ERR_OR_NULL(chip->tcpci))
 		return PTR_ERR(chip->tcpci);
 
+	ret = devm_request_threaded_irq(chip->dev, client->irq, NULL,
+					rt1711h_irq,
+					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
+					dev_name(chip->dev), chip);
+	if (ret < 0)
+		return ret;
+	enable_irq_wake(client->irq);
+
 	return 0;
 }
 
Signature · 1 line
2.7.4
Tested-by on v2 1/1
#1 lore raw
Quoted 9 lines · On Tue, Jun 2, 2020 at 6:18 PM <[email protected]> wrote:

From: Li Jun <[email protected]>

John reported screaming irq caused by rt1711h when system boot[1], this is because irq request is done before tcpci_register_port(), so the chip->tcpci has not been setup, irq handler is entered but can't do anything, this patch is to address this by moving the irq request after tcpci_register_port().

Quoted 6 lines

[1] https://lore.kernel.org/linux-usb/[email protected]

Fixes ce08eaeb6388 ("staging: typec: rt1711h typec chip driver")
Cc John Stultz <[email protected]>

Thanks so much for this, and sorry for my delay here.

thanks
-john

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, Jun 03, 2020 at 09:02:51AM +0800, [email protected] wrote:

From: Li Jun <[email protected]>

John reported screaming irq caused by rt1711h when system boot[1], this is because irq request is done before tcpci_register_port(), so the chip->tcpci has not been setup, irq handler is entered but can't do anything, this patch is to address this by moving the irq request after tcpci_register_port().

Quoted 6 lines

[1] https://lore.kernel.org/linux-usb/[email protected]

Fixes ce08eaeb6388 ("staging: typec: rt1711h typec chip driver")
Cc John Stultz <[email protected]>

No Cc: <[email protected]> ? In any case, FWIW:

Quoted 54 lines

---
changes for v2:
- Add fix tag.
- Use lore.kernel.org link.
- Add Guenter's R-b tag.

 drivers/usb/typec/tcpm/tcpci_rt1711h.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/usb/typec/tcpm/tcpci_rt1711h.c +2 -21
index 0173890..b56a088 100644
@@ -179,26 +179,6 @@ static irqreturn_t rt1711h_irq(int irq, void *dev_id)
 	return tcpci_irq(chip->tcpci);
 }
 
-static int rt1711h_init_alert(struct rt1711h_chip *chip,
-			      struct i2c_client *client)
-{
-	int ret;
-
-	/* Disable chip interrupts before requesting irq */
-	ret = rt1711h_write16(chip, TCPC_ALERT_MASK, 0);
-	if (ret < 0)
-		return ret;
-
-	ret = devm_request_threaded_irq(chip->dev, client->irq, NULL,
-					rt1711h_irq,
-					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
-					dev_name(chip->dev), chip);
-	if (ret < 0)
-		return ret;
-	enable_irq_wake(client->irq);
-	return 0;
-}
-
 static int rt1711h_sw_reset(struct rt1711h_chip *chip)
 {
 	int ret;
@@ -260,7 +240,8 @@ static int rt1711h_probe(struct i2c_client *client,
 	if (ret < 0)
 		return ret;
 
-	ret = rt1711h_init_alert(chip, client);
+	/* Disable chip interrupts before requesting irq */
+	ret = rt1711h_write16(chip, TCPC_ALERT_MASK, 0);
 	if (ret < 0)
 		return ret;
 
@@ -271,6 +252,14 @@ static int rt1711h_probe(struct i2c_client *client,
 	if (IS_ERR_OR_NULL(chip->tcpci))
 		return PTR_ERR(chip->tcpci);
 

drivers/usb/typec/tcpm/tcpci_rt1711h.c static int rt1711h_probe(struct i2c_client *client, · line 264

Quoted 10 lines
drivers/usb/typec/tcpm/tcpci_rt1711h.c +8 -0
+	ret = devm_request_threaded_irq(chip->dev, client->irq, NULL,
+					rt1711h_irq,
+					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
+					dev_name(chip->dev), chip);
+	if (ret < 0)
+		return ret;
+	enable_irq_wake(client->irq);
+
 	return 0;
 }

thanks,

Signature · 1 line
heikki