linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe()
@ 2022-01-10 16:35 Martin Kepplinger
  2022-01-11  9:11 ` Heikki Krogerus
  2022-01-11 11:10 ` Hector Martin
  0 siblings, 2 replies; 4+ messages in thread
From: Martin Kepplinger @ 2022-01-10 16:35 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, sven, hdegoede, marcan
  Cc: kernel, linux-usb, linux-kernel, Martin Kepplinger

Commit 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by default")
writes a fixed set of interrupts to TPS_REG_INT_MASK1. In case interrupts
had been enabled by the firmware by default, these get disabled now
which can break use cases. Only append to what is already enabled instead.

Fixes: 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by default")
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 drivers/usb/typec/tipd/core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 6d27a5b5e3ca..365ee5494c15 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -744,10 +744,14 @@ static int tps6598x_probe(struct i2c_client *client)
 
 		irq_handler = cd321x_interrupt;
 	} else {
+		ret = tps6598x_read64(tps, TPS_REG_INT_MASK1, &mask1);
+		if (ret)
+			return ret;
+
 		/* Enable power status, data status and plug event interrupts */
-		mask1 = TPS_REG_INT_POWER_STATUS_UPDATE |
-			TPS_REG_INT_DATA_STATUS_UPDATE |
-			TPS_REG_INT_PLUG_EVENT;
+		mask1 |= TPS_REG_INT_POWER_STATUS_UPDATE |
+			 TPS_REG_INT_DATA_STATUS_UPDATE |
+			 TPS_REG_INT_PLUG_EVENT;
 	}
 
 	/* Make sure the controller has application firmware running */
-- 
2.30.2


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

* Re: [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe()
  2022-01-10 16:35 [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe() Martin Kepplinger
@ 2022-01-11  9:11 ` Heikki Krogerus
  2022-01-11 11:10 ` Hector Martin
  1 sibling, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2022-01-11  9:11 UTC (permalink / raw)
  To: Martin Kepplinger
  Cc: gregkh, sven, hdegoede, marcan, kernel, linux-usb, linux-kernel

Hi Martin,

On Mon, Jan 10, 2022 at 05:35:59PM +0100, Martin Kepplinger wrote:
> Commit 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by default")
> writes a fixed set of interrupts to TPS_REG_INT_MASK1. In case interrupts
> had been enabled by the firmware by default, these get disabled now
> which can break use cases. Only append to what is already enabled instead.

No, we have to know what are the interrupts that are actually needed.
Commmit 9990f2f6264c fixed an interrupt flood issue that was seen on
some platforms where the firmware I guess enabled absolutely
everything. This would just revert that.

So only enable the interrupts that you know you need.

> Fixes: 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by default")

What is this fixing? What are the use cases you are talking about?

> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
>  drivers/usb/typec/tipd/core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 6d27a5b5e3ca..365ee5494c15 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -744,10 +744,14 @@ static int tps6598x_probe(struct i2c_client *client)
>  
>  		irq_handler = cd321x_interrupt;
>  	} else {
> +		ret = tps6598x_read64(tps, TPS_REG_INT_MASK1, &mask1);
> +		if (ret)
> +			return ret;
> +
>  		/* Enable power status, data status and plug event interrupts */
> -		mask1 = TPS_REG_INT_POWER_STATUS_UPDATE |
> -			TPS_REG_INT_DATA_STATUS_UPDATE |
> -			TPS_REG_INT_PLUG_EVENT;
> +		mask1 |= TPS_REG_INT_POWER_STATUS_UPDATE |
> +			 TPS_REG_INT_DATA_STATUS_UPDATE |
> +			 TPS_REG_INT_PLUG_EVENT;
>  	}
>  
>  	/* Make sure the controller has application firmware running */

thanks,

-- 
heikki

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

* Re: [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe()
  2022-01-10 16:35 [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe() Martin Kepplinger
  2022-01-11  9:11 ` Heikki Krogerus
@ 2022-01-11 11:10 ` Hector Martin
  2022-01-13  9:15   ` Martin Kepplinger
  1 sibling, 1 reply; 4+ messages in thread
From: Hector Martin @ 2022-01-11 11:10 UTC (permalink / raw)
  To: Martin Kepplinger, heikki.krogerus, gregkh, sven, hdegoede
  Cc: kernel, linux-usb, linux-kernel

On 2022/01/11 1:35, Martin Kepplinger wrote:
> Commit 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by default")
> writes a fixed set of interrupts to TPS_REG_INT_MASK1. In case interrupts
> had been enabled by the firmware by default, these get disabled now
> which can break use cases. Only append to what is already enabled instead.
> 

I'm confused. The kernel drives the hardware, it needs to enable only
the interrupts it can handle. Do you have some kind of firmware trying
to share access to the same I2C port that needs other interrupts? That
sounds like a recipe for trouble... or am I misunderstanding things?

If the *kernel* needs other interrupts enabled to make something work,
then they should also be enabled unconditionally, and you'd have to
check the IRQ handler to make sure it actually handles it.

-- 
Hector Martin (marcan@marcan.st)
Public Key: https://mrcn.st/pub

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

* Re: [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe()
  2022-01-11 11:10 ` Hector Martin
@ 2022-01-13  9:15   ` Martin Kepplinger
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Kepplinger @ 2022-01-13  9:15 UTC (permalink / raw)
  To: Hector Martin, heikki.krogerus, gregkh, sven, hdegoede
  Cc: kernel, linux-usb, linux-kernel

Am Dienstag, dem 11.01.2022 um 20:10 +0900 schrieb Hector Martin:
> On 2022/01/11 1:35, Martin Kepplinger wrote:
> > Commit 9990f2f6264c ("usb: typec: tipd: Enable event interrupts by
> > default")
> > writes a fixed set of interrupts to TPS_REG_INT_MASK1. In case
> > interrupts
> > had been enabled by the firmware by default, these get disabled now
> > which can break use cases. Only append to what is already enabled
> > instead.
> > 
> 
> I'm confused. The kernel drives the hardware, it needs to enable only
> the interrupts it can handle. Do you have some kind of firmware
> trying
> to share access to the same I2C port that needs other interrupts?
> That
> sounds like a recipe for trouble... or am I misunderstanding things?
> 
> If the *kernel* needs other interrupts enabled to make something
> work,
> then they should also be enabled unconditionally, and you'd have to
> check the IRQ handler to make sure it actually handles it.
> 

true. sorry for the confusion. we need to submit the patches for the
interrupt handler to handle what we need and then we'll extend the mask
accordingly. please ignore this patch.

thank you,
                               martin



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

end of thread, other threads:[~2022-01-13  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 16:35 [PATCH v1] usb: typec: tipd: keep default interrupts enabled during probe() Martin Kepplinger
2022-01-11  9:11 ` Heikki Krogerus
2022-01-11 11:10 ` Hector Martin
2022-01-13  9:15   ` Martin Kepplinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).