ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform
Shuai Xue
reviewerPATCH 1/1 ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform
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.
--- drivers/acpi/apei/einj.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/acpi/apei/einj.c +7 -1
@@ -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;
Signature · 1 line
2.20.1.12.g72788fdb
Luck, Tony
reviewer- 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
Shuai Xue
reviewerQuoted 11 lines · Tony
drivers/acpi/apei/einj.c +3
-1-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 #defineEINJ_STATUS_FAIL) 2 = Invalid Access (Linux #defineEINJ_STATUS_INVAL)
Absolutely right.
Quoted 3 lines
I don't see how reporting
-EBUSYfor 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?
Quoted 2 lines
-Tony
Thank you for comments.
Best Regards.
Shuai
Luck, Tony
reviewerQuoted 7 lines
Quoted 2 lines
I don't see how reporting
-EBUSYfor the "Unknown Failure" case is actually better.Tony, did you misunderstand this patch?
The original code report
-EBUSYfor both "Unknown Failure" and "Invalid Access" cases.
I mixed up what was already in the kernel with what the patch was changing.
Quoted 4 lines
This patch intends to report
-EINVALfor "Invalid Access" case and keeps reporting-EBUSYfor "Unknown Failure" case unchanged. Although-EBUSYfor "Unknown Failure" case is not a good choice. Will-EIOfor "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
Shuai Xue
reviewerQuoted 10 lines · Tony
Quoted 7 lines
Quoted 2 lines
I don't see how reporting
-EBUSYfor the "Unknown Failure" case is actually better.Tony, did you misunderstand this patch?
The original code report
-EBUSYfor both "Unknown Failure" and "Invalid Access" cases.I mixed up what was already in the kernel with what the patch was changing.
Quoted 8 lines
Quoted 4 lines
This patch intends to report
-EINVALfor "Invalid Access" case and keeps reporting-EBUSYfor "Unknown Failure" case unchanged. Although-EBUSYfor "Unknown Failure" case is not a good choice. Will-EIOfor "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.
Quoted 4 lines
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.
Quoted 3 lines
-Tony
Best Regards,
Shuai
Luck, Tony
reviewerQuoted 9 lines
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 argumentThen 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
Shuai Xue
reviewerQuoted 4 lines · Tony
Quoted 4 lines
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:
Quoted 8 lines
Quoted 5 lines
# select a invalid core or device to inject # echo 1 > error_inject echo: write error: Invalid argumentThen 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.
Quoted 11 lines
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)
Quoted 2 lines
-Tony
Thanks.
Best Regards,
Shuai
Quoted 3 lines
Fix to return
-EINVALin 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:
-Tony
Rafael J. Wysocki
maintainerQuoted 8 lines · Tony
Quoted 4 lines
Fix to return
-EINVALin 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.
Quoted 3 lines
But for the code:
Reviewed-by Tony Luck <[email protected]>
And add the above tag to it when resending.
Shuai Xue
reviewerQuoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · Tony
Quoted 4 lines
Fix to return
-EINVALin the__einj_error_inject()error handling case instead of-EBUSY, when explicitly indicated by the platform in the status of the completed operation.
Quoted 7 lines
Quoted 3 lines
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.
Quoted 6 lines
Quoted 4 lines
But for the code:
Reviewed-by Tony Luck <[email protected]>And add the above tag to it when resending.
Got it.
Thank you.
Best Regards.
Shuai
Shuai Xue
reviewerQuoted 8 lines · Tony
Quoted 3 lines
Fix to return
-EINVALin 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.
Quoted 5 lines
But for the code:
Reviewed-by Tony Luck <[email protected]>-Tony
Got, I will rephrase the commit log based on follow up discussion.
Thank you for reviews.
Cheers,
Shuai
Shuai Xue
reviewerPATCH v2 1/1 ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform
In reply to Shuai XueOSPM executes an EXECUTE_OPERATION action to instruct the platform to begin the injection operation, then executes a GET_COMMAND_STATUS action to determine the status of the completed operation. The ACPI Specification documented error codes[1] are:
0 = Success (Linux #define EINJ_STATUS_SUCCESS) 1 = Unknown failure (Linux #define EINJ_STATUS_FAIL) 2 = Invalid Access (Linux #define EINJ_STATUS_INVAL)
The original code report -EBUSY for both "Unknown Failure" and "Invalid Access" cases. Actually, firmware could do some platform dependent sanity checks and returns different error codes, e.g. "Invalid Access" to indicate to the user that the parameters they supplied cannot be used for injection.
To this end, fix to return -EINVAL in the __einj_error_inject() error handling case instead of always -EBUSY, when explicitly indicated by the platform in the status of the completed operation.
[1] ACPI Specification 6.5 18.6.1. Error Injection Table
---
changelog since v1:
- elaborate commit log based on follow up discussion with Tony
- pick up Reviewed-by tag of Tony
--- drivers/acpi/apei/einj.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/acpi/apei/einj.c +7 -1
@@ -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;
Signature · 1 line
2.20.1.12.g72788fdb
Quoted 43 lines · Shuai Xue
OSPM executes an
EXECUTE_OPERATIONaction to instruct the platform to begin the injection operation, then executes aGET_COMMAND_STATUSaction to determine the status of the completed operation. The ACPI Specification documented error codes[1] are:0 = Success (Linux #define
EINJ_STATUS_SUCCESS) 1 = Unknown failure (Linux #defineEINJ_STATUS_FAIL) 2 = Invalid Access (Linux #defineEINJ_STATUS_INVAL)The original code report
-EBUSYfor both "Unknown Failure" and "Invalid Access" cases. Actually, firmware could do some platform dependent sanity checks and returns different error codes, e.g. "Invalid Access" to indicate to the user that the parameters they supplied cannot be used for injection.To this end, fix to return
-EINVALin the__einj_error_inject()error handling case instead of always-EBUSY, when explicitly indicated by the platform in the status of the completed operation.[1] ACPI Specification 6.5 18.6.1. Error Injection Table
Signed-off-by Shuai Xue <[email protected]>Reviewed-by Tony Luck <[email protected]>---
changelog since v1:
- elaborate commit log based on follow up discussion with Tony
- pick up Reviewed-by tag of Tony--- drivers/acpi/apei/einj.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/acpi/apei/einj.c +2
-1@@ -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 )
drivers/acpi/apei/einj.c static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
Quoted 10 lines
drivers/acpi/apei/einj.c +5
-1+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; --
Applied as 6.4 material, thanks!