Skip to content

Commit f4ecf4c

Browse files
committed
Merge: Update drivers/platform/x86/pmt & pmc
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6384 JIRA: https://issues.redhat.com/browse/RHEL-79553 The following upstream commits were excluded from the backport as they are difficult to backport to RHEL mainly due to scope: cdd30eb module: Convert symbol namespace to string literal 7ff2fec platform/x86/intel/pmt: Constify 'struct bin_attribute' e5d3a57 x86/cpu: Make all all CPUID leaf names consistent 3ea5eb6 platform/x86: Switch back to struct platform_driver::remove() Signed-off-by: David Arcari <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: Steve Best <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents 0af29bd + 1399e22 commit f4ecf4c

File tree

11 files changed

+31
-24
lines changed

11 files changed

+31
-24
lines changed

arch/x86/events/intel/pt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/slab.h>
1919
#include <linux/device.h>
2020

21+
#include <asm/cpuid.h>
2122
#include <asm/perf_event.h>
2223
#include <asm/insn.h>
2324
#include <asm/io.h>

arch/x86/events/intel/pt.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ struct topa_entry {
3737
u64 rsvd4 : 12;
3838
};
3939

40-
/* TSC to Core Crystal Clock Ratio */
41-
#define CPUID_TSC_LEAF 0x15
42-
4340
struct pt_pmu {
4441
struct pmu pmu;
4542
u32 caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];

arch/x86/include/asm/cpuid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ enum cpuid_regs_idx {
1919
CPUID_EDX,
2020
};
2121

22+
#define CPUID_TSC_LEAF 0x15
23+
2224
#ifdef CONFIG_X86_32
2325
extern int have_cpuid_p(void);
2426
#else

arch/x86/kernel/tsc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/static_key.h>
1717
#include <linux/static_call.h>
1818

19+
#include <asm/cpuid.h>
1920
#include <asm/hpet.h>
2021
#include <asm/timer.h>
2122
#include <asm/vgtod.h>
@@ -663,13 +664,13 @@ unsigned long native_calibrate_tsc(void)
663664
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
664665
return 0;
665666

666-
if (boot_cpu_data.cpuid_level < 0x15)
667+
if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF)
667668
return 0;
668669

669670
eax_denominator = ebx_numerator = ecx_hz = edx = 0;
670671

671672
/* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */
672-
cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx);
673+
cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx);
673674

674675
if (ebx_numerator == 0 || eax_denominator == 0)
675676
return 0;
@@ -1065,18 +1066,16 @@ core_initcall(cpufreq_register_tsc_scaling);
10651066

10661067
#endif /* CONFIG_CPU_FREQ */
10671068

1068-
#define ART_CPUID_LEAF (0x15)
10691069
#define ART_MIN_DENOMINATOR (1)
10701070

1071-
10721071
/*
10731072
* If ART is present detect the numerator:denominator to convert to TSC
10741073
*/
10751074
static void __init detect_art(void)
10761075
{
10771076
unsigned int unused;
10781077

1079-
if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF)
1078+
if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF)
10801079
return;
10811080

10821081
/*
@@ -1089,7 +1088,7 @@ static void __init detect_art(void)
10891088
tsc_async_resets)
10901089
return;
10911090

1092-
cpuid(ART_CPUID_LEAF, &art_base_clk.denominator,
1091+
cpuid(CPUID_TSC_LEAF, &art_base_clk.denominator,
10931092
&art_base_clk.numerator, &art_base_clk.freq_khz, &unused);
10941093

10951094
art_base_clk.freq_khz /= KHZ;

drivers/platform/x86/intel/pmc/core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/suspend.h>
2323
#include <linux/units.h>
2424

25+
#include <asm/cpuid.h>
2526
#include <asm/cpu_device_id.h>
2627
#include <asm/intel-family.h>
2728
#include <asm/msr.h>
@@ -625,8 +626,8 @@ static u32 convert_ltr_scale(u32 val)
625626
static int pmc_core_ltr_show(struct seq_file *s, void *unused)
626627
{
627628
struct pmc_dev *pmcdev = s->private;
628-
u64 decoded_snoop_ltr, decoded_non_snoop_ltr;
629-
u32 ltr_raw_data, scale, val;
629+
u64 decoded_snoop_ltr, decoded_non_snoop_ltr, val;
630+
u32 ltr_raw_data, scale;
630631
u16 snoop_ltr, nonsnoop_ltr;
631632
unsigned int i, index, ltr_index = 0;
632633

@@ -935,13 +936,13 @@ static unsigned int pmc_core_get_crystal_freq(void)
935936
{
936937
unsigned int eax_denominator, ebx_numerator, ecx_hz, edx;
937938

938-
if (boot_cpu_data.cpuid_level < 0x15)
939+
if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF)
939940
return 0;
940941

941942
eax_denominator = ebx_numerator = ecx_hz = edx = 0;
942943

943-
/* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */
944-
cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx);
944+
/* TSC/Crystal ratio, plus optionally Crystal Hz */
945+
cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx);
945946

