patch-2.4.4 linux/arch/ia64/sn/io/ml_SN_intr.c

Next file: linux/arch/ia64/sn/io/ml_iograph.c
Previous file: linux/arch/ia64/sn/io/ml_SN_init.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.3/linux/arch/ia64/sn/io/ml_SN_intr.c linux/arch/ia64/sn/io/ml_SN_intr.c
@@ -34,6 +34,8 @@
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/xtalk/xtalk.h>
 #include <asm/sn/pci/pcibr_private.h>
+#include <asm/sn/intr.h>
+
 
 #if DEBUG_INTR_TSTAMP_DEBUG
 #include <sys/debug.h>
@@ -65,6 +67,8 @@
 
 extern cnodeid_t master_node_get(devfs_handle_t vhdl);
 
+extern snia_error_intr_handler(int irq, void *devid, struct pt_regs *pt_regs);
+
 
 #define INTR_LOCK(vecblk) \
      (s = mutex_spinlock(&(vecblk)->vector_lock))
@@ -99,7 +103,7 @@
 void
 intr_stray(void *lvl)
 {
-    printk("Stray Interrupt - level %ld to cpu %d", (long)lvl, cpuid());
+    PRINT_WARNING("Stray Interrupt - level %ld to cpu %d", (long)lvl, cpuid());
 }
 
 #if defined(DEBUG)
@@ -119,7 +123,7 @@
 
 intr_dev_targ_map_t 	intr_dev_targ_map[MAX_DEVICES];
 uint64_t		intr_dev_targ_map_size;
-lock_t			intr_dev_targ_map_lock;
+spinlock_t		intr_dev_targ_map_lock;
 
 /* Print out the device - target cpu mapping.
  * This routine is used only in the idbg command
@@ -220,7 +224,7 @@
 
 	    }
 
-	spinlock_init(&vecblk->vector_lock, "ivecb");
+	mutex_spinlock_init(&vecblk->vector_lock);
 
 	vecblk->vector_count = 0;    
 	for (i = 0; i < CPUS_PER_SUBNODE; i++)
@@ -254,7 +258,7 @@
 {
     intr_vecblk_t	*vecblk;
     hub_intmasks_t 	*hub_intmasks;
-    int s;
+    unsigned long s;
     int rv = 0;
     int ip;
     synergy_da_t	*sda;
@@ -283,8 +287,7 @@
     INTR_LOCK(vecblk);
 
     if (bit <= -1) {
-	// bit = 0;
-	bit = 7;  /* First available on SNIA */
+	bit = 0;
 	ASSERT(reserve == II_RESERVE);
 	/* Choose any available level */
 	for (; bit < N_INTPEND_BITS; bit++) {
@@ -449,9 +452,9 @@
 {
     intr_vecblk_t	*vecblk;
     hubreg_t		*intpend_masks;
-    int s;
     int rv = 0;
     int ip;
+    unsigned long s;
 
     ASSERT(bit < N_INTPEND_BITS * 2);
 
@@ -530,7 +533,7 @@
 {
     intr_vecblk_t	*vecblk;
     hubreg_t		*intpend_masks;
-    int s;
+    unsigned long s;
     int rv = 0;
     int ip;
 
@@ -582,8 +585,8 @@
 do_intr_block_bit(cpuid_t cpu, int bit, int block)
 {
 	intr_vecblk_t *vecblk;
-	int s;
 	int ip;
+	unsigned long s;
 	hubreg_t *intpend_masks;
 	volatile hubreg_t mask_value;
 	volatile hubreg_t *mask_reg;
@@ -671,7 +674,6 @@
 		int local_cpu_num;
 
 		cpu = cnode_slice_to_cpuid(cnode, slice);
-		cpu = cpu_logical_id(cpu);
 		if (cpu == CPU_NONE)
 			continue;
 
@@ -711,7 +713,7 @@
 }
 
 
-#ifndef CONFIG_IA64_SGI_IO
+#ifdef	LATER
 /*
  * Convert a subnode vertex into a (cnodeid, which_subnode) pair.
  * Return 0 on success, non-zero on failure.
@@ -736,7 +738,7 @@
 	return(0); /* success */
 }
 
-#endif /* CONFIG_IA64_SGI_IO */
+#endif /* LATER */
 
 /* Make it easy to identify subnode vertices in the hwgraph */
 void
@@ -755,13 +757,14 @@
 }
 
 
-#ifndef CONFIG_IA64_SGI_IO
 /*
  * Given a device descriptor, extract interrupt target information and
  * choose an appropriate CPU.  Return CPU_NONE if we can't make sense
  * out of the target information.
  * TBD: Should this be considered platform-independent code?
  */
+
+#ifdef	LATER
 static cpuid_t
 intr_target_from_desc(device_desc_t dev_desc, int favor_subnode)
 {
@@ -799,10 +802,10 @@
 cpuchosen:
 	return(cpuid);
 }
-#endif /* CONFIG_IA64_SGI_IO */
+#endif	/* LATER */
 
 
-#ifndef CONFIG_IA64_SGI_IO
+#ifdef	LATER
 /*
  * Check if we had already visited this candidate cnode
  */
@@ -824,7 +827,7 @@
 	return(visited_cnodes);
 }
 
