Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1424547
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 7/8] x86/microcode: convert to use sysdata API |
| Date | 2016-06-17 02:10 +0200 |
| Message-ID | <rKPwe-7h2-17@gated-at.bofh.it> (permalink) |
| References | <rKPmx-6T5-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This uses the new flexible firmware API, since we don't
have to keep the firmware around the sysdata API does the
freeing for us safely.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
arch/x86/kernel/cpu/microcode/amd.c | 56 +++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 27a0228c9cae..df4351ce4256 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -23,7 +23,7 @@
#define pr_fmt(fmt) "microcode: " fmt
#include <linux/earlycpio.h>
-#include <linux/firmware.h>
+#include <linux/sysdata.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/initrd.h>
@@ -872,6 +872,31 @@ enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t s
return ret;
}
+struct amd_ucode_req {
+ int cpu;
+ struct cpuinfo_x86 *c;
+ enum ucode_state state;
+ const char *name;
+};
+
+static int request_microcode_amd_cb(void *context,
+ const struct sysdata_file *sysdata)
+{
+ struct amd_ucode_req *req = context;
+
+ if (*(u32 *)sysdata->data != UCODE_MAGIC) {
+ pr_err("invalid magic value (0x%08x)\n",
+ *(u32 *)sysdata->data);
+ req->state = UCODE_ERROR;
+ return -EINVAL;
+ }
+
+ req->state = load_microcode_amd(req->cpu, req->c->x86,
+ sysdata->data, sysdata->size);
+
+ return 0;
+}
+
/*
* AMD microcode firmware naming convention, up to family 15h they are in
* the legacy file:
@@ -891,10 +916,13 @@ enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t s
static enum ucode_state request_microcode_amd(int cpu, struct device *device,
bool refresh_fw)
{
+ struct amd_ucode_req req;
char fw_name[36] = "amd-ucode/microcode_amd.bin";
struct cpuinfo_x86 *c = &cpu_data(cpu);
- enum ucode_state ret = UCODE_NFOUND;
- const struct firmware *fw;
+ const struct sysdata_file_desc sysdata_desc = {
+ SYSDATA_DEFAULT_SYNC(request_microcode_amd_cb, &req),
+ .optional = true,
+ };
/* reload ucode container only on the boot cpu */
if (!refresh_fw || c->cpu_index != boot_cpu_data.cpu_index)
@@ -903,24 +931,16 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device,
if (c->x86 >= 0x15)
snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
- if (request_firmware_direct(&fw, (const char *)fw_name, device)) {
- pr_debug("failed to load file %s\n", fw_name);
- goto out;
- }
+ req.cpu = cpu;
+ req.c = c;
+ req.name = fw_name;
+ req.state = UCODE_NFOUND;
- ret = UCODE_ERROR;
- if (*(u32 *)fw->data != UCODE_MAGIC) {
- pr_err("invalid magic value (0x%08x)\n", *(u32 *)fw->data);
- goto fw_release;
+ if (sysdata_file_request((const char *)fw_name, &sysdata_desc, device)) {
+ pr_debug("failed to load file %s\n", fw_name);
}
- ret = load_microcode_amd(cpu, c->x86, fw->data, fw->size);
-
- fw_release:
- release_firmware(fw);
-
- out:
- return ret;
+ return req.state;
}
static enum ucode_state
--
2.8.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/8] firmware: add new sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:00 +0200
[PATCH v2 6/8] Documentation/firmware_class: add sysdata API converter SmPL patch "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:00 +0200
[PATCH v2 3/8] selftests: firmware: only modprobe if driver is missing "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:10 +0200
[PATCH v2 7/8] x86/microcode: convert to use sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:10 +0200
[PATCH v2 1/8] firmware: add new extensible firmware API - sysdata_file_request*() "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:10 +0200
[PATCH v2 8/8] p54: convert to sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 02:10 +0200
Re: [PATCH v2 8/8] p54: convert to sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 03:40 +0200
Re: [PATCH v2 8/8] p54: convert to sysdata API Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-17 05:10 +0200
Re: [PATCH v2 8/8] p54: convert to sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-17 20:40 +0200
Re: [PATCH v2 0/8] firmware: add new sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-18 01:50 +0200
Re: [PATCH v2 0/8] firmware: add new sysdata API "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-06-18 02:40 +0200
csiph-web