aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_intr.c
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2019-03-24 17:53:26 +0000
committerIan Lepore <ian@FreeBSD.org>2019-03-24 17:53:26 +0000
commit67da50a047d459c59fed2da51e7a3297b827a253 (patch)
tree09f8c3fa09e1e7bb7d1c215c33d26044da743faa /sys/kern/kern_intr.c
parent425c24e5da3fdd2a716d9f545faafddcac99334b (diff)
downloadsrc-67da50a047d459c59fed2da51e7a3297b827a253.tar.gz
src-67da50a047d459c59fed2da51e7a3297b827a253.zip
Truncate a too-long interrupt handler name when there is only one handler.
There are only 19 bytes available for the name of an interrupt plus the name(s) of handlers/drivers using it. There is a mechanism from the days of shared interrupts that replaces some of the handler names with '+' when they don't all fit into 19 bytes. In modern times there is typically only one device on an interrupt, but long device names are the norm, especially with embedded systems. Also, in systems with multiple interrupt controllers, the names of the interrupts themselves can be long. For example, 'gic0,s54: imx6_anatop0' doesn't fit, and replacing the device driver name with a '+' provides no useful info at all. When there is only one handler but its name was too long to fit, this change truncates enough leading chars of the handler name (replacing them with a '-' char to indicate that some chars are missing) to use all 19 bytes, preserving the unit number typically on the end of the name. Using the prior example, this results in: 'gic0,s54:-6_anatop0' which provides plenty of info to figure out which device is involved. PR: 211946 Reviewed by: gonzo@ (prior version without the '-' char) Differential Revision: https://reviews.freebsd.org/D19675
Notes
Notes: svn path=/head/; revision=345475
Diffstat (limited to 'sys/kern/kern_intr.c')
-rw-r--r--sys/kern/kern_intr.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index 97691cf2c53b..91be14a9c5f0 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -197,7 +197,7 @@ intr_event_update(struct intr_event *ie)
/* Run through all the handlers updating values. */
CK_SLIST_FOREACH(ih, &ie->ie_handlers, ih_next) {
- if (strlen(ie->ie_fullname) + strlen(ih->ih_name) + 1 <
+ if (strlen(ie->ie_fullname) + strlen(ih->ih_name) + 2 <
sizeof(ie->ie_fullname)) {
strcat(ie->ie_fullname, " ");
strcat(ie->ie_fullname, ih->ih_name);
@@ -209,10 +209,20 @@ intr_event_update(struct intr_event *ie)
}
/*
- * If the handler names were too long, add +'s to indicate missing
- * names. If we run out of room and still have +'s to add, change
- * the last character from a + to a *.
+ * If there is only one handler and its name is too long, just copy in
+ * as much of the end of the name (includes the unit number) as will
+ * fit. Otherwise, we have multiple handlers and not all of the names
+ * will fit. Add +'s to indicate missing names. If we run out of room
+ * and still have +'s to add, change the last character from a + to a *.
*/
+ if (missed == 1 && space == 1) {
+ ih = CK_SLIST_FIRST(&ie->ie_handlers);
+ missed = strlen(ie->ie_fullname) + strlen(ih->ih_name) + 2 -
+ sizeof(ie->ie_fullname);
+ strcat(ie->ie_fullname, (missed == 0) ? " " : "-");
+ strcat(ie->ie_fullname, &ih->ih_name[missed]);
+ missed = 0;
+ }
last = &ie->ie_fullname[sizeof(ie->ie_fullname) - 2];
while (missed-- > 0) {
if (strlen(ie->ie_fullname) + 1 == sizeof(ie->ie_fullname)) {