linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled
@ 2021-09-26 10:14 Xu Yang
  2021-09-27 10:06 ` Heikki Krogerus
  2021-10-01 13:05 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Xu Yang @ 2021-09-26 10:14 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh; +Cc: linux-usb, linux-imx, jun.li

USB TCPCI Spec, 4.4.3 Mask Registers:
"A masked register will still indicate in the ALERT register, but shall
not set the Alert# pin low."

Thus, the Extended Status will still indicate in ALERT register if vSafe0V
is detected by TCPC even though being masked. In current code, howerer,
this event will not be handled in detection time. Rather it will be
handled when next ALERT event coming(CC evnet, PD event, etc).

Tcpm might transition to a wrong state in this situation. Thus, the vSafe0V
event should not be handled when it's masked.

Fixes: 766c485b86ef ("usb: typec: tcpci: Add support to report vSafe0V")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 drivers/usb/typec/tcpm/tcpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 9858716698df..c15eec9cc460 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -696,7 +696,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
 		tcpm_pd_receive(tcpci->port, &msg);
 	}
 
-	if (status & TCPC_ALERT_EXTENDED_STATUS) {
+	if (tcpci->data->vbus_vsafe0v && (status & TCPC_ALERT_EXTENDED_STATUS)) {
 		ret = regmap_read(tcpci->regmap, TCPC_EXTENDED_STATUS, &raw);
 		if (!ret && (raw & TCPC_EXTENDED_STATUS_VSAFE0V))
 			tcpm_vbus_change(tcpci->port);
-- 
2.25.1


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

* Re: [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled
  2021-09-26 10:14 [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled Xu Yang
@ 2021-09-27 10:06 ` Heikki Krogerus
  2021-10-01 13:05 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2021-09-27 10:06 UTC (permalink / raw)
  To: Xu Yang; +Cc: linux, gregkh, linux-usb, linux-imx, jun.li

On Sun, Sep 26, 2021 at 06:14:15PM +0800, Xu Yang wrote:
> USB TCPCI Spec, 4.4.3 Mask Registers:
> "A masked register will still indicate in the ALERT register, but shall
> not set the Alert# pin low."
> 
> Thus, the Extended Status will still indicate in ALERT register if vSafe0V
> is detected by TCPC even though being masked. In current code, howerer,
> this event will not be handled in detection time. Rather it will be
> handled when next ALERT event coming(CC evnet, PD event, etc).
> 
> Tcpm might transition to a wrong state in this situation. Thus, the vSafe0V
> event should not be handled when it's masked.
> 
> Fixes: 766c485b86ef ("usb: typec: tcpci: Add support to report vSafe0V")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 9858716698df..c15eec9cc460 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -696,7 +696,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
>  		tcpm_pd_receive(tcpci->port, &msg);
>  	}
>  
> -	if (status & TCPC_ALERT_EXTENDED_STATUS) {
> +	if (tcpci->data->vbus_vsafe0v && (status & TCPC_ALERT_EXTENDED_STATUS)) {
>  		ret = regmap_read(tcpci->regmap, TCPC_EXTENDED_STATUS, &raw);
>  		if (!ret && (raw & TCPC_EXTENDED_STATUS_VSAFE0V))
>  			tcpm_vbus_change(tcpci->port);
> -- 
> 2.25.1

-- 
heikki

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

* Re: [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled
  2021-09-26 10:14 [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled Xu Yang
  2021-09-27 10:06 ` Heikki Krogerus
@ 2021-10-01 13:05 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-10-01 13:05 UTC (permalink / raw)
  To: Xu Yang; +Cc: heikki.krogerus, gregkh, linux-usb, linux-imx, jun.li

On Sun, Sep 26, 2021 at 06:14:15PM +0800, Xu Yang wrote:
> USB TCPCI Spec, 4.4.3 Mask Registers:
> "A masked register will still indicate in the ALERT register, but shall
> not set the Alert# pin low."
> 
> Thus, the Extended Status will still indicate in ALERT register if vSafe0V
> is detected by TCPC even though being masked. In current code, howerer,
> this event will not be handled in detection time. Rather it will be
> handled when next ALERT event coming(CC evnet, PD event, etc).
> 
> Tcpm might transition to a wrong state in this situation. Thus, the vSafe0V
> event should not be handled when it's masked.
> 
> Fixes: 766c485b86ef ("usb: typec: tcpci: Add support to report vSafe0V")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/usb/typec/tcpm/tcpci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 9858716698df..c15eec9cc460 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -696,7 +696,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
>  		tcpm_pd_receive(tcpci->port, &msg);
>  	}
>  
> -	if (status & TCPC_ALERT_EXTENDED_STATUS) {
> +	if (tcpci->data->vbus_vsafe0v && (status & TCPC_ALERT_EXTENDED_STATUS)) {
>  		ret = regmap_read(tcpci->regmap, TCPC_EXTENDED_STATUS, &raw);
>  		if (!ret && (raw & TCPC_EXTENDED_STATUS_VSAFE0V))
>  			tcpm_vbus_change(tcpci->port);
> -- 
> 2.25.1
> 

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

end of thread, other threads:[~2021-10-01 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-26 10:14 [PATCH 1/1] usb: typec: tcpci: don't handle vSafe0V event if it's not enabled Xu Yang
2021-09-27 10:06 ` Heikki Krogerus
2021-10-01 13:05 ` Guenter Roeck

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).