From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH 1/4] firmware: dmi: Remember the memory type
Date: Mon, 14 Oct 2019 11:38:29 +0200 [thread overview]
Message-ID: <20191014113829.7e8f5df1@endymion> (raw)
In-Reply-To: <20191014113636.57b5ce89@endymion>
Store the memory type while walking the memory slots, and provide a
way to retrieve it later.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
drivers/firmware/dmi_scan.c | 25 ++++++++++++++++++++++++-
include/linux/dmi.h | 2 ++
2 files changed, 26 insertions(+), 1 deletion(-)
--- linux-5.3.orig/drivers/firmware/dmi_scan.c 2019-10-08 14:27:23.783640227 +0200
+++ linux-5.3/drivers/firmware/dmi_scan.c 2019-10-08 16:35:35.442803880 +0200
@@ -35,6 +35,7 @@ static struct dmi_memdev_info {
const char *bank;
u64 size; /* bytes */
u16 handle;
+ u8 type; /* DDR2, DDR3, DDR4 etc */
} *dmi_memdev;
static int dmi_memdev_nr;
@@ -391,7 +392,7 @@ static void __init save_mem_devices(cons
u64 bytes;
u16 size;
- if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x12)
+ if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x13)
return;
if (nr >= dmi_memdev_nr) {
pr_warn(FW_BUG "Too many DIMM entries in SMBIOS table\n");
@@ -400,6 +401,7 @@ static void __init save_mem_devices(cons
dmi_memdev[nr].handle = get_unaligned(&dm->handle);
dmi_memdev[nr].device = dmi_string(dm, d[0x10]);
dmi_memdev[nr].bank = dmi_string(dm, d[0x11]);
+ dmi_memdev[nr].type = d[0x12];
size = get_unaligned((u16 *)&d[0xC]);
if (size == 0)
@@ -1128,3 +1130,24 @@ u64 dmi_memdev_size(u16 handle)
return ~0ull;
}
EXPORT_SYMBOL_GPL(dmi_memdev_size);
+
+/**
+ * dmi_memdev_type - get the memory type
+ * @handle: DMI structure handle
+ *
+ * Return the DMI memory type of the module in the slot associated with the
+ * given DMI handle, or 0x0 if no such DMI handle exists.
+ */
+u8 dmi_memdev_type(u16 handle)
+{
+ int n;
+
+ if (dmi_memdev) {
+ for (n = 0; n < dmi_memdev_nr; n++) {
+ if (handle == dmi_memdev[n].handle)
+ return dmi_memdev[n].type;
+ }
+ }
+ return 0x0; /* Not a valid value */
+}
+EXPORT_SYMBOL_GPL(dmi_memdev_type);
--- linux-5.3.orig/include/linux/dmi.h 2019-10-04 16:14:24.575714482 +0200
+++ linux-5.3/include/linux/dmi.h 2019-10-08 17:42:19.726907967 +0200
@@ -113,6 +113,7 @@ extern int dmi_walk(void (*decode)(const
extern bool dmi_match(enum dmi_field f, const char *str);
extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
extern u64 dmi_memdev_size(u16 handle);
+extern u8 dmi_memdev_type(u16 handle);
#else
@@ -142,6 +143,7 @@ static inline bool dmi_match(enum dmi_fi
static inline void dmi_memdev_name(u16 handle, const char **bank,
const char **device) { }
static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
+static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
static inline const struct dmi_system_id *
dmi_first_match(const struct dmi_system_id *list) { return NULL; }
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2019-10-14 9:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 9:36 [PATCH 0/4] Instantiate SPD EEPROMs at boot on x86 Jean Delvare
2019-10-14 9:38 ` Jean Delvare [this message]
2019-10-14 9:38 ` [PATCH 2/4] firmware: dmi: Add dmi_memdev_handle Jean Delvare
2019-10-14 9:39 ` [PATCH 3/4] i2c: smbus: Add a way to instantiate SPD EEPROMs automatically Jean Delvare
2019-10-14 10:21 ` kbuild test robot
2019-10-14 10:21 ` kbuild test robot
2019-10-14 14:55 ` Jean Delvare
2019-10-14 14:55 ` Jean Delvare
2019-10-14 9:41 ` [PATCH 4/4] i2c: i801: Instantiate " Jean Delvare
2019-10-14 10:22 ` kbuild test robot
2019-10-14 10:22 ` kbuild test robot
2019-10-14 18:02 ` Jean Delvare
2019-10-14 18:02 ` Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2019-11-18 9:24 [PATCH 0/4 v2] Instantiate SPD EEPROMs at boot on x86 Jean Delvare
2019-11-18 9:25 ` [PATCH 1/4] firmware: dmi: Remember the memory type Jean Delvare
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=20191014113829.7e8f5df1@endymion \
--to=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.