Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4896601rwr; Mon, 8 May 2023 14:32:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WJF/MoTPFneNjmVUe8Ewcza54dmtIWTknvnSuZBxho9x8f8bj6GZtHeFWU0DhF2QkDjU+ X-Received: by 2002:a17:903:2498:b0:1ac:4027:fa16 with SMTP id p24-20020a170903249800b001ac4027fa16mr12526472plw.20.1683581566556; Mon, 08 May 2023 14:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683581566; cv=none; d=google.com; s=arc-20160816; b=cjW+GEKJeNgoZcDLpw+WvUTb+HTn2FW4GFYWzb9Xa1y/zRDDV2KaIMhFHv+hWCDsen ilNYCZTquyKd0h6hVd4oNcWJ5g4KEiE0Od3jABDJ1Xl2FpzpyIJoRPwGfwuCIGRS2sZ1 Y7etD2A533Ut+78briF5dzw3uGUr2nbxE5NdOzFfCsfeM7qq7UxKIw/1tspBmmVKzFgo ECR0FNaDM8J750THJ9AC03SHmOYyAAwrE+b5rMO3nDmrdFsuY4jg9Fq2RzHu1o+ezm/1 sPC55B3axkm0Ki8vaQKuWmAx2J6/1lwbR5WOEzwkPY2xXwzZMbHsEiOuMOiYKFQkg/+A KObg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=yh86qVTwZ6VGC+iFBj5h0VPqRoZ1lDKWlx5pY2sNDCE=; b=X8UZgN+O36l5wbGqQeKVfo/9C2sLYSwHN89v89KZGoNjvqw9swPMiuTot8DeGfp4n9 jUlT3kwETBUuVkvwMHJE0oe4SNSZjcS+G0f2CHK/bgpyZpGWnYS9baF18V2QEY4flA/T 45EXOD0O/hVaAOWGZBSfDrWuXZZidEMssaEmOJnkMI26nsHDsH7JfnHt4kAGIVtL03Xi PTvIXRkt/FbAQ+XiQERB8kRw+9v6xHWlIKboYUZXFH9SlzLc7m+3BGQBztmvLCQwxEVg KQyXXnieprTjnDPXFgkMsyyIaEfq9J2JIzSB6bo/usa/OxrHCJDQSO2HlLUpR/zDQRFt k2VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BfN+bx4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a17090274c200b001a699fc81e8si8825915plt.98.2023.05.08.14.32.30; Mon, 08 May 2023 14:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BfN+bx4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233409AbjEHV0X (ORCPT + 99 others); Mon, 8 May 2023 17:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjEHV0V (ORCPT ); Mon, 8 May 2023 17:26:21 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63337D87; Mon, 8 May 2023 14:25:45 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2ac87e7806aso43326501fa.3; Mon, 08 May 2023 14:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683581139; x=1686173139; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yh86qVTwZ6VGC+iFBj5h0VPqRoZ1lDKWlx5pY2sNDCE=; b=BfN+bx4YB2m2ui+hvbkR4KkQv30l09RYbtI+n1c7LCbmCUXzLrPYAJJ9bkJgcs82fJ FLkWNJFOcRN6SgfsVfZl4Q7Iv6I+cIlBHy0EuKr4tI+1kb1Nqa/QcTGGHY6td0guv5jx bH2/FQBFTEHGIU1SDKUYNPr5I06TjX8e+9zLUFapr0iWDWwVrlZWLWyvqLIAewAvR++M YhwFIf91CwCmUAzyBTp3LQTw4cUZO6tyPqbqHqmW3UkpdwMLVKYy0C7KxXkCVOxP8cQb i9/cPu1S4vsEEuvbrQYXBHXFfr58QC0vBg3YKK07sdILwl0xNwJFKSiYwDIpD1EFin2B Hv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683581139; x=1686173139; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yh86qVTwZ6VGC+iFBj5h0VPqRoZ1lDKWlx5pY2sNDCE=; b=fwiJqc8xUoWQmGosDfwiS+C2lb3AQpv24bL/CdwmeJm3I/sGV8eaIKdBuiZ/6FSFXW ZWUJThGEAUF/VrGr0+RHVcMBBeH+GGXaawvfkO6f0tO28Erx9ccXmfGi+183JfD2+nIb Dcya/jflvwDwIsU/2VkqUAUf9D1DxFuuRgSk+Xl3EJqUfDkSUzE6DwJuJbmoWhs8app9 EiBgkQa1EZAYQ8Bzg/8oPGbapA5UYX7kThTr51Vsh69mL4vXdEBSC8gpAPxCCPGfPolP 0zK7MFbb3TAtBMfmd6ohMYXJlnXnstcESPQa7k9pN7FdOLcNcLNngA3oj9bUyU2tQxRj njDw== X-Gm-Message-State: AC+VfDxOVK7s1GkxuLgPA3hEYm4An7+Qy3y/EGX1iytS9qhiKocCJz/8 HRS3nRvIRpdEFKjxnMyDrI64JWhAXx5nm4DVcUrutYom X-Received: by 2002:a2e:7a13:0:b0:2a6:1682:3a1e with SMTP id v19-20020a2e7a13000000b002a616823a1emr122647ljc.31.1683581139546; Mon, 08 May 2023 14:25:39 -0700 (PDT) MIME-Version: 1.0 References: <20230420165454.9517-1-jorge.lopez2@hp.com> <20230420165454.9517-6-jorge.lopez2@hp.com> <24fb56f9-49c6-432d-8c2f-17df7f7e37b2@t-8ch.de> <34539db1-98a4-4696-934b-af04d74720cc@t-8ch.de> <5662fa47-1156-459b-af86-31351d69cc3f@t-8ch.de> In-Reply-To: <5662fa47-1156-459b-af86-31351d69cc3f@t-8ch.de> From: Jorge Lopez Date: Mon, 8 May 2023 16:25:11 -0500 Message-ID: Subject: Re: [PATCH v11 05/14] HP BIOSCFG driver - ordered-attributes To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 8, 2023 at 3:50=E2=80=AFPM Thomas Wei=C3=9Fschuh wrote: > > On 2023-05-08 08:56:55-0500, Jorge Lopez wrote: > > On Sat, May 6, 2023 at 12:51=E2=80=AFAM Thomas Wei=C3=9Fschuh wrote: > > > > > > On 2023-05-05 16:57:59-0500, Jorge Lopez wrote: > > > > On Fri, May 5, 2023 at 4:11=E2=80=AFPM Thomas Wei=C3=9Fschuh wrote: > > > > > > > > > > On 2023-05-05 11:09:55-0500, Jorge Lopez wrote: > > > > > > On Sun, Apr 23, 2023 at 1:55=E2=80=AFAM wrote= : > > > > > > > > > > > > > > On 2023-04-20 11:54:45-0500, Jorge Lopez wrote: > > > > > > > > .../x86/hp/hp-bioscfg/ordered-attributes.c | 563 ++++++= ++++++++++++ > > > > > > > > 1 file changed, 563 insertions(+) > > > > > > > > create mode 100644 drivers/platform/x86/hp/hp-bioscfg/orde= red-attributes.c > > > > > > > > > > > > > > > > diff --git a/drivers/platform/x86/hp/hp-bioscfg/ordered-att= ributes.c b/drivers/platform/x86/hp/hp-bioscfg/ordered-attributes.c > > > > > > > > new file mode 100644 > > > > > > > > index 000000000000..5e5d540f728d > > > > > > > > --- /dev/null > > > > > > > > > > > > > > + elem_found =3D 0; > > > > > > > > + while (elem_found < bioscfg_drv.ordered_list_data[ins= tance_id].elements_size) { > > > > > > > > + > > > > > > > > + value =3D strsep(&new_values, ","); > > > > > > > > > > > > > > The docs say the separator is semicolon. > > > > > > > > > > > > BIOS reports the current value using ',' as separator instead o= f ";". > > > > > > > > > > > > ./hp-bioscfg/attributes/UEFI Boot Order/current_value > > > > > > HDD:M.2:3,HDD:USB:1(Disabled),HDD:M.2:4,HDD:M.2:1,HDD:M.2:2,NET= WORK > > > > > > IPV4:EMBEDDED:1,NETWORK IPV6:EMBEDDED:1,NETWORK > > > > > > IPV4:EXPANSION:1,NETWORK IPV6:EXPANSION:1 > > > > > > > > > > > > To avoid having to convert from "," to ";" and vice versa, I wi= ll > > > > > > update the documentation to reflect the use of "'," commas as = the > > > > > > separator > > > > > > > > > > The enum data format uses ";". Therefore it makes sense to also s= tick to > > > > > ";". > > > > > The implementation detail of the BIOS using ',' should not matter= to > > > > > users. > > > > > > > > The use of ',' does matter because BIOS expects the updated string = to > > > > use commas as separators > > > > current_value is reported by BIOS using commas. Any changes to the > > > > order of items in that string needs to use commas. > > > > > > > > The difference with enum is the fact the user needs to enter only = one > > > > value out of those possible values available and no separators are > > > > needed. > > > > For ordered attributes... > > > > > > > > when the current value is "foo,bar,baz". the user provides a str= ing > > > > which items are ordered differently. i.e. "baz,bar,foo" > > > > if the new string is using semicolon instead of comma for the > > > > separator, BIOS will reject the data. > > > > > > Of course the BIOS expects the format with comma. > > > > > > But the users of this API should not have to care about implementatio= n > > > details like that. > > > They want a consistent API. As the ordered-list type is fairly genera= l > > > it may be promoted to be a general attribute type later. > > > > > > If this happens the API can't be changed as that would break users of > > > hp-bioscfg. So either there would be two APIs for the ordered-list, o= ne > > > for hp-bioscfg and one for all other drivers, or different attribute > > > types would use different kinds of separators. > > > > > > Was there an issue with the previous replacement logic? > > > > No issue. I was anticipating a potential problem/confusion and created > > a solution. Customers will start using this driver when it becomes > > part of the upstream code. > > Users primarily will use Powershell scripts to interact with the > > driver. The use of powershell will require the user to have the > > knowledge and convert ';' semicolon to ',' commas prior to submitting > > the request to the driver. AFIK, the boot order is one of those > > attributes that is not configured often by the user. Just my opinion. > > If this conversion is done by the driver why would the users have to > care? The driver currently does not do any conversion hence the reason for my concerns. I will reinstate the conversion which was removed in an earlier review. > > > > > > > The whole point of device drivers is to translate general kernel APIs > > > into whatever a specific device needs, switching around ',' and ';' > > > seems not so bad. > > > > So, are you saying, it is ok for the driver to convert ';' semicolon > > to ',' commas prior to submitting a request to change any attribute > > of type 'ordered-list' or when reading current value ? > > If that is correct, then we can change the documentation back to use > > ';' semicolons. > > Please confirm. > > A device drivers task it to translate from the domain of the kernel and > its unified APIs to whatever a specific device needs. > > If we agree that it is more consistent to use semicolons for class > firmware-attribute APIs then the driver would make sure that userspace > always sees semicolons while the ACPI calls always use commas. > > This means translating semicolon->comma when writing to and > comma->semicolon when reading from ACPI. > Userspace should not be exposed to the implementation details but just > the consistent and documented kernel API. > > > > > > > > > + if (value !=3D NULL) { > > > > > > > > + if (!*value) > > > > > > > > + continue; > > > > > > > > + elem_found++; > > > > > > > > + } > > > > > > > > + > > > > > > > > + found =3D 0; > > > > > > > > + for (elem =3D 0; elem < bioscfg_drv.ordered_l= ist_data[instance_id].elements_size; elem++) { > > > > > > > > + if (!strcasecmp(bioscfg_drv.ordered_l= ist_data[instance_id].elements[elem], value)) { > > > > > > > > > > > > > > It's surprising that this is case-insensitive. > > > > > > > > > > > > As validated in earlier reviews, BIOS rejects strings that do = not > > > > > > match the internal values. > > > > > > > > > > > > > > > > > > > > + > > > > > > > > + strscpy(bioscfg_drv.ordered_list_data[instance_id].co= mmon.display_name_language_code, > > > > > > > > + LANG_CODE_STR, > > > > > > > > + sizeof(bioscfg_drv.ordered_list_data[instance= _id].common.display_name_language_code)); > > > > > > > > > > > > > > This seems to be the same for every type. Can it not be moved= into > > > > > > > common code? > > > > > > > > > > > > Each instance requires to report 'display_name_language_code' h= ence it > > > > > > cannot be moved to a common code. > > > > > > > > > > Can it every be different from LANG_CODE_STR? > > > > > > > > Yes. The string currently is LANG_CODE_STR (en_US.UTF-8) but it > > > > will change as the BIOS provides additional translations at a later > > > > time. > > > > This is a future enhancement for the driver. > > > > > > Is this planned for the near future? > > > And/Or already implemented in the BIOS? > > > > > > If there are no concrete plans to implement this soon, in my opinion, > > > it would be better to only introduce this code when it does something > > > useful. > > > > There are no concrete plans yet for the driver. BIOS provides > > translations for strings (F10) UI but the attributes are reported in > > English regardless of the language configured. > > firmware-attributes requires 'display_name_language_code' to be > > reported. At this time, the driver can provide a common helper to > > assign the LANG_CODE_STR to the corresponding attribute. > > Yes please. > > Create an attribute in bioscfg.c that can be used in all the other > attribute_groups. Will do! > > > > > > If not instead of having one kobj_attribute diplay_langcode for e= ach > > > > > string/enum/integer/etc you could have one kobj_attribute defined= in > > > > > bioscfg.c and then added to each string_attrs, enum_attrs... > > > > > > > > > > The _show() callback for this attribute would just return the con= stant > > > > > string. > > > > > > > > > > This removes the need for many attribute definition, members in t= he data > > > > > struct, initialization of these member...