git: 09bd542d17c9 - main - xen/intr: rework xen_intr_alloc_isrc() call structure
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Apr 2023 14:00:54 UTC
The branch main has been updated by royger:
URL: https://cgit.FreeBSD.org/src/commit/?id=09bd542d17c938b236822d1dd09ef0bab8c1de04
commit 09bd542d17c938b236822d1dd09ef0bab8c1de04
Author: Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2021-05-11 19:05:03 +0000
Commit: Roger Pau Monné <royger@FreeBSD.org>
CommitDate: 2023-04-14 13:58:49 +0000
xen/intr: rework xen_intr_alloc_isrc() call structure
The call structure around xen_intr_alloc_isrc() was rather awful.
Notably finding a structure for reuse is part of allocation, but this
was done outside xen_intr_alloc_isrc(). Move this into
xen_intr_alloc_isrc() so the function handles all allocation steps.
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D30726
---
sys/x86/xen/xen_intr.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c
index c1ca984bf6ef..6e4b1d9df1f8 100644
--- a/sys/x86/xen/xen_intr.c
+++ b/sys/x86/xen/xen_intr.c
@@ -318,6 +318,10 @@ xen_intr_alloc_isrc(enum evtchn_type type)
int error;
KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held"));
+ isrc = xen_intr_find_unused_isrc(type);
+ if (isrc != NULL) {
+ return (isrc);
+ }
if (xen_intr_auto_vector_count >= NR_EVENT_CHANNELS) {
if (!warned) {
@@ -424,13 +428,10 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port,
*port_handlep = NULL;
mtx_lock(&xen_intr_isrc_lock);
- isrc = xen_intr_find_unused_isrc(type);
+ isrc = xen_intr_alloc_isrc(type);
if (isrc == NULL) {
- isrc = xen_intr_alloc_isrc(type);
- if (isrc == NULL) {
- mtx_unlock(&xen_intr_isrc_lock);
- return (ENOSPC);
- }
+ mtx_unlock(&xen_intr_isrc_lock);
+ return (ENOSPC);
}
isrc->xi_port = local_port;
isrc->xi_close = false;