Skip to contentSkip to conversation

staging: typec: tcpm: Consider port_type while determining unattached_state

PATCH In review Badhri Jagan Sridharan 2 participants 4 messages Aug 10, 2017 – Aug 11, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: typec: tcpm: Consider port_type while determining unattached_state

While performing PORT_RESET, upon receiving the cc disconnect signal from the underlaying tcpc device, TCPM transitions into unattached state. Consider, the current type of port while determining the unattached state.

In the below logs, although the port_type was set to sink, TCPM transitioned into SRC_UNATTACHED.

[  762.290654] state change SRC_READY -> PORT_RESET
[  762.324531] Setting voltage/current limit 0 mV 0 mA
[  762.327912] polarity 0
[  762.334864] cc:=0
[  762.347193] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms
[  762.347200] VBUS off
[  762.347203] CC1: 2 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected]
[  762.347206] state change PORT_RESET -> SRC_UNATTACHED
---
 drivers/staging/typec/tcpm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/staging/typec/tcpm.c +8 -2
index 20eb4ebcf8c3..4c526341d850 100644
@@ -2099,10 +2099,16 @@ static inline enum tcpm_state ready_state(struct tcpm_port *port)
 
 static inline enum tcpm_state unattached_state(struct tcpm_port *port)
 {
-	if (port->pwr_role == TYPEC_SOURCE)
+	if (port->port_type == TYPEC_PORT_DRP) {
+		if (port->pwr_role == TYPEC_SOURCE)
+			return SRC_UNATTACHED;
+		else
+			return SNK_UNATTACHED;
+	} else if (port->port_type == TYPEC_PORT_DFP) {
 		return SRC_UNATTACHED;
-	else
+	} else {
 		return SNK_UNATTACHED;
+	}
 }
 
 static void tcpm_check_send_discover(struct tcpm_port *port)
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
#1 lore raw

Please hold off on reviewing this patch.
Patch went wrong while rebasing.

Thanks,
Badhri

Quoted 48 lines · Badhri Jagan Sridharan

While performing PORT_RESET, upon receiving the cc disconnect signal from the underlaying tcpc device, TCPM transitions into unattached state. Consider, the current type of port while determining the unattached state.

In the below logs, although the port_type was set to sink, TCPM transitioned into SRC_UNATTACHED.

[  762.290654] state change SRC_READY -> PORT_RESET
[  762.324531] Setting voltage/current limit 0 mV 0 mA
[  762.327912] polarity 0
[  762.334864] cc:=0
[  762.347193] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms
[  762.347200] VBUS off
[  762.347203] CC1: 2 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected]
[  762.347206] state change PORT_RESET -> SRC_UNATTACHED
---
 drivers/staging/typec/tcpm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/staging/typec/tcpm.c +8 -3
index 20eb4ebcf8c3..4c526341d850 100644
@@ -2099,10 +2099,16 @@ static inline enum tcpm_state ready_state(struct tcpm_port *port)
 
 static inline enum tcpm_state unattached_state(struct tcpm_port *port)
 {
-       if (port->pwr_role == TYPEC_SOURCE)
+       if (port->port_type == TYPEC_PORT_DRP) {
+               if (port->pwr_role == TYPEC_SOURCE)
+                       return SRC_UNATTACHED;
+               else
+                       return SNK_UNATTACHED;
+       } else if (port->port_type == TYPEC_PORT_DFP) {
                return SRC_UNATTACHED;
-       else
+       } else {
                return SNK_UNATTACHED;
+       }
 }
 
 static void tcpm_check_send_discover(struct tcpm_port *port)
--

2.14.0.434.g98096fd7a8-goog

#2 lore raw
In reply to Badhri Jagan Sridharan
url: https://github.com/0day-ci/linux/commits/Badhri-Jagan-Sridharan/staging-typec-tcpm-Consider-port_type-while-determining-unattached_state/20170812-071822 config: i386-randconfig-x019-201732…

