Skip to contentSkip to conversation

tps6598x: clear int mask on probe failure

PATCH In review Jens Axboe 3 participants 4 messages Feb 15, 2022 – Feb 17, 2022

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH 1/1 tps6598x: clear int mask on probe failure

The interrupt mask is enabled before any potential failure points in the driver, which can leave a failure path where we exit with interrupts enabled but the device not live. This causes an infinite stream of interrupts on an Apple M1 Pro laptop on USB-C.

Add a failure label that's used post enabling interrupts, where we mask them again before returning an error.

---
 drivers/usb/typec/tipd/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +4 -3
index 6d27a5b5e3ca..7ffcda94d323 100644
@@ -761,12 +761,12 @@ static int tps6598x_probe(struct i2c_client *client)
 
 	ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
 	if (ret < 0)
-		return ret;
+		goto err_clear_mask;
 	trace_tps6598x_status(status);
 
 	ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf);
 	if (ret < 0)
-		return ret;
+		goto err_clear_mask;
 
 	/*
 	 * This fwnode has a "compatible" property, but is never populated as a
@@ -855,7 +855,8 @@ static int tps6598x_probe(struct i2c_client *client)
 	usb_role_switch_put(tps->role_sw);
 err_fwnode_put:
 	fwnode_handle_put(fwnode);
-
+err_clear_mask:
+	tps6598x_write64(tps, TPS_REG_INT_MASK1, 0);
 	return ret;
 }
 
Signature · 4 lines
2.34.1

-- 
Jens Axboe
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jens Axboe

The interrupt mask is enabled before any potential failure points in the driver, which can leave a failure path where we exit with interrupts enabled but the device not live. This causes an infinite stream of interrupts on an Apple M1 Pro laptop on USB-C.

Add a failure label that's used post enabling interrupts, where we mask them again before returning an error.

Should this be marked as a fix?

Quoted 32 lines
---
 drivers/usb/typec/tipd/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +4 -3
index 6d27a5b5e3ca..7ffcda94d323 100644
@@ -761,12 +761,12 @@ static int tps6598x_probe(struct i2c_client *client)
 
 	ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
 	if (ret < 0)
-		return ret;
+		goto err_clear_mask;
 	trace_tps6598x_status(status);
 
 	ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf);
 	if (ret < 0)
-		return ret;
+		goto err_clear_mask;
 
 	/*
 	 * This fwnode has a "compatible" property, but is never populated as a
@@ -855,7 +855,8 @@ static int tps6598x_probe(struct i2c_client *client)
 	usb_role_switch_put(tps->role_sw);
 err_fwnode_put:
 	fwnode_handle_put(fwnode);
-
+err_clear_mask:
+	tps6598x_write64(tps, TPS_REG_INT_MASK1, 0);
 	return ret;
 }
Signature · 1 line
heikki
author
#2 lore raw
Quoted 6 lines · Heikki Krogerus
Quoted 5 lines · Jens Axboe

The interrupt mask is enabled before any potential failure points in the driver, which can leave a failure path where we exit with interrupts enabled but the device not live. This causes an infinite stream of interrupts on an Apple M1 Pro laptop on USB-C.

Quoted 7 lines
Quoted 5 lines

Add a failure label that's used post enabling interrupts, where we mask them again before returning an error.

Should this be marked as a fix?

Maybe, I can try and dig out the offending commit. From some quick checking, it didn't come in with recent fixes, so it's probably been there since support got added. Maybe we just mark it stable?

Quoted 1 line

Thanks! Greg, will you pick this up?

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 15 lines · Jens Axboe
Quoted 6 lines · Heikki Krogerus
Quoted 5 lines · Jens Axboe

The interrupt mask is enabled before any potential failure points in the driver, which can leave a failure path where we exit with interrupts enabled but the device not live. This causes an infinite stream of interrupts on an Apple M1 Pro laptop on USB-C.

Quoted 7 lines
Quoted 5 lines

Add a failure label that's used post enabling interrupts, where we mask them again before returning an error.

Should this be marked as a fix?

Quoted 7 lines

Maybe, I can try and dig out the offending commit. From some quick checking, it didn't come in with recent fixes, so it's probably been there since support got added. Maybe we just mark it stable?

Quoted 1 line

Thanks! Greg, will you pick this up?

Will do, thanks.

greg k-h