git: 942bc09fc257 - stable/13 - arm64: Check for intrng-reported errors in gicv3_its

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Tue, 25 Jan 2022 01:40:19 UTC
The branch stable/13 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=942bc09fc2575d432c916316f55edaed7f7b3159

commit 942bc09fc2575d432c916316f55edaed7f7b3159
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-01-03 17:09:42 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-01-24 23:59:58 +0000

    arm64: Check for intrng-reported errors in gicv3_its
    
    Currently, any errors when adding a PIC child handler are ignored,
    instead just continuing on to registering that PIC as an MSI, and
    ignoring any errors that occur for that too.
    
    Reviewed by:    andrew
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D33342
    
    (cherry picked from commit 3582b9e372c2556adc0fcc42466ead8b2bda7850)
---
 sys/arm64/arm64/gicv3_its.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index 84b1a574f02f..9e24d37e3a63 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -1942,11 +1942,19 @@ gicv3_its_fdt_attach(device_t dev)
 	/* Register this device as a interrupt controller */
 	xref = OF_xref_from_node(ofw_bus_get_node(dev));
 	sc->sc_pic = intr_pic_register(dev, xref);
-	intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
+	err = intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
 	    gicv3_its_intr, sc, sc->sc_irq_base, sc->sc_irq_length);
+	if (err != 0) {
+		device_printf(dev, "Failed to add PIC handler: %d\n", err);
+		return (err);
+	}
 
 	/* Register this device to handle MSI interrupts */
-	intr_msi_register(dev, xref);
+	err = intr_msi_register(dev, xref);
+	if (err != 0) {
+		device_printf(dev, "Failed to register for MSIs: %d\n", err);
+		return (err);
+	}
 
 	return (0);
 }
@@ -2003,11 +2011,19 @@ gicv3_its_acpi_attach(device_t dev)
 
 	di = device_get_ivars(dev);
 	sc->sc_pic = intr_pic_register(dev, di->msi_xref);
-	intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
+	err = intr_pic_add_handler(device_get_parent(dev), sc->sc_pic,
 	    gicv3_its_intr, sc, sc->sc_irq_base, sc->sc_irq_length);
+	if (err != 0) {
+		device_printf(dev, "Failed to add PIC handler: %d\n", err);
+		return (err);
+	}
 
 	/* Register this device to handle MSI interrupts */
-	intr_msi_register(dev, di->msi_xref);
+	err = intr_msi_register(dev, di->msi_xref);
+	if (err != 0) {
+		device_printf(dev, "Failed to register for MSIs: %d\n", err);
+		return (err);
+	}
 
 	return (0);
 }