From 117a6cdd67438bcc1fe4afc227ee54ebac392181 Mon Sep 17 00:00:00 2001 From: knakahara Date: Fri, 15 May 2015 08:36:41 +0000 Subject: [PATCH] pci_msi_string() must be used by MD code only. --- sys/arch/x86/include/pci_machdep_common.h | 3 +- sys/arch/x86/pci/pci_intr_machdep.c | 10 ++-- sys/arch/x86/pci/pci_msi_machdep.c | 56 +++++++++++------------ sys/arch/x86/pci/pci_msi_machdep.h | 4 +- sys/arch/x86/x86/intr.c | 7 +-- 5 files changed, 41 insertions(+), 39 deletions(-) diff --git a/sys/arch/x86/include/pci_machdep_common.h b/sys/arch/x86/include/pci_machdep_common.h index 9835c39bcc05..521635be244c 100644 --- a/sys/arch/x86/include/pci_machdep_common.h +++ b/sys/arch/x86/include/pci_machdep_common.h @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep_common.h,v 1.17 2015/05/15 08:26:44 knakahara Exp $ */ +/* $NetBSD: pci_machdep_common.h,v 1.18 2015/05/15 08:36:41 knakahara Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -129,7 +129,6 @@ int pci_intx_alloc(const struct pci_attach_args *, pci_intr_handle_t **); /* experimental MSI support */ -const char *pci_msi_string(pci_chipset_tag_t, pci_intr_handle_t, char *, size_t); int pci_msi_count(const struct pci_attach_args *); int pci_msi_alloc(const struct pci_attach_args *, pci_intr_handle_t **, int *); diff --git a/sys/arch/x86/pci/pci_intr_machdep.c b/sys/arch/x86/pci/pci_intr_machdep.c index b81e5c22e160..14e5e0f7ea1c 100644 --- a/sys/arch/x86/pci/pci_intr_machdep.c +++ b/sys/arch/x86/pci/pci_intr_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.33 2015/05/15 08:36:41 knakahara Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.33 2015/05/15 08:36:41 knakahara Exp $"); #include #include @@ -226,9 +226,6 @@ pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, { pci_chipset_tag_t ipc; - if (INT_VIA_MSI(ih)) - return pci_msi_string(pc, ih, buf, len); - for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) { if ((ipc->pc_present & PCI_OVERRIDE_INTR_STRING) == 0) continue; @@ -236,6 +233,9 @@ pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, buf, len); } + if (INT_VIA_MSI(ih)) + return x86_pci_msi_string(pc, ih, buf, len); + return intr_string(ih & ~MPSAFE_MASK, buf, len); } diff --git a/sys/arch/x86/pci/pci_msi_machdep.c b/sys/arch/x86/pci/pci_msi_machdep.c index c4a0be1a86a0..761d147df202 100644 --- a/sys/arch/x86/pci/pci_msi_machdep.c +++ b/sys/arch/x86/pci/pci_msi_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $ */ +/* $NetBSD: pci_msi_machdep.c,v 1.5 2015/05/15 08:36:41 knakahara Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.5 2015/05/15 08:36:41 knakahara Exp $"); #include #include @@ -65,28 +65,6 @@ __KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahar #define DPRINTF(msg) #endif -/* - * Return intrid for a MSI/MSI-X device. - * "buf" must be allocated by caller. - */ -const char * -pci_msi_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, - size_t len) -{ - int dev, vec; - - KASSERT(INT_VIA_MSI(ih)); - - dev = MSI_INT_DEV(ih); - vec = MSI_INT_VEC(ih); - if (MSI_INT_IS_MSIX(ih)) - snprintf(buf, len, "msix%d vec %d", dev, vec); - else - snprintf(buf, len, "msi%d vec %d", dev, vec); - - return buf; -} - static pci_intr_handle_t pci_msi_calculate_handle(struct pic *msi_pic, int vector) { @@ -134,7 +112,7 @@ pci_msi_alloc_vectors(struct pic *msi_pic, uint *table_indexes, int *count) pih = pci_msi_calculate_handle(msi_pic, table_index); - intrstr = pci_msi_string(NULL, pih, intrstr_buf, + intrstr = x86_pci_msi_string(NULL, pih, intrstr_buf, sizeof(intrstr_buf)); isp = intr_allocate_io_intrsource(intrstr); if (isp == NULL) { @@ -162,7 +140,7 @@ pci_msi_free_vectors(struct pic *msi_pic, pci_intr_handle_t *pihs, int count) mutex_enter(&cpu_lock); for (i = 0; i < count; i++) { pih = pci_msi_calculate_handle(msi_pic, i); - intrstr = pci_msi_string(NULL, pih, intrstr_buf, + intrstr = x86_pci_msi_string(NULL, pih, intrstr_buf, sizeof(intrstr_buf)); intr_free_io_intrsource(intrstr); } @@ -372,9 +350,31 @@ x86_pci_msix_release_internal(pci_intr_handle_t *pihs, int count) /*****************************************************************************/ /* - * extern for pci_intr_machdep.c + * extern for MD code. */ +/* + * Return intrid for a MSI/MSI-X device. + * "buf" must be allocated by caller. + */ +const char * +x86_pci_msi_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, + size_t len) +{ + int dev, vec; + + KASSERT(INT_VIA_MSI(ih)); + + dev = MSI_INT_DEV(ih); + vec = MSI_INT_VEC(ih); + if (MSI_INT_IS_MSIX(ih)) + snprintf(buf, len, "msix%d vec %d", dev, vec); + else + snprintf(buf, len, "msi%d vec %d", dev, vec); + + return buf; +} + /* * Release MSI handles. */ @@ -467,7 +467,7 @@ x86_pci_msix_disestablish(pci_chipset_tag_t pc, void *cookie) /*****************************************************************************/ /* - * these APIs may be MI code. + * extern for MI code. */ /* diff --git a/sys/arch/x86/pci/pci_msi_machdep.h b/sys/arch/x86/pci/pci_msi_machdep.h index 6ffffee34574..f20ce492a9e8 100644 --- a/sys/arch/x86/pci/pci_msi_machdep.h +++ b/sys/arch/x86/pci/pci_msi_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: pci_msi_machdep.h,v 1.1 2015/05/15 08:26:44 knakahara Exp $ */ +/* $NetBSD: pci_msi_machdep.h,v 1.2 2015/05/15 08:36:41 knakahara Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. @@ -29,6 +29,8 @@ #ifndef _X86_PCI_PCI_MSI_MACHDEP_H_ #define _X86_PCI_PCI_MSI_MACHDEP_H_ +const char *x86_pci_msi_string(pci_chipset_tag_t, pci_intr_handle_t, + char *, size_t); void x86_pci_msi_release(pci_chipset_tag_t, pci_intr_handle_t *, int); void *x86_pci_msi_establish(pci_chipset_tag_t, pci_intr_handle_t, diff --git a/sys/arch/x86/x86/intr.c b/sys/arch/x86/x86/intr.c index 6581f94ed4f2..7b4aa4533676 100644 --- a/sys/arch/x86/x86/intr.c +++ b/sys/arch/x86/x86/intr.c @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.84 2015/05/09 13:05:51 christos Exp $ */ +/* $NetBSD: intr.c,v 1.85 2015/05/15 08:36:41 knakahara Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.84 2015/05/09 13:05:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.85 2015/05/15 08:36:41 knakahara Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -177,6 +177,7 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.84 2015/05/09 13:05:51 christos Exp $"); #endif #include +#include #if NPCI == 0 #define msipic_is_msi_pic(PIC) (false) @@ -487,7 +488,7 @@ create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len) else if (pic->pic_type == PIC_MSIX) MSI_INT_MAKE_MSIX(pih); - return pci_msi_string(NULL, pih, buf, len); + return x86_pci_msi_string(NULL, pih, buf, len); } #endif