public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Herrmann <herrmann.der.user@googlemail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Dmitry Adamushko <dmitry.adamushko@gmail.com>,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Mike Travis <travis@sgi.com>,
	Tigran Aivazian <tigran@aivazian.fsnet.co.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <borislav.petkov@amd.com>,
	Andreas Mohr <andi@lisas.de>, Jack Steiner <steiner@sgi.com>
Subject: [PATCH] x86, ucode-amd: Move family check to microcde_amd.c's init function
Date: Tue, 17 Nov 2009 08:06:38 +0100	[thread overview]
Message-ID: <20091117070638.GA27691@alberich.amd.com> (raw)
In-Reply-To: <20091112113343.GA1386@elte.hu>

... to avoid useless trial to load firmware on systems with
unsupported AMD CPUs.

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 arch/x86/kernel/microcode_amd.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

Patch is against tip/master.

Regards,
Andreas


diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 26e33bd..d0bb5ad 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -34,6 +34,7 @@ MODULE_LICENSE("GPL v2");
 #define UCODE_UCODE_TYPE           0x00000001
 
 const struct firmware *firmware;
+static int supported_cpu;
 
 struct equiv_cpu_entry {
 	u32	installed_cpu;
@@ -73,15 +74,12 @@ static struct equiv_cpu_entry *equiv_cpu_table;
 
 static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
 {
-	struct cpuinfo_x86 *c = &cpu_data(cpu);
 	u32 dummy;
 
-	memset(csig, 0, sizeof(*csig));
-	if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
-		pr_warning("microcode: CPU%d: AMD CPU family 0x%x not "
-			   "supported\n", cpu, c->x86);
+	if (!supported_cpu)
 		return -1;
-	}
+
+	memset(csig, 0, sizeof(*csig));
 	rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
 	pr_info("microcode: CPU%d: patch_level=0x%x\n", cpu, csig->rev);
 	return 0;
@@ -331,6 +329,17 @@ static void microcode_fini_cpu_amd(int cpu)
 void init_microcode_amd(struct device *device)
 {
 	const char *fw_name = "amd-ucode/microcode_amd.bin";
+	struct cpuinfo_x86 *c = &boot_cpu_data;
+
+	BUG_ON(c->x86_vendor != X86_VENDOR_AMD);
+
+	if (c->x86 < 0x10) {
+		pr_warning("microcode: AMD CPU family 0x%x not supported\n",
+			   c->x86);
+		return;
+	}
+	supported_cpu = 1;
+
 	if (request_firmware(&firmware, fw_name, device))
 		pr_err("microcode: failed to load file %s\n", fw_name);
 }
-- 
1.6.5.2


  parent reply	other threads:[~2009-11-17  7:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-02 20:08 [ RFC, PATCH - 1/2, v2 ] x86-microcode: refactor microcode output messages dimm
2009-11-04 12:27 ` Ingo Molnar
2009-11-05 15:37 ` Andreas Herrmann
2009-11-05 18:40   ` Dmitry Adamushko
2009-11-06 12:34     ` Andreas Herrmann
2009-11-06 12:56       ` Dmitry Adamushko
2009-11-06 19:46         ` Andreas Herrmann
2009-11-07 12:22           ` Dmitry Adamushko
2009-11-11 16:07             ` Dmitry Adamushko
2009-11-11 19:38               ` Andreas Herrmann
2009-11-12 11:33                 ` Ingo Molnar
2009-11-12 11:54                   ` Dmitry Adamushko
2009-11-12 12:06                     ` Dmitry Adamushko
2009-11-12 15:20                       ` Andreas Herrmann
2009-11-12 15:48                         ` Dmitry Adamushko
2009-11-12 17:09                           ` Borislav Petkov
2009-11-17  7:06                   ` Andreas Herrmann [this message]
2009-11-17  9:24                     ` [tip:x86/microcode] x86: ucode-amd: Move family check to microcde_amd.c's init function tip-bot for Andreas Herrmann

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=20091117070638.GA27691@alberich.amd.com \
    --to=herrmann.der.user@googlemail.com \
    --cc=andi@lisas.de \
    --cc=borislav.petkov@amd.com \
    --cc=dmitry.adamushko@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=steiner@sgi.com \
    --cc=tglx@linutronix.de \
    --cc=tigran@aivazian.fsnet.co.uk \
    --cc=travis@sgi.com \
    /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