-#endif /* CONFIG_IA64_SGI_IO */
+#endif /* LATER */
 
 
 
@@ -915,7 +918,7 @@
 {
 	cpuid_t		cpuid;				/* possible intr targ*/
 	cnodeid_t 	candidate;			/* possible canidate */
-#ifndef BRINGUP
+#ifdef LATER
 	cnodeid_t	visited_cnodes[MAX_NASIDS], 	/* nodes seen so far */
 		        center,				/* node we are on */
 		        candidate;			/* possible canidate */
@@ -926,10 +929,10 @@
 							 */
 		        maxradius = physmem_maxradius();
 	void		*rv;
-#endif /* BRINGUP */
+#endif /* LATER */
 	int		which_subnode = SUBNODE_ANY;
 
-#if CONFIG_IA64_SGI_IO /* SN1 + pcibr Addressing Limitation */
+/* SN1 + pcibr Addressing Limitation */
 	{
 	devfs_handle_t pconn_vhdl;
 	pcibr_soft_t pcibr_soft;
@@ -962,9 +965,8 @@
 		}
 	}
 	}
-#endif /* CONFIG_IA64_SGI_IO */
 
-#ifndef CONFIG_IA64_SGI_IO
+#ifdef	LATER
 	/* 
 	 * If an interrupt target was specified for this
 	 * interrupt allocation, try to use it.
@@ -998,7 +1000,7 @@
 		 */
 
 	}
