public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Sven Peter <sven@svenpeter.dev>
Subject: Re: [PATCH] tps6598x: clear int mask on probe failure
Date: Thu, 17 Feb 2022 10:30:56 +0200	[thread overview]
Message-ID: <Yg4HwO2SKGDvOASz@kuha.fi.intel.com> (raw)
In-Reply-To: <e6b80669-20f3-06e7-9ed5-8951a9c6db6f@kernel.dk>

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

  reply	other threads:[~2022-02-17  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 18:22 [PATCH] tps6598x: clear int mask on probe failure Jens Axboe
2022-02-17  8:30 ` Heikki Krogerus [this message]
2022-02-17 13:51   ` Jens Axboe
2022-02-17 14:08     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yg4HwO2SKGDvOASz@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sven@svenpeter.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox