From patchwork Tue Sep 6 13:44:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 603041 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp3091675ltw; Tue, 6 Sep 2022 06:44:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4bOtGhPFkJgOKZ+7B82o9LpW9Zpkwn4qBux5yhCbpg20sjkWJ06O285ELk0by9LbORxqTn X-Received: by 2002:a17:907:1690:b0:731:56b6:fded with SMTP id hc16-20020a170907169000b0073156b6fdedmr40039617ejc.119.1662471894036; Tue, 06 Sep 2022 06:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662471894; cv=none; d=google.com; s=arc-20160816; b=LD7fmw+KSlej8j9Gio+lcTiKEYfVzqNvYKKhtNB8FdNXn4ZdR1MeqBWUkYdOPDixfq c5sQUMmxraXvThfytnasg3ae8EgIf/q4IYjAZ5KTeRQonwYMDbgh9wqFMUMmQ+YYF4dh VHQXe2TQmmfSLbvNgjUMCevQC08CkwqWD88TB7taTJ0Aipu9ugXf0/lL2nMvv3/eigFI M3+fiCxqiqhV0NvgHRIwiwZZdqR9rGi3V3ht8SAL0+0ktKQafWEeQGV0dxePnmUbj1mG jSKoTFHMINu8pHuEI0ajRD893BnPhJtGpfArXF6Dva2dN9jzPItPY2wDdx/QVUQvfqrv J08A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KsGBN7dLy4q3TeQQmsDywPtn2m3V5eSK1ppBgO8D3xg=; b=REw+2s9bgrm63SFJj1NK1cxI1H8xDjyVmXAwmFrW0jxy2sAeC3FIg0yzPVkxKIe4BF es0GZ1yLqOWmxEVuZrjVz1Q8WAD1+ePNXJ9Vi0DGTVoq2IF98IQN4LbkKWgfLY9iV9eU XS0SePRHp5olIS7sDSWyZoFwrvDFs91ocmuCEV48AoIrTrtavdAJVaeAGXkd9lfbvIqL MxocxfKEOdoLwwovX5wSqvv0QcN5XK4D1ujeUMh4Vk53pbDvqu30ujQVoH7Fnb7dqVzH rMSdA/nSLcNi8/5WOH3dxshkIWF0i+j2BbdVyfaL9kFgh0cT++wwUAKONooqJxKS1ZGb KxHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wBCOiKYw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id dt4-20020a170907728400b0072f0f088ed7si9810717ejc.712.2022.09.06.06.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 06:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wBCOiKYw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3639F849EA; Tue, 6 Sep 2022 15:44:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wBCOiKYw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E57FC84A1A; Tue, 6 Sep 2022 15:44:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 60CD0849AA for ; Tue, 6 Sep 2022 15:44:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52f.google.com with SMTP id z21so5172669edi.1 for ; Tue, 06 Sep 2022 06:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KsGBN7dLy4q3TeQQmsDywPtn2m3V5eSK1ppBgO8D3xg=; b=wBCOiKYwM4mGDZUo6l68tblLVt57cCnO0dlzFPj9+m6cwKXe3agxiM3w4t9T5c822i vHmFd2F08bUrX81t/h4PDzg0mngbB9Rc9o4i3td1G9Zw6NdmogU7T7gEUyKKcTc80AWl QbbYgxulWB5Eg2dTQ3tlb2xmb5BU1/X0zl/rOC6l89urohdQtpIJ4XgFlijFlBgxh8XD aHytniLKGTLlVdJAIobcF9aM/ihpO7LPTDZ4SPCBt4t9+UWGW7vuTPDPDkCRiaaFestv 9P32ZrGj43CH92zBQtpgZICS0UhzD3oYWJkwsmFbfxddgY5VD5SQi69VzD1CfFOvTGgX 5HBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KsGBN7dLy4q3TeQQmsDywPtn2m3V5eSK1ppBgO8D3xg=; b=h1yL2aMN8ooI48PrqxwSNjw+MAj6qGtRMJjV8AWmRfv7nVQ97I/cXbauy/NItVEWP0 eO4WFqVMQO+xyGn1S5w0MXYGVbEpVNxf0gwM7n7Ad+K2E2PDHyu6glGTvcqCW11gPGOJ uNDyo6pu7OtmOBso2OaL5eMGhw66ZGqQbzlQtO0mhqJf1RtQ9fRduRZrfTzAR9wIrM4Y qR3iK6b4O97tu0W0SctGf3rCNzI2bDv/zBKRvfSJ6q7s4DhLDxBJyQjySBo0Ee6UIwKc 5q8zldycF/JfIbqzlJe6DaeoeDbzJ7qLBPvDmxQ7owSV9ftEa8lh/IIdPn13uDL2Bxjz WLbg== X-Gm-Message-State: ACgBeo0DsGDn9dDw7GQ5K44iwyXJqKH0pM3NWFxuDlmBNzKLyzH8SEzb 03ImCopxuD/6oyVtH7ygeEl2Cc6GlNzVNQ== X-Received: by 2002:a05:6402:f18:b0:44d:9a45:394 with SMTP id i24-20020a0564020f1800b0044d9a450394mr12375719eda.138.1662471889015; Tue, 06 Sep 2022 06:44:49 -0700 (PDT) Received: from localhost.localdomain ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id p23-20020a056402501700b0043ba7df7a42sm8473330eda.26.2022.09.06.06.44.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 06:44:48 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, heinrich.schuchardt@canonical.com, pbrobinson@gmail.com, Ilias Apalodimas Subject: [PATCH 2/2] smbios: Fallback to the default DT if sysinfo nodes are missing Date: Tue, 6 Sep 2022 16:44:26 +0300 Message-Id: <20220906134426.53748-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906134426.53748-1-ilias.apalodimas@linaro.org> References: <20220906134426.53748-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean In order to fill in the SMBIOS tables U-Boot currently relies on a "u-boot,sysinfo-smbios" compatible node. This is fine for the boards that already include such nodes. However with some recent EFI changes, the majority of boards can boot up distros, which usually rely on things like dmidecode etc for their reporting. For boards that lack this special node the SMBIOS output looks like: System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown This looks problematic since most of the info are "Unknown". The DT spec specifies standard properties containing relevant information like 'model' and 'compatible' for which the suggested format is . So let's add a last resort to our current smbios parsing. If none of the sysinfo properties are found, we can scan the root node for 'model' and 'compatible'. pre-patch dmidecode: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown Handle 0x0002, DMI type 2, 14 bytes Base Board Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Not Specified Asset Tag: Unknown Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0000 Type: Motherboard Handle 0x0003, DMI type 3, 21 bytes Chassis Information Manufacturer: Unknown Type: Desktop Lock: Not Present Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None OEM Information: 0x00000000 Height: Unspecified Number Of Power Cords: Unspecified Contained Elements: 0 post-pastch dmidecode: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: socionext,developer-box Product Name: Socionext Developer Box Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown Handle 0x0002, DMI type 2, 14 bytes Base Board Information Manufacturer: socionext,developer-box Product Name: Socionext Developer Box Version: Unknown Serial Number: Not Specified Asset Tag: Unknown Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0000 Type: Motherboard Handle 0x0003, DMI type 3, 21 bytes Chassis Information Manufacturer: socionext,developer-box Type: Desktop Lock: Not Present Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None OEM Information: 0x00000000 Height: Unspecified Number Of Power Cords: Unspecified Contained Elements: 0 Signed-off-by: Ilias Apalodimas Reviewed-by: Peter Robinson Tested-by: Peter Robinson --- lib/smbios.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/smbios.c b/lib/smbios.c index fcc8686993ef..f2eb961f514b 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -43,6 +43,20 @@ DECLARE_GLOBAL_DATA_PTR; +/** + * struct sysifno_to_dt - Mapping of sysinfo strings to DT + * + * @sysinfo_str: sysinfo string + * @dt_str: DT string + */ +static const struct { + const char *sysinfo_str; + const char *dt_str; +} sysifno_to_dt[] = { + { .sysinfo_str = "product", .dt_str = "model" }, + { .sysinfo_str = "manufacturer", .dt_str = "compatible" }, +}; + /** * struct smbios_ctx - context for writing SMBIOS tables * @@ -87,6 +101,18 @@ struct smbios_write_method { const char *subnode_name; }; +static const char *convert_sysinfo_to_dt(const char *sysinfo_str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(sysifno_to_dt); i++) { + if (!strcmp(sysinfo_str, sysifno_to_dt[i].sysinfo_str)) + return sysifno_to_dt[i].dt_str; + } + + return NULL; +} + /** * smbios_add_string() - add a string to the string area * @@ -148,9 +174,20 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, return smbios_add_string(ctx, val); } if (IS_ENABLED(CONFIG_OF_CONTROL)) { - const char *str; + const char *str = NULL; - str = ofnode_read_string(ctx->node, prop); + /* + * If the node is not valid fallback and try the entire DT + * so we can at least fill in maufacturer and board type + */ + if (!ofnode_valid(ctx->node)) { + const char *nprop = convert_sysinfo_to_dt(prop); + + if (nprop) + str = ofnode_read_string(ofnode_root(), nprop); + } else { + str = ofnode_read_string(ctx->node, prop); + } return smbios_add_string(ctx, str); }