Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1446777ybv; Thu, 6 Feb 2020 04:19:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxdPacMx9ddxEPGydcJ2MtV5FjNgEB1bo3gIHmNa+Rz8ClKj7GKlsSVARfk3KOrw8gLjsXB X-Received: by 2002:a9d:6c9a:: with SMTP id c26mr28846660otr.279.1580991556017; Thu, 06 Feb 2020 04:19:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580991556; cv=none; d=google.com; s=arc-20160816; b=FChs4K0xd1VXLW8Gk/H9PDoOkgQ00CiQ05zcmA34mHiSp+Bs+8Ay5RvMkNSoik1hwH aW/v4a43CTE+nlUdxdxj5Fo5KhFlFd1bHwMTMzGCeuFpucdYnJ52l6Ol0BrjCzyArfIv N7OqzkHl7reYTENMq8uTY2ZtZ57MhMsg75vqiYHUTBhumqwn8mpvXYSaPc3pbwH94Qdy zPT8U0/Y6iSOyxD+1RqvaoOlqVmvgUGfGAoQoQ32fNBK/hMotp59/dbPj4Gis5a6JLiV 1nTtAFkYQpQ8i2V0ARR4h62iJPWNw9GH045wIH/laPYux6Jay8pG4Xh9GK6wYWgo1qcC qtTg== 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=MsM3iIWrdFtRrWZMc+SN12UdO78GEqAlqDw29z0/wWo=; b=PyfmBxXFiQJedMPY79mJjvABgnM+2iQ9vvKjb9ASEBLfWLA51/ewjpGmgHKWgAMeme xousCqfCNj8snw6/45IHMdICUwcXPaKEZUaeFQqcjH8HlXsHIkzTdEWQWBejFxV0286y cFCgpYHqX+BjmIYoOtbxbSFXHLRtFl8TVuscxpSrJwKXF9RkqDy3pZh/Y+S4y2Ik3aBo NVPwXkiNE6tTvsOiekRS/35bW6Sby8EhQDqriPjiBNJ/LPscM+yU7kDTrdrdstt8h0ST zHnQZ/SzNKOw9fQktBhD4/PJhueq6cz3GcRJXfmMWEnycod9xSLS/4OZFK4THg5b6XW4 qnUQ== 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 b10si1735682oiy.254.2020.02.06.04.18.59; Thu, 06 Feb 2020 04:19:16 -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 S1727887AbgBFMQl (ORCPT + 99 others); Thu, 6 Feb 2020 07:16:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:53050 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbgBFMQl (ORCPT ); Thu, 6 Feb 2020 07:16:41 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A79BEB1FA; Thu, 6 Feb 2020 12:16:38 +0000 (UTC) Date: Thu, 6 Feb 2020 13:16:30 +0100 From: Jean Delvare To: Erwan Velu Cc: Erwan Velu , Masahiro Yamada , Michal Marek , Mattias Jacobsson <2pi@mok.nu>, Andy Shevchenko , Bjorn Helgaas , "David S. Miller" , Changbin Du , "Robert P. J. Day" , Sumit Garg , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH 1/2] firmware/dmi: Report DMI Bios release Message-ID: <20200206131630.4b18472e@endymion> In-Reply-To: <20191127150729.860625-1-e.velu@criteo.com> References: <20190918094323.17515-1-e.velu@criteo.com> <20191127150729.860625-1-e.velu@criteo.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (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 Hi Erwan, Once again, sorry for the late answer. On Wed, 27 Nov 2019 16:07:25 +0100, Erwan Velu wrote: > Some vendors like HPe or Dell, encode the release version of their BIOS > in the "System BIOS {Major|Minor} Release" fields of Type 0. > > This information is used to know which bios release actually runs. > It could be used for some quirks, debugging sessions or inventory tasks. > > A typical output for a Dell system running the 65.27 bios is : > > [root@t1700 ~]# cat /sys/devices/virtual/dmi/id/bios_release > 65.27 > [root@t1700 ~]# > > This commit add dmi_save_release() function have the logic to > check if the field is valid. If so, it reports the actual value. > > Signed-off-by: Erwan Velu > --- > drivers/firmware/dmi-id.c | 3 +++ > drivers/firmware/dmi_scan.c | 29 +++++++++++++++++++++++++++++ > include/linux/mod_devicetable.h | 1 + > scripts/mod/file2alias.c | 1 + > 4 files changed, 34 insertions(+) > > diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c > index ff39f64f2aae..a2aac65ff771 100644 > --- a/drivers/firmware/dmi-id.c > +++ b/drivers/firmware/dmi-id.c > @@ -42,6 +42,7 @@ DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR); > DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION); > DEFINE_DMI_ATTR_WITH_SHOW(bios_date, 0444, DMI_BIOS_DATE); > DEFINE_DMI_ATTR_WITH_SHOW(sys_vendor, 0444, DMI_SYS_VENDOR); > +DEFINE_DMI_ATTR_WITH_SHOW(bios_release, 0444, DMI_BIOS_RELEASE); > DEFINE_DMI_ATTR_WITH_SHOW(product_name, 0444, DMI_PRODUCT_NAME); > DEFINE_DMI_ATTR_WITH_SHOW(product_version, 0444, DMI_PRODUCT_VERSION); > DEFINE_DMI_ATTR_WITH_SHOW(product_serial, 0400, DMI_PRODUCT_SERIAL); > @@ -78,6 +79,7 @@ static ssize_t get_modalias(char *buffer, size_t buffer_size) > { "bvn", DMI_BIOS_VENDOR }, > { "bvr", DMI_BIOS_VERSION }, > { "bd", DMI_BIOS_DATE }, > + { "br", DMI_BIOS_RELEASE }, > { "svn", DMI_SYS_VENDOR }, > { "pn", DMI_PRODUCT_NAME }, > { "pvr", DMI_PRODUCT_VERSION }, > @@ -187,6 +189,7 @@ static void __init dmi_id_init_attr_table(void) > ADD_DMI_ATTR(bios_vendor, DMI_BIOS_VENDOR); > ADD_DMI_ATTR(bios_version, DMI_BIOS_VERSION); > ADD_DMI_ATTR(bios_date, DMI_BIOS_DATE); > + ADD_DMI_ATTR(bios_release, DMI_BIOS_RELEASE); > ADD_DMI_ATTR(sys_vendor, DMI_SYS_VENDOR); > ADD_DMI_ATTR(product_name, DMI_PRODUCT_NAME); > ADD_DMI_ATTR(product_version, DMI_PRODUCT_VERSION); > diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c > index 1e21fc3e9851..d010c915c1ab 100644 > --- a/drivers/firmware/dmi_scan.c > +++ b/drivers/firmware/dmi_scan.c > @@ -181,6 +181,34 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot, > dmi_ident[slot] = p; > } > > +static void __init dmi_save_release(const struct dmi_header *dm, int slot, > + int index) > +{ > + const u8 *minor, *major; > + char *s; > + > + /* If the table doesn't have the field, let's return */ > + if (dmi_ident[slot] || dm->length < index) > + return; > + > + minor = (u8 *) dm + index; > + major = (u8 *) dm + index - 1; > + > + /* As per the spec, if the system doesn't support this field, > + * the value is FF > + */ > + if (major[0] == 0xFF && minor[0] == 0xFF) When using a pointer to a single entity, the common practice is to use *major rather than major[0]. > + return; > + > + s = dmi_alloc(4); 4 bytes (3 + 1) were enough when you encoded a single byte. Now that you encode 2 bytes separates by a dot, you need 8 (3 + 1 + 3 + 1). > + if (!s) > + return; > + > + sprintf(s, "%u.%u", major[0], minor[0]); Here too, *major would be preferred. > + > + dmi_ident[slot] = s; > +} > + > static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, > int index) > { > @@ -438,6 +466,7 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy) > dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); > dmi_save_ident(dm, DMI_BIOS_VERSION, 5); > dmi_save_ident(dm, DMI_BIOS_DATE, 8); > + dmi_save_release(dm, DMI_BIOS_RELEASE, 21); > break; > case 1: /* System Information */ > dmi_save_ident(dm, DMI_SYS_VENDOR, 4); > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h > index 5714fd35a83c..618933d770e6 100644 > --- a/include/linux/mod_devicetable.h > +++ b/include/linux/mod_devicetable.h > @@ -532,6 +532,7 @@ enum dmi_field { > DMI_BIOS_VENDOR, > DMI_BIOS_VERSION, > DMI_BIOS_DATE, > + DMI_BIOS_RELEASE, > DMI_SYS_VENDOR, > DMI_PRODUCT_NAME, > DMI_PRODUCT_VERSION, > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index c91eba751804..cc48930cc02a 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -936,6 +936,7 @@ static const struct dmifield { > { "bvn", DMI_BIOS_VENDOR }, > { "bvr", DMI_BIOS_VERSION }, > { "bd", DMI_BIOS_DATE }, > + { "br", DMI_BIOS_RELEASE }, > { "svn", DMI_SYS_VENDOR }, > { "pn", DMI_PRODUCT_NAME }, > { "pvr", DMI_PRODUCT_VERSION }, -- Jean Delvare SUSE L3 Support