Message ID | 20230317073310.4237-1-xueshuai@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp199353wrt; Fri, 17 Mar 2023 00:41:08 -0700 (PDT) X-Google-Smtp-Source: AK7set+Sq23Rh8S0fBATTYRkfeovG5DOZr+c9LBsBATssf3OfpHO97B4s0O9+2OAiZCtfHXT/oye X-Received: by 2002:a17:902:7296:b0:1a0:463d:fd09 with SMTP id d22-20020a170902729600b001a0463dfd09mr5939299pll.1.1679038867765; Fri, 17 Mar 2023 00:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679038867; cv=none; d=google.com; s=arc-20160816; b=oFyRgeWSbmkZhPHOcoOtfkWowLV+NwKfASwS5ijsC4WTiRql2U7HvsNYHHbjFHfnNi HrmJnF4iWJ2K+GNwugeGjjhynwp+S0yoo0GPoxyiuRY8b0phF7HZ2H5807fZdACeGbIr V5AG/xVe20X31VoTtQNph9NpmtoRF0itU4/aL+/3y79ZfeTDglMUGhL1dVzgLRJtOwhZ usduivZucUX1WUE5oQAACjOEr2W9fe7W9/sfj1OTQKCoA5CUytvvOfgpdm98l9EyovFc xYbfPZPgeS0+1Xvg3MbN4vaL9SfxDLots347e4vGk8+qpIH+90CA6ARxhO/c/KbMTzWF 9cLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YBVjqCfAaXIHocj/biG1BN/9O47mNxf9p94ncJmBaIk=; b=tPK54DXb8DXs7gqSLFWLSkfpBsqBRUrW7DXiz+cBkkY9QhEwo4deph+jAFANZXoUFg dfvwBAqpPJ5IN2a5JKl/tocSv/9gW+Vqam5gottBiEwJn5fuO7keicFr4+Lo+ux90sur 9JYLqOrwxP003RIcDWn6p1eEm1JyBIfvhxnnO6UTDERAw2AHzdvmXHcyUTTKNEBLB0Gd FbKsDuoxIPNO5p7eNbx8AynZMRFnz7VveaVaTUQDswhD+bMFw9Xi2NPm3vwdRUB8CsKK 78cnaQQKrRHYVUHsCzOVSKQs/MU7Ib7MF2Y0rv8fTBMyN0xK63wBkSI8R+RLr0RWB0pf FSng== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020a170903230300b0019ad97d72cfsi1797791plh.590.2023.03.17.00.40.54; Fri, 17 Mar 2023 00:41:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbjCQHd1 (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 17 Mar 2023 03:33:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjCQHdZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Mar 2023 03:33:25 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F84F2ED7D; Fri, 17 Mar 2023 00:33:22 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0Ve20Ajj_1679038395; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Ve20Ajj_1679038395) by smtp.aliyun-inc.com; Fri, 17 Mar 2023 15:33:19 +0800 From: Shuai Xue <xueshuai@linux.alibaba.com> To: tony.luck@intel.com Cc: xueshuai@linux.alibaba.com, baolin.wang@linux.alibaba.com, benjamin.cheatham@amd.com, bp@alien8.de, dan.j.williams@intel.com, james.morse@arm.com, jaylu102@amd.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, zhuo.song@linux.alibaba.com Subject: [PATCH] ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform Date: Fri, 17 Mar 2023 15:33:10 +0800 Message-Id: <20230317073310.4237-1-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760599859992157544?= X-GMAIL-MSGID: =?utf-8?q?1760599859992157544?= |
Series |
ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform
|
|
Commit Message
Shuai Xue
March 17, 2023, 7:33 a.m. UTC
Fix to return -EINVAL in the __einj_error_inject() error handling case
instead of -EBUSY, when explicitly indicated by the platform in the status
of the completed operation.
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
---
drivers/acpi/apei/einj.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
- if (val != EINJ_STATUS_SUCCESS) + if (val == EINJ_STATUS_FAIL) return -EBUSY; + else if (val == EINJ_STATUS_INVAL) + return -EINVAL; The ACPI Specification is really vague here. Documented error codes are 0 = Success (Linux #define EINJ_STATUS_SUCCESS) 1 = Unknown failure (Linux #define EINJ_STATUS_FAIL) 2 = Invalid Access (Linux #define EINJ_STATUS_INVAL) I don't see how reporting -EBUSY for the "Unknown Failure" case is actually better. -Tony
On 2023/3/18 AM5:24, Luck, Tony wrote: > - if (val != EINJ_STATUS_SUCCESS) > + if (val == EINJ_STATUS_FAIL) > return -EBUSY; > + else if (val == EINJ_STATUS_INVAL) > + return -EINVAL; > > The ACPI Specification is really vague here. Documented error codes are > > 0 = Success (Linux #define EINJ_STATUS_SUCCESS) > 1 = Unknown failure (Linux #define EINJ_STATUS_FAIL) > 2 = Invalid Access (Linux #define EINJ_STATUS_INVAL) Absolutely right. > > I don't see how reporting -EBUSY for the "Unknown Failure" case is > actually better. Tony, did you misunderstand this patch? The original code report -EBUSY for both "Unknown Failure" and "Invalid Access" cases. This patch intends to report -EINVAL for "Invalid Access" case and keeps reporting -EBUSY for "Unknown Failure" case unchanged. Although -EBUSY for "Unknown Failure" case is not a good choice. Will -EIO for "Unknown failure" case be better? By the way, do you think -EIO for time out case is suitable. for (;;) { rc = apei_exec_run(&ctx, ACPI_EINJ_CHECK_BUSY_STATUS); if (rc) return rc; val = apei_exec_ctx_get_output(&ctx); if (!(val & EINJ_OP_BUSY)) break; if (einj_timedout(&timeout)) return -EIO; For example, the OSPM will may warn: Firmware does not respond in time. And a message is printed on the console: echo: write error: Input/output error Will -EBUSY or -ETIME for timeout be better? > > -Tony Thank you for comments. Best Regards. Shuai
>> I don't see how reporting -EBUSY for the "Unknown Failure" case is >> actually better. > > Tony, did you misunderstand this patch? > > The original code report -EBUSY for both "Unknown Failure" and > "Invalid Access" cases. I mixed up what was already in the kernel with what the patch was changing. > This patch intends to report -EINVAL for "Invalid Access" case > and keeps reporting -EBUSY for "Unknown Failure" case unchanged. > Although -EBUSY for "Unknown Failure" case is not a good choice. > Will -EIO for "Unknown failure" case be better? Is this for some real use case? Do you have a BIOS EINJ implementation that is returning these different codes? What will the user do differently if they see these different error strings? # echo 1 > error_inject ... different error messages here ... -Tony
On 2023/3/21 AM12:32, Luck, Tony wrote: >>> I don't see how reporting -EBUSY for the "Unknown Failure" case is >>> actually better. >> >> Tony, did you misunderstand this patch? >> >> The original code report -EBUSY for both "Unknown Failure" and >> "Invalid Access" cases. > > I mixed up what was already in the kernel with what the patch was changing. > >> This patch intends to report -EINVAL for "Invalid Access" case >> and keeps reporting -EBUSY for "Unknown Failure" case unchanged. >> Although -EBUSY for "Unknown Failure" case is not a good choice. >> Will -EIO for "Unknown failure" case be better? > > Is this for some real use case? > > Do you have a BIOS EINJ implementation that is returning these different codes? Yes, our BIOS tester complains that EINJ always reports EBUSY, and he has no idea about it. It can not help him determine whether it is a BIOS bug or an injection operation error. > What will the user do differently if they see these different error strings? > > # echo 1 > error_inject > ... different error messages here ... For example, with original code: # select a invalid core or device to inject # echo 1 > error_inject echo: write error: Device or resource busy When tester sees that, he will submit a bug to BIOS developer. Actually, firmware will do some platform dependent sanity checks and returns different error codes. In this case, user injects to a invalid device, platform returns "Invalid Access". And user is expected to see: # select a invalid core or device to inject # echo 1 > error_inject echo: write error: Invalid argument Then user is expected to check his injection argument first. > > -Tony > Best Regards, Shuai
> Actually, firmware will do some platform dependent sanity checks and returns > different error codes. In this case, user injects to a invalid device, platform > returns "Invalid Access". And user is expected to see: > > # select a invalid core or device to inject > # echo 1 > error_inject > echo: write error: Invalid argument > > Then user is expected to check his injection argument first. Thanks. This makes sense. You want EINVAL when the user chose bad arguments, and some other code for problem in BIOS. If the BIOS has an issue, is it possible, or likely, that it is a temporary problem? If so, EBUSY may be OK. The message " Device or resource busy" might encourage the user to wait and try again. If it is not going to get better by itself, then one of: #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ might be a better choice. -Tony
On 2023/3/22 AM12:09, Luck, Tony wrote: >> Actually, firmware will do some platform dependent sanity checks and returns >> different error codes. In this case, user injects to a invalid device, platform >> returns "Invalid Access". And user is expected to see: >> >> # select a invalid core or device to inject >> # echo 1 > error_inject >> echo: write error: Invalid argument >> >> Then user is expected to check his injection argument first. > > Thanks. This makes sense. You want EINVAL when the user chose > bad arguments, and some other code for problem in BIOS. Yes, exactly. > > If the BIOS has an issue, is it possible, or likely, that it is a temporary > problem? If so, EBUSY may be OK. The message " Device or resource busy" > might encourage the user to wait and try again. > > If it is not going to get better by itself, then one of: > > #define EIO 5 /* I/O error */ > #define ENXIO 6 /* No such device or address */ > > might be a better choice. Yes, BIOS may temporarily not complete error injection (ACPI_EINJ_EXECUTE_OPERATION) on time, in which case, kernel return EIO. for (;;) { rc = apei_exec_run(&ctx, ACPI_EINJ_CHECK_BUSY_STATUS); if (rc) return rc; val = apei_exec_ctx_get_output(&ctx); if (!(val & EINJ_OP_BUSY)) break; if (einj_timedout(&timeout)) return -EIO; In summary, you are asking that: - report -EINVAL for "Invalid Access" case - keeps reporting -EBUSY for "Unknown Failure" case unchanged. - and keeps EIO for temporarily time out unchanged. right? (This patch is doing so) > > -Tony Thanks. Best Regards, Shuai
> Fix to return -EINVAL in the __einj_error_inject() error handling case > instead of -EBUSY, when explicitly indicated by the platform in the status > of the completed operation. Needs a bit longer description on the use case based on follow up discussion. Key information is the EINVAL is an indicator to the user that the parameters they supplied cannot be used for injection. But for the code: Reviewed-by: Tony Luck <tony.luck@intel.com> -Tony
On Wed, Mar 22, 2023 at 5:13 PM Luck, Tony <tony.luck@intel.com> wrote: > > > Fix to return -EINVAL in the __einj_error_inject() error handling case > > instead of -EBUSY, when explicitly indicated by the platform in the status > > of the completed operation. > > Needs a bit longer description on the use case based on follow up discussion. > Key information is the EINVAL is an indicator to the user that the parameters they > supplied cannot be used for injection. Right. So Shuai, please resend the patch with a more elaborate changelog. > But for the code: > > Reviewed-by: Tony Luck <tony.luck@intel.com> And add the above tag to it when resending.
On 2023/3/23 AM12:07, Luck, Tony wrote: >> Fix to return -EINVAL in the __einj_error_inject() error handling case >> instead of -EBUSY, when explicitly indicated by the platform in the status >> of the completed operation. > > Needs a bit longer description on the use case based on follow up discussion. > Key information is the EINVAL is an indicator to the user that the parameters they > supplied cannot be used for injection. > > But for the code: > > Reviewed-by: Tony Luck <tony.luck@intel.com> > > -Tony Got, I will rephrase the commit log based on follow up discussion. Thank you for reviews. Cheers, Shuai
On 2023/3/23 AM12:52, Rafael J. Wysocki wrote: > On Wed, Mar 22, 2023 at 5:13 PM Luck, Tony <tony.luck@intel.com> wrote: >> >>> Fix to return -EINVAL in the __einj_error_inject() error handling case >>> instead of -EBUSY, when explicitly indicated by the platform in the status >>> of the completed operation. >> >> Needs a bit longer description on the use case based on follow up discussion. >> Key information is the EINVAL is an indicator to the user that the parameters they >> supplied cannot be used for injection. > > Right. > > So Shuai, please resend the patch with a more elaborate changelog. Ok, I will do it later. > >> But for the code: >> >> Reviewed-by: Tony Luck <tony.luck@intel.com> > > And add the above tag to it when resending. Got it. Thank you. Best Regards. Shuai
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index b4373e575660..fa0b4320312e 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -489,9 +489,15 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, if (rc) return rc; val = apei_exec_ctx_get_output(&ctx); - if (val != EINJ_STATUS_SUCCESS) + if (val == EINJ_STATUS_FAIL) return -EBUSY; + else if (val == EINJ_STATUS_INVAL) + return -EINVAL; + /* + * The error is injected into the platform successfully, then it needs + * to trigger the error. + */ rc = apei_exec_run(&ctx, ACPI_EINJ_GET_TRIGGER_TABLE); if (rc) return rc;