Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add pci_intr_distribute(9) for x86.



details:   https://anonhg.NetBSD.org/src/rev/97e4b38333a0
branches:  trunk
changeset: 807914:97e4b38333a0
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Apr 27 06:42:52 2015 +0000

description:
add pci_intr_distribute(9) for x86.

diffstat:

 distrib/sets/lists/comp/mi                |    4 +-
 share/man/man9/Makefile                   |   11 +-
 share/man/man9/pci_intr_distribute.9      |   53 ++
 sys/arch/x86/include/intr.h               |   15 +-
 sys/arch/x86/include/intr_distribute.h    |   40 ++
 sys/arch/x86/include/pci_machdep.h        |    4 +-
 sys/arch/x86/include/pci_machdep_common.h |    5 +-
 sys/arch/x86/pci/pci_intr_machdep.c       |   15 +-
 sys/arch/x86/x86/intr.c                   |  544 ++++++++++++++++++++++++++++-
 sys/kern/kern_stub.c                      |    6 +-
 sys/sys/intr.h                            |    4 +-
 11 files changed, 666 insertions(+), 35 deletions(-)

diffs (truncated from 1075 to 300 lines):

diff -r 4aa0e0e5c64a -r 97e4b38333a0 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Mon Apr 27 02:59:44 2015 +0000
+++ b/distrib/sets/lists/comp/mi        Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.1954 2015/04/21 11:10:29 pooka Exp $
+#      $NetBSD: mi,v 1.1955 2015/04/27 06:42:52 knakahara Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -17131,6 +17131,7 @@
 ./usr/share/man/html9/in_getifa.html           comp-sys-htmlman        html
 ./usr/share/man/html9/incore.html              comp-sys-htmlman        html
 ./usr/share/man/html9/inittodr.html            comp-sys-htmlman        html
+./usr/share/man/html9/pci_intr_distribute.html comp-sys-htmlman        html
 ./usr/share/man/html9/intro.html               comp-sys-htmlman        html
 ./usr/share/man/html9/ioasic.html              comp-sys-htmlman        html
 ./usr/share/man/html9/ioasic_attach_devs.html  comp-sys-htmlman        html
@@ -24063,6 +24064,7 @@
 ./usr/share/man/man9/in_getifa.9               comp-sys-man            .man
 ./usr/share/man/man9/incore.9                  comp-sys-man            .man
 ./usr/share/man/man9/inittodr.9                        comp-sys-man            .man
+./usr/share/man/man9/pci_intr_distribute.9     comp-sys-man            .man
 ./usr/share/man/man9/intro.9                   comp-sys-man            .man
 ./usr/share/man/man9/ioasic.9                  comp-sys-man            .man
 ./usr/share/man/man9/ioasic_attach_devs.9      comp-sys-man            .man
diff -r 4aa0e0e5c64a -r 97e4b38333a0 share/man/man9/Makefile
--- a/share/man/man9/Makefile   Mon Apr 27 02:59:44 2015 +0000
+++ b/share/man/man9/Makefile   Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.384 2015/04/21 11:10:29 pooka Exp $
+#       $NetBSD: Makefile,v 1.385 2015/04/27 06:42:52 knakahara Exp $
 
 #      Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -39,10 +39,11 @@
        microseq.9 microtime.9 microuptime.9 mi_switch.9 module.9 \
        mstohz.9 mutex.9 m_tag.9 namecache.9 \
        namei.9 nullop.9 opencrypto.9 optstr.9 \
