Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Apr 2006 07:23:19 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 94516 for review
Message-ID:  <200604030723.k337NJsJ058392@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94516

Change 94516 by kmacy@kmacy_storage:sun4v_work on 2006/04/03 07:22:38

	create separate intrq_alloc function so that per-cpu queues are pre-allocated before cpu_mp_bootstrap
	initialize IPIs locally

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/intr_machdep.c#5 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/intr_machdep.c#5 (text+ko) ====

@@ -74,12 +74,14 @@
 #include <sys/mutex.h>
 #include <sys/pcpu.h>
 #include <sys/proc.h>
+#include <sys/smp.h>
 #include <sys/vmmeter.h>
 
 #include <machine/frame.h>
 #include <machine/intr_machdep.h>
 #include <machine/hypervisor_api.h>
 #include <machine/cpu.h>
+#include <machine/smp.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -119,14 +121,25 @@
 int cpu_q_entries = 128;
 int dev_q_entries = 128;
 
+static vm_offset_t *mondo_data_array;
+static vm_offset_t *cpu_list_array;
+static vm_offset_t *cpu_q_array;
+static vm_offset_t *dev_q_array;
+static vm_offset_t *rq_array;
+static vm_offset_t *nrq_array;
+static int cpu_list_size;
+
+
+
 /* protect the intr_vectors table */
 static struct mtx intr_table_lock;
 
 static void intr_execute_handlers(void *);
 static void intr_stray_level(struct trapframe *);
 static void intr_stray_vector(void *);
-static int intrcnt_setname(const char *, int);
+static int  intrcnt_setname(const char *, int);
 static void intrcnt_updatename(int, const char *, int);
+static void cpu_intrq_alloc(void);
 
 /*
  * not MPSAFE
@@ -207,7 +220,7 @@
 intr_stray_level(struct trapframe *tf)
 {
 
-	printf("stray level interrupt\n");
+	printf("stray level interrupt - pil=%ld\n", tf->tf_pil);
 }
 
 static void
@@ -240,8 +253,14 @@
 		intr_vectors[i].iv_vec = i;
 	}
 	intr_handlers[PIL_LOW] = intr_fast;
+	
+#ifdef SMP
+	intr_handlers[PIL_AST] = cpu_ipi_ast;
+	intr_handlers[PIL_RENDEZVOUS] = (ih_func_t *)smp_rendezvous_action;
+	intr_handlers[PIL_STOP]= cpu_ipi_stop;
+#endif
 	mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN);
-		
+	cpu_intrq_alloc();
 	cpu_intrq_init();
 
 }
@@ -365,42 +384,64 @@
 /* 
  * Allocate and register intrq fields
  */
+static void 
+cpu_intrq_alloc(void)
+{
+	
+
+	
+	mondo_data_array = malloc(INTR_REPORT_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(mondo_data_array == NULL);
+
+	cpu_list_size = CPU_LIST_SIZE > INTR_REPORT_SIZE ? CPU_LIST_SIZE : INTR_REPORT_SIZE;
+	cpu_list_array = malloc(cpu_list_size*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(cpu_list_array == NULL);
+	
+	cpu_q_array = malloc(INTR_CPU_Q_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(cpu_q_array == NULL);
+	
+	dev_q_array = malloc(INTR_DEV_Q_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(dev_q_array == NULL);
+
+	rq_array = malloc(2*CPU_RQ_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(rq_array == NULL);
+	
+	nrq_array = malloc(2*CPU_NRQ_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO);
+	PANIC_IF(nrq_array == NULL);
+
+}
+
 void 
 cpu_intrq_init()
 {
-	
+
 	uint64_t error;
-	int cpu_list_size;
 
-	pcpup->pc_mondo_data = malloc(INTR_REPORT_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_mondo_data == NULL)
+	pcpup->pc_mondo_data = mondo_data_array + curcpu*INTR_REPORT_SIZE;
 	pcpup->pc_mondo_data_ra = vtophys(pcpup->pc_mondo_data);
 	
-	cpu_list_size = CPU_LIST_SIZE > INTR_REPORT_SIZE ? CPU_LIST_SIZE : INTR_REPORT_SIZE;
-	pcpup->pc_cpu_list = malloc(cpu_list_size, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_cpu_list == NULL)
+	pcpup->pc_cpu_list = cpu_list_array + curcpu*cpu_list_size;
+
 	pcpup->pc_cpu_list_ra = vtophys(pcpup->pc_cpu_list);
 
-	pcpup->pc_cpu_q = malloc(INTR_CPU_Q_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_cpu_q == NULL);
+	pcpup->pc_cpu_q = cpu_q_array + curcpu*INTR_CPU_Q_SIZE;
+
 	pcpup->pc_cpu_q_ra = vtophys(pcpup->pc_cpu_q);
 	pcpup->pc_cpu_q_size = INTR_CPU_Q_SIZE;
 
-	pcpup->pc_dev_q = malloc(INTR_DEV_Q_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_dev_q == NULL);
+	pcpup->pc_dev_q = dev_q_array + curcpu*INTR_DEV_Q_SIZE;
 	pcpup->pc_dev_q_ra = vtophys(pcpup->pc_dev_q);
 	pcpup->pc_dev_q_size = INTR_DEV_Q_SIZE;
 
-	pcpup->pc_rq = malloc(2*CPU_RQ_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_rq == NULL);
+	pcpup->pc_rq = rq_array + curcpu*2*CPU_RQ_SIZE;
 	pcpup->pc_rq_ra = vtophys(pcpup->pc_rq);
 	pcpup->pc_rq_size = CPU_RQ_SIZE;
 
-	pcpup->pc_nrq = malloc(2*CPU_NRQ_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
-	PANIC_IF(pcpup->pc_nrq == NULL);
+	pcpup->pc_nrq = nrq_array + curcpu*2*CPU_NRQ_SIZE;
 	pcpup->pc_nrq_ra = vtophys(pcpup->pc_nrq);
 	pcpup->pc_nrq_size = CPU_NRQ_SIZE;
 
+
 	error = hv_cpu_qconf(Q(CPU_MONDO_QUEUE_HEAD), pcpup->pc_cpu_q_ra, cpu_q_entries);
 	if (error != H_EOK)
 		panic("cpu_mondo queue configuration failed: %lu", error);
@@ -417,5 +458,4 @@
 	if (error != H_EOK)
 		panic("non-resumable error queue configuration failed: %lu", error);
 
-
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604030723.k337NJsJ058392>