Skip to content

Commit 8465625

Browse files
committed
Merge branch 'x86-amd-nb-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 AMD northbridge updates from Ingo Molnar: "Update DF/SMN access and k10temp for AMD F17h M30h, by Brian Woods: 'Updates the data fabric/system management network code needed to get k10temp working for M30h. Since there are now processors which have multiple roots per DF/SMN interface, there needs to some logic which skips N-1 root complexes per DF/SMN interface. This is because the root complexes per interface are redundant (as far as DF/SMN goes). These changes shouldn't effect past processors and, for F17h M0Xh, the mappings stay the same.' The hwmon changes were seen and acked by hwmon maintainer Guenter Roeck" * 'x86-amd-nb-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: hwmon/k10temp: Add support for AMD family 17h, model 30h CPUs x86/amd_nb: Add PCI device IDs for family 17h, model 30h x86/amd_nb: Add support for newer PCI topologies hwmon/k10temp, x86/amd_nb: Consolidate shared device IDs
2 parents 17bf423 + 210ba12 commit 8465625

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

arch/x86/kernel/amd_nb.c

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
#include <linux/errno.h>
1212
#include <linux/export.h>
1313
#include <linux/spinlock.h>
14+
#include <linux/pci_ids.h>
1415
#include <asm/amd_nb.h>
1516

1617
#define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450
1718
#define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0
18-
#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463
19+
#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480
1920
#define PCI_DEVICE_ID_AMD_17H_DF_F4 0x1464
20-
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb
2121
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F4 0x15ec
22+
#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F4 0x1494
2223

2324
/* Protect the PCI config register pairs used for SMN and DF indirect access. */
2425
static DEFINE_MUTEX(smn_mutex);
@@ -28,9 +29,11 @@ static u32 *flush_words;
2829
static const struct pci_device_id amd_root_ids[] = {
2930
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_ROOT) },
3031
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_ROOT) },
32+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_ROOT) },
3133
{}
3234
};
3335

36+
3437
#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704
3538

3639
const struct pci_device_id amd_nb_misc_ids[] = {
@@ -44,6 +47,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
4447
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
4548
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
4649
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) },
50+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) },
4751
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
4852
{}
4953
};
@@ -57,6 +61,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
5761
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
5862
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
5963
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F4) },
64+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) },
6065
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
6166
{}
6267
};
@@ -214,7 +219,10 @@ int amd_cache_northbridges(void)
214219
const struct pci_device_id *root_ids = amd_root_ids;
215220
struct pci_dev *root, *misc, *link;
216221
struct amd_northbridge *nb;
217-
u16 i = 0;
222+
u16 roots_per_misc = 0;
223+
u16 misc_count = 0;
224+
u16 root_count = 0;
225+
u16 i, j;
218226

219227
if (amd_northbridges.num)
220228
return 0;
@@ -227,26 +235,55 @@ int amd_cache_northbridges(void)
227235

228236
misc = NULL;
229237
while ((misc = next_northbridge(misc, misc_ids)) != NULL)
230-
i++;
238+
misc_count++;
231239

232-
if (!i)
240+
if (!misc_count)
233241
return -ENODEV;
234242

235-
nb = kcalloc(i, sizeof(struct amd_northbridge), GFP_KERNEL);
243+
root = NULL;
244+
while ((root = next_northbridge(root, root_ids)) != NULL)
245+
root_count++;
246+
247+
if (root_count) {
248+
roots_per_misc = root_count / misc_count;
249+
250+
/*
251+
* There should be _exactly_ N roots for each DF/SMN
252+
* interface.
253+
*/
254+
if (!roots_per_misc || (root_count % roots_per_misc)) {
255+
pr_info("Unsupported AMD DF/PCI configuration found\n");
256+
return -ENODEV;
257+
}
258+
}
259+
260+
nb = kcalloc(misc_count, sizeof(struct amd_northbridge), GFP_KERNEL);
236261
if (!nb)
237262
return -ENOMEM;
238263

239264
amd_northbridges.nb = nb;
240-
amd_northbridges.num = i;
265+
amd_northbridges.num = misc_count;
241266

242267
link = misc = root = NULL;
243-
for (i = 0; i != amd_northbridges.num; i++) {
268+
for (i = 0; i < amd_northbridges.num; i++) {
244269
node_to_amd_nb(i)->root = root =
245270
next_northbridge(root, root_ids);
246271
node_to_amd_nb(i)->misc = misc =
247272
next_northbridge(misc, misc_ids);
248273
node_to_amd_nb(i)->link = link =
249274
next_northbridge(link, link_ids);
275+
276+
/*
277+
* If there are more PCI root devices than data fabric/
278+
* system management network interfaces, then the (N)
279+
* PCI roots per DF/SMN interface are functionally the
280+
* same (for DF/SMN access) and N-1 are redundant. N-1
281+
* PCI roots should be skipped per DF/SMN interface so
282+
* the following DF/SMN interfaces get mapped to
283+
* correct PCI roots.
284+
*/
285+
for (j = 1; j < roots_per_misc; j++)
286+
root = next_northbridge(root, root_ids);
250287
}
251288

252289
if (amd_gart_present())

drivers/hwmon/k10temp.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/init.h>
2424
#include <linux/module.h>
2525
#include <linux/pci.h>
26+
#include <linux/pci_ids.h>
2627
#include <asm/amd_nb.h>
2728
#include <asm/processor.h>
2829

@@ -41,14 +42,6 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
4142
#define PCI_DEVICE_ID_AMD_15H_M70H_NB_F3 0x15b3
4243
#endif
4344

44-
#ifndef PCI_DEVICE_ID_AMD_17H_DF_F3
45-
#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463
46-
#endif
47-
48-
#ifndef PCI_DEVICE_ID_AMD_17H_M10H_DF_F3
49-
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb
50-
#endif
51-
5245
/* CPUID function 0x80000001, ebx */
5346
#define CPUID_PKGTYPE_MASK 0xf0000000
5447
#define CPUID_PKGTYPE_F 0x00000000
@@ -367,6 +360,7 @@ static const struct pci_device_id k10temp_id_table[] = {
367360
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
368361
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
369362
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) },
363+
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) },
370364
{}
371365
};
372366
MODULE_DEVICE_TABLE(pci, k10temp_id_table);

include/linux/pci_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@
545545
#define PCI_DEVICE_ID_AMD_16H_NB_F4 0x1534
546546
#define PCI_DEVICE_ID_AMD_16H_M30H_NB_F3 0x1583
547547
#define PCI_DEVICE_ID_AMD_16H_M30H_NB_F4 0x1584
548+
#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463
549+
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb
550+
#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F3 0x1493
548551
#define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703
549552
#define PCI_DEVICE_ID_AMD_LANCE 0x2000
550553
#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001

0 commit comments

Comments
 (0)