Skip to contentSkip to conversation

acpi: apei: clear error status before acknowledging the error

PATCH In review Tyler Baicar 5 participants 12 messages Aug 28, 2017 – Sep 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 acpi: apei: clear error status before acknowledging the error

Currently we acknowledge errors before clearing the error status. This could cause a new error to be populated by firmware in-between the error acknowledgment and the error status clearing which would cause the second error's status to be cleared without being handled. So, clear the error status before acknowledging the errors.

Also, make sure to acknowledge the error if the error status read fails.

V3: Seperate check for -ENOENT return value

V2: Only send error ack if there was an error populated
Remove curly braces that are no longer needed

---
 drivers/acpi/apei/ghes.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/acpi/apei/ghes.c +9 -7
index d661d45..8d43b1c 100644
@@ -743,17 +743,19 @@ static int ghes_proc(struct ghes *ghes)
 	}
 	ghes_do_proc(ghes, ghes->estatus);
 
+out:
+	ghes_clear_estatus(ghes);
+
+	if (rc == -ENOENT)
+		return rc;
+
 	/*
 	 * GHESv2 type HEST entries introduce support for error acknowledgment,
 	 * so only acknowledge the error if this support is present.
 	 */
-	if (is_hest_type_generic_v2(ghes)) {
-		rc = ghes_ack_error(ghes->generic_v2);
-		if (rc)
-			return rc;
-	}
-out:
-	ghes_clear_estatus(ghes);
+	if (is_hest_type_generic_v2(ghes))
+		return ghes_ack_error(ghes->generic_v2);
+
 	return rc;
 }
 
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
#1 lore raw
Quoted 28 lines · Tyler Baicar

Currently we acknowledge errors before clearing the error status. This could cause a new error to be populated by firmware in-between the error acknowledgment and the error status clearing which would cause the second error's status to be cleared without being handled. So, clear the error status before acknowledging the errors.

Also, make sure to acknowledge the error if the error status read fails.

drivers/acpi/apei/ghes.c +6 -0
+out:
+	ghes_clear_estatus(ghes);
+
 
+	if (rc == -ENOENT)
+		return rc;
+

  /*
   * GHESv2 type HEST entries introduce support for error acknowledgment,
   * so only acknowledge the error if this support is present. */

drivers/acpi/apei/ghes.c static int ghes_proc(struct ghes *ghes) · line 756

Quoted 1 line
drivers/acpi/apei/ghes.c +1 -0
+	if (is_hest_type_generic_v2(ghes))

You can also do this here, like

	if (is_hest_type_generic_v2(ghes) && rc != -ENOENT)

though I left this for Rafael to choose which one is preferable.

Quoted 2 lines
drivers/acpi/apei/ghes.c +2 -0
+		return ghes_ack_error(ghes->generic_v2);
+
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw
Quoted 2 lines · Andy Shevchenko

You can also do this here, like

	if (is_hest_type_generic_v2(ghes) && rc != -ENOENT)

https://lkml.kernel.org/r/[email protected]

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#3 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko

You can also do this here, like

      if (is_hest_type_generic_v2(ghes) && rc != -ENOENT)

https://lkml.kernel.org/r/[email protected]

       if (rc != -ENOENT && is_hest_type_generic_v2(ghes))

:-)

But again, your call to choose :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 4 lines · Andy Shevchenko
       if (rc != -ENOENT && is_hest_type_generic_v2(ghes))

:-)

But again, your call to choose :-)

Slow down please.

What do you think is more readable: a compound if-statement or two simple ones, the second one with an explanatory comment?

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#5 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 4 lines · Andy Shevchenko
       if (rc != -ENOENT && is_hest_type_generic_v2(ghes))

:-)

But again, your call to choose :-)

Slow down please.

What do you think is more readable: a compound if-statement or two simple ones, the second one with an explanatory comment?

For my opinion, since you asked, the either case needs a comment on top of that additional check.
Separate conditionals in independent cases are, of course, better. Though, here they are dependent (as I read from commit message). So, _personally_ I would go with compound one, but note first sentence in this response.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 2 lines · Andy Shevchenko

For my opinion, since you asked, the either case needs a comment on top of that additional check.

That's because the comment belongs to the v2 part of the check.

Quoted 1 line

Separate conditionals in independent cases are, of course, better.

Yes, and separate are easier to read if you read them like this:

+ if (rc == -ENOENT)
+ return rc;

<--- Ok, we got the missing entry out of the way, now, here, we have a valid entry. Now we can concentrate on processing it further.