946947
if (ebx_numerator == 0 || eax_denominator == 0)
947948
return 0;

drivers/platform/x86/intel/pmc/core_ssram.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset)
269269
/*
270270
* The secondary PMC BARS (which are behind hidden PCI devices)
271271
* are read from fixed offsets in MMIO of the primary PMC BAR.
272+
* If a device is not present, the value will be 0.
272273
*/
273274
ssram_base = get_base(tmp_ssram, offset);
275+
if (!ssram_base)
276+
return 0;
277+
274278
ssram = ioremap(ssram_base, SSRAM_HDR_SIZE);
275279
if (!ssram)
276280
return -ENOMEM;

drivers/platform/x86/intel/pmt/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Intel Platform Monitoring Technology Drivers
55
#
66

7-
pmt_class-objs += class.o
87
obj-$(CONFIG_INTEL_PMT_CLASS) += pmt_class.o
9-
pmt_telemetry-objs += telemetry.o
8+
pmt_class-y := class.o
109
obj-$(CONFIG_INTEL_PMT_TELEMETRY) += pmt_telemetry.o
11-
pmt_crashlog-objs += crashlog.o
10+
pmt_telemetry-y := telemetry.o
1211
obj-$(CONFIG_INTEL_PMT_CRASHLOG) += pmt_crashlog.o
12+
pmt_crashlog-y := crashlog.o

drivers/platform/x86/intel/pmt/class.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count)
5959
}
6060

6161
int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
62-
void __iomem *addr, u32 count)
62+
void __iomem *addr, loff_t off, u32 count)
6363
{
6464
if (cb && cb->read_telem)
65-
return cb->read_telem(pdev, guid, buf, count);
65+
return cb->read_telem(pdev, guid, buf, off, count);
66+
67+
addr += off;
6668

6769
if (guid == GUID_SPR_PUNIT)
6870
/* PUNIT on SPR only supports aligned 64-bit read */
@@ -96,7 +98,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
9698
count = entry->size - off;
9799

98100
count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
99-
entry->base + off, count);
101+
entry->base, off, count);
100102

101103
return count;
102104
}
@@ -207,7 +209,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
207209
/*
208210
* Some hardware use a different calculation for the base address
209211
* when access_type == ACCESS_LOCAL. On the these systems
210-
* ACCCESS_LOCAL refers to an address in the same BAR as the
212+
* ACCESS_LOCAL refers to an address in the same BAR as the
211213
* header but at a fixed offset. But as the header address was
212214
* supplied to the driver, we don't know which BAR it was in.
213215
* So search for the bar whose range includes the header address.

drivers/platform/x86/intel/pmt/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct intel_pmt_namespace {
6262
};
6363

6464
int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
65-
void __iomem *addr, u32 count);
65+
void __iomem *addr, loff_t off, u32 count);
6666
bool intel_pmt_is_early_client_hw(struct device *dev);
6767
int intel_pmt_dev_create(struct intel_pmt_entry *entry,
6868
struct intel_pmt_namespace *ns,

drivers/platform/x86/intel/pmt/telemetry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count)
219219
if (offset + NUM_BYTES_QWORD(count) > size)
220220
return -EINVAL;
221221

222-
pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset,
222+
pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base, offset,
223223
NUM_BYTES_QWORD(count));
224224

225225
return ep->present ? 0 : -EPIPE;

0 commit comments

Comments
 (0)