Re: [PATCH 5.15 456/731] extcon: usbc-tusb320: Update state on probe even if no IRQ pending

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 28, 2022 at 03:39:23PM +0100, Greg Kroah-Hartman wrote:
> From: Marek Vasut <marex@xxxxxxx>
> 
> [ Upstream commit 581c848b610dbf3fe1ed4d85fd53d0743c61faba ]
> 
> Currently this driver triggers extcon and typec state update in its
> probe function, to read out current state reported by the chip and
> report the correct state to upper layers. This synchronization is
> performed correctly, but only in case the chip indicates a pending
> interrupt in reg09 register.
> 
> This fails to cover the situation where all interrupts reported by
> the chip were already handled by Linux before reboot, then the system
> rebooted, and then Linux starts again. In this case, the TUSB320 no
> longer reports any interrupts in reg09, and the state update does not
> perform any update as it depends on that interrupt indication.
> 
> Fix this by turning tusb320_irq_handler() into a thin wrapper around
> tusb320_state_update_handler(), where the later now contains the bulk
> of the code of tusb320_irq_handler(), but adds new function parameter
> "force_update". The "force_update" parameter can be used by the probe
> function to assure that the state synchronization is always performed,
> independent of the interrupt indicated in reg09. The interrupt handler
> tusb320_irq_handler() callback uses force_update=false to avoid state
> updates on potential spurious interrupts and retain current behavior.
> 
> Fixes: 06bc4ca115cdd ("extcon: Add driver for TI TUSB320")
> Signed-off-by: Marek Vasut <marex@xxxxxxx>
> Reviewed-by: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>
> Acked-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/20221120141509.81012-1-marex@xxxxxxx
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---

Is the Fixes: tag here actually wrong? There was a regression report here:

https://lore.kernel.org/all/fd0f2d56-495e-6fdd-d1e8-ff40b558101e@xxxxxxxxxx/

which this patch fixed. But according to the report, it was a regression
introduced by Marek's recent addition of typec support. Since that new
functionality is not normally wanted in stable, can these three tusb320
patches simply be dropped?

Marek, Peter, any thoughts?

Kind regards,
Alvin

>  drivers/extcon/extcon-usbc-tusb320.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
> index edb8c3f997c9..b0f6e16ab0a9 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -313,9 +313,9 @@ static void tusb320_typec_irq_handler(struct tusb320_priv *priv, u8 reg9)
>  		typec_set_pwr_opmode(port, TYPEC_PWR_MODE_USB);
>  }
>  
> -static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
> +static irqreturn_t tusb320_state_update_handler(struct tusb320_priv *priv,
> +						bool force_update)
>  {
> -	struct tusb320_priv *priv = dev_id;
>  	unsigned int reg;
>  
>  	if (regmap_read(priv->regmap, TUSB320_REG9, &reg)) {
> @@ -323,7 +323,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
>  		return IRQ_NONE;
>  	}
>  
> -	if (!(reg & TUSB320_REG9_INTERRUPT_STATUS))
> +	if (!force_update && !(reg & TUSB320_REG9_INTERRUPT_STATUS))
>  		return IRQ_NONE;
>  
>  	tusb320_extcon_irq_handler(priv, reg);
> @@ -334,6 +334,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> +static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
> +{
> +	struct tusb320_priv *priv = dev_id;
> +
> +	return tusb320_state_update_handler(priv, false);
> +}
> +
>  static const struct regmap_config tusb320_regmap_config = {
>  	.reg_bits = 8,
>  	.val_bits = 8,
> @@ -460,7 +467,7 @@ static int tusb320_probe(struct i2c_client *client,
>  		return ret;
>  
>  	/* update initial state */
> -	tusb320_irq_handler(client->irq, priv);
> +	tusb320_state_update_handler(priv, true);
>  
>  	/* Reset chip to its default state */
>  	ret = tusb320_reset(priv);
> @@ -471,7 +478,7 @@ static int tusb320_probe(struct i2c_client *client,
>  		 * State and polarity might change after a reset, so update
>  		 * them again and make sure the interrupt status bit is cleared.
>  		 */
> -		tusb320_irq_handler(client->irq, priv);
> +		tusb320_state_update_handler(priv, true);
>  
>  	ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
>  					tusb320_irq_handler,
> -- 
> 2.35.1
> 
> 
>




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux