linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
@ 2018-07-17 14:36 Adam Thomson
  2018-07-17 15:51 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Adam Thomson @ 2018-07-17 14:36 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, support.opensource

There is a bug in the sink PDO search code when trying to select
a PPS APDO. The current code actually sets the starting index for
searching to whatever value 'i' is, rather than choosing index 1
to avoid the first PDO (always 5V fixed). As a result, for sources
which support PPS but whose PPS APDO index does not match with the
supporting sink PPS APDO index for the platform, no valid PPS APDO
will be found so this feature will not be permitted.

Sadly in testing, both Source and Sink capabilities matched up and
this was missed. Code is now updated to correctly set the start
index to 1, and testing with additional PPS capable sources show
this to work as expected.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 drivers/usb/typec/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 74e0cda..4f1f421 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
 			 * PPS APDO. Again skip the first sink PDO as this will
 			 * always be 5V 3A.
 			 */
-			for (j = i; j < port->nr_snk_pdo; j++) {
+			for (j = 1; j < port->nr_snk_pdo; j++) {
 				pdo = port->snk_pdo[j];
 
 				switch (pdo_type(pdo)) {
-- 
1.9.1


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

* Re: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-17 14:36 [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection Adam Thomson
@ 2018-07-17 15:51 ` Guenter Roeck
  2018-07-20 10:42 ` Heikki Krogerus
  2018-07-20 13:59 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2018-07-17 15:51 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
	support.opensource

On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> There is a bug in the sink PDO search code when trying to select
> a PPS APDO. The current code actually sets the starting index for
> searching to whatever value 'i' is, rather than choosing index 1
> to avoid the first PDO (always 5V fixed). As a result, for sources
> which support PPS but whose PPS APDO index does not match with the
> supporting sink PPS APDO index for the platform, no valid PPS APDO
> will be found so this feature will not be permitted.
> 
> Sadly in testing, both Source and Sink capabilities matched up and
> this was missed. Code is now updated to correctly set the start
> index to 1, and testing with additional PPS capable sources show
> this to work as expected.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

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

> ---
>  drivers/usb/typec/tcpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 74e0cda..4f1f421 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
>  			 * PPS APDO. Again skip the first sink PDO as this will
>  			 * always be 5V 3A.
>  			 */
> -			for (j = i; j < port->nr_snk_pdo; j++) {
> +			for (j = 1; j < port->nr_snk_pdo; j++) {
>  				pdo = port->snk_pdo[j];
>  
>  				switch (pdo_type(pdo)) {
> -- 
> 1.9.1
> 

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

* Re: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-17 14:36 [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection Adam Thomson
  2018-07-17 15:51 ` Guenter Roeck
@ 2018-07-20 10:42 ` Heikki Krogerus
  2018-07-20 13:59 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2018-07-20 10:42 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	support.opensource

On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> There is a bug in the sink PDO search code when trying to select
> a PPS APDO. The current code actually sets the starting index for
> searching to whatever value 'i' is, rather than choosing index 1
> to avoid the first PDO (always 5V fixed). As a result, for sources
> which support PPS but whose PPS APDO index does not match with the
> supporting sink PPS APDO index for the platform, no valid PPS APDO
> will be found so this feature will not be permitted.
> 
> Sadly in testing, both Source and Sink capabilities matched up and
> this was missed. Code is now updated to correctly set the start
> index to 1, and testing with additional PPS capable sources show
> this to work as expected.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

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

> ---
>  drivers/usb/typec/tcpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 74e0cda..4f1f421 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
>  			 * PPS APDO. Again skip the first sink PDO as this will
>  			 * always be 5V 3A.
>  			 */
> -			for (j = i; j < port->nr_snk_pdo; j++) {
> +			for (j = 1; j < port->nr_snk_pdo; j++) {
>  				pdo = port->snk_pdo[j];
>  
>  				switch (pdo_type(pdo)) {

Thanks,

-- 
heikki

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

* Re: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-17 14:36 [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection Adam Thomson
  2018-07-17 15:51 ` Guenter Roeck
  2018-07-20 10:42 ` Heikki Krogerus
@ 2018-07-20 13:59 ` Greg Kroah-Hartman
  2018-07-20 14:16   ` Adam Thomson
  2 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-07-20 13:59 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Heikki Krogerus, Guenter Roeck, linux-usb, linux-kernel,
	support.opensource

On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> There is a bug in the sink PDO search code when trying to select
> a PPS APDO. The current code actually sets the starting index for
> searching to whatever value 'i' is, rather than choosing index 1
> to avoid the first PDO (always 5V fixed). As a result, for sources
> which support PPS but whose PPS APDO index does not match with the
> supporting sink PPS APDO index for the platform, no valid PPS APDO
> will be found so this feature will not be permitted.
> 
> Sadly in testing, both Source and Sink capabilities matched up and
> this was missed. Code is now updated to correctly set the start
> index to 1, and testing with additional PPS capable sources show
> this to work as expected.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
>  drivers/usb/typec/tcpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 74e0cda..4f1f421 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
>  			 * PPS APDO. Again skip the first sink PDO as this will
>  			 * always be 5V 3A.
>  			 */
> -			for (j = i; j < port->nr_snk_pdo; j++) {
> +			for (j = 1; j < port->nr_snk_pdo; j++) {
>  				pdo = port->snk_pdo[j];
>  
>  				switch (pdo_type(pdo)) {

What commit id does this "fix"?

Does it need to go into 4.18-final?  To the stable kernels?

thanks,

greg k-h

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

* RE: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-20 13:59 ` Greg Kroah-Hartman
@ 2018-07-20 14:16   ` Adam Thomson
  2018-07-20 14:39     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Thomson @ 2018-07-20 14:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Adam Thomson
  Cc: Heikki Krogerus, Guenter Roeck, linux-usb, linux-kernel,
	Support Opensource

On 20 July 2018 14:59, Greg Kroah-Hartman wrote:

> On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> > There is a bug in the sink PDO search code when trying to select
> > a PPS APDO. The current code actually sets the starting index for
> > searching to whatever value 'i' is, rather than choosing index 1
> > to avoid the first PDO (always 5V fixed). As a result, for sources
> > which support PPS but whose PPS APDO index does not match with the
> > supporting sink PPS APDO index for the platform, no valid PPS APDO
> > will be found so this feature will not be permitted.
> >
> > Sadly in testing, both Source and Sink capabilities matched up and
> > this was missed. Code is now updated to correctly set the start
> > index to 1, and testing with additional PPS capable sources show
> > this to work as expected.
> >
> > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > ---
> >  drivers/usb/typec/tcpm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > index 74e0cda..4f1f421 100644
> > --- a/drivers/usb/typec/tcpm.c
> > +++ b/drivers/usb/typec/tcpm.c
> > @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct
> tcpm_port *port)
> >  			 * PPS APDO. Again skip the first sink PDO as this will
> >  			 * always be 5V 3A.
> >  			 */
> > -			for (j = i; j < port->nr_snk_pdo; j++) {
> > +			for (j = 1; j < port->nr_snk_pdo; j++) {
> >  				pdo = port->snk_pdo[j];
> >
> >  				switch (pdo_type(pdo)) {
> 
> What commit id does this "fix"?
> 
> Does it need to go into 4.18-final?  To the stable kernels?

Sorry, missed that info. This fixes commit:

2eadc33f40d4c59dd0649f8b6958872d85ad05d7
'typec: tcpm: Add core support for sink side PPS'

This patch only went into v4.18-rc1 so should only be targeted for v4.18-final.

Do you want me to resend with this information added?

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

* Re: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-20 14:16   ` Adam Thomson
@ 2018-07-20 14:39     ` Greg Kroah-Hartman
  2018-07-20 14:44       ` Adam Thomson
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-07-20 14:39 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Heikki Krogerus, Guenter Roeck, linux-usb, linux-kernel,
	Support Opensource

On Fri, Jul 20, 2018 at 02:16:33PM +0000, Adam Thomson wrote:
> On 20 July 2018 14:59, Greg Kroah-Hartman wrote:
> 
> > On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> > > There is a bug in the sink PDO search code when trying to select
> > > a PPS APDO. The current code actually sets the starting index for
> > > searching to whatever value 'i' is, rather than choosing index 1
> > > to avoid the first PDO (always 5V fixed). As a result, for sources
> > > which support PPS but whose PPS APDO index does not match with the
> > > supporting sink PPS APDO index for the platform, no valid PPS APDO
> > > will be found so this feature will not be permitted.
> > >
> > > Sadly in testing, both Source and Sink capabilities matched up and
> > > this was missed. Code is now updated to correctly set the start
> > > index to 1, and testing with additional PPS capable sources show
> > > this to work as expected.
> > >
> > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > ---
> > >  drivers/usb/typec/tcpm.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > index 74e0cda..4f1f421 100644
> > > --- a/drivers/usb/typec/tcpm.c
> > > +++ b/drivers/usb/typec/tcpm.c
> > > @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct
> > tcpm_port *port)
> > >  			 * PPS APDO. Again skip the first sink PDO as this will
> > >  			 * always be 5V 3A.
> > >  			 */
> > > -			for (j = i; j < port->nr_snk_pdo; j++) {
> > > +			for (j = 1; j < port->nr_snk_pdo; j++) {
> > >  				pdo = port->snk_pdo[j];
> > >
> > >  				switch (pdo_type(pdo)) {
> > 
> > What commit id does this "fix"?
> > 
> > Does it need to go into 4.18-final?  To the stable kernels?
> 
> Sorry, missed that info. This fixes commit:
> 
> 2eadc33f40d4c59dd0649f8b6958872d85ad05d7
> 'typec: tcpm: Add core support for sink side PPS'
> 
> This patch only went into v4.18-rc1 so should only be targeted for v4.18-final.
> 
> Do you want me to resend with this information added?

It's ok, this time, I'll go hand-edit it...

greg k-h

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

* RE: [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
  2018-07-20 14:39     ` Greg Kroah-Hartman
@ 2018-07-20 14:44       ` Adam Thomson
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Thomson @ 2018-07-20 14:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Adam Thomson
  Cc: Heikki Krogerus, Guenter Roeck, linux-usb, linux-kernel,
	Support Opensource

On 20 July 2018 15:40, Greg Kroah-Hartman wrote:

> On Fri, Jul 20, 2018 at 02:16:33PM +0000, Adam Thomson wrote:
> > On 20 July 2018 14:59, Greg Kroah-Hartman wrote:
> >
> > > On Tue, Jul 17, 2018 at 03:36:19PM +0100, Adam Thomson wrote:
> > > > There is a bug in the sink PDO search code when trying to select
> > > > a PPS APDO. The current code actually sets the starting index for
> > > > searching to whatever value 'i' is, rather than choosing index 1
> > > > to avoid the first PDO (always 5V fixed). As a result, for sources
> > > > which support PPS but whose PPS APDO index does not match with the
> > > > supporting sink PPS APDO index for the platform, no valid PPS APDO
> > > > will be found so this feature will not be permitted.
> > > >
> > > > Sadly in testing, both Source and Sink capabilities matched up and
> > > > this was missed. Code is now updated to correctly set the start
> > > > index to 1, and testing with additional PPS capable sources show
> > > > this to work as expected.
> > > >
> > > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > > ---
> > > >  drivers/usb/typec/tcpm.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > > index 74e0cda..4f1f421 100644
> > > > --- a/drivers/usb/typec/tcpm.c
> > > > +++ b/drivers/usb/typec/tcpm.c
> > > > @@ -2238,7 +2238,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct
> > > tcpm_port *port)
> > > >  			 * PPS APDO. Again skip the first sink PDO as this will
> > > >  			 * always be 5V 3A.
> > > >  			 */
> > > > -			for (j = i; j < port->nr_snk_pdo; j++) {
> > > > +			for (j = 1; j < port->nr_snk_pdo; j++) {
> > > >  				pdo = port->snk_pdo[j];
> > > >
> > > >  				switch (pdo_type(pdo)) {
> > >
> > > What commit id does this "fix"?
> > >
> > > Does it need to go into 4.18-final?  To the stable kernels?
> >
> > Sorry, missed that info. This fixes commit:
> >
> > 2eadc33f40d4c59dd0649f8b6958872d85ad05d7
> > 'typec: tcpm: Add core support for sink side PPS'
> >
> > This patch only went into v4.18-rc1 so should only be targeted for v4.18-final.
> >
> > Do you want me to resend with this information added?
> 
> It's ok, this time, I'll go hand-edit it...

Thanks :)

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

end of thread, other threads:[~2018-07-20 14:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 14:36 [PATCH] usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection Adam Thomson
2018-07-17 15:51 ` Guenter Roeck
2018-07-20 10:42 ` Heikki Krogerus
2018-07-20 13:59 ` Greg Kroah-Hartman
2018-07-20 14:16   ` Adam Thomson
2018-07-20 14:39     ` Greg Kroah-Hartman
2018-07-20 14:44       ` Adam Thomson

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