pci_msi_string() must be used by MD code only.

This commit is contained in:
knakahara 2015-05-15 08:36:41 +00:00
parent 6d12998d34
commit 117a6cdd67
5 changed files with 41 additions and 39 deletions

View File

@ -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 *);

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/param.h>
@ -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);
}

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/param.h>
@ -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.
*/
/*

View File

@ -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,

View File

@ -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 <sys/cdefs.h>
__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 <x86/pci/msipic.h>
#include <x86/pci/pci_msi_machdep.h>
#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