... other check and ack and ...

And this becomes a lot more natural when you're staring at a big function which does a lot of things and you concentrate only on the main path.

Oh, and this is how those checks get translated to asm as there you don't really have compound if-statements. So if you switch your mind to reading such checks separately, you're practically ready to read their asm translation too...

Anyway, this is how I see it.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#7 lore raw
Quoted 34 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko

For my opinion, since you asked, the either case needs a comment on top of that additional check.

That's because the comment belongs to the v2 part of the check.

Quoted 1 line

Separate conditionals in independent cases are, of course, better.

Yes, and separate are easier to read if you read them like this:

(quoted diff) +2 -0
+       if (rc == -ENOENT)
+               return rc;

<--- Ok, we got the missing entry out of the way, now, here, we have a valid entry. Now we can concentrate on processing it further.

... other check and ack and ...

And this becomes a lot more natural when you're staring at a big function which does a lot of things and you concentrate only on the main path.

Oh, and this is how those checks get translated to asm as there you don't really have compound if-statements. So if you switch your mind to reading such checks separately, you're practically ready to read their asm translation too...

Anyway, this is how I see it.

--
Regards/Gruss,
Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
In reply to Borislav Petkov
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko

For my opinion, since you asked, the either case needs a comment on top of that additional check.

That's because the comment belongs to the v2 part of the check.

Sorry not being clear, I meant another, separate comment.

Quoted 15 lines
Quoted 1 line

Separate conditionals in independent cases are, of course, better.

Yes, and separate are easier to read if you read them like this:

(quoted diff) +2 -0
+       if (rc == -ENOENT)
+               return rc;

<--- Ok, we got the missing entry out of the way, now, here, we have a valid entry. Now we can concentrate on processing it further.

... other check and ack and ...

And this becomes a lot more natural when you're staring at a big function which does a lot of things and you concentrate only on the main path.

Quoted 6 lines

Oh, and this is how those checks get translated to asm as there you don't really have compound if-statements. So if you switch your mind to reading such checks separately, you're practically ready to read their asm translation too...

Anyway, this is how I see it.

Looking into commit message again I think the word 'also' creates all this. Two separate commits might be perfect, though good enough is to have an additional comment to the new check.

Thanks for sharing detailed point of view.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer Reviewed-by on v3 1/1
#9 lore raw
In reply to Tyler Baicar
Quoted 11 lines · Tyler Baicar

Currently we acknowledge errors before clearing the error status. This could cause a new error to be populated by firmware in-between the error acknowledgment and the error status clearing which would cause the second error's status to be cleared without being handled. So, clear the error status before acknowledging the errors.

Also, make sure to acknowledge the error if the error status read fails.

V3: Seperate check for -ENOENT return value

Quoted 7 lines

V2: Only send error ack if there was an error populated
Remove curly braces that are no longer needed

---
 drivers/acpi/apei/ghes.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#10 lore raw
Quoted 12 lines · Borislav Petkov
Quoted 11 lines · Tyler Baicar

Currently we acknowledge errors before clearing the error status. This could cause a new error to be populated by firmware in-between the error acknowledgment and the error status clearing which would cause the second error's status to be cleared without being handled. So, clear the error status before acknowledging the errors.

Also, make sure to acknowledge the error if the error status read fails.

V3: Seperate check for -ENOENT return value

Quoted 8 lines
Quoted 7 lines

V2: Only send error ack if there was an error populated
Remove curly braces that are no longer needed

---
  drivers/acpi/apei/ghes.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)

Hello Rafael,

Were you able to apply this patch?

Thanks,
Tyler

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
#11 lore raw
Quoted 16 lines · Tyler
Quoted 15 lines · Borislav Petkov
Quoted 14 lines · Tyler Baicar

Currently we acknowledge errors before clearing the error status. This could cause a new error to be populated by firmware in-between the error acknowledgment and the error status clearing which would cause the second error's status to be cleared without being handled. So, clear the error status before acknowledging the errors.

Also, make sure to acknowledge the error if the error status read fails.

V3: Seperate check for -ENOENT return value

V2: Only send error ack if there was an error populated Remove curly braces that are no longer needed

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

---
  drivers/acpi/apei/ghes.c | 16 +++++++++-------

  1 file changed, 9 insertions(+), 7 deletions(-)

Hello Rafael,

Were you able to apply this patch?

I haven't heard anything on this patch. It would be great to have it in 4.14 :)

Thanks,
Tyler