Module Name: src Committed By: bouyer Date: Tue May 24 14:00:24 UTC 2022
Modified Files: src/sys/arch/x86/pci: msipic.c pci_machdep.c src/sys/arch/xen/x86: pintr.c xen_intr.c Log Message: - msipic_construct_msix_pic(): set mp_table_base to memaddr (without table_offset), this is what Xen wants while there use pci_conf_write16() in msi_set_msictl_enablebit() too, for consistency (it seems that Xen accepts the 32bit write at this point, but this may change). - xen_map_msix_pirq(): don't forget to set map_irq.table_base in the MSI-X case, otherwise Xen maps it as MSI - call pic_hwunmask() after pirq_establish() in msi/msix case, to make sure the msi-x vector is unmasked. Now MSI-X works with Xen so stop disabling it in pci_attach_hook(). To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/pci/msipic.c cvs rdiff -u -r1.90 -r1.91 src/sys/arch/x86/pci/pci_machdep.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/x86/pintr.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/xen/x86/xen_intr.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/x86/pci/msipic.c diff -u src/sys/arch/x86/pci/msipic.c:1.26 src/sys/arch/x86/pci/msipic.c:1.27 --- src/sys/arch/x86/pci/msipic.c:1.26 Mon May 23 15:03:05 2022 +++ src/sys/arch/x86/pci/msipic.c Tue May 24 14:00:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: msipic.c,v 1.26 2022/05/23 15:03:05 bouyer Exp $ */ +/* $NetBSD: msipic.c,v 1.27 2022/05/24 14:00:23 bouyer Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.26 2022/05/23 15:03:05 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.27 2022/05/24 14:00:23 bouyer Exp $"); #include "opt_intrdebug.h" @@ -356,7 +356,11 @@ msi_set_msictl_enablebit(struct pic *pic else ctl &= ~PCI_MSI_CTL_MSI_ENABLE; +#ifdef XENPV + pci_conf_write16(pc, tag, off + PCI_MSI_CTL + 2, ctl >> 16); +#else pci_conf_write(pc, tag, off, ctl); +#endif } static void @@ -771,7 +775,7 @@ msipic_construct_msix_pic(const struct p msix_pic->pic_msipic->mp_bstag = bstag; msix_pic->pic_msipic->mp_bshandle = bshandle; msix_pic->pic_msipic->mp_bssize = bssize; - msix_pic->pic_msipic->mp_i.mp_table_base = memaddr + table_offset; + msix_pic->pic_msipic->mp_i.mp_table_base = memaddr; return msix_pic; } Index: src/sys/arch/x86/pci/pci_machdep.c diff -u src/sys/arch/x86/pci/pci_machdep.c:1.90 src/sys/arch/x86/pci/pci_machdep.c:1.91 --- src/sys/arch/x86/pci/pci_machdep.c:1.90 Mon May 23 15:03:05 2022 +++ src/sys/arch/x86/pci/pci_machdep.c Tue May 24 14:00:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.90 2022/05/23 15:03:05 bouyer Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.91 2022/05/24 14:00:23 bouyer Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.90 2022/05/23 15:03:05 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.91 2022/05/24 14:00:23 bouyer Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -565,14 +565,6 @@ pci_attach_hook(device_t parent, device_ } } -#ifdef XENPV - /* - * XXX MSI-X doesn't work for XenPV yet - setup seems to be correct, - * XXX but no interrupts are actually delivered. - */ - pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY; -#endif - #endif /* __HAVE_PCI_MSI_MSIX */ } Index: src/sys/arch/xen/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.21 src/sys/arch/xen/x86/pintr.c:1.22 --- src/sys/arch/xen/x86/pintr.c:1.21 Mon May 23 15:03:05 2022 +++ src/sys/arch/xen/x86/pintr.c Tue May 24 14:00:23 2022 @@ -103,7 +103,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.21 2022/05/23 15:03:05 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.22 2022/05/24 14:00:23 bouyer Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -234,9 +234,11 @@ xen_map_msix_pirq(struct pic *pic, int c map_irq.pirq = -1; map_irq.bus = msi_i->mp_bus; map_irq.devfn = (msi_i->mp_dev << 3) | msi_i->mp_fun; - aprint_debug("xen_map_msix_pirq bus %d devfn 0x%x (%d %d) count %d", + map_irq.table_base = msi_i->mp_table_base; + + aprint_debug("xen_map_msix_pirq bus %d devfn 0x%x (%d %d) count %d base 0x%lx", map_irq.bus, map_irq.devfn, msi_i->mp_dev, msi_i->mp_fun, - count); + count, map_irq.table_base); for (i = 0; i < count; i++) { map_irq.entry_nr = i; Index: src/sys/arch/xen/x86/xen_intr.c diff -u src/sys/arch/xen/x86/xen_intr.c:1.29 src/sys/arch/xen/x86/xen_intr.c:1.30 --- src/sys/arch/xen/x86/xen_intr.c:1.29 Mon Aug 9 21:20:50 2021 +++ src/sys/arch/xen/x86/xen_intr.c Tue May 24 14:00:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.29 2021/08/09 21:20:50 andvar Exp $ */ +/* $NetBSD: xen_intr.c,v 1.30 2022/05/24 14:00:23 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.29 2021/08/09 21:20:50 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.30 2022/05/24 14:00:23 bouyer Exp $"); #include "opt_multiprocessor.h" #include "opt_pci.h" @@ -167,6 +167,8 @@ xen_intr_establish_xname(int legacy_irq, "non-legacy IRQon i8259 "); gsi = xen_pic_to_gsi(pic, pin); + if (gsi < 0) + return NULL; KASSERTMSG(gsi < NR_EVENT_CHANNELS, "gsi %d >= NR_EVENT_CHANNELS %u", gsi, (int)NR_EVENT_CHANNELS); @@ -195,6 +197,8 @@ xen_intr_establish_xname(int legacy_irq, pih = pirq_establish(gsi, evtchn, handler, arg, level, intrstr, xname, mpsafe); pih->pic = pic; + if (msipic_is_msi_pic(pic)) + pic->pic_hwunmask(pic, pin); return pih; #endif /* NPCI > 0 || NISA > 0 */