-       panic.9 pathbuf.9 pci.9 pci_configure_bus.9 pci_intr.9 pckbport.9 \
-       pcmcia.9 pcq.9 pcu.9 percpu.9 pfil.9 physio.9 pmap.9 pmatch.9 \
-       pmc.9 pmf.9 pool.9 pool_cache.9 powerhook_establish.9 ppi.9 \
-       ppsratecheck.9 preempt.9 proc_find.9 pserialize.9 putter.9 \
+       panic.9 pathbuf.9 pci.9 pci_configure_bus.9 pci_intr.9 \
+       pci_intr_distribute.9 pckbport.9 pcmcia.9 pcq.9 pcu.9 \
+       percpu.9 pfil.9 physio.9 pmap.9 pmatch.9 pmc.9 pmf.9 pool.9 \
+       pool_cache.9 powerhook_establish.9 ppi.9 ppsratecheck.9 preempt.9 \
+       proc_find.9 pserialize.9 putter.9 \
        radio.9 ras.9 rasops.9 ratecheck.9 resettodr.9 rnd.9 rndsink.9 \
        roundup.9 rssadapt.9 rt_timer.9 rwlock.9 RUN_ONCE.9 STACK.9 \
        scanc.9 \
diff -r 4aa0e0e5c64a -r 97e4b38333a0 share/man/man9/pci_intr_distribute.9
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man9/pci_intr_distribute.9      Mon Apr 27 06:42:52 2015 +0000
@@ -0,0 +1,53 @@
+.\" $NetBSD: pci_intr_distribute.9,v 1.1 2015/04/27 06:42:52 knakahara Exp $
+.\"
+.\" Copyright (c) 2015 Internet Initiative Japan Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 8, 2015
+.Dt PCI_INTR_DISTRIBUTE 9
+.Os
+.Sh NAME
+.Nm pci_intr_distribute
+.Sh SYNOPSIS
+.In dev/pci/pcivar.h
+.Ft int
+.Fn pci_intr_distribute "void *ich" "const kcpuset_t *newset" \
+"kcpuset_t *oldset"
+.Sh DESCRIPTION
+The
+.Nm
+functions exist to assing an interrupt to CPU.
+.Pp
+If a driver (or the other kernel component) wishes to assign an
+interrupt to CPU, it should pass the return value of
+.Fn pci_intr_establish
+to the
+.Ft ich .
+And it should set kcpuset which want to assign to
+.Ft newset .
+If it want to get the assignment before changing, it should be
+pass non-NULL value to
+.Ft oldset .
+If not, it should set NULL to
+.Ft oldset .
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Mon Apr 27 02:59:44 2015 +0000
+++ b/sys/arch/x86/include/intr.h       Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.45 2014/07/20 15:46:34 uebayasi Exp $       */
+/*     $NetBSD: intr.h,v 1.46 2015/04/27 06:42:52 knakahara Exp $      */
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@
 #endif
 
 #include <sys/evcnt.h>
+#include <sys/queue.h>
 #include <machine/intrdefs.h>
 
 #ifndef _LOCORE
@@ -71,6 +72,11 @@
        void *ist_resume;
 };
 
+struct percpu_evcnt {
+       cpuid_t cpuid;
+       uint64_t count;
+};
+
 struct intrsource {
        int is_maxlevel;                /* max. IPL for this source */
        int is_pin;                     /* IRQ for legacy; pin for IO APIC,
@@ -86,6 +92,10 @@
        int is_idtvec;
        int is_minlevel;
        char is_evname[32];             /* event counter name */
+       char is_intrid[INTRIDBUF];      /* intrid created by create_intrid() */
+       cpuid_t is_active_cpu;          /* active cpuid */
+       struct percpu_evcnt *is_saved_evcnt;    /* interrupt count of deactivated cpus */
+       SIMPLEQ_ENTRY(intrsource) is_list;      /* link of intrsources */
 };
 
 #define IS_LEGACY      0x0001          /* legacy ISA irq source */
@@ -182,6 +192,9 @@
 struct pic *intr_findpic(int);
 void intr_printconfig(void);
 
+struct intrsource *intr_allocate_io_intrsource(const char *);
+void intr_free_io_intrsource(const char *);
+
 int x86_send_ipi(struct cpu_info *, int);
 void x86_broadcast_ipi(int);
 void x86_ipi_handler(void);
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/include/intr_distribute.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86/include/intr_distribute.h    Mon Apr 27 06:42:52 2015 +0000
@@ -0,0 +1,40 @@
+/*     $NetBSD: intr_distribute.h,v 1.1 2015/04/27 06:42:52 knakahara Exp $    */
+
+/*
+ * Copyright (c) 2015 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _X86_INTR_DISTRIBUTE_H_
+#define _X86_INTR_DISTRIBUTE_H_
+
+#ifdef _KERNEL
+
+#include <sys/kcpuset.h>
+
+int intr_distribute(struct intrhand *, const kcpuset_t *, kcpuset_t *);
+
+#endif /* _KERNEL */
+
+#endif /* !_X86_INTR_DISTRIBUTE_H_ */
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/include/pci_machdep.h
--- a/sys/arch/x86/include/pci_machdep.h        Mon Apr 27 02:59:44 2015 +0000
+++ b/sys/arch/x86/include/pci_machdep.h        Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.h,v 1.15 2015/03/04 05:35:50 knakahara Exp $       */
+/*     $NetBSD: pci_machdep.h,v 1.16 2015/04/27 06:42:52 knakahara Exp $       */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -33,6 +33,8 @@
 #ifndef _X86_PCI_MACHDEP_H_
 #define _X86_PCI_MACHDEP_H_
 
+#include <x86/intr_distribute.h>
+
 /*
  * Types provided to machine-independent PCI code
  * See also i82093var.h to find out pci_intr_handle_t's bitfield.
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/include/pci_machdep_common.h
--- a/sys/arch/x86/include/pci_machdep_common.h Mon Apr 27 02:59:44 2015 +0000
+++ b/sys/arch/x86/include/pci_machdep_common.h Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep_common.h,v 1.13 2014/03/29 19:28:30 christos Exp $ */
+/*     $NetBSD: pci_machdep_common.h,v 1.14 2015/04/27 06:42:52 knakahara Exp $        */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -41,6 +41,8 @@
 #define        __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_DISESTABLISH
 #endif
 
+#include <sys/kcpuset.h>
+
 /*
  * x86-specific PCI structure and type definitions.
  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
@@ -116,6 +118,7 @@
 void           *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
                    int, int (*)(void *), void *);
 void           pci_intr_disestablish(pci_chipset_tag_t, void *);
+int            pci_intr_distribute(void *, const kcpuset_t *, kcpuset_t *);
 
 /* experimental MSI support */
 void *pci_msi_establish(struct pci_attach_args *, int, int (*)(void *), void *);
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c       Mon Apr 27 02:59:44 2015 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c       Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_intr_machdep.c,v 1.27 2014/03/29 19:28:30 christos Exp $   */
+/*     $NetBSD: pci_intr_machdep.c,v 1.28 2015/04/27 06:42:52 knakahara Exp $  */
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,15 +73,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.27 2014/03/29 19:28:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.28 2015/04/27 06:42:52 knakahara Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/systm.h>
+#include <sys/cpu.h>
 #include <sys/errno.h>
 #include <sys/device.h>
 #include <sys/intr.h>
+#include <sys/kmem.h>
 #include <sys/malloc.h>
 
 #include <dev/pci/pcivar.h>
@@ -328,6 +330,15 @@
        intr_disestablish(cookie);
 }
 
+int
+pci_intr_distribute(void *cookie, const kcpuset_t *newset, kcpuset_t *oldset)
+{
+
+       /* XXX Is pc_ov->ov_intr_distribute required? */
+
+       return intr_distribute(cookie, newset, oldset);
+}
+
 #if NIOAPIC > 0
 /*
  * experimental support for MSI, does support a single vector,
diff -r 4aa0e0e5c64a -r 97e4b38333a0 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Mon Apr 27 02:59:44 2015 +0000
+++ b/sys/arch/x86/x86/intr.c   Mon Apr 27 06:42:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.78 2015/04/08 05:52:41 knakahara Exp $      */
+/*     $NetBSD: intr.c,v 1.79 2015/04/27 06:42:52 knakahara Exp $      */
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */



Home | Main Index | Thread Index | Old Index