Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1021328lqt; Tue, 19 Mar 2024 10:22:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMohY04q8y2GNvny72xG4hCGCV4+bVNBLibrAaTbHVwbbN+SFVuKRFBsHRdN8i89REfGNY+yRFSeRiNVo9rEmLhBwqoucD/qFDGQYF1w== X-Google-Smtp-Source: AGHT+IGiPntj+8QhP8w1CD7c8cMrYGNSvzMyupOfw60FD752QnuLOEBnkuHkZYXX++w5jkZZVK1u X-Received: by 2002:a05:6402:4147:b0:568:7ad9:f2af with SMTP id x7-20020a056402414700b005687ad9f2afmr2612522eda.27.1710868949398; Tue, 19 Mar 2024 10:22:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710868949; cv=pass; d=google.com; s=arc-20160816; b=oMtaGYt2BNZApZEvYlMOA8oZtvCOyVqKpjeeb1bex/R11G1x/qyW2r1WMjsWv3MQ0g e74//O8d+gdmoucPADhoVLlZlXUlI4Exl6vCXV9sr+EXT77YDAArOemKzoXzNjqedGuY Mw4zfOjQsr51xdXS51ZIiMjkodCrn3t1F8vahQfBxL92szOZe8h8ODbKwC5DvB73Kta1 qNw9FzvynhE98TOu3sWuC+nn9g3Lsm89gZeD9Zl+QQOVIx4EcUd1eWmmjKH5x9/GmUki xvjWbrB9r7jXpZgHwQlqKXpjcnAx26jfrUlcXOpV4cINj3nCTgzagrsWeEfl6Rkfyqoa DEzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=2HDHlxWDcpYVAxzok8fqyi4Iyi5sqk/ii2Z/jBclxJI=; fh=ZSZ8onN1RYBym8yWASJlnpphNbP+KS90adPDTl0oClw=; b=gyO+W/sEefnErXRtp5yXoDjzGOQtwkU/Q4Beu4D8VozeYocVA4WFl45xerEEdD7fv6 lGBos8WsOwMbrvF+IjqgLkM6LUxc8u8yPTuFoGR2Z++TegOlHFtYNDbN+9wN4qfncvbz akIJHv6ykbkXUz+JY26d370Pw3QClqc4B6bt3HsbDF2OEubiCoHes6G1ZOepgJXj3Ji1 oF+zTKiNiKib7xgJma2+tFUSwBm4dwFG+NHm7bhjRd7nkMvxSPp7wH68G5IiPEm4Xxov BZCBYWm+6OmwvpMByeRWSXnmLPUhTPWaA/IwVlPEkwi6TKPRr9+ezaaRaSoiNgJy7wqp LpiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H8uGJ0Hi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-107896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fj5-20020a0564022b8500b005687137bdbbsi5845584edb.457.2024.03.19.10.22.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 10:22:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H8uGJ0Hi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-107896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B7D341F270F7 for ; Tue, 19 Mar 2024 17:14:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6879F25777; Tue, 19 Mar 2024 17:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H8uGJ0Hi" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8831B25601; Tue, 19 Mar 2024 17:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710868476; cv=none; b=cFUb0eaWzjg7TYFG7WZ3YxZJAx6/AgoNETl4y6QVhy/3N7QJFavd9/2ukAX7sNtSEHT+kBk0QC3h687M+Il/+U+yk0+ay1CxWmSGtkrSXET1Z2jFo0V3xvQ7UjlLxV3ikREKMg4SH9IpxK/vXMAOYM3TrZpSBz563ZdHeBLnWpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710868476; c=relaxed/simple; bh=k/GfgwRI/ijf/uVg7xWos3W1r9MkqyAZbqmhnCW/Ze0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DhK9URd5UXZEI27sc/7PMevXkTAZ48X/0ylVx6Ebpfm11Wp8QTUVhPbLCAo898pQrre6ckAnZkGjdReiSfoI1P95x2EvW38HS/xuzPtooN741lhjpeDEctI3TBc+vr/XRScXq99WnmxRS3C/AUk0mHLfqonZfPeBRPuZ3HhwtuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H8uGJ0Hi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F0E3C43394; Tue, 19 Mar 2024 17:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710868476; bh=k/GfgwRI/ijf/uVg7xWos3W1r9MkqyAZbqmhnCW/Ze0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=H8uGJ0HiJrClx6+giK7xETCTfdfIs1lhiGAu8IYK6EkWDgJkDJT/ydBAhl5L9u/Kq uaN94tScqQYSegWgwm8XKrg8TTqyYkg+jfp2utHf/rPAIKMd78TQbCOQADWMYnxcut +KPMXKbQCFpY5jpcvW05SKB1KpmBmrlJoFB5y6UlmC3wl7Vi4av5KPt1WlF7WX+rWI 5k7u7aJXyyiiHYn9iCcO86maZUxarp0xHp0ACD4G8+NPbFrTSrASjPCkGthpPzO/Le yjq46To9zprEnNJXVOSCWIMz7byabwmYQcvJ4fUnCA635ZzwxlB4s98BFizdnchpSE eBuVbjmIk7+Sg== Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d109e82bd0so77294801fa.3; Tue, 19 Mar 2024 10:14:36 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXIfb9aVWv+6N/cT8sU2oZ8SNd82l7PTLBI7S+TJGJk890u9J+PdBkAsLRGa0RTXXmKy5WcmkJmn2z9PHKaXEAwTBlR3u5FdEnb X-Gm-Message-State: AOJu0YxSYArFoG07oLJ/h/pJEuorPpEK6IBQ7/CUF1XnQ778ikxKL+d5 jDQP5Do5nipZlMEDcV9EoX/pAjLd6HjvDmZ5bH2Q5ZFpmryJG4r/8Zfu/yBLjcSH4uRE3be8Dk/ ior1bqyJjJJ/dLUATFOoFqChD4tI= X-Received: by 2002:a05:651c:387:b0:2d4:22a6:cb15 with SMTP id e7-20020a05651c038700b002d422a6cb15mr1982908ljp.25.1710868474544; Tue, 19 Mar 2024 10:14:34 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240318020916.1299190-1-haibo1.xu@intel.com> In-Reply-To: <20240318020916.1299190-1-haibo1.xu@intel.com> From: Ard Biesheuvel Date: Tue, 19 Mar 2024 18:14:23 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] riscv: dmi: Add SMBIOS/DMI support To: Haibo Xu Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-efi@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sunilvl@ventanamicro.com, xiaobo55x@gmail.com Content-Type: text/plain; charset="UTF-8" On Mon, 18 Mar 2024 at 02:55, Haibo Xu wrote: > > Enable the dmi driver for riscv which would allow access the > SMBIOS info through some userspace file(/sys/firmware/dmi/*). > > The change was based on that of arm64 and has been verified > by dmidecode tool. > > Signed-off-by: Haibo Xu Reviewed-by: Ard Biesheuvel > --- > Changes since v1 > - Change to use memremap/memunmap for dmi_(early)_remap/unmap > definition(suggested by Ard) > - Minor clean up for comments (Ard) > --- > arch/riscv/Kconfig | 11 +++++++++++ > arch/riscv/include/asm/dmi.h | 24 ++++++++++++++++++++++++ > drivers/firmware/efi/riscv-runtime.c | 13 +++++++++++++ > 3 files changed, 48 insertions(+) > create mode 100644 arch/riscv/include/asm/dmi.h > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 8ebafe337eac..3639151cb4ef 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -952,6 +952,17 @@ config EFI > allow the kernel to be booted as an EFI application. This > is only useful on systems that have UEFI firmware. > > +config DMI > + bool "Enable support for SMBIOS (DMI) tables" > + depends on EFI > + default y > + help > + This enables SMBIOS/DMI feature for systems. > + > + This option is only useful on systems that have UEFI firmware. > + However, even with this option, the resultant kernel should > + continue to boot on existing non-UEFI platforms. > + > config CC_HAVE_STACKPROTECTOR_TLS > def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0) > > diff --git a/arch/riscv/include/asm/dmi.h b/arch/riscv/include/asm/dmi.h > new file mode 100644 > index 000000000000..ca7cce557ef7 > --- /dev/null > +++ b/arch/riscv/include/asm/dmi.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2024 Intel Corporation > + * > + * based on arch/arm64/include/asm/dmi.h > + * > + * This file is subject to the terms and conditions of the GNU General Public > + * License. See the file "COPYING" in the main directory of this archive > + * for more details. > + */ > + > +#ifndef __ASM_DMI_H > +#define __ASM_DMI_H > + > +#include > +#include > + > +#define dmi_early_remap(x, l) memremap(x, l, MEMREMAP_WB) > +#define dmi_early_unmap(x, l) memunmap(x) > +#define dmi_remap(x, l) memremap(x, l, MEMREMAP_WB) > +#define dmi_unmap(x) memunmap(x) > +#define dmi_alloc(l) kzalloc(l, GFP_KERNEL) > + > +#endif > diff --git a/drivers/firmware/efi/riscv-runtime.c b/drivers/firmware/efi/riscv-runtime.c > index 09525fb5c240..c3bfb9e77e02 100644 > --- a/drivers/firmware/efi/riscv-runtime.c > +++ b/drivers/firmware/efi/riscv-runtime.c > @@ -152,3 +152,16 @@ void arch_efi_call_virt_teardown(void) > { > efi_virtmap_unload(); > } > + > +static int __init riscv_dmi_init(void) > +{ > + /* > + * On riscv, DMI depends on UEFI, and dmi_setup() needs to > + * be called early because dmi_id_init(), which is an arch_initcall > + * itself, depends on dmi_scan_machine() having been called already. > + */ > + dmi_setup(); > + > + return 0; > +} > +core_initcall(riscv_dmi_init); > -- > 2.34.1 >