Re: [PATCH v1 1/4] usb: typec: tps6598x: Add trace event for IRQ events

2021-02-11 Thread kernel test robot
Hi "Guido,

I love your patch! Perhaps something to improve:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.11-rc7 next-20210211]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Guido-G-nther/usb-typec-tps6598x-Add-IRQ-flag-and-register-tracing/20210212-001108
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
usb-testing
config: mips-randconfig-r036-20210209 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
c9439ca36342fb6013187d0a69aef92736951476)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# 
https://github.com/0day-ci/linux/commit/bb7c40815d7d301dc6d52b1213d82b18696abf14
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Guido-G-nther/usb-typec-tps6598x-Add-IRQ-flag-and-register-tracing/20210212-001108
git checkout bb7c40815d7d301dc6d52b1213d82b18696abf14
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   In file included from drivers/usb/typec/tps6598x.c:21:
   In file included from drivers/usb/typec/./tps6598x_trace.h:97:
   In file included from include/trace/define_trace.h:102:
   In file included from include/trace/trace_events.h:401:
>> drivers/usb/typec/./tps6598x_trace.h:86:9: warning: shift count >= width of 
>> type [-Wshift-count-overflow]
 show_irq_flags(__entry->event1),
 ^~~~
   drivers/usb/typec/./tps6598x_trace.h:51:5: note: expanded from macro 
'show_irq_flags'
   { TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE,
"ERROR_DEVICE_INCOMPATIBLE" }, \
 ^
   drivers/usb/typec/tps6598x.h:31:48: note: expanded from macro 
'TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE'
   #define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE   BIT(0+32)
   ^
   include/vdso/bits.h:7:26: note: expanded from macro 'BIT'
   #define BIT(nr) (UL(1) << (nr))
  ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/trace/trace_events.h:80:16: note: expanded from macro 'TRACE_EVENT'
PARAMS(print));   \
~~~^~~
   include/linux/tracepoint.h:97:25: note: expanded from macro 'PARAMS'
   #define PARAMS(args...) args
   ^
   include/trace/trace_events.h:367:22: note: expanded from macro 
'DECLARE_EVENT_CLASS'
   trace_seq_printf(s, print); \
   ^
   In file included from drivers/usb/typec/tps6598x.c:21:
   In file included from drivers/usb/typec/./tps6598x_trace.h:97:
   In file included from include/trace/define_trace.h:102:
   In file included from include/trace/trace_events.h:401:
>> drivers/usb/typec/./tps6598x_trace.h:86:9: warning: shift count >= width of 
>> type [-Wshift-count-overflow]
 show_irq_flags(__entry->event1),
 ^~~~
   drivers/usb/typec/./tps6598x_trace.h:52:5: note: expanded from macro 
'show_irq_flags'
   { TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR, 
"ERROR_CANNOT_PROVIDE_PWR" }, \
 ^
   drivers/usb/typec/tps6598x.h:30:47: note: expanded from macro 
'TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR'
   #define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWRBIT(1+32)
   ^
   include/vdso/bits.h:7:26: note: expanded from macro 'BIT'
   #define BIT(nr) (UL(1) << (nr))
  ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/trace/trace_events.h:80:16: note: expanded from macro 'TRACE_EVENT'
PARAMS(print));   \
~~~^~~
   include/linux/tracepoint.h:97:25: note: expanded from macro 'PARAMS'
   #define PARAMS(args...) args
   ^
   include/trace/trace_events.h:367:22: note: expanded from macro 
'DECLARE_EVENT_CLASS'
   trace_seq_printf(s, print); \
  

[PATCH v1 1/4] usb: typec: tps6598x: Add trace event for IRQ events

2021-02-11 Thread Guido Günther
Allow to get irq event information via the tracing framework.  This
allows to inspect USB-C negotiation at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/Makefile |  3 +
 drivers/usb/typec/tps6598x.c   |  9 ++-
 drivers/usb/typec/tps6598x.h   | 61 +++
 drivers/usb/typec/tps6598x_trace.h | 97 ++
 4 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/typec/tps6598x.h
 create mode 100644 drivers/usb/typec/tps6598x_trace.h

diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index d03b48c4b864..27aa12129190 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+# define_trace.h needs to know how to find our header
+CFLAGS_tps6598x.o  := -I$(src)
+
 obj-$(CONFIG_TYPEC)+= typec.o
 typec-y:= class.o mux.o bus.o
 obj-$(CONFIG_TYPEC)+= altmodes/
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 6e6ef6317523..bc34b35e909f 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -6,6 +6,8 @@
  * Author: Heikki Krogerus 
  */
 
+#include "tps6598x.h"
+
 #include 
 #include 
 #include 
@@ -15,6 +17,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "tps6598x_trace.h"
+
 /* Register offsets */
 #define TPS_REG_VID0x00
 #define TPS_REG_MODE   0x03
@@ -32,9 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_INT_* bits */
-#define TPS_REG_INT_PLUG_EVENT BIT(3)
-
 /* TPS_REG_STATUS bits */
 #define TPS_STATUS_PLUG_PRESENTBIT(0)
 #define TPS_STATUS_ORIENTATION BIT(4)
@@ -428,6 +430,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read events\n", __func__);
goto err_unlock;
}
+   trace_tps6598x_irq(event1, event2);
 
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
new file mode 100644
index ..3040cfdd2b8f
--- /dev/null
+++ b/drivers/usb/typec/tps6598x.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Driver for TI TPS6598x USB Power Delivery controller family
+ *
+ * Copyright (C) 2017, Intel Corporation
+ * Author: Heikki Krogerus 
+ */
+
+#ifndef __TPS6598X_H__
+#define __TPS6598X_H__
+
+
+/* TPS_REG_INT_* bits */
+#define TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDMBIT(27+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM BIT(26+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_EXIT BIT(25+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ENTERED  BIT(24+32)
+#define TPS_REG_INT_EXIT_MODES_COMPLETEBIT(20+32)
+#define TPS_REG_INT_DISCOVER_MODES_COMPLETEBIT(19+32)
+#define TPS_REG_INT_VDM_MSG_SENT   BIT(18+32)
+#define TPS_REG_INT_VDM_ENTERED_MODE   BIT(17+32)
+#define TPS_REG_INT_ERROR_UNABLE_TO_SOURCE BIT(14+32)
+#define TPS_REG_INT_SRC_TRANSITION BIT(10+32)
+#define TPS_REG_INT_ERROR_DISCHARGE_FAILED BIT(9+32)
+#define TPS_REG_INT_ERROR_MESSAGE_DATA BIT(7+32)
+#define TPS_REG_INT_ERROR_PROTOCOL_ERROR   BIT(6+32)
+#define TPS_REG_INT_ERROR_MISSING_GET_CAP_MESSAGE  BIT(4+32)
+#define TPS_REG_INT_ERROR_POWER_EVENT_OCCURRED BIT(3+32)
+#define TPS_REG_INT_ERROR_CAN_PROVIDE_PWR_LATERBIT(2+32)
+#define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR   BIT(1+32)
+#define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE  BIT(0+32)
+#define TPS_REG_INT_CMD2_COMPLETE  BIT(31)
+#define TPS_REG_INT_CMD1_COMPLETE  BIT(30)
+#define TPS_REG_INT_ADC_HIGH_THRESHOLD BIT(29)
+#define TPS_REG_INT_ADC_LOW_THRESHOLD  BIT(28)
+#define TPS_REG_INT_PD_STATUS_UPDATE   BIT(27)
+#define TPS_REG_INT_STATUS_UPDATE  BIT(26)
+#define TPS_REG_INT_DATA_STATUS_UPDATE BIT(25)
+#define TPS_REG_INT_POWER_STATUS_UPDATEBIT(24)
+#define TPS_REG_INT_PP_SWITCH_CHANGED  BIT(23)
+#define TPS_REG_INT_HIGH_VOLTAGE_WARNING   BIT(22)
+#define TPS_REG_INT_USB_HOST_PRESENT_NO_LONGER BIT(21)
+#define TPS_REG_INT_USB_HOST_PRESENT   BIT(20)
+#define TPS_REG_INT_GOTO_MIN_RECEIVED  BIT(19)
+#define TPS_REG_INT_PR_SWAP_REQUESTED  BIT(17)
+#define TPS_REG_INT_SINK_CAP_MESSAGE_READY BIT(15)
+#define TPS_REG_INT_SOURCE_CAP_MESSAGE_READY   BIT(14)
+#define TPS_REG_INT_NEW_CONTRACT_AS_PROVIDER   BIT(13)
+#define TPS_REG_INT_NEW_CONTRACT_AS_CONSUMER