Re: [PATCH v6 4/7] hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device
On 2022/4/7 12:28, kernel test robot wrote: > Hi Yicong, > > I love your patch! Perhaps something to improve: > > [auto build test WARNING on joro-iommu/next] > [also build test WARNING on linus/master linux/master v5.18-rc1 next-20220406] > [cannot apply to tip/perf/core] > [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/intel-lab-lkp/linux/commits/Yicong-Yang/Add-support-for-HiSilicon-PCIe-Tune-and-Trace-device/20220406-200044 > base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next > config: alpha-allyesconfig > (https://download.01.org/0day-ci/archive/20220407/202204071201.acepulor-...@intel.com/config) > compiler: alpha-linux-gcc (GCC) 11.2.0 > 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 > # > https://github.com/intel-lab-lkp/linux/commit/9400668b70cbcd5ec74a52f043c3a333b80135f8 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review > Yicong-Yang/Add-support-for-HiSilicon-PCIe-Tune-and-Trace-device/20220406-200044 > git checkout 9400668b70cbcd5ec74a52f043c3a333b80135f8 > # save the config file to linux build tree > mkdir build_dir > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross > O=build_dir ARCH=alpha SHELL=/bin/bash drivers/hwtracing/ptt/ > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > All warnings (new ones prefixed by >>): > >drivers/hwtracing/ptt/hisi_ptt.c: In function 'hisi_ptt_tune_data_get': >>> drivers/hwtracing/ptt/hisi_ptt.c:46:16: warning: conversion from 'long >>> unsigned int' to 'u32' {aka 'unsigned int'} changes value from >>> '18446744073709551615' to '4294967295' [-Woverflow] > 46 | writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); > |^~~~ Thanks for the report. using of ~0U will fix this. >drivers/hwtracing/ptt/hisi_ptt.c: At top level: >drivers/hwtracing/ptt/hisi_ptt.c:1131:6: warning: no previous prototype > for 'hisi_ptt_remove' [-Wmissing-prototypes] > 1131 | void hisi_ptt_remove(struct pci_dev *pdev) > | ^~~ > for here I missed the static identifier. will fix. thanks. > > vim +46 drivers/hwtracing/ptt/hisi_ptt.c > > 33 > 34static int hisi_ptt_tune_data_get(struct hisi_ptt *hisi_ptt, > 35 u32 event, u16 *data) > 36{ > 37u32 reg; > 38 > 39reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); > 40reg &= ~(HISI_PTT_TUNING_CTRL_CODE | > HISI_PTT_TUNING_CTRL_SUB); > 41reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | > HISI_PTT_TUNING_CTRL_SUB, > 42 event); > 43writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); > 44 > 45/* Write all 1 to indicates it's the read process */ > > 46writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); > 47 > 48if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) > 49return -ETIMEDOUT; > 50 > 51reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_DATA); > 52reg &= HISI_PTT_TUNING_DATA_VAL_MASK; > 53*data = FIELD_GET(HISI_PTT_TUNING_DATA_VAL_MASK, reg); > 54 > 55return 0; > 56} > 57 > ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v6 4/7] hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device
Hi Yicong, I love your patch! Perhaps something to improve: [auto build test WARNING on joro-iommu/next] [also build test WARNING on linus/master linux/master v5.18-rc1 next-20220406] [cannot apply to tip/perf/core] [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/intel-lab-lkp/linux/commits/Yicong-Yang/Add-support-for-HiSilicon-PCIe-Tune-and-Trace-device/20220406-200044 base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220407/202204071201.acepulor-...@intel.com/config) compiler: alpha-linux-gcc (GCC) 11.2.0 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 # https://github.com/intel-lab-lkp/linux/commit/9400668b70cbcd5ec74a52f043c3a333b80135f8 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Yicong-Yang/Add-support-for-HiSilicon-PCIe-Tune-and-Trace-device/20220406-200044 git checkout 9400668b70cbcd5ec74a52f043c3a333b80135f8 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/hwtracing/ptt/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/hwtracing/ptt/hisi_ptt.c: In function 'hisi_ptt_tune_data_get': >> drivers/hwtracing/ptt/hisi_ptt.c:46:16: warning: conversion from 'long >> unsigned int' to 'u32' {aka 'unsigned int'} changes value from >> '18446744073709551615' to '4294967295' [-Woverflow] 46 | writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); |^~~~ drivers/hwtracing/ptt/hisi_ptt.c: At top level: drivers/hwtracing/ptt/hisi_ptt.c:1131:6: warning: no previous prototype for 'hisi_ptt_remove' [-Wmissing-prototypes] 1131 | void hisi_ptt_remove(struct pci_dev *pdev) | ^~~ vim +46 drivers/hwtracing/ptt/hisi_ptt.c 33 34 static int hisi_ptt_tune_data_get(struct hisi_ptt *hisi_ptt, 35u32 event, u16 *data) 36 { 37 u32 reg; 38 39 reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); 40 reg &= ~(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB); 41 reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB, 42event); 43 writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); 44 45 /* Write all 1 to indicates it's the read process */ > 46 writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); 47 48 if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) 49 return -ETIMEDOUT; 50 51 reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_DATA); 52 reg &= HISI_PTT_TUNING_DATA_VAL_MASK; 53 *data = FIELD_GET(HISI_PTT_TUNING_DATA_VAL_MASK, reg); 54 55 return 0; 56 } 57 -- 0-DAY CI Kernel Test Service https://01.org/lkp ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v6 4/7] hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device
Add tune function for the HiSilicon Tune and Trace device. The interface of tune is exposed through sysfs attributes of PTT PMU device. Signed-off-by: Yicong Yang Reviewed-by: Jonathan Cameron --- drivers/hwtracing/ptt/hisi_ptt.c | 154 +++ drivers/hwtracing/ptt/hisi_ptt.h | 20 2 files changed, 174 insertions(+) diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c index 266b0195ce8c..200a2de7b512 100644 --- a/drivers/hwtracing/ptt/hisi_ptt.c +++ b/drivers/hwtracing/ptt/hisi_ptt.c @@ -21,6 +21,159 @@ #include "hisi_ptt.h" +static bool hisi_ptt_wait_tuning_finish(struct hisi_ptt *hisi_ptt) +{ + u32 val; + + return !readl_poll_timeout(hisi_ptt->iobase + HISI_PTT_TUNING_INT_STAT, + val, !(val & HISI_PTT_TUNING_INT_STAT_MASK), + HISI_PTT_WAIT_POLL_INTERVAL_US, + HISI_PTT_WAIT_TUNE_TIMEOUT_US); +} + +static int hisi_ptt_tune_data_get(struct hisi_ptt *hisi_ptt, + u32 event, u16 *data) +{ + u32 reg; + + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); + reg &= ~(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB); + reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB, + event); + writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); + + /* Write all 1 to indicates it's the read process */ + writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); + + if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) + return -ETIMEDOUT; + + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_DATA); + reg &= HISI_PTT_TUNING_DATA_VAL_MASK; + *data = FIELD_GET(HISI_PTT_TUNING_DATA_VAL_MASK, reg); + + return 0; +} + +static int hisi_ptt_tune_data_set(struct hisi_ptt *hisi_ptt, + u32 event, u16 data) +{ + u32 reg; + + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); + reg &= ~(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB); + reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB, + event); + writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); + + writel(FIELD_PREP(HISI_PTT_TUNING_DATA_VAL_MASK, data), + hisi_ptt->iobase + HISI_PTT_TUNING_DATA); + + if (!hisi_ptt_wait_tuning_finish(hisi_ptt)) + return -ETIMEDOUT; + + return 0; +} + +static ssize_t hisi_ptt_tune_attr_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev)); + struct dev_ext_attribute *ext_attr; + struct hisi_ptt_tune_desc *desc; + int ret; + u16 val; + + ext_attr = container_of(attr, struct dev_ext_attribute, attr); + desc = ext_attr->var; + + if (!mutex_trylock(&hisi_ptt->mutex)) + return -EBUSY; + + ret = hisi_ptt_tune_data_get(hisi_ptt, desc->event_code, &val); + + mutex_unlock(&hisi_ptt->mutex); + return ret ? ret : sysfs_emit(buf, "%u\n", val); +} + +static ssize_t hisi_ptt_tune_attr_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev)); + struct dev_ext_attribute *ext_attr; + struct hisi_ptt_tune_desc *desc; + int ret; + u16 val; + + ext_attr = container_of(attr, struct dev_ext_attribute, attr); + desc = ext_attr->var; + + if (kstrtou16(buf, 10, &val)) + return -EINVAL; + + if (!mutex_trylock(&hisi_ptt->mutex)) + return -EBUSY; + + ret = hisi_ptt_tune_data_set(hisi_ptt, desc->event_code, val); + + mutex_unlock(&hisi_ptt->mutex); + return ret ? ret : count; +} + +#define HISI_PTT_TUNE_ATTR(_name, _val, _show, _store) \ + static struct hisi_ptt_tune_desc _name##_desc = { \ + .name = #_name, \ + .event_code = _val, \ + }; \ + static struct dev_ext_attribute hisi_ptt_##_name##_attr = { \ + .attr = __ATTR(_name, 0600, _show, _store), \ + .var= &_name##_desc,\ + } + +#define HISI_PTT_TUNE_ATTR_COMMON(_name, _val) \ + HISI_PTT_TUNE_ATTR(_name, _val, \ + hisi_ptt_tune_attr_show, \ + hisi_ptt_tune_attr_store) + +/* + * The value of the tuning event are composed of two parts: main event code in bit[0,15]