From: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <hpa@zytor.com>,
<x86@kernel.org>, <bp@suse.de>, <bhelgaas@google.com>,
<linux-kernel@vger.kernel.org>
Cc: <Suravee.Suthikulpanit@amd.com>, <joro@8bytes.org>,
Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Subject: [PATCH] x86, aperture: Check for GART before accessing GART registers
Date: Wed, 1 Apr 2015 09:32:08 -0500 [thread overview]
Message-ID: <1427898728-3434-1-git-send-email-Aravind.Gopalakrishnan@amd.com> (raw)
GART registers are not present in newer processors (Fam15h, Model 10h
and later). So, avoid accesses to GART registers in PCI config
space by returning early in early_gart_iommu_check() and
gart_iommu_hole_init() if GART is not available.
Refactoring the family check used in amd_nb into an inline function
so we can use it here as well as in amd_nb.c
Tested the patch on Fam10h and Fam15h Model 00h-fh and this code
runs fine. On Fam15h Model 60h-6fh and on Fam16h, we bail early
as they don't have GART.
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Reviewed-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
arch/x86/include/asm/amd_nb.h | 11 +++++++++++
arch/x86/kernel/amd_nb.c | 4 +---
arch/x86/kernel/aperture_64.c | 4 ++--
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
index aaac3b2..864c8bd 100644
--- a/arch/x86/include/asm/amd_nb.h
+++ b/arch/x86/include/asm/amd_nb.h
@@ -98,11 +98,22 @@ static inline u16 amd_get_node_id(struct pci_dev *pdev)
return 0;
}
+static inline bool amd_gart_present(void)
+{
+ /* GART present only on Fam15h upto model 0fh */
+ if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 ||
+ (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model < 0x10))
+ return true;
+
+ return false;
+}
+
#else
#define amd_nb_num(x) 0
#define amd_nb_has_feature(x) false
#define node_to_amd_nb(x) NULL
+#define amd_gart_present(x) false
#endif
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 5caed1d..29fa475 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -89,9 +89,7 @@ int amd_cache_northbridges(void)
next_northbridge(link, amd_nb_link_ids);
}
- /* GART present only on Fam15h upto model 0fh */
- if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 ||
- (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model < 0x10))
+ if (amd_gart_present())
amd_northbridges.flags |= AMD_NB_GART;
/*
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 76164e1..1cb170b 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -262,7 +262,7 @@ void __init early_gart_iommu_check(void)
u64 aper_base = 0, last_aper_base = 0;
int aper_enabled = 0, last_aper_enabled = 0, last_valid = 0;
- if (!early_pci_allowed())
+ if (!early_pci_allowed() || !amd_gart_present())
return;
/* This is mostly duplicate of iommu_hole_init */
@@ -356,7 +356,7 @@ int __init gart_iommu_hole_init(void)
int i, node;
if (gart_iommu_aperture_disabled || !fix_aperture ||
- !early_pci_allowed())
+ !early_pci_allowed() || !amd_gart_present())
return -ENODEV;
pr_info("Checking aperture...\n");
--
1.9.1
next reply other threads:[~2015-04-01 20:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 14:32 Aravind Gopalakrishnan [this message]
2015-04-02 6:59 ` [PATCH] x86, aperture: Check for GART before accessing GART registers Borislav Petkov
2015-04-02 10:01 ` Ingo Molnar
2015-04-02 15:54 ` Aravind Gopalakrishnan
2015-04-02 16:06 ` Ingo Molnar
2015-04-02 16:23 ` Aravind Gopalakrishnan
2015-04-02 16:53 ` Borislav Petkov
2015-04-02 17:04 ` Aravind Gopalakrishnan
2015-04-02 17:17 ` Borislav Petkov
2015-04-02 18:19 ` Ingo Molnar
2015-04-06 23:10 ` Aravind Gopalakrishnan
2015-04-07 12:34 ` Borislav Petkov
2015-04-07 14:46 ` Aravind Gopalakrishnan
2015-04-07 14:57 ` Borislav Petkov
2015-04-07 20:34 ` Aravind Gopalakrishnan
2015-04-08 7:25 ` Borislav Petkov
2015-04-14 11:15 ` Jörg-Volker Peetz
2015-04-14 11:33 ` Borislav Petkov
2015-04-14 18:22 ` Jörg-Volker Peetz
2015-04-14 18:36 ` Borislav Petkov
2015-05-04 11:11 ` Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427898728-3434-1-git-send-email-Aravind.Gopalakrishnan@amd.com \
--to=aravind.gopalakrishnan@amd.com \
--cc=Suravee.Suthikulpanit@amd.com \
--cc=bhelgaas@google.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).