Hi Badhri,

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Badhri-Jagan-Sridharan/staging-typec-tcpm-Consider-port_type-while-determining-unattached_state/20170812-071822
config: i386-randconfig-x019-201732 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/list.h:4,
from include/linux/wait.h:6,
from include/linux/completion.h:11,
from drivers/staging/typec/tcpm.c:17:
drivers/staging/typec/tcpm.c: In function 'unattached_state':
drivers/staging/typec/tcpm.c:2101:10: error: 'struct tcpm_port' has no member named 'port_type'

     if (port->port_type == TYPEC_PORT_DRP) {
             ^
   include/linux/compiler.h:156:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/staging/typec/tcpm.c:2101:2: note: in expansion of macro 'if'
     if (port->port_type == TYPEC_PORT_DRP) {
     ^~
   drivers/staging/typec/tcpm.c:2101:10: error: 'struct tcpm_port' has no member named 'port_type'
     if (port->port_type == TYPEC_PORT_DRP) {
             ^
   include/linux/compiler.h:156:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> drivers/staging/typec/tcpm.c:2101:2: note: in expansion of macro 'if'
     if (port->port_type == TYPEC_PORT_DRP) {
     ^~
   drivers/staging/typec/tcpm.c:2101:10: error: 'struct tcpm_port' has no member named 'port_type'
     if (port->port_type == TYPEC_PORT_DRP) {
             ^
   include/linux/compiler.h:167:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> drivers/staging/typec/tcpm.c:2101:2: note: in expansion of macro 'if'
     if (port->port_type == TYPEC_PORT_DRP) {
     ^~
   drivers/staging/typec/tcpm.c:2106:17: error: 'struct tcpm_port' has no member named 'port_type'
     } else if (port->port_type == TYPEC_PORT_DFP) {
                    ^
   include/linux/compiler.h:156:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers/staging/typec/tcpm.c:2106:9: note: in expansion of macro 'if'
     } else if (port->port_type == TYPEC_PORT_DFP) {
            ^~
   drivers/staging/typec/tcpm.c:2106:17: error: 'struct tcpm_port' has no member named 'port_type'
     } else if (port->port_type == TYPEC_PORT_DFP) {
                    ^
   include/linux/compiler.h:156:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers/staging/typec/tcpm.c:2106:9: note: in expansion of macro 'if'
     } else if (port->port_type == TYPEC_PORT_DFP) {
            ^~
   drivers/staging/typec/tcpm.c:2106:17: error: 'struct tcpm_port' has no member named 'port_type'
     } else if (port->port_type == TYPEC_PORT_DFP) {
                    ^
   include/linux/compiler.h:167:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers/staging/typec/tcpm.c:2106:9: note: in expansion of macro 'if'
     } else if (port->port_type == TYPEC_PORT_DFP) {
            ^~
   drivers/staging/typec/tcpm.c: At top level:
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:390:2: note: in expansion of macro 'if'
     if (p_size == (size_t)-1 && q_size == (size_t)-1)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:380:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:378:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:369:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:367:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:358:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   include/linux/string.h:356:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^~
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~

include/linux/string.h:348:2: note: in expansion of macro 'if'

vim +/if +2101 drivers/staging/typec/tcpm.c

2098
2099 static inline enum tcpm_state unattached_state(struct tcpm_port *port)
2100 {

> 2101		if (port->port_type == TYPEC_PORT_DRP) {

2102 if (port->pwr_role == TYPEC_SOURCE)
2103 return SRC_UNATTACHED;
2104 else
2105 return SNK_UNATTACHED;
2106 } else if (port->port_type == TYPEC_PORT_DFP) {
2107 return SRC_UNATTACHED;
2108 } else {
2109 return SNK_UNATTACHED;
2110 }
2111 }
2112

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to Badhri Jagan Sridharan
url: https://github.com/0day-ci/linux/commits/Badhri-Jagan-Sridharan/staging-typec-tcpm-Consider-port_type-while-determining-unattached_state/20170812-071822 config: xtensa-allmodconfig (attached as…

Hi Badhri,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Badhri-Jagan-Sridharan/staging-typec-tcpm-Consider-port_type-while-determining-unattached_state/20170812-071822
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa

All error/warnings (new ones prefixed by >>):

drivers/staging/typec/tcpm.c: In function 'unattached_state':

>> drivers/staging/typec/tcpm.c:2101:10: error: 'struct tcpm_port' has no member named 'port_type'
     if (port->port_type == TYPEC_PORT_DRP) {
             ^
   drivers/staging/typec/tcpm.c:2106:17: error: 'struct tcpm_port' has no member named 'port_type'
     } else if (port->port_type == TYPEC_PORT_DFP) {
                    ^
>> drivers/staging/typec/tcpm.c:2111:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +2101 drivers/staging/typec/tcpm.c

2098
2099 static inline enum tcpm_state unattached_state(struct tcpm_port *port)
2100 {

> 2101		if (port->port_type == TYPEC_PORT_DRP) {
  2102			if (port->pwr_role == TYPEC_SOURCE)
  2103				return SRC_UNATTACHED;
  2104			else
  2105				return SNK_UNATTACHED;
  2106		} else if (port->port_type == TYPEC_PORT_DFP) {
  2107			return SRC_UNATTACHED;
  2108		} else {
  2109			return SNK_UNATTACHED;
  2110		}
> 2111	}

2112

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation