git: 0edbab45af5d - stable/13 - arm: add an interrupt rman to nexus

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 17 Apr 2023 17:03:57 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=0edbab45af5d36596b77e7d6da71c3b529b09bc1

commit 0edbab45af5d36596b77e7d6da71c3b529b09bc1
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-12-05 15:27:50 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-04-17 16:02:56 +0000

    arm: add an interrupt rman to nexus
    
    Allow the nexus bus to own and manage interrupt resources. Currently,
    interrupt resources on this architecture are managed completely by
    ofwbus, but it is desirable that system-wide memory and interrupt
    resources be managed by the top-level bus.
    
    This is a pre-requisite to moving this resource management out of
    ofwbus.
    
    Reviewed By:    ian, Elliott Mitchell <ehem+freebsd@m5p.com>
    MFC after:      1 month
    Differential Revision: https://reviews.freebsd.org/D32357
    
    (cherry picked from commit 1d03c3578d05b011dc714ec0735a5783c421530b)
---
 sys/arm/arm/nexus.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index be84ab82d43f..f2506dfb3cb5 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -77,6 +77,7 @@ struct nexus_device {
 #define DEVTONX(dev)	((struct nexus_device *)device_get_ivars(dev))
 
 static struct rman mem_rman;
+static struct rman irq_rman;
 
 static	int nexus_probe(device_t);
 static	int nexus_attach(device_t);
@@ -171,6 +172,12 @@ nexus_attach(device_t dev)
 	if (rman_init(&mem_rman) ||
 	    rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR))
 		panic("nexus_probe mem_rman");
+	irq_rman.rm_start = 0;
+	irq_rman.rm_end = ~0;
+	irq_rman.rm_type = RMAN_ARRAY;
+	irq_rman.rm_descr = "Interrupts";
+	if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0))
+		panic("nexus_attach irq_rman");
 
 	/*
 	 * First, deal with the children we know about already
@@ -227,6 +234,10 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
 	flags &= ~RF_ACTIVE;
 
 	switch (type) {
+	case SYS_RES_IRQ:
+		rm = &irq_rman;
+		break;
+
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
 		rm = &mem_rman;