All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tps6598x: clear int mask on probe failure
@ 2022-02-15 18:22 Jens Axboe
  2022-02-17  8:30 ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-02-15 18:22 UTC (permalink / raw)
  To: heikki.krogerus, Greg Kroah-Hartman; +Cc: linux-usb, LKML, Sven Peter

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.

Suggested-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/typec/tipd/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 6d27a5b5e3ca..7ffcda94d323 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -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;
 }
 
-- 
2.34.1

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tps6598x: clear int mask on probe failure
  2022-02-15 18:22 [PATCH] tps6598x: clear int mask on probe failure Jens Axboe
@ 2022-02-17  8:30 ` Heikki Krogerus
  2022-02-17 13:51   ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2022-02-17  8:30 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Greg Kroah-Hartman, linux-usb, LKML, Sven Peter

On Tue, Feb 15, 2022 at 11:22:04AM -0700, Jens Axboe wrote:
> 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.
> 
> Suggested-by: Sven Peter <sven@svenpeter.dev>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Should this be marked as a fix?

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 6d27a5b5e3ca..7ffcda94d323 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -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;
>  }

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tps6598x: clear int mask on probe failure
  2022-02-17  8:30 ` Heikki Krogerus
@ 2022-02-17 13:51   ` Jens Axboe
  2022-02-17 14:08     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-02-17 13:51 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: Greg Kroah-Hartman, linux-usb, LKML, Sven Peter

On 2/17/22 1:30 AM, Heikki Krogerus wrote:
> On Tue, Feb 15, 2022 at 11:22:04AM -0700, Jens Axboe wrote:
>> 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.
>>
>> Suggested-by: Sven Peter <sven@svenpeter.dev>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> 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?

> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Thanks! Greg, will you pick this up?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tps6598x: clear int mask on probe failure
  2022-02-17 13:51   ` Jens Axboe
@ 2022-02-17 14:08     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-17 14:08 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Heikki Krogerus, linux-usb, LKML, Sven Peter

On Thu, Feb 17, 2022 at 06:51:27AM -0700, Jens Axboe wrote:
> On 2/17/22 1:30 AM, Heikki Krogerus wrote:
> > On Tue, Feb 15, 2022 at 11:22:04AM -0700, Jens Axboe wrote:
> >> 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.
> >>
> >> Suggested-by: Sven Peter <sven@svenpeter.dev>
> >> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> > 
> > 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?
> 
> > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 
> Thanks! Greg, will you pick this up?

Will do, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-17 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 18:22 [PATCH] tps6598x: clear int mask on probe failure Jens Axboe
2022-02-17  8:30 ` Heikki Krogerus
2022-02-17 13:51   ` Jens Axboe
2022-02-17 14:08     ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.