-#endif  /* CONFIG_IA64_SGI_IO */
+#endif  /* LATER */
 	
 	/* Check if we can find a valid interrupt target candidate on
 	 * the master node for the device.
@@ -1019,7 +1021,7 @@
 			intr_unreserve_level(cpuid, *resp_bit);
 	}
 
-	printk("Cannot target interrupts to closest node(%d): %ld (0x%lx)\n",
+	PRINT_WARNING("Cannot target interrupts to closest node(%d): %ld (0x%lx)\n",
 		master_node_get(dev),(long) owner_dev, (unsigned long)owner_dev);
 
 	/* Fall through into the default algorithm
@@ -1076,10 +1078,11 @@
 #else  /* BRINGUP */
 	{
 	// Do a stupid round-robin assignment of the node.
-		static cnodeid_t last_node = 0;
+		static cnodeid_t last_node = -1;
 
-		if (last_node > numnodes) last_node = 0;
-		for (candidate = last_node; candidate <= numnodes; candidate++) {
+		if (last_node >= numnodes) last_node = 0;
+		for (candidate = last_node + 1; candidate != last_node; candidate++) {
+			if (candidate == numnodes) candidate = 0;
 			cpuid = intr_bit_reserve_test(CPU_NONE,
 					      which_subnode,
 					      candidate,
@@ -1091,18 +1094,18 @@
 
 			if (cpuid != CPU_NONE) {
 				if (cpu_on_subnode(cpuid, which_subnode)) {
-					last_node++;
+					last_node = candidate;
 					return(cpuid);	/* got a valid interrupt target */
 				}
 				else
 					intr_unreserve_level(cpuid, *resp_bit);
 			}
-			last_node++;
 		}
+		last_node = candidate;
 	}
 #endif
 
-	printk("Cannot target interrupts to any close node: %ld (0x%lx)\n",
+	PRINT_WARNING("Cannot target interrupts to any close node: %ld (0x%lx)\n",
 		(long)owner_dev, (unsigned long)owner_dev);
 
 	/* In the worst case try to allocate interrupt bits on the
@@ -1127,7 +1130,7 @@
 			intr_unreserve_level(cpuid, *resp_bit);
 	}
 
-	printk("Cannot target interrupts: %ld (0x%lx)\n",
+	PRINT_WARNING("Cannot target interrupts: %ld (0x%lx)\n",
 		(long)owner_dev, (unsigned long)owner_dev);
 
 	return(CPU_NONE);	/* Should never get here */
@@ -1515,6 +1518,7 @@
 	}
 }
 
+#endif /* BRINGUP */
 
 struct hardwired_intr_s {
 	signed char level;
@@ -1525,17 +1529,9 @@
 	{ INT_PEND0_BASELVL + GFX_INTR_A,	0, 	"Gfx A" },
 	{ INT_PEND0_BASELVL + GFX_INTR_B,	0, 	"Gfx B" },
 	{ INT_PEND0_BASELVL + PG_MIG_INTR,	II_THREADED, "Migration" },
-#if defined(SN1) && !defined(DIRECT_L1_CONSOLE)
 	{ INT_PEND0_BASELVL + UART_INTR,	II_THREADED, "Bedrock/L1" },
-#else
-	{ INT_PEND0_BASELVL + UART_INTR,	0,	"Hub I2C" },
-#endif
 	{ INT_PEND0_BASELVL + CC_PEND_A,	0,	"Crosscall A" },
 	{ INT_PEND0_BASELVL + CC_PEND_B,	0,	"Crosscall B" },
-	{ INT_PEND0_BASELVL + MSC_MESG_INTR,	II_THREADED, "MSC Message" },
-	{ INT_PEND0_BASELVL + CPU_ACTION_A,	0,	"CPU Action A" },
-	{ INT_PEND0_BASELVL + CPU_ACTION_B,	0,	"CPU Action B" },
-	{ INT_PEND1_BASELVL + IO_ERROR_INTR,	II_ERRORINT, "IO Error" },
 	{ INT_PEND1_BASELVL + CLK_ERR_INTR,	II_ERRORINT, "Clock Error" },
 	{ INT_PEND1_BASELVL + COR_ERR_INTR_A,	II_ERRORINT, "Correctable Error A" },
 	{ INT_PEND1_BASELVL + COR_ERR_INTR_B,	II_ERRORINT, "Correctable Error B" },
@@ -1546,13 +1542,11 @@
 	{ INT_PEND1_BASELVL + MSC_PANIC_INTR,	II_ERRORINT, "MSC Panic" },
 	{ INT_PEND1_BASELVL + LLP_PFAIL_INTR_A,	II_ERRORINT, "LLP Pfail WAR" },
 	{ INT_PEND1_BASELVL + LLP_PFAIL_INTR_B,	II_ERRORINT, "LLP Pfail WAR" },
-#ifdef SN1
 	{ INT_PEND1_BASELVL + NACK_INT_A,	0, "CPU A Nack count == NACK_CMP" },
 	{ INT_PEND1_BASELVL + NACK_INT_B,	0, "CPU B Nack count == NACK_CMP" },
 	{ INT_PEND1_BASELVL + LB_ERROR,		0, "Local Block Error" },
 	{ INT_PEND1_BASELVL + XB_ERROR,		0, "Local XBar Error" },
-#endif /* SN1 */	
-	{ -1, 0, (char *)NULL}
+	{ -1, 0, (char *)NULL},
 };
 
 /*
@@ -1567,7 +1561,13 @@
 	int i;
 	char subnode_done[NUM_SUBNODES];
 
-	cpu = cnodetocpu(cnode);
+	// cpu = cnodetocpu(cnode);
+	for (cpu = 0; cpu < smp_num_cpus; cpu++) {
+		if (cpuid_to_cnodeid(cpu) == cnode) {
+			break;
+		}
+	}
+	if (cpu == smp_num_cpus) cpu = CPU_NONE;
 	if (cpu == CPU_NONE) {
 		printk("Node %d has no CPUs", cnode);
 		return;
@@ -1576,7 +1576,7 @@
 	for (i=0; i<NUM_SUBNODES; i++)
 		subnode_done[i] = 0;
 
-	for (; cpu<maxcpus && cpu_enabled(cpu) && cputocnode(cpu) == cnode; cpu++) {
+	for (; cpu<smp_num_cpus && cpu_enabled(cpu) && cpuid_to_cnodeid(cpu) == cnode; cpu++) {
 		int which_subnode = cpuid_to_subnode(cpu);
 		if (subnode_done[which_subnode])
 			continue;
@@ -1594,7 +1594,6 @@
 	}
 }
 
-#endif /* BRINGUP */
 
 /*
  * Check and clear interrupts.
@@ -1612,7 +1611,7 @@
 		for (i = 0; i < N_INTPEND_BITS; i++) {
 			if (bits & (1 << i)) {
 #ifdef INTRDEBUG
-				printk( "Nasid %d interrupt bit %d set in %s",
+				PRINT_WARNING("Nasid %d interrupt bit %d set in %s",
 					nasid, i, name);
 #endif
 				LOCAL_HUB_CLR_INTR(base_level + i);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)