Skip to content

Commit 2871d7b

Browse files
committed
Merge: platform/x86/amd/pmc: updates
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1389 Description: Updates for AMD Power Management Controller primarily responsible for S2Idle transactions that are driven from a platform firmware running on SMU. JIRA: https://issues.redhat.com/browse/RHEL-103121 Build Info: 68763666 Tested: Successful tested on AMD (amd-krackan-01) system. Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: John W. Linville <linville@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Scott Weaver <scweaver@redhat.com>
2 parents d3280bd + f26455a commit 2871d7b

File tree

23 files changed

+598
-568
lines changed

23 files changed

+598
-568
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ config X86_MCE_INTEL
11911191
config X86_MCE_AMD
11921192
def_bool y
11931193
prompt "AMD MCE features"
1194-
depends on X86_MCE && X86_LOCAL_APIC && AMD_NB
1194+
depends on X86_MCE && X86_LOCAL_APIC
11951195
help
11961196
Additional support for AMD specific MCE features such as
11971197
the DRAM Error Threshold.

arch/x86/include/asm/amd_nb.h renamed to arch/x86/include/asm/amd/nb.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,10 @@ struct amd_l3_cache {
2626
u8 subcaches[4];
2727
};
2828

29-
struct threshold_block {
30-
unsigned int block; /* Number within bank */
31-
unsigned int bank; /* MCA bank the block belongs to */
32-
unsigned int cpu; /* CPU which controls MCA bank */
33-
u32 address; /* MSR address for the block */
34-
u16 interrupt_enable; /* Enable/Disable APIC interrupt */
35-
bool interrupt_capable; /* Bank can generate an interrupt. */
36-
37-
u16 threshold_limit; /*
38-
* Value upon which threshold
39-
* interrupt is generated.
40-
*/
41-
42-
struct kobject kobj; /* sysfs object */
43-
struct list_head miscj; /*
44-
* List of threshold blocks
45-
* within a bank.
46-
*/
47-
};
48-
49-
struct threshold_bank {
50-
struct kobject *kobj;
51-
struct threshold_block *blocks;
52-
53-
/* initialized to the number of CPUs on the node sharing this bank */
54-
refcount_t cpus;
55-
unsigned int shared;
56-
};
57-
5829
struct amd_northbridge {
5930
struct pci_dev *misc;
6031
struct pci_dev *link;
6132
struct amd_l3_cache l3_cache;
62-
struct threshold_bank *bank4;
6333
};
6434

6535
struct amd_northbridge_info {

arch/x86/kernel/amd_gart_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <asm/gart.h>
4040
#include <asm/set_memory.h>
4141
#include <asm/dma.h>
42-
#include <asm/amd_nb.h>
42+
#include <asm/amd/nb.h>
4343
#include <asm/x86_init.h>
4444

4545
static unsigned long iommu_bus_base; /* GART remapping area (physical) */

arch/x86/kernel/amd_nb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/export.h>
1414
#include <linux/spinlock.h>
1515
#include <linux/pci_ids.h>
16-
#include <asm/amd_nb.h>
16+
#include <asm/amd/nb.h>
1717

1818
static u32 *flush_words;
1919

arch/x86/kernel/aperture_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <asm/gart.h>
3030
#include <asm/pci-direct.h>
3131
#include <asm/dma.h>
32-
#include <asm/amd_nb.h>
32+
#include <asm/amd/nb.h>
3333
#include <asm/x86_init.h>
3434
#include <linux/crash_dump.h>
3535

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/sched/clock.h>
1010
#include <linux/random.h>
1111
#include <linux/topology.h>
12-
#include <asm/amd/fch.h>
12+
#include <linux/platform_data/x86/amd-fch.h>
1313
#include <asm/processor.h>
1414
#include <asm/apic.h>
1515
#include <asm/cacheinfo.h>

arch/x86/kernel/cpu/cacheinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <asm/cpufeature.h>
2222
#include <asm/cacheinfo.h>
23-
#include <asm/amd_nb.h>
23+
#include <asm/amd/nb.h>
2424
#include <asm/smp.h>
2525
#include <asm/mtrr.h>
2626
#include <asm/tlbflush.h>

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 26 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*
55
* Written by Jacob Shin - AMD, Inc.
66
* Maintained by: Borislav Petkov <bp@alien8.de>
7-
*
8-
* All MC4_MISCi registers are shared between cores on a node.
97
*/
108
#include <linux/interrupt.h>
119
#include <linux/notifier.h>
@@ -20,7 +18,6 @@
2018
#include <linux/smp.h>
2119
#include <linux/string.h>
2220

23-
#include <asm/amd_nb.h>
2421
#include <asm/traps.h>
2522
#include <asm/apic.h>
2623
#include <asm/mce.h>
@@ -221,6 +218,32 @@ static const struct smca_hwid smca_hwid_mcatypes[] = {
221218
#define MAX_MCATYPE_NAME_LEN 30
222219
static char buf_mcatype[MAX_MCATYPE_NAME_LEN];
223220

221+
struct threshold_block {
222+
/* This block's number within its bank. */
223+
unsigned int block;
224+
/* MCA bank number that contains this block. */
225+
unsigned int bank;
226+
/* CPU which controls this block's MCA bank. */
227+
unsigned int cpu;
228+
/* MCA_MISC MSR address for this block. */
229+
u32 address;
230+
/* Enable/Disable APIC interrupt. */
231+
bool interrupt_enable;
232+
/* Bank can generate an interrupt. */
233+
bool interrupt_capable;
234+
/* Value upon which threshold interrupt is generated. */
235+
u16 threshold_limit;
236+
/* sysfs object */
237+
struct kobject kobj;
238+
/* List of threshold blocks within this block's MCA bank. */
239+
struct list_head miscj;
240+
};
241+
242+
struct threshold_bank {
243+
struct kobject *kobj;
244+
struct threshold_block *blocks;
245+
};
246+
224247
static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks);
225248

226249
/*
@@ -333,19 +356,6 @@ struct thresh_restart {
333356
u16 old_limit;
334357
};
335358

336-
static inline bool is_shared_bank(int bank)
337-
{
338-
/*
339-
* Scalable MCA provides for only one core to have access to the MSRs of
340-
* a shared bank.
341-
*/
342-
if (mce_flags.smca)
343-
return false;
344-
345-
/* Bank 4 is for northbridge reporting and is thus shared */
346-
return (bank == 4);
347-
}
348-
349359
static const char *bank4_names(const struct threshold_block *b)
350360
{
351361
switch (b->address) {
@@ -1194,62 +1204,17 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb
11941204
return err;
11951205
}
11961206

1197-
static int __threshold_add_blocks(struct threshold_bank *b)
1198-
{
1199-
struct list_head *head = &b->blocks->miscj;
1200-
struct threshold_block *pos = NULL;
1201-
struct threshold_block *tmp = NULL;
1202-
int err = 0;
1203-
1204-
err = kobject_add(&b->blocks->kobj, b->kobj, b->blocks->kobj.name);
1205-
if (err)
1206-
return err;
1207-
1208-
list_for_each_entry_safe(pos, tmp, head, miscj) {
1209-
1210-
err = kobject_add(&pos->kobj, b->kobj, pos->kobj.name);
1211-
if (err) {
1212-
list_for_each_entry_safe_reverse(pos, tmp, head, miscj)
1213-
kobject_del(&pos->kobj);
1214-
1215-
return err;
1216-
}
1217-
}
1218-
return err;
1219-
}
1220-
12211207
static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu,
12221208
unsigned int bank)
12231209
{
12241210
struct device *dev = this_cpu_read(mce_device);
1225-
struct amd_northbridge *nb = NULL;
12261211
struct threshold_bank *b = NULL;
12271212
const char *name = get_name(cpu, bank, NULL);
12281213
int err = 0;
12291214

12301215
if (!dev)
12311216
return -ENODEV;
12321217

1233-
if (is_shared_bank(bank)) {
1234-
nb = node_to_amd_nb(topology_amd_node_id(cpu));
1235-
1236-
/* threshold descriptor already initialized on this node? */
1237-
if (nb && nb->bank4) {
1238-
/* yes, use it */
1239-
b = nb->bank4;
1240-
err = kobject_add(b->kobj, &dev->kobj, name);
1241-
if (err)
1242-
goto out;
1243-
1244-
bp[bank] = b;
1245-
refcount_inc(&b->cpus);
1246-
1247-
err = __threshold_add_blocks(b);
1248-
1249-
goto out;
1250-
}
1251-
}
1252-
12531218
b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL);
12541219
if (!b) {
12551220
err = -ENOMEM;
@@ -1263,17 +1228,6 @@ static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu,
12631228
goto out_free;
12641229
}
12651230

