Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2595992ybc; Mon, 18 Nov 2019 01:27:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxre9cG8ydKNKAap8kr3zbcbhzq1kiSYXAFwJUTd4vWBUYF0Hr/4De4mq2RN1CAi5jrnr1v X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr25638858ejb.9.1574069226235; Mon, 18 Nov 2019 01:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574069226; cv=none; d=google.com; s=arc-20160816; b=ZtusCKHhLXLuiJQZOp8QVgIYwEYxxlgQa2jYgZHw2yzEAzEB8saCnpmTq4lj/grrFN TScCWLJRYEh5kqhpexUtEwXHdTP8rcdPgRJpXw4QoAOqaaE5sXI+JDNSkI8htB1gW5A+ sR9cUZZIpT3SBrSgmCL5E5ub8e19jvNzxrDyiqbKnSYT2Wpxuh9QKgyOT+tOwdDvEbn6 jNBZgzbp48g1tNrHT48VdXaZ2CPKfb1lqsG8wiM0rQ8Ha4oROJ2Gurlnr7DpTc6GBhfB EA/SgNzfGVINjPA6bDaO34C8f74OKW3xUiGL3k9X3bgOFhiVZTyFjNWbH0TRqSDJVtbo Y2qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=dnjP6nWJVdRfDLykPQChBbWVYgvWYRNIJTKF3yCmsn4=; b=S0YAjHxr01K25y+8kidJ8+9NxGISCZ0vtpvX4lU3/hWrYxQ0YgfBifOfFvMG2oQoPU nmznv9apxv7veKIBwfYAfIOaCSgJludRZZySwK6/JqpB94RU6hCeh5pOids8YzDsJCwm 5PVhQyKa4WpIC2JzX4gMKRb6kmADV+ipVWAviTKo+mNK9gNuVte6BI5AVeRQAImJ3Wsp pZ9WOAwQqCRokYyi/baPPiyD7CMqtmmMf0kCGpPqys5RN2TlBng5gOAriYe++U44YfOp /eA8OtMUBkUHHAUbRVcnABeW3uTd0DTqx8so54YY/0OLlK34XZ9fRqiGSVh3mlHQJKwH t5cw== 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 v42si13209671edc.378.2019.11.18.01.26.42; Mon, 18 Nov 2019 01:27:06 -0800 (PST) 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 S1726714AbfKRJZp (ORCPT + 99 others); Mon, 18 Nov 2019 04:25:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:56354 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726460AbfKRJZp (ORCPT ); Mon, 18 Nov 2019 04:25:45 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8A9D1AD55; Mon, 18 Nov 2019 09:25:43 +0000 (UTC) Date: Mon, 18 Nov 2019 10:25:42 +0100 From: Jean Delvare To: Linux I2C , LKML Cc: Wolfram Sang Subject: [PATCH 1/4] firmware: dmi: Remember the memory type Message-ID: <20191118102542.0dc43cd2@endymion> In-Reply-To: <20191118102410.78cd8e6e@endymion> References: <20191118102410.78cd8e6e@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Store the memory type while walking the memory slots, and provide a way to retrieve it later. Signed-off-by: Jean Delvare --- 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