Received: by 2002:a89:28c:0:b0:1ef:fe5e:92fe with SMTP id j12csp15183lqh; Sun, 17 Mar 2024 18:55:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNnWHjuHIWTwwaoSsSgxH0NlWIRz5CKsDA9sRpKhHl+jSJ2JDPIQ8Zk7NfTtFUb/zLhsead6rsg0w9dl7nI4PtFyt+KRjjX1P7lVfQnQ== X-Google-Smtp-Source: AGHT+IGjG7tS0fqKUqVc2KCq7uBWMuomR98Q+ArebPOwuJbeS9WtROSNjU4nWaIBS7tB0fw+J8zu X-Received: by 2002:a05:6808:bd1:b0:3c3:773b:1289 with SMTP id o17-20020a0568080bd100b003c3773b1289mr10688945oik.5.1710726942857; Sun, 17 Mar 2024 18:55:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710726942; cv=pass; d=google.com; s=arc-20160816; b=JUEQFCg4iSt+VK2O24GSNf288AfPqOXMlXRSE7OQu82xbFazha+f3/Z5OclIZKOQ4h bpb7CyB1x9Xym4pt5t7XRl/gQT6F9rTp8wmsGUqL0T0WtlDKYeY4zCqyXY7sGnToWFzo 5rLSJdxUuI4qBrJApWNdbqvyCcZFQPf/4Ov/p36G67w/4za0yTZk5zJzRfwI8vQ4MjUc ZFOivXe3zUZPEtYWNTwcuN3GSCmLiDfjJe3OhWpsg08D9DMrfl33sbd7oI3NhWVmckk1 7E/Pth1l0ZUnrHaNHaHMMpt5+8BhcTyZtnDu84dYOm9essMyzDQkLDQ3B+nTiJ01IznX R8jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qFCwf1zcrp+b4dlQR88VkpDxTEKSxM7wJOihp+9wc38=; fh=gB+M8ebMapnvp9xkRHvRz0EJpdHG/h3U/jofg4cgSBs=; b=yIhlqneRv5OscZLLzU7ijNK0AEF12YHawhxRRijuFLhexfcpHXP3HpmFgOITPN2hVv qm5FTPl2TxUJ8eoFbBIgQEpUlIKeNvLO5Rg5B5zdEBc346/bt7vqOptKmLOzHKB6T+c9 HGhpBcLHinQ1Fs6a78AM1y5m0/a51nIVMYm2DSlcqQRyg4clXy4BsJkPRaeHg3mzEtXU y244ifixLEKmkCBctaCdeTrwBRUAEpqKdVYmDOTZl3wC/vHrXbMNWdwCjtyTeKcOYV9H 2+EgGDl9oKLO01xkj0POrxfjF4MQPe7tlZdFgj+TqLRj2EPoGJ1alMVhZwA4idjXKH05 J7IQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UjUANLT9; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-105639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ks1-20020a056a004b8100b006e650128b24si7938704pfb.124.2024.03.17.18.55.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 18:55:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UjUANLT9; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-105639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 398CD283ABE for ; Mon, 18 Mar 2024 01:55:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E0B71E87E; Mon, 18 Mar 2024 01:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UjUANLT9" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 AC3EE1E862; Mon, 18 Mar 2024 01:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710726934; cv=none; b=sBXtAwAJnfX1qgqLUoWRa4ZnKim8PYb3lX2qGhfTTa3n7JAozK8kuVatpayzoNvUm2NpnDL/9MrR39rJVtLN0LEhsIPT3euPpnD9EWhFrOgeO7grqUuBmupgWQFhM+FM2G5wgeNoh2T/53ciklmY1y4lMSv/mSfNbRUb4hS4BEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710726934; c=relaxed/simple; bh=iUMk+G89JkHrqV4fUL3Gt28oxAeNaZnrFGaHr6SxGkU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PZqhkYlnKHq2fXG2WjHTdyGtKOLhklEO49UOIOwp6L67yDF5DgN/ilHBNSt3NNAYZjBrybiiAcwPPlzOPBtPe926pSKCPzBbLFBJoonwdrpiR2gyX6E3bU4oYftCWR2Z3DJKks+LBxIZ5oWPDcE7VD5y54kP9pHnRbirFH6m31I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UjUANLT9; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710726933; x=1742262933; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=iUMk+G89JkHrqV4fUL3Gt28oxAeNaZnrFGaHr6SxGkU=; b=UjUANLT9jAo8tjCK8wAGSQTnlyg600xxCaigcuF7w8QVrL65eZqD44O9 5jZDUwXyDyfx2zCB5zdHj4lVUk9cXDlyer3T/qYJNLnDwjb+D7t9Xb+HZ kz1JORYPXyI8Z2pmU5u5Jvpw6EvzEdY4P18js1u8mJ1Nxddzg6aYXXK5W zUIANXikv7HzvjyuDrS4AuMS7O0thEdDJV2Z+Sna7P0zL1iZO0h+NBLRJ x1fdkgXWeeiT8bmUY9iPvMOW3fWJfAicC6TWELU5J/7DO4mjXNwxd5LEt K33Cus+19/TVQ1R0rBTGu2U1Z9fQDjSkp42zwIJsDQrBvOTlL6auz1ogF A==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="16668193" X-IronPort-AV: E=Sophos;i="6.07,133,1708416000"; d="scan'208";a="16668193" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 18:55:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,133,1708416000"; d="scan'208";a="44248090" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orviesa002.jf.intel.com with ESMTP; 17 Mar 2024 18:55:29 -0700 From: Haibo Xu To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-efi@vger.kernel.org Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, ardb@kernel.org, sunilvl@ventanamicro.com, xiaobo55x@gmail.com, Haibo Xu Subject: [PATCH v2] riscv: dmi: Add SMBIOS/DMI support Date: Mon, 18 Mar 2024 10:09:16 +0800 Message-Id: <20240318020916.1299190-1-haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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