1266-
if (is_shared_bank(bank)) {
1267-
b->shared = 1;
1268-
refcount_set(&b->cpus, 1);
1269-
1270-
/* nb is already initialized, see above */
1271-
if (nb) {
1272-
WARN_ON(nb->bank4);
1273-
nb->bank4 = b;
1274-
}
1275-
}
1276-
12771231
err = allocate_threshold_blocks(cpu, b, bank, 0, mca_msr_reg(bank, MCA_MISC));
12781232
if (err)
12791233
goto out_kobj;
@@ -1306,40 +1260,11 @@ static void deallocate_threshold_blocks(struct threshold_bank *bank)
13061260
kobject_put(&bank->blocks->kobj);
13071261
}
13081262

1309-
static void __threshold_remove_blocks(struct threshold_bank *b)
1310-
{
1311-
struct threshold_block *pos = NULL;
1312-
struct threshold_block *tmp = NULL;
1313-
1314-
kobject_put(b->kobj);
1315-
1316-
list_for_each_entry_safe(pos, tmp, &b->blocks->miscj, miscj)
1317-
kobject_put(b->kobj);
1318-
}
1319-
13201263
static void threshold_remove_bank(struct threshold_bank *bank)
13211264
{
1322-
struct amd_northbridge *nb;
1323-
13241265
if (!bank->blocks)
13251266
goto out_free;
13261267

1327-
if (!bank->shared)
1328-
goto out_dealloc;
1329-
1330-
if (!refcount_dec_and_test(&bank->cpus)) {
1331-
__threshold_remove_blocks(bank);
1332-
return;
1333-
} else {
1334-
/*
1335-
* The last CPU on this node using the shared bank is going
1336-
* away, remove that bank now.
1337-
*/
1338-
nb = node_to_amd_nb(topology_amd_node_id(smp_processor_id()));
1339-
nb->bank4 = NULL;
1340-
}
1341-
1342-
out_dealloc:
13431268
deallocate_threshold_blocks(bank);
13441269

13451270
out_free:

arch/x86/kernel/cpu/mce/inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <linux/pci.h>
2525
#include <linux/uaccess.h>
2626

27-
#include <asm/amd_nb.h>
27+
#include <asm/amd/nb.h>
2828
#include <asm/apic.h>
2929
#include <asm/irq_vectors.h>
3030
#include <asm/mce.h>

arch/x86/mm/amdtopology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <asm/numa.h>
2626
#include <asm/mpspec.h>
2727
#include <asm/apic.h>
28-
#include <asm/amd_nb.h>
28+
#include <asm/amd/nb.h>
2929

3030
static unsigned char __initdata nodeids[8];
3131

0 commit comments

Comments
 (0)