ref: 0f56fefd45ab50ddc28c062b492b64a17c26e08a
parent: 2594b99629957d8ce380157e9af4a5feff86c5fe
author: cinap_lenrek <[email protected]>
date: Sat Nov 21 16:48:25 EST 2020
pc, pc64: implement disabling of msi interrupts
--- a/sys/src/9/pc/io.h
+++ b/sys/src/9/pc/io.h
@@ -48,15 +48,19 @@
typedef struct Vctl {
Vctl* next; /* handlers on this vector */
- char name[KNAMELEN]; /* of driver */
+ void (*f)(Ureg*, void*); /* handler to call */
+ void* a; /* argument to call it with */
+
int isintr; /* interrupt or fault/trap */
- int irq;
- int tbdf;
+
int (*isr)(int); /* get isr bit for this irq */
int (*eoi)(int); /* eoi */
- void (*f)(Ureg*, void*); /* handler to call */
- void* a; /* argument to call it with */
+ void (*disable)(Vctl*);
+ int irq;
+ int tbdf;
+
+ char name[KNAMELEN]; /* of driver */
} Vctl;
enum {
--- a/sys/src/9/pc/mp.c
+++ b/sys/src/9/pc/mp.c
@@ -469,6 +469,15 @@
return -1;
}
+static void
+msiintrdisable(Vctl *v)
+{
+ Pcidev *pci;
+
+ if((pci = pcimatchtbdf(v->tbdf)) != nil)
+ pcimsidisable(pci);
+}
+
static int
msiintrenable(Vctl *v)
{
@@ -493,6 +502,7 @@
cpu = mpintrcpu();
if(pcimsienable(pci, 0xFEE00000ULL | (cpu << 12), vno | (1<<14)) < 0)
return -1;
+ v->disable = msiintrdisable;
v->isr = lapicisr;
v->eoi = lapiceoi;
return vno;
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -89,8 +89,7 @@
irq = 9;
if(arch->intrvecno == nil || (tbdf != BUSUNKNOWN && (irq == 0xff || irq == 0))){
/*
- * on APIC machine, irq is pretty meaningless
- * and disabling a the vector is not implemented.
+ * on APIC machine, irq is pretty meaningless.
* however, we still want to remove the matching
* Vctl entry to prevent calling Vctl.f() with a
* stale Vctl.a pointer.
@@ -109,6 +108,8 @@
break;
}
if(v != nil){
+ if(v->disable != nil)
+ (*v->disable)(v);
*pv = v->next;
xfree(v);
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -111,6 +111,8 @@
break;
}
if(v != nil){
+ if(v->disable != nil)
+ (*v->disable)(v);
*pv = v->next;
xfree(v);