Module Name: src Committed By: knakahara Date: Wed Jun 26 10:20:06 UTC 2019
Modified Files: src/sys/arch/x86/pci: msipic.c Log Message: Fix updating "Multiple Message Enable" field for MSI multiple vectors. Pointed out by jmcneill@n.o, thanks. I tested ahcisata for MSI single vector regression. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/pci/msipic.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.16 src/sys/arch/x86/pci/msipic.c:1.17 --- src/sys/arch/x86/pci/msipic.c:1.16 Tue Jun 18 10:06:49 2019 +++ src/sys/arch/x86/pci/msipic.c Wed Jun 26 10:20:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: msipic.c,v 1.16 2019/06/18 10:06:49 msaitoh Exp $ */ +/* $NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.16 2019/06/18 10:06:49 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $"); #include "opt_intrdebug.h" @@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1 #include <sys/errno.h> #include <sys/kmem.h> #include <sys/mutex.h> +#include <sys/bitops.h> #include <dev/pci/pcivar.h> @@ -754,6 +755,25 @@ msipic_set_msi_vectors(struct pic *msi_p KASSERT(msipic_is_msi_pic(msi_pic)); + if (msi_pic->pic_type == PIC_MSI) { + pci_chipset_tag_t pc; + struct pci_attach_args *pa; + pcitag_t tag; + int off, err __diagused; + pcireg_t ctl; + + pc = NULL; + pa = &msi_pic->pic_msipic->mp_pa; + tag = pa->pa_tag; + err = pci_get_capability(pc, tag, PCI_CAP_MSI, &off, NULL); + KASSERT(err != 0); + + ctl = pci_conf_read(pc, tag, off + PCI_MSI_CTL); + ctl &= ~PCI_MSI_CTL_MME_MASK; + ctl |= __SHIFTIN(ilog2(count), PCI_MSI_CTL_MME_MASK); + pci_conf_write(pc, tag, off + PCI_MSI_CTL, ctl); + } + msi_pic->pic_msipic->mp_veccnt = count; return 0; }