Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Dec 2015 14:22:58 +0000 (UTC)
From:      Michal Meloun <mmel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r291649 - head/sys/arm/arm
Message-ID:  <201512021422.tB2EMwkB002462@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mmel
Date: Wed Dec  2 14:22:58 2015
New Revision: 291649
URL: https://svnweb.freebsd.org/changeset/base/291649

Log:
  ARM: Fix of detection of root interrupt controller.
  This fixes detection of root interrupt controller for cases,
  when interrupt parent is not defined at all or it's not defined directly
  in controller node.
  
  Approved by:	kib (mentor)

Modified:
  head/sys/arm/arm/gic.c

Modified: head/sys/arm/arm/gic.c
==============================================================================
--- head/sys/arm/arm/gic.c	Wed Dec  2 14:21:16 2015	(r291648)
+++ head/sys/arm/arm/gic.c	Wed Dec  2 14:22:58 2015	(r291649)
@@ -461,9 +461,13 @@ arm_gic_attach(device_t dev)
 		goto cleanup;
 	}
 
-	i = OF_getencprop(ofw_bus_get_node(dev), "interrupt-parent",
-	    &pxref, sizeof(pxref));
-	if (i > 0 && xref == pxref) {
+	/*
+	 * Controller is root if:
+	 * - doesn't have interrupt parent
+	 * - his interrupt parent is this controller
+	 */
+	pxref = ofw_bus_find_iparent(ofw_bus_get_node(dev));
+	if (pxref == 0 || xref == pxref) {
 		if (arm_pic_claim_root(dev, xref, arm_gic_intr, sc,
 		    GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) {
 			device_printf(dev, "could not set PIC as a root\n");
@@ -471,6 +475,12 @@ arm_gic_attach(device_t dev)
 			goto cleanup;
 		}
 	} else {
+		if (sc->gic_res[2] == NULL) {
+			device_printf(dev,
+			    "not root PIC must have defined interrupt\n");
+			arm_pic_unregister(dev, xref);
+			goto cleanup;
+		}
 		if (bus_setup_intr(dev, sc->gic_res[2], INTR_TYPE_CLK,
 		    arm_gic_intr, NULL, sc, &sc->gic_intrhand)) {
 			device_printf(dev, "could not setup irq handler\n");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512021422.tB2EMwkB002462>