tree:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x8...
review-hans
head: 8d01cf643b3f8bc79c5b6bf18382b943143d9090
commit: 8074a79fad2e34fce11ea2b2c515b984fc6b2a08 [79/82] platform/x86: intel_pmc_core: Add
option to set/clear LPM mode
config: x86_64-randconfig-m001-20210419 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
smatch warnings:
drivers/platform/x86/intel_pmc_core.c:1369 pmc_core_lpm_latch_mode_write() warn: unsigned
'ret' is never less than zero.
vim +/ret +1369 drivers/platform/x86/intel_pmc_core.c
1352
1353 static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
1354 const char __user *userbuf,
1355 size_t count, loff_t *ppos)
1356 {
1357 struct seq_file *s = file->private_data;
1358 struct pmc_dev *pmcdev = s->private;
1359 bool clear = false, c10 = false;
1360 unsigned char buf[8];
1361 size_t ret;
1362 int idx, m, mode;
1363 u32 reg;
1364
1365 if (count > sizeof(buf) - 1)
1366 return -EINVAL;
1367
1368 ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf, count);
1369 if (ret < 0)
1370 return ret;
1371
1372 buf[count] = '\0';
1373
1374 /*
1375 * Allowed strings are:
1376 * Any enabled substate, e.g. 'S0i2.0'
1377 * 'c10'
1378 * 'clear'
1379 */
1380 mode = sysfs_match_string(pmc_lpm_modes, buf);
1381
1382 /* Check string matches enabled mode */
1383 pmc_for_each_mode(idx, m, pmcdev)
1384 if (mode == m)
1385 break;
1386
1387 if (mode != m || mode < 0) {
1388 if (sysfs_streq(buf, "clear"))
1389 clear = true;
1390 else if (sysfs_streq(buf, "c10"))
1391 c10 = true;
1392 else
1393 return -EINVAL;
1394 }
1395
1396 if (clear) {
1397 mutex_lock(&pmcdev->lock);
1398
1399 reg = pmc_core_reg_read(pmcdev, pmcdev->map->etr3_offset);
1400 reg |= ETR3_CLEAR_LPM_EVENTS;
1401 pmc_core_reg_write(pmcdev, pmcdev->map->etr3_offset, reg);
1402
1403 mutex_unlock(&pmcdev->lock);
1404
1405 return count;
1406 }
1407
1408 if (c10) {
1409 mutex_lock(&pmcdev->lock);
1410
1411 reg = pmc_core_reg_read(pmcdev, pmcdev->map->lpm_sts_latch_en_offset);
1412 reg &= ~LPM_STS_LATCH_MODE;
1413 pmc_core_reg_write(pmcdev, pmcdev->map->lpm_sts_latch_en_offset, reg);
1414
1415 mutex_unlock(&pmcdev->lock);
1416
1417 return count;
1418 }
1419
1420 /*
1421 * For LPM mode latching we set the latch enable bit and selected mode
1422 * and clear everything else.
1423 */
1424 reg = LPM_STS_LATCH_MODE | BIT(mode);
1425 mutex_lock(&pmcdev->lock);
1426 pmc_core_reg_write(pmcdev, pmcdev->map->lpm_sts_latch_en_offset, reg);
1427 mutex_unlock(&pmcdev->lock);
1428
1429 return count;
1430 }
1431 DEFINE_PMC_CORE_ATTR_WRITE(pmc_core_lpm_latch_mode);
1432
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org