novena-next / docs

MIT License
13 stars 3 forks source link

Update irqbalanced #16

Open Jookia opened 4 years ago

Jookia commented 4 years ago

The novena irqbalanced port includes changes to balance i.MX6 interrupts. Port these to a newer irqbalance. Here's a quick and dirty patch I did a long time ago that kind of shows what needs to be done, based on top of irqbalance's git commit c63839ce3615e5430f6d549d75cb3e4e474306ea

commit e3a7593ee22585028565ebb7275a90ec48aa4176 (HEAD -> tmp)
Author: root <root@novena-choice-citizen-recovery.gateway>
Date:   Sun Jul 15 20:26:36 2018 +1000

    t

diff --git a/irqbalance.h b/irqbalance.h
index b7a26fc..ddbf47d 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -15,8 +15,8 @@
 #include "types.h"
 #include "config.h"

-#ifdef __aarch64__
-#define AARCH64
+#if defined(__aarch64__) || defined(__arm__)
+#define ARM
 #endif

 #ifdef HAVE_NUMA_H
diff --git a/procinterrupts.c b/procinterrupts.c
index 7283998..714fdd5 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -32,7 +32,7 @@
 #include "cpumask.h"
 #include "irqbalance.h"

-#ifdef AARCH64
+#ifdef ARM
 #include <sys/types.h>
 #include <regex.h>
 #include <dirent.h>
@@ -43,7 +43,7 @@
 static int proc_int_has_msi = 0;
 static int msi_found_in_sysfs = 0;

-#ifdef AARCH64
+#ifdef ARM
 struct irq_match {
        char *matchstring;
        regex_t rcomp;
@@ -110,6 +110,16 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
                { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
                { "[A-Z0-9]{4}[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
                { "PNP[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
+               { "PS/2|serial|i8042|acpi|floppy|parport|keyboard|usb|usb-ohci|usb-uhci|uhci_hcd|ohci_hcd|ehci_hcd|EMU11K1|ci_hdrc",
commit e3a7593ee22585028565ebb7275a90ec48aa4176 (HEAD -> tmp)
Author: root <root@novena-choice-citizen-recovery.gateway>
Date:   Sun Jul 15 20:26:36 2018 +1000

    t

diff --git a/irqbalance.h b/irqbalance.h
index b7a26fc..ddbf47d 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -15,8 +15,8 @@
 #include "types.h"
 #include "config.h"

-#ifdef __aarch64__
-#define AARCH64
+#if defined(__aarch64__) || defined(__arm__)
+#define ARM
 #endif

 #ifdef HAVE_NUMA_H
diff --git a/procinterrupts.c b/procinterrupts.c
index 7283998..714fdd5 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -32,7 +32,7 @@
 #include "cpumask.h"
 #include "irqbalance.h"

-#ifdef AARCH64
+#ifdef ARM
 #include <sys/types.h>
 #include <regex.h>
 #include <dirent.h>
@@ -43,7 +43,7 @@
 static int proc_int_has_msi = 0;
 static int msi_found_in_sysfs = 0;

-#ifdef AARCH64
+#ifdef ARM
 struct irq_match {
        char *matchstring;
        regex_t rcomp;
@@ -110,6 +110,16 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
                { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
                { "[A-Z0-9]{4}[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
                { "PNP[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
+               { "PS/2|serial|i8042|acpi|floppy|parport|keyboard|usb|usb-ohci|usb-uhci|uhci_hcd|ohci_hcd|ehci_hcd|EMU11K1|ci_hdrc",
+                       {NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_LEGACY },
+               { "rtc|timer|twd",
+                       {NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_LEGACY },
+               { "aic7xxx|aic79xx|ide|cciss|cpqarray|qla2|megaraid|fusion|libata|ohci1394|sym53c8xx|ahci|mmc",
+                       {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_SCSI },
+               { "e100|eepro100|orinoco_cs|wvlan_cs|3c5|HiSax|skge|sky2",
+                       {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
+               { "VPU|vpu|ipu|galcore|hdmi|spdif|gpu|imx_drm",
+                       {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_VIDEO },
                { ".*", {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER},
                {NULL},
        };
@@ -137,6 +147,7 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
                        if (matches[i].refine_match)
                            matches[i].refine_match(name, info);
                        log(TO_ALL, LOG_DEBUG, "IRQ %s(%d) guessed as class %d\n", name, info->irq,info->class);
+                       break;
                }       
        }

@@ -151,7 +162,7 @@ GList* collect_full_irq_list()
        char *line = NULL;
        size_t size = 0;
        char *irq_name, *irq_mod, *savedptr, *last_token, *p;
-#ifdef AARCH64
+#ifdef ARM
        char *tmp;
 #endif

@@ -194,7 +205,7 @@ GList* collect_full_irq_list()
                        last_token = p;
                }

-#ifdef AARCH64
+#ifdef ARM
                /* Of course the formatting for /proc/interrupts is different on different arches */
                irq_name = last_token;
                tmp = strchr(irq_name, '\n');
@@ -214,7 +225,7 @@ GList* collect_full_irq_list()
                                info->type = IRQ_TYPE_VIRT_EVENT;
                                info->class = IRQ_VIRT_EVENT;
                        } else {
-#ifdef AARCH64
+#ifdef ARM
                                guess_arm_irq_hints(irq_name, info);
 #else
                                info->type = IRQ_TYPE_LEGACY;