Commit feb4e4c6 authored by Pu Wen's avatar Pu Wen
Browse files

x86/amd_nb: Add support for Hygon family 18h model 5h

hygon inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I7DX6V


CVE: NA

---------------------------

Add root and DF F1/F3/F4 device IDs for Hygon family 18h model
5h processors. But some model 5h processors have the legacy(M04H)
DF devices, so add a if conditional to read the df1 register.

Signed-off-by: default avatarPu Wen <puwen@hygon.cn>
parent 450ca7f6
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@
#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F4 0x1444
#define PCI_DEVICE_ID_AMD_19H_DF_F4	0x1654

#define PCI_DEVICE_ID_HYGON_18H_M05H_ROOT  0x14a0
#define PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1 0x1491
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F1 0x14b1
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F4 0x14b4

/* Protect the PCI config register pairs used for SMN and DF indirect access. */
static DEFINE_MUTEX(smn_mutex);
@@ -78,18 +81,21 @@ static const struct pci_device_id amd_nb_link_ids[] = {
static const struct pci_device_id hygon_root_ids[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_ROOT) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_ROOT) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_ROOT) },
	{}
};

static const struct pci_device_id hygon_nb_misc_ids[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3) },
	{}
};

static const struct pci_device_id hygon_nb_link_ids[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F4) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) },
	{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_DF_F4) },
	{}
};

@@ -247,10 +253,24 @@ EXPORT_SYMBOL_GPL(hygon_nb_num);
static int get_df1_register(struct pci_dev *misc, int offset, u32 *value)
{
	struct pci_dev *df_f1 = NULL;
	u32 device;
	int err;

	while ((df_f1 = pci_get_device(misc->vendor,
			PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1, df_f1)))
	switch (boot_cpu_data.x86_model) {
	case 0x4:
		device = PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1;
		break;
	case 0x5:
		if (misc->device == PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3)
			device = PCI_DEVICE_ID_HYGON_18H_M05H_DF_F1;
		else
			device = PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1;
		break;
	default:
		return -ENODEV;
	}

	while ((df_f1 = pci_get_device(misc->vendor, device, df_f1)))
		if (pci_domain_nr(df_f1->bus) == pci_domain_nr(misc->bus) &&
		    df_f1->bus->number == misc->bus->number &&
		    PCI_SLOT(df_f1->devfn) == PCI_SLOT(misc->devfn))
+1 −0
Original line number Diff line number Diff line
@@ -2573,6 +2573,7 @@
#define PCI_VENDOR_ID_ZHAOXIN		0x1d17

#define PCI_VENDOR_ID_HYGON		0x1d94
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3	0x14b3

#define PCI_VENDOR_ID_TEKRAM		0x1de1
#define PCI_DEVICE_ID_TEKRAM_DC290	0xdc29