git: d9817976625f - main - intr/x86: replace use of vector in interface with intsrc

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 09 May 2024 23:20:50 UTC
The branch main has been updated by imp:

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

commit d9817976625ff9655f481066905cf9abac5520ab
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2024-05-09 23:04:35 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-09 23:15:07 +0000

    intr/x86: replace use of vector in interface with intsrc
    
    Several x86 interrupt core functions were already operating on intsrc
    structures.  Now switch the remaining 3 to intsrc for consistency.
    
    Swap the order of intr_add_handler()'s first two arguments.  This
    matches INTRNG and is more consistent with other functions in this
    interface.
    
    Differential Revision: https://reviews.freebsd.org/D35386
    Reviewed by: imp, markj (previous version)
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1126
---
 sys/x86/include/intr_machdep.h  | 10 +++++-----
 sys/x86/include/xen/arch-intr.h |  4 ++--
 sys/x86/x86/intr_machdep.c      | 19 ++++---------------
 sys/x86/x86/nexus.c             | 21 +++++++++++++++++----
 4 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/sys/x86/include/intr_machdep.h b/sys/x86/include/intr_machdep.h
index 64f0174ea637..d7bfcdc126a9 100644
--- a/sys/x86/include/intr_machdep.h
+++ b/sys/x86/include/intr_machdep.h
@@ -138,12 +138,12 @@ void	elcr_write_trigger(u_int irq, enum intr_trigger trigger);
 #ifdef SMP
 void	intr_add_cpu(u_int cpu);
 #endif
-int	intr_add_handler(const char *name, int vector, driver_filter_t filter,
-    driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep,
-    int domain);
-int	intr_config_intr(int vector, enum intr_trigger trig,
+int	intr_add_handler(struct intsrc *isrc, const char *name,
+     driver_filter_t filter, driver_intr_t handler, void *arg,
+     enum intr_type flags, void **cookiep, int domain);
+int	intr_config_intr(struct intsrc *isrc, enum intr_trigger trig,
     enum intr_polarity pol);
-int	intr_describe(u_int vector, void *ih, const char *descr);
+int	intr_describe(struct intsrc *isrc, void *ih, const char *descr);
 void	intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
 u_int	intr_next_cpu(int domain);
 struct intsrc *intr_lookup_source(int vector);
diff --git a/sys/x86/include/xen/arch-intr.h b/sys/x86/include/xen/arch-intr.h
index eae3994108cc..5ce0ca06e925 100644
--- a/sys/x86/include/xen/arch-intr.h
+++ b/sys/x86/include/xen/arch-intr.h
@@ -67,7 +67,7 @@ xen_arch_intr_add_handler(const char *name, driver_filter_t filter,
     struct xenisrc *isrc, void **cookiep)
 {
 
-	return (intr_add_handler(name, isrc->xi_arch.vector, filter, handler,
+	return (intr_add_handler(&isrc->xi_arch.intsrc, name, filter, handler,
 	    arg, flags, cookiep, 0));
 }
 
@@ -75,7 +75,7 @@ static inline int
 xen_arch_intr_describe(struct xenisrc *isrc, void *cookie, const char *descr)
 {
 
-	return (intr_describe(isrc->xi_arch.vector, cookie, descr));
+	return (intr_describe(&isrc->xi_arch.intsrc, cookie, descr));
 }
 
 static inline int
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c
index 458a0cb396bb..023c3df22580 100644
--- a/sys/x86/x86/intr_machdep.c
+++ b/sys/x86/x86/intr_machdep.c
@@ -255,16 +255,12 @@ intr_lookup_source(int vector)
 }
 
 int
-intr_add_handler(const char *name, int vector, driver_filter_t filter,
+intr_add_handler(struct intsrc *isrc, const char *name, driver_filter_t filter,
     driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep,
     int domain)
 {
-	struct intsrc *isrc;
 	int error;
 
-	isrc = intr_lookup_source(vector);
-	if (isrc == NULL)
-		return (EINVAL);
 	error = intr_event_add_handler(isrc->is_event, name, filter, handler,
 	    arg, intr_priority(flags), flags, cookiep);
 	if (error == 0) {
@@ -303,13 +299,10 @@ intr_remove_handler(void *cookie)
 }
 
 int
-intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol)
+intr_config_intr(struct intsrc *isrc, enum intr_trigger trig,
+    enum intr_polarity pol)
 {
-	struct intsrc *isrc;
 
-	isrc = intr_lookup_source(vector);
-	if (isrc == NULL)
-		return (EINVAL);
 	return (isrc->is_pic->pic_config_intr(isrc, trig, pol));
 }
 
@@ -513,14 +506,10 @@ atpic_reset(void)
 
 /* Add a description to an active interrupt handler. */
 int
-intr_describe(u_int vector, void *ih, const char *descr)
+intr_describe(struct intsrc *isrc, void *ih, const char *descr)
 {
-	struct intsrc *isrc;
 	int error;
 
-	isrc = intr_lookup_source(vector);
-	if (isrc == NULL)
-		return (EINVAL);
 	error = intr_event_describe_handler(isrc->is_event, ih, descr);
 	if (error)
 		return (error);
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
index 8f55b543eee2..aa62c920bcd8 100644
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -458,6 +458,7 @@ nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
 		 void *arg, void **cookiep)
 {
 	int		error, domain;
+	struct intsrc	*isrc;
 
 	/* somebody tried to setup an irq that failed to allocate! */
 	if (irq == NULL)
@@ -476,8 +477,11 @@ nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
 	if (bus_get_domain(child, &domain) != 0)
 		domain = 0;
 
-	error = intr_add_handler(device_get_nameunit(child),
-	    rman_get_start(irq), filter, ihand, arg, flags, cookiep, domain);
+	isrc = intr_lookup_source(rman_get_start(irq));
+	if (isrc == NULL)
+		return (EINVAL);
+	error = intr_add_handler(isrc, device_get_nameunit(child),
+	    filter, ihand, arg, flags, cookiep, domain);
 	if (error == 0)
 		rman_set_irq_cookie(irq, *cookiep);
 
@@ -524,15 +528,24 @@ static int
 nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
     enum intr_polarity pol)
 {
-	return (intr_config_intr(irq, trig, pol));
+	struct intsrc *isrc;
+
+	isrc = intr_lookup_source(irq);
+	if (isrc == NULL)
+		return (EINVAL);
+	return (intr_config_intr(isrc, trig, pol));
 }
 
 static int
 nexus_describe_intr(device_t dev, device_t child, struct resource *irq,
     void *cookie, const char *descr)
 {
+	struct intsrc *isrc;
 
-	return (intr_describe(rman_get_start(irq), cookie, descr));
+	isrc = intr_lookup_source(rman_get_start(irq));
+	if (isrc == NULL)
+		return (EINVAL);
+	return (intr_describe(isrc, cookie, descr));
 }
 
 static struct resource_list *