Skip to contentSkip to conversation

acpi: apei: Bug fix to enable APEI support for ARMv8

PATCH Superseded Loc Ho 4 participants 19 messages Nov 7, 2015 – Jan 13, 2016

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Loc Ho

author
#0 lore raw

v3 cover acpi: apei: Bug fix to enable APEI support for ARMv8

v3
* Change the title of the patch to reflect the patch
* Completely dropped the driver. Instead, move completely to the FW by accessing the GIC directly.
* Fix a bug with function acpi_gsi_to_irq
* Enable APEI multiple GHES source to share an single external IRQ

v2
* Make all code more generic naming
* Still waiting for comment from Linaro folks on APEI

---
Loc Ho (2):
acpi: Fix proper return code for function acpi_gsi_to_irq
acpi: apei: Enable APEI multiple GHES source to share an single
external IRQ

 drivers/acpi/apei/ghes.c |    2 +-
 drivers/acpi/gsi.c       |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
author
#1 lore raw

PATCH v3 1/2 acpi: Fix proper return code for function acpi_gsi_to_irq

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

---
 drivers/acpi/gsi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/gsi.c +2 -2
index fa4585a..0ed1003 100644
@@ -43,7 +43,7 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  *
  * irq location updated with irq value [>0 on success, 0 on failure]
  *
- * Returns: linux IRQ number on success (>0)
+ * Returns: 0 on success
  *          -EINVAL on failure
  */
 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
@@ -56,7 +56,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
 	 * *irq == 0 means no mapping, that should
 	 * be reported as a failure
 	 */
-	return (*irq > 0) ? *irq : -EINVAL;
+	return (*irq > 0) ? 0 : -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
 
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 23 lines · Loc Ho

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

---
 drivers/acpi/gsi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/gsi.c +1 -1
index fa4585a..0ed1003 100644
@@ -43,7 +43,7 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  *
  * irq location updated with irq value [>0 on success, 0 on failure]
  *
- * Returns: linux IRQ number on success (>0)
+ * Returns: 0 on success
  *          -EINVAL on failure
  */
 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)

drivers/acpi/gsi.c int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) · line 61

Quoted 7 lines
drivers/acpi/gsi.c +1 -1
@@ -56,7 +56,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
 	 * *irq == 0 means no mapping, that should
 	 * be reported as a failure
 	 */
-	return (*irq > 0) ? *irq : -EINVAL;
+	return (*irq > 0) ? 0 : -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);

That function can be simplified. It should be made to return the irq number on success and 0 on failure. No need for that *irq output argument.

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#3 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 37 lines · Borislav Petkov
Quoted 23 lines · Loc Ho

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

---
 drivers/acpi/gsi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/gsi.c +1 -1
index fa4585a..0ed1003 100644
@@ -43,7 +43,7 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  *
  * irq location updated with irq value [>0 on success, 0 on failure]
  *
- * Returns: linux IRQ number on success (>0)
+ * Returns: 0 on success
  *          -EINVAL on failure
  */
 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)

drivers/acpi/gsi.c int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) · line 61

Quoted 7 lines
drivers/acpi/gsi.c +1 -1
@@ -56,7 +56,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
       * *irq == 0 means no mapping, that should
       * be reported as a failure
       */
-     return (*irq > 0) ? *irq : -EINVAL;
+     return (*irq > 0) ? 0 : -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);

That function can be simplified. It should be made to return the irq number on success and 0 on failure. No need for that *irq output argument.

Quoted 5 lines

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.

Hi Boris,
The same function which is implemented for x86 (arch/x86/kernel/acpi/boot.c) also returns 0 on success and -1 on failure. If we need to change the API, need to change for X86 too which we don't have a way to test it.

Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#4 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 5 lines · Tuan Phan

Hi Boris,
The same function which is implemented for x86 (arch/x86/kernel/acpi/boot.c) also returns 0 on success and -1 on failure. If we need to change the API, need to change for X86 too which we don't have a way to test it.

Well, fortunately, I have an x86 box to test it :-)

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#5 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 3 lines · Borislav Petkov

That function can be simplified. It should be made to return the irq number on success and 0 on failure. No need for that *irq output argument.

It will be problem because irq number can be 0 on X86?

Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#6 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 1 line · Tuan Phan

It will be problem because irq number can be 0 on X86?

tglx says not really but historically irq 0 has been the timer irq.

How about returning a negative value on error and positive or 0 for an IRQ?

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#7 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 8 lines · Borislav Petkov
Quoted 1 line · Tuan Phan

It will be problem because irq number can be 0 on X86?

tglx says not really but historically irq 0 has been the timer irq.

How about returning a negative value on error and positive or 0 for an IRQ?

That's exactly the patch tries to do:
int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
@@ -56,7 +56,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
* *irq == 0 means no mapping, that should
* be reported as a failure
*/
- return (*irq > 0) ? *irq : -EINVAL;
+ return (*irq > 0) ? 0 : -EINVAL;
}

So are you good with it?

Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#8 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 1 line · Tuan Phan

So are you good with it?

How about this instead:

---

drivers/acpi/gsi.c +8 -3
index fa4585a6914e..e42f6b7eac13 100644
@@ -46,17 +46,22 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  * Returns: linux IRQ number on success (>0)
  *          -EINVAL on failure
  */
-int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
+int acpi_gsi_to_irq(u32 gsi)
 {
+	unsigned int irq;
+
 	struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
 							DOMAIN_BUS_ANY);
 
-	*irq = irq_find_mapping(d, gsi);
+	irq = irq_find_mapping(d, gsi);
 	/*
 	 * *irq == 0 means no mapping, that should
 	 * be reported as a failure
 	 */
-	return (*irq > 0) ? *irq : -EINVAL;
+	if (irq > 0)
+		return irq;
+	else
+		return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
 
Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#9 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 25 lines · Borislav Petkov
Quoted 1 line · Tuan Phan

So are you good with it?

How about this instead:

---

drivers/acpi/gsi.c +4 -2
index fa4585a6914e..e42f6b7eac13 100644
@@ -46,17 +46,22 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  * Returns: linux IRQ number on success (>0)
  *          -EINVAL on failure
  */
-int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
+int acpi_gsi_to_irq(u32 gsi)
 {
+       unsigned int irq;
+
        struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
                                                        DOMAIN_BUS_ANY);
 
-       *irq = irq_find_mapping(d, gsi);
+       irq = irq_find_mapping(d, gsi);
        /*

drivers/acpi/gsi.c static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity) · line 66

Quoted 10 lines
drivers/acpi/gsi.c +4 -1
         * *irq == 0 means no mapping, that should
         * be reported as a failure
         */
-       return (*irq > 0) ? *irq : -EINVAL;
+       if (irq > 0)
+               return irq;
+       else
+               return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);

Well, it basically the same as old code except the change of API interface. And it requires some changes in ACPI core and X86/I64 arch code. Do we really want to go with this solution instead of just return 0 on success and -EINVAL on failure?

Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#10 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 3 lines · Tuan Phan

Well, it basically the same as old code except the change of API interface. And it requires some changes in ACPI core and X86/I64 arch code.

That's why I said:

"Patch 1 could be improved. It is Rafael's call in the end of the day."

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
#11 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

In reply to Loc Ho
Quoted 2 lines · Loc Ho

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

I have to ask: why do you feel the need to change an API that behaves like the rest of the IRQ allocation functions (at least when it comes to its return value)?

0 is defined as an invalid interrupt, and I wish it stayed that way.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#12 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 9 lines · Marc Zyngier
Quoted 2 lines · Loc Ho

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

I have to ask: why do you feel the need to change an API that behaves like the rest of the IRQ allocation functions (at least when it comes to its return value)?

0 is defined as an invalid interrupt, and I wish it stayed that way.

The upper caller expects 0 for success.
In drivers/acpi/apei/ghes.c:

        case ACPI_HEST_NOTIFY_EXTERNAL:
                /* External interrupt vector is GSI */
                rc = acpi_gsi_to_irq(generic->notify.vector, &ghes->irq);
                if (rc) {
                        pr_err(GHES_PFX "Failed to map GSI to IRQ for
generic hardware error source: %d\n",
                               generic->header.source_id);
                        goto err_edac_unreg;
                }

Also the implementation of acpi_gsi_to_irq for X86 in arch/x86/kernel/acpi/boot.c also return 0 for success and -1 for failure.
int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)

{
        int rc, irq, trigger, polarity;

        if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
                *irqp = gsi;
                return 0;
        }

        rc = acpi_get_override_irq(gsi, &trigger, &polarity);
        if (rc == 0) {
                trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
                polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
                irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
                if (irq >= 0) {
                        *irqp = irq;
                        return 0;
                }
        }

        return -1;
}
Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#13 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 40 lines · Tuan Phan
Quoted 9 lines · Marc Zyngier
Quoted 2 lines · Loc Ho

The function acpi_gsi_to_irq should returns 0 on success as upper function caller expect an 0 for sucesss.

I have to ask: why do you feel the need to change an API that behaves like the rest of the IRQ allocation functions (at least when it comes to its return value)?

0 is defined as an invalid interrupt, and I wish it stayed that way.

The upper caller expects 0 for success.
In drivers/acpi/apei/ghes.c:

        case ACPI_HEST_NOTIFY_EXTERNAL:
                /* External interrupt vector is GSI */
                rc = acpi_gsi_to_irq(generic->notify.vector, &ghes->irq);
                if (rc) {
                        pr_err(GHES_PFX "Failed to map GSI to IRQ for
generic hardware error source: %d\n",
                               generic->header.source_id);
                        goto err_edac_unreg;
                }

Also the implementation of acpi_gsi_to_irq for X86 in arch/x86/kernel/acpi/boot.c also return 0 for success and -1 for failure.
int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)

{
        int rc, irq, trigger, polarity;

        if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
                *irqp = gsi;
                return 0;
        }

        rc = acpi_get_override_irq(gsi, &trigger, &polarity);
        if (rc == 0) {
                trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
                polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
                irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
Quoted 9 lines
                if (irq >= 0) {
                        *irqp = irq;
                        return 0;
                }
        }

        return -1;
}

Right. In which case please document this properly in the commit log.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#14 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 2 lines · Marc Zyngier

Right. In which case please document this properly in the commit log.

Do we need to post a new patch with updated description or wait Rafael's input?

Signature · 8 lines
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and contains information that 
is confidential and proprietary to Applied Micro Circuits Corporation or 
its subsidiaries. It is to be used solely for the purpose of furthering the 
parties' business relationship. All unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
#15 lore raw

Re: [PATCH v3 1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Quoted 4 lines · Tuan Phan
Quoted 2 lines · Marc Zyngier
Quoted 2 lines

Right. In which case please document this properly in the commit log.

Do we need to post a new patch with updated description or wait Rafael's input?

Given that there is quite a few comments on this series already, it would make sense to update it and repost it.

Quoted 8 lines

-- CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

And please fix your email setup. By the look of it, I'm not even supposed to read this.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author
#16 lore raw

PATCH v3 2/2 acpi: apei: Enable APEI multiple GHES source to share an single external IRQ

In reply to Loc Ho

This patch allows APEI generic error source table with external IRQ to share an single IRQ.

---
 drivers/acpi/apei/ghes.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/apei/ghes.c +1 -1
index 3dd9c46..edc8a39 100644
@@ -1011,7 +1011,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
 			       generic->header.source_id);
 			goto err_edac_unreg;
 		}
-		rc = request_irq(ghes->irq, ghes_irq_func, 0, "GHES IRQ", ghes);
+		rc = request_irq(ghes->irq, ghes_irq_func, IRQF_SHARED, "GHES IRQ", ghes);
 		if (rc) {
 			pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n",
 			       generic->header.source_id);
Signature · 1 line
1.7.1
author
#17 lore raw
In reply to Loc Ho

Hi Borislav/Doung/etc,

Quoted 11 lines

v3
* Change the title of the patch to reflect the patch
* Completely dropped the driver. Instead, move completely to the FW by accessing the GIC directly.
* Fix a bug with function acpi_gsi_to_irq
* Enable APEI multiple GHES source to share an single external IRQ

v2
* Make all code more generic naming
* Still waiting for comment from Linaro folks on APEI

Quoted 5 lines

---
Loc Ho (2):
acpi: Fix proper return code for function acpi_gsi_to_irq
acpi: apei: Enable APEI multiple GHES source to share an single
external IRQ

It has been awhile and I thought I check again on this. Any issue with these two changes as it is needed for ARMv8 64-bit APEI support. Without these two changes, APEI support will NOT work with X-Gene platforms.

-Loc

#18 lore raw
Quoted 4 lines · Loc Ho

It has been awhile and I thought I check again on this. Any issue with these two changes as it is needed for ARMv8 64-bit APEI support. Without these two changes, APEI support will NOT work with X-Gene platforms.

Patch 1 could be improved. It is Rafael's call in the end of the day.

Patch 2 looks ok to me.

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.