[PATCH 6/8] coresight: Refactor out buffer allocation function for ETR

kernel test robot lkp at intel.com
Thu Mar 9 00:18:20 PST 2023


Hi James,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc1 next-20230309]
[cannot apply to atorgue-stm32/stm32-next soc/for-next]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/James-Clark/coresight-Use-enum-type-for-cs_mode-wherever-possible/20230309-014226
patch link:    https://lore.kernel.org/r/20230308173904.3449231-7-james.clark%40arm.com
patch subject: [PATCH 6/8] coresight: Refactor out buffer allocation function for ETR
config: arm-randconfig-r046-20230308 (https://download.01.org/0day-ci/archive/20230309/202303091603.UuxHblt7-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.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/3651e0e04e2a01c3cbcb4a4e9289092f2377dc13
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review James-Clark/coresight-Use-enum-type-for-cs_mode-wherever-possible/20230309-014226
        git checkout 3651e0e04e2a01c3cbcb4a4e9289092f2377dc13
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/hwtracing/coresight/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp at intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303091603.UuxHblt7-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/hwtracing/coresight/coresight-tmc-etr.c: In function 'tmc_etr_get_sysfs_buffer':
>> drivers/hwtracing/coresight/coresight-tmc-etr.c:1174:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
    1174 |         int ret = 0;
         |             ^~~


vim +/ret +1174 drivers/hwtracing/coresight/coresight-tmc-etr.c

6c6ed1e244c053 Mathieu Poirier  2016-05-03  1171  
3651e0e04e2a01 James Clark      2023-03-08  1172  static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1173  {
de5461970b3e9e Mathieu Poirier  2016-05-03 @1174  	int ret = 0;
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1175  	unsigned long flags;
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1176  	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
96a7f644006ecc Suzuki K Poulose 2018-09-20  1177  	struct etr_buf *sysfs_buf = NULL, *new_buf = NULL, *free_buf = NULL;
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1178  
de5461970b3e9e Mathieu Poirier  2016-05-03  1179  	/*
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1180  	 * If we are enabling the ETR from disabled state, we need to make
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1181  	 * sure we have a buffer with the right size. The etr_buf is not reset
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1182  	 * immediately after we stop the tracing in SYSFS mode as we wait for
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1183  	 * the user to collect the data. We may be able to reuse the existing
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1184  	 * buffer, provided the size matches. Any allocation has to be done
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1185  	 * with the lock released.
de5461970b3e9e Mathieu Poirier  2016-05-03  1186  	 */
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1187  	spin_lock_irqsave(&drvdata->spinlock, flags);
96a7f644006ecc Suzuki K Poulose 2018-09-20  1188  	sysfs_buf = READ_ONCE(drvdata->sysfs_buf);
96a7f644006ecc Suzuki K Poulose 2018-09-20  1189  	if (!sysfs_buf || (sysfs_buf->size != drvdata->size)) {
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1190  		spin_unlock_irqrestore(&drvdata->spinlock, flags);
de5461970b3e9e Mathieu Poirier  2016-05-03  1191  
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1192  		/* Allocate memory with the locks released */
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1193  		free_buf = new_buf = tmc_etr_setup_sysfs_buf(drvdata);
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1194  		if (IS_ERR(new_buf))
3651e0e04e2a01 James Clark      2023-03-08  1195  			return new_buf;
de5461970b3e9e Mathieu Poirier  2016-05-03  1196  
de5461970b3e9e Mathieu Poirier  2016-05-03  1197  		/* Let's try again */
de5461970b3e9e Mathieu Poirier  2016-05-03  1198  		spin_lock_irqsave(&drvdata->spinlock, flags);
de5461970b3e9e Mathieu Poirier  2016-05-03  1199  	}
de5461970b3e9e Mathieu Poirier  2016-05-03  1200  
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1201  	if (drvdata->reading || drvdata->mode == CS_MODE_PERF) {
de5461970b3e9e Mathieu Poirier  2016-05-03  1202  		ret = -EBUSY;
de5461970b3e9e Mathieu Poirier  2016-05-03  1203  		goto out;
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1204  	}
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1205  
f2facc3366d77e Mathieu Poirier  2016-05-03  1206  	/*
f2facc3366d77e Mathieu Poirier  2016-05-03  1207  	 * In sysFS mode we can have multiple writers per sink.  Since this
f2facc3366d77e Mathieu Poirier  2016-05-03  1208  	 * sink is already enabled no memory is needed and the HW need not be
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1209  	 * touched, even if the buffer size has changed.
f2facc3366d77e Mathieu Poirier  2016-05-03  1210  	 */
f973d88b757037 Mathieu Poirier  2019-04-25  1211  	if (drvdata->mode == CS_MODE_SYSFS) {
f973d88b757037 Mathieu Poirier  2019-04-25  1212  		atomic_inc(csdev->refcnt);
f2facc3366d77e Mathieu Poirier  2016-05-03  1213  		goto out;
f973d88b757037 Mathieu Poirier  2019-04-25  1214  	}
f2facc3366d77e Mathieu Poirier  2016-05-03  1215  
de5461970b3e9e Mathieu Poirier  2016-05-03  1216  	/*
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1217  	 * If we don't have a buffer or it doesn't match the requested size,
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1218  	 * use the buffer allocated above. Otherwise reuse the existing buffer.
de5461970b3e9e Mathieu Poirier  2016-05-03  1219  	 */
96a7f644006ecc Suzuki K Poulose 2018-09-20  1220  	sysfs_buf = READ_ONCE(drvdata->sysfs_buf);
96a7f644006ecc Suzuki K Poulose 2018-09-20  1221  	if (!sysfs_buf || (new_buf && sysfs_buf->size != new_buf->size)) {
96a7f644006ecc Suzuki K Poulose 2018-09-20  1222  		free_buf = sysfs_buf;
96a7f644006ecc Suzuki K Poulose 2018-09-20  1223  		drvdata->sysfs_buf = new_buf;
de5461970b3e9e Mathieu Poirier  2016-05-03  1224  	}
de5461970b3e9e Mathieu Poirier  2016-05-03  1225  
de5461970b3e9e Mathieu Poirier  2016-05-03  1226  out:
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1227  	spin_unlock_irqrestore(&drvdata->spinlock, flags);
6c6ed1e244c053 Mathieu Poirier  2016-05-03  1228  
de5461970b3e9e Mathieu Poirier  2016-05-03  1229  	/* Free memory outside the spinlock if need be */
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1230  	if (free_buf)
75f4e3619fe202 Suzuki K Poulose 2018-07-11  1231  		tmc_etr_free_sysfs_buf(free_buf);
3651e0e04e2a01 James Clark      2023-03-08  1232  	return drvdata->sysfs_buf;
3651e0e04e2a01 James Clark      2023-03-08  1233  }
3651e0e04e2a01 James Clark      2023-03-08  1234  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests



More information about the linux-arm-kernel mailing list