From: Dan Carpenter <dan.carpenter@oracle.com>
To: kan.liang@linux.intel.com, linux-perf-users@vger.kernel.org
Subject: [bug report] perf/x86: Add Intel Tiger Lake uncore support
Date: Tue, 25 Jan 2022 10:43:19 +0300 [thread overview]
Message-ID: <20220125074319.GA3211@kili> (raw)
Hello Kan Liang,
The patch fdb64822443e: "perf/x86: Add Intel Tiger Lake uncore
support" from Feb 6, 2020, leads to the following Smatch static
checker warning:
arch/x86/events/intel/uncore_snb.c:1486 __uncore_imc_init_box()
warn: cast after binop
arch/x86/events/intel/uncore_snb.c
1465 static void __uncore_imc_init_box(struct intel_uncore_box *box,
1466 unsigned int base_offset)
1467 {
1468 struct pci_dev *pdev = tgl_uncore_get_mc_dev();
1469 struct intel_uncore_pmu *pmu = box->pmu;
1470 struct intel_uncore_type *type = pmu->type;
1471 resource_size_t addr;
1472 u32 mch_bar;
1473
1474 if (!pdev) {
1475 pr_warn("perf uncore: Cannot find matched IMC device.\n");
1476 return;
1477 }
1478
1479 pci_read_config_dword(pdev, SNB_UNCORE_PCI_IMC_BAR_OFFSET, &mch_bar);
1480 /* MCHBAR is disabled */
1481 if (!(mch_bar & BIT(0))) {
1482 pr_warn("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n");
1483 return;
1484 }
1485 mch_bar &= ~BIT(0);
--> 1486 addr = (resource_size_t)(mch_bar + TGL_UNCORE_MMIO_IMC_MEM_OFFSET * pmu->pmu_idx);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
All of these are 32 bit values. If we really need a 64bit type, these
will overflow before the cast to resource_size_t. This code is 2 years
old, so I suspect the cast is only required on line 1490 and that one is
correct.
1487
1488 #ifdef CONFIG_PHYS_ADDR_T_64BIT
1489 pci_read_config_dword(pdev, SNB_UNCORE_PCI_IMC_BAR_OFFSET + 4, &mch_bar);
1490 addr |= ((resource_size_t)mch_bar << 32);
1491 #endif
1492
1493 addr += base_offset;
1494 box->io_addr = ioremap(addr, type->mmio_map_size);
1495 if (!box->io_addr)
1496 pr_warn("perf uncore: Failed to ioremap for %s.\n", type->name);
1497 }
regards,
dan carpenter
next reply other threads:[~2022-01-25 7:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 7:43 Dan Carpenter [this message]
2022-01-25 13:32 ` [bug report] perf/x86: Add Intel Tiger Lake uncore support Liang, Kan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220125074319.GA3211@kili \
--to=dan.carpenter@oracle.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-perf-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).