Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1060177oof; Tue, 25 Sep 2018 07:48:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV62lokupKiMwGuz0KMJy5aRXB7WHaCutrjpWOE8nEAT30K0D+5b/ID1gLlrFrGpF4yn4TY+O X-Received: by 2002:a62:3001:: with SMTP id w1-v6mr1522343pfw.19.1537886899730; Tue, 25 Sep 2018 07:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537886899; cv=none; d=google.com; s=arc-20160816; b=hUNFM2hW6KMYcCFLTQjBNTIr4U8O3vOTHVaESR81bT7cTit7gE36DJhnjANPs1Y7+9 IaQNxZuckk4fylQTlNN4WK4aezHl3qUgQu8go726mQ+4Stob1t3xfIhBROVqGiNePTHN hcm7uoNVbvgwHhjT8eLgEo22ET9C//EA111o1P3EkzEODNnd488flg24EK64cbkyRndt ltvXiKnRbsNMgiT16S6y1PXtDY11T8XfX+W4g9KCe1kV25Z51epJiTdv34xzRfWDkDT7 mllYumyDNMuUX1O9CoXE47LspqqQVVARf0TRieDUv2MLlfkSm5a5VqvYlOtVvs53X1+J xTww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=JtRqjaYfNXQQn6yM65HP7OaZiVDjU4PRDFh7ovYwmPA=; b=mCD7PQTgMZmCuNF6c6hPaeYUft6xTREXLe7yuyo+nwz5ZOEnqRq/T1Xk5DAt46uZRU hXupUaA8xR6YdLGlPAoJbBRb9e0nPsSzqkD2UcaqVZK/hAo6IWByDRaRcJbx9O5BGccj 0fAoITsgTP7tChAddum9nRxn/hYmJwOxYdNjlXmeN1BQAqqU0yRD0haxZr+GAxmgiE4i cgJ46UYh14iHi0vjJPEuEsSV+qZpwZ63NLYw4uvy1mIpm0vW+59SliY3/P+XY9tRb97k uHjCUK61FzQOJ+TpKDH1hO5wafWmYj+z12MM1FKNyHgMAUzHHHJfUPj9jxi9qPM8YPcd YXVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si2706086ple.189.2018.09.25.07.48.04; Tue, 25 Sep 2018 07:48:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbeIYUzH (ORCPT + 99 others); Tue, 25 Sep 2018 16:55:07 -0400 Received: from smtp17.cstnet.cn ([159.226.251.17]:45915 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729224AbeIYUzH (ORCPT ); Tue, 25 Sep 2018 16:55:07 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-09 (Coremail) with SMTP id swCowACXnZFlSqpbK8_iDA--.14S2; Tue, 25 Sep 2018 22:47:05 +0800 (CST) From: Pu Wen To: bp@alien8.de, bhelgaas@google.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, helgaas@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pci@vger.kernel.org, Pu Wen Subject: [PATCH 2/2] x86/pci: Add Hygon Dhyana support to PCI and north bridge Date: Tue, 25 Sep 2018 22:46:11 +0800 Message-Id: <5f8877bd413f2ea0833378dd5454df0720e1c0df.1537885177.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20180924152448.GE20187@zn.tnic> References: <580dc519d37ad9257520fe8c533f2c61d3e0cd83.1537533369.git.puwen@hygon.cn> <20180924152448.GE20187@zn.tnic> X-CM-TRANSID: swCowACXnZFlSqpbK8_iDA--.14S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXw15Cr45Ww4kZw1DAFyUtrb_yoWrtrWxpr W3XrWkJr4rWr47Wa98trWUZrs8ZF1vkayfCrW7Gw1Sq3WDuF1rXrsavw1ay3W2yayDXa18 Ja95X3WrJa1UtF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I 8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8 ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x 0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Zr0_Wr1UMIIF0xvEx4A2jsIE14v2 6r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0J UKeHgUUUUU= X-Originating-IP: [182.150.46.145] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Hygon registered its PCI Vendor ID as a new one 0x1d94, and there are PCI Devices 0x1450/0x1463/0x1464 for Host bridge on Hygon Dhyana platform, so add Hygon Dhyana support to the PCI and north bridge subsystem by using the code path of AMD family 17h. Signed-off-by: Pu Wen Acked-by: Bjorn Helgaas # pci_ids.h --- arch/x86/kernel/amd_nb.c | 41 +++++++++++++++++++++++++++++++++++------ arch/x86/pci/amd_bus.c | 6 ++++-- include/linux/pci_ids.h | 2 ++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index b51c6b1..b6ceaf0 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -61,6 +61,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) }, + {} +}; + +const struct pci_device_id hygon_nb_misc_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_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) }, + {} +}; + const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[] __initconst = { { 0x00, 0x18, 0x20 }, { 0xff, 0x00, 0x20 }, @@ -197,12 +212,21 @@ int amd_cache_northbridges(void) u16 i = 0; struct amd_northbridge *nb; struct pci_dev *root, *misc, *link; + const struct pci_device_id *root_ids = amd_root_ids; + const struct pci_device_id *misc_ids = amd_nb_misc_ids; + const struct pci_device_id *link_ids = amd_nb_link_ids; + + if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { + root_ids = hygon_root_ids; + misc_ids = hygon_nb_misc_ids; + link_ids = hygon_nb_link_ids; + } if (amd_northbridges.num) return 0; misc = NULL; - while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL) + while ((misc = next_northbridge(misc, misc_ids)) != NULL) i++; if (!i) @@ -218,11 +242,11 @@ int amd_cache_northbridges(void) link = misc = root = NULL; for (i = 0; i != amd_northbridges.num; i++) { node_to_amd_nb(i)->root = root = - next_northbridge(root, amd_root_ids); + next_northbridge(root, root_ids); node_to_amd_nb(i)->misc = misc = - next_northbridge(misc, amd_nb_misc_ids); + next_northbridge(misc, misc_ids); node_to_amd_nb(i)->link = link = - next_northbridge(link, amd_nb_link_ids); + next_northbridge(link, link_ids); } if (amd_gart_present()) @@ -263,13 +287,17 @@ bool __init early_is_amd_nb(u32 device) { const struct pci_device_id *id; u32 vendor = device & 0xffff; + const struct pci_device_id *misc_ids = amd_nb_misc_ids; if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) return false; + if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) + misc_ids = hygon_nb_misc_ids; + device >>= 16; - for (id = amd_nb_misc_ids; id->vendor; id++) + for (id = misc_ids; id->vendor; id++) if (vendor == id->vendor && device == id->device) return true; return false; @@ -281,7 +309,8 @@ struct resource *amd_get_mmconfig_range(struct resource *res) u64 base, msr; unsigned int segn_busn_bits; - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) return NULL; /* assume all cpus from fam10h have mmconfig */ diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c index 649bdde..bfa50e6 100644 --- a/arch/x86/pci/amd_bus.c +++ b/arch/x86/pci/amd_bus.c @@ -93,7 +93,8 @@ static int __init early_root_info_init(void) vendor = id & 0xffff; device = (id>>16) & 0xffff; - if (vendor != PCI_VENDOR_ID_AMD) + if (vendor != PCI_VENDOR_ID_AMD && + vendor != PCI_VENDOR_ID_HYGON) continue; if (hb_probes[i].device == device) { @@ -390,7 +391,8 @@ static int __init pci_io_ecs_init(void) static int __init amd_postcore_init(void) { - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) return 0; early_root_info_init(); diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index d157983..8a0841c 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2561,6 +2561,8 @@ #define PCI_VENDOR_ID_AMAZON 0x1d0f +#define PCI_VENDOR_ID_HYGON 0x1d94 + #define PCI_VENDOR_ID_TEKRAM 0x1de1 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 -- 2.7.4