Module Name:    src
Committed By:   snj
Date:           Sun Oct  4 00:03:20 UTC 2009

Modified Files:
        src/sys/arch/xen/x86 [netbsd-5]: intr.c
        src/sys/arch/xen/xen [netbsd-5]: isa_machdep.c pci_intr_machdep.c
            pciide_machdep.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1054):
        sys/arch/xen/x86/intr.c: revision 1.22
        sys/arch/xen/xen/isa_machdep.c: revision 1.14
        sys/arch/xen/xen/pci_intr_machdep.c: revision 1.9
        sys/arch/xen/xen/pciide_machdep.c: revision 1.12
When ioapic is used, for ISA interrupts, reuse the legacy ISA interrupt
number instead of allocating a new one. Force allocating a new interrupt number
for PCI devices, as the number stored in the PCI interrupt register
may be wrong.
This should help using a pciide controller in compat mode or ISA devices
in a non-0 domain.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/arch/xen/x86/intr.c
cvs rdiff -u -r1.12 -r1.12.6.1 src/sys/arch/xen/xen/isa_machdep.c
cvs rdiff -u -r1.7.6.1 -r1.7.6.2 src/sys/arch/xen/xen/pci_intr_machdep.c
cvs rdiff -u -r1.11 -r1.11.6.1 src/sys/arch/xen/xen/pciide_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/intr.c
diff -u src/sys/arch/xen/x86/intr.c:1.21 src/sys/arch/xen/x86/intr.c:1.21.4.1
--- src/sys/arch/xen/x86/intr.c:1.21	Fri Sep  5 13:37:24 2008
+++ src/sys/arch/xen/x86/intr.c	Sun Oct  4 00:03:19 2009
@@ -103,7 +103,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2008/09/05 13:37:24 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21.4.1 2009/10/04 00:03:19 snj Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -268,12 +268,14 @@
 		irq = vect2irq[ioapic->sc_pins[pin].ip_vector];
 		if (ioapic->sc_pins[pin].ip_vector == 0 || irq == 0) {
 			/* allocate IRQ */
-			irq = xen_next_irq--;
+			irq = APIC_IRQ_LEGACY_IRQ(*pirq);
+			if (irq <= 0 || irq > 15)
+				irq = xen_next_irq--;
 			/* allocate vector and route interrupt */
 			op.cmd = PHYSDEVOP_ASSIGN_VECTOR;
 			op.u.irq_op.irq = irq;
 			if (HYPERVISOR_physdev_op(&op) < 0)
-				panic("PHYSDEVOP_ASSIGN_VECTOR");
+				panic("PHYSDEVOP_ASSIGN_VECTOR irq %d", irq);
 			irq2vect[irq] = op.u.irq_op.vector;
 			vect2irq[op.u.irq_op.vector] = irq;
 			pic->pic_addroute(pic, &phycpu_info_primary, pin,

Index: src/sys/arch/xen/xen/isa_machdep.c
diff -u src/sys/arch/xen/xen/isa_machdep.c:1.12 src/sys/arch/xen/xen/isa_machdep.c:1.12.6.1
--- src/sys/arch/xen/xen/isa_machdep.c:1.12	Thu Jul  3 15:44:19 2008
+++ src/sys/arch/xen/xen/isa_machdep.c	Sun Oct  4 00:03:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: isa_machdep.c,v 1.12 2008/07/03 15:44:19 drochner Exp $	*/
+/*	$NetBSD: isa_machdep.c,v 1.12.6.1 2009/10/04 00:03:20 snj Exp $	*/
 /*	NetBSD isa_machdep.c,v 1.11 2004/06/20 18:04:08 thorpej Exp 	*/
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.12 2008/07/03 15:44:19 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.12.6.1 2009/10/04 00:03:20 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -159,7 +159,7 @@
 	struct ioapic_softc *pic = NULL;
 #endif
 
-	ih.pirq = irq;
+	ih.pirq = 0;
 
 #if NIOAPIC > 0
 	if (mp_busses != NULL) {
@@ -178,6 +178,7 @@
 			printf("isa_intr_establish: no MP mapping found\n");
 	}
 #endif
+	ih.pirq |= (irq & 0xff);
 
 	evtch = xen_intr_map(&ih.pirq, type);
 	if (evtch == -1)

Index: src/sys/arch/xen/xen/pci_intr_machdep.c
diff -u src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.1 src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.2
--- src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.1	Sat Oct  3 23:54:05 2009
+++ src/sys/arch/xen/xen/pci_intr_machdep.c	Sun Oct  4 00:03:20 2009
@@ -1,4 +1,4 @@
-/*      $NetBSD: pci_intr_machdep.c,v 1.7.6.1 2009/10/03 23:54:05 snj Exp $      */
+/*      $NetBSD: pci_intr_machdep.c,v 1.7.6.2 2009/10/04 00:03:20 snj Exp $      */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.7.6.1 2009/10/03 23:54:05 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.7.6.2 2009/10/04 00:03:20 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -109,8 +109,8 @@
 	pci_decompose_tag(pc, pa->pa_tag, &bus, &dev, &func);
 	if (mp_busses != NULL) {
 		if (intr_find_mpmapping(bus, (dev<<2)|(rawpin-1), ihp) == 0) {
-			if ((ihp->pirq & 0xff) == 0)
-				ihp->pirq |= line;
+			/* make sure a new IRQ will be allocated */
+			ihp->pirq &= ~0xff;
 			goto end;
 		}
 		/*

Index: src/sys/arch/xen/xen/pciide_machdep.c
diff -u src/sys/arch/xen/xen/pciide_machdep.c:1.11 src/sys/arch/xen/xen/pciide_machdep.c:1.11.6.1
--- src/sys/arch/xen/xen/pciide_machdep.c:1.11	Thu Jul  3 15:44:19 2008
+++ src/sys/arch/xen/xen/pciide_machdep.c	Sun Oct  4 00:03:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_machdep.c,v 1.11 2008/07/03 15:44:19 drochner Exp $	*/
+/*	$NetBSD: pciide_machdep.c,v 1.11.6.1 2009/10/04 00:03:20 snj Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.11 2008/07/03 15:44:19 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.11.6.1 2009/10/04 00:03:20 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,11 +89,12 @@
 	if (HYPERVISOR_physdev_op(&physdev_op) < 0)
 		panic("HYPERVISOR_physdev_op(PHYSDEVOP_PCI_INITIALISE_DEVICE)");
 #endif /* !XEN3 */
-	xenih.pirq = PCIIDE_COMPAT_IRQ(chan);
+	xenih.pirq = 0;
 #if NIOAPIC > 0
 	if (mp_busses != NULL) {
-		if (intr_find_mpmapping(mp_isa_bus, xenih.pirq, &xenih) == 0 ||
-		    intr_find_mpmapping(mp_eisa_bus, xenih.pirq, &xenih) == 0) {
+		int irq = PCIIDE_COMPAT_IRQ(chan);
+		if (intr_find_mpmapping(mp_isa_bus, irq, &xenih) == 0 ||
+		    intr_find_mpmapping(mp_eisa_bus, irq, &xenih) == 0) {
 			if (!APIC_IRQ_ISLEGACY(xenih.pirq)) {
 				pic = ioapic_find(APIC_IRQ_APIC(xenih.pirq));
 				if (pic == NULL) {
@@ -108,6 +109,7 @@
 			    "no MP mapping found\n");
 	}
 #endif
+	xenih.pirq |= PCIIDE_COMPAT_IRQ(chan);
 	evtch = xen_intr_map(&xenih.pirq, IST_EDGE);
 	if (evtch == -1)
 		return NULL;

Reply via email to