linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Keep other events when receiving FRS and Sourcing_vbus events
@ 2021-08-03  9:13 Kyle Tso
  2021-08-03 13:48 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Tso @ 2021-08-03  9:13 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh; +Cc: badhri, linux-usb, linux-kernel, Kyle Tso

When receiving FRS and Sourcing_Vbus events from low-level drivers, keep
other events which come a bit earlier so that they will not be ignored
in the event handler.

Fixes: 8dc4bd073663 ("usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)")
Cc: Badhri Jagan Sridharan <badhri@google.com>
Signed-off-by: Kyle Tso <kyletso@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 5b22a1c931a9..b9bb63d749ec 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -5369,7 +5369,7 @@ EXPORT_SYMBOL_GPL(tcpm_pd_hard_reset);
 void tcpm_sink_frs(struct tcpm_port *port)
 {
 	spin_lock(&port->pd_event_lock);
-	port->pd_events = TCPM_FRS_EVENT;
+	port->pd_events |= TCPM_FRS_EVENT;
 	spin_unlock(&port->pd_event_lock);
 	kthread_queue_work(port->wq, &port->event_work);
 }
@@ -5378,7 +5378,7 @@ EXPORT_SYMBOL_GPL(tcpm_sink_frs);
 void tcpm_sourcing_vbus(struct tcpm_port *port)
 {
 	spin_lock(&port->pd_event_lock);
-	port->pd_events = TCPM_SOURCING_VBUS;
+	port->pd_events |= TCPM_SOURCING_VBUS;
 	spin_unlock(&port->pd_event_lock);
 	kthread_queue_work(port->wq, &port->event_work);
 }
-- 
2.32.0.554.ge1b32706d8-goog


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

* Re: [PATCH] usb: typec: tcpm: Keep other events when receiving FRS and Sourcing_vbus events
  2021-08-03  9:13 [PATCH] usb: typec: tcpm: Keep other events when receiving FRS and Sourcing_vbus events Kyle Tso
@ 2021-08-03 13:48 ` Guenter Roeck
  2021-08-03 19:22   ` Badhri Jagan Sridharan
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2021-08-03 13:48 UTC (permalink / raw)
  To: Kyle Tso, heikki.krogerus, gregkh; +Cc: badhri, linux-usb, linux-kernel

On 8/3/21 2:13 AM, Kyle Tso wrote:
> When receiving FRS and Sourcing_Vbus events from low-level drivers, keep
> other events which come a bit earlier so that they will not be ignored
> in the event handler.
> 
> Fixes: 8dc4bd073663 ("usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)")
> Cc: Badhri Jagan Sridharan <badhri@google.com>
> Signed-off-by: Kyle Tso <kyletso@google.com>

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

> ---
>   drivers/usb/typec/tcpm/tcpm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 5b22a1c931a9..b9bb63d749ec 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5369,7 +5369,7 @@ EXPORT_SYMBOL_GPL(tcpm_pd_hard_reset);
>   void tcpm_sink_frs(struct tcpm_port *port)
>   {
>   	spin_lock(&port->pd_event_lock);
> -	port->pd_events = TCPM_FRS_EVENT;
> +	port->pd_events |= TCPM_FRS_EVENT;
>   	spin_unlock(&port->pd_event_lock);
>   	kthread_queue_work(port->wq, &port->event_work);
>   }
> @@ -5378,7 +5378,7 @@ EXPORT_SYMBOL_GPL(tcpm_sink_frs);
>   void tcpm_sourcing_vbus(struct tcpm_port *port)
>   {
>   	spin_lock(&port->pd_event_lock);
> -	port->pd_events = TCPM_SOURCING_VBUS;
> +	port->pd_events |= TCPM_SOURCING_VBUS;
>   	spin_unlock(&port->pd_event_lock);
>   	kthread_queue_work(port->wq, &port->event_work);
>   }
> 


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

* Re: [PATCH] usb: typec: tcpm: Keep other events when receiving FRS and Sourcing_vbus events
  2021-08-03 13:48 ` Guenter Roeck
@ 2021-08-03 19:22   ` Badhri Jagan Sridharan
  0 siblings, 0 replies; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2021-08-03 19:22 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Kyle Tso, Heikki Krogerus, Greg Kroah-Hartman, USB, LKML

On Tue, Aug 3, 2021 at 6:48 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 8/3/21 2:13 AM, Kyle Tso wrote:
> > When receiving FRS and Sourcing_Vbus events from low-level drivers, keep
> > other events which come a bit earlier so that they will not be ignored
> > in the event handler.
> >
> > Fixes: 8dc4bd073663 ("usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)")
> > Cc: Badhri Jagan Sridharan <badhri@google.com>
> > Signed-off-by: Kyle Tso <kyletso@google.com>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
>
> > ---
> >   drivers/usb/typec/tcpm/tcpm.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 5b22a1c931a9..b9bb63d749ec 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -5369,7 +5369,7 @@ EXPORT_SYMBOL_GPL(tcpm_pd_hard_reset);
> >   void tcpm_sink_frs(struct tcpm_port *port)
> >   {
> >       spin_lock(&port->pd_event_lock);
> > -     port->pd_events = TCPM_FRS_EVENT;
> > +     port->pd_events |= TCPM_FRS_EVENT;
> >       spin_unlock(&port->pd_event_lock);
> >       kthread_queue_work(port->wq, &port->event_work);
> >   }
> > @@ -5378,7 +5378,7 @@ EXPORT_SYMBOL_GPL(tcpm_sink_frs);
> >   void tcpm_sourcing_vbus(struct tcpm_port *port)
> >   {
> >       spin_lock(&port->pd_event_lock);
> > -     port->pd_events = TCPM_SOURCING_VBUS;
> > +     port->pd_events |= TCPM_SOURCING_VBUS;
> >       spin_unlock(&port->pd_event_lock);
> >       kthread_queue_work(port->wq, &port->event_work);
> >   }
> >
>

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

end of thread, other threads:[~2021-08-03 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  9:13 [PATCH] usb: typec: tcpm: Keep other events when receiving FRS and Sourcing_vbus events Kyle Tso
2021-08-03 13:48 ` Guenter Roeck
2021-08-03 19:22   ` Badhri Jagan Sridharan

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