mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] 2.6.8.1 ES7000 subarch update
@ 2004-09-02 23:52 Jason Davis
  2004-09-03  8:28 ` Christoph Hellwig
  2004-09-03 11:15 ` Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Davis @ 2004-09-02 23:52 UTC (permalink / raw)
  To: LKML, Andrew Morton

Howdy -

The patch below adds hooks for the ES7000 Management Processor driver and implements an algorithm to determine an available GSI override for correctly mapping GSIs to IO-APIC pins. GSI overrides are required for the ES7000 platform since IRQ to pin mappings are NOT all one-to-one. This patch applies to the Unisys specific ES7000 machines. Extensive tests has been done on several models of the ES7000 to verify this patch.

Thanks,
Jason Davis


diff -Naur linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000.h linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000.h
--- linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000.h	2004-08-14 06:54:50.000000000 -0400
+++ linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000.h	2004-09-01 23:25:34.863415632 -0400
@@ -104,6 +104,13 @@
 #define	MIP_SW_APIC		0x1020b
 #define	MIP_FUNC(VALUE) 	(VALUE & 0xff)
 
+#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
+#define IOAPIC_GSI_BOUND(ioapic) ((ioapic+1) * (nr_ioapic_registers[ioapic]-1))
+#define MAX_GSI_MAPSIZE 32
+#endif
+
+extern unsigned long io_apic_irqs;
+
 extern int parse_unisys_oem (char *oemptr, int oem_entries);
 extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
 extern int es7000_start_cpu(int cpu, unsigned long eip);
diff -Naur linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000plat.c linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000plat.c
--- linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000plat.c	2004-08-14 06:56:22.000000000 -0400
+++ linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000plat.c	2004-09-01 23:43:36.287014256 -0400
@@ -51,27 +51,81 @@
 int 			mip_port;
 unsigned long		mip_addr, host_addr;
 
+EXPORT_SYMBOL(mip_reg);
+EXPORT_SYMBOL(host_reg);
+EXPORT_SYMBOL(mip_port);
+EXPORT_SYMBOL(mip_addr);
+EXPORT_SYMBOL(host_addr);
+
+#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
+static unsigned long cycle_irqs = 0;
+static unsigned long free_irqs = 0;
+static int gsi_map[MAX_GSI_MAPSIZE] = { [0 ... MAX_GSI_MAPSIZE-1] = -1 };
+
+/*
+ * GSI override for ES7000 platforms.
+ */
+
+static int __init
+es7000_gsi_override(int ioapic, int gsi)
+{
+	static int newgsi = 0;
+
+	if (gsi_map[gsi] != -1)
+		gsi = gsi_map[gsi];
+	else if (cycle_irqs ^ free_irqs)
+	{
+		newgsi = find_next_bit(&cycle_irqs, IOAPIC_GSI_BOUND(0), newgsi);
+		__set_bit(newgsi, &free_irqs);
+		gsi_map[gsi] = newgsi;
+		gsi = newgsi;
+		newgsi++;
+		Dprintk("es7000_gsi_override: free_irqs = 0x%lx\n", free_irqs);
+	}
+
+	return gsi;
+}
+
 static int __init
 es7000_rename_gsi(int ioapic, int gsi)
 {
-	if (ioapic)
+	static int initialized = 0;
+	int i;
+
+	/*
+	 * These should NEVER be true at this point but we'd rather be
+	 * safe than sorry.
+	 */
+	if (acpi_disabled || acpi_pci_disabled || acpi_noirq)
 		return gsi;
-	else {
-		if (gsi == 0)
-			return 13;
-		if (gsi == 1)
-			return 16;
-		if (gsi == 4)
-			return 17;
-		if (gsi == 6)
-			return 18;
-		if (gsi == 7)
-			return 19;
-		if (gsi == 8)
-			return 20;
+
+	if (ioapic)
 		return gsi;
-        }
+
+	if (!initialized) {
+		unsigned long tmp_irqs = 0;
+
+		for (i = 0; i < nr_ioapic_registers[0]; i++)
+			__set_bit(mp_irqs[i].mpc_srcbusirq, &tmp_irqs);
+
+		cycle_irqs = (~tmp_irqs & io_apic_irqs & ((1 << IOAPIC_GSI_BOUND(0)) - 1));
+
+		initialized = 1;
+		Dprintk("es7000_rename_gsi: cycle_irqs = 0x%lx\n", cycle_irqs);
+	}
+
+	for (i = 0; i < nr_ioapic_registers[0]; i++) {
+		if (mp_irqs[i].mpc_srcbusirq == gsi) {
+			if (mp_irqs[i].mpc_dstirq == gsi)
+				return gsi;
+			else
+				return es7000_gsi_override(0, gsi);
+		}
+	}
+
+	return gsi;
 }
+#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
 
 /*
  * Parse the OEM Table


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 2.6.8.1 ES7000 subarch update
  2004-09-02 23:52 [PATCH] 2.6.8.1 ES7000 subarch update Jason Davis
@ 2004-09-03  8:28 ` Christoph Hellwig
  2004-09-03 11:15 ` Alan Cox
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2004-09-03  8:28 UTC (permalink / raw)
  To: Jason Davis; +Cc: LKML, Andrew Morton

> +EXPORT_SYMBOL(mip_reg);
> +EXPORT_SYMBOL(host_reg);
> +EXPORT_SYMBOL(mip_port);
> +EXPORT_SYMBOL(mip_addr);
> +EXPORT_SYMBOL(host_addr);

There's no modular user of these anywhere in sight. 

> +	else if (cycle_irqs ^ free_irqs)
> +	{

wrong indentation.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 2.6.8.1 ES7000 subarch update
  2004-09-02 23:52 [PATCH] 2.6.8.1 ES7000 subarch update Jason Davis
  2004-09-03  8:28 ` Christoph Hellwig
@ 2004-09-03 11:15 ` Alan Cox
  2004-09-03 12:32   ` Arjan van de Ven
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Cox @ 2004-09-03 11:15 UTC (permalink / raw)
  To: Jason Davis; +Cc: LKML, Andrew Morton

On Gwe, 2004-09-03 at 00:52, Jason Davis wrote:
>  int 			mip_port;
>  unsigned long		mip_addr, host_addr;
>  
> +EXPORT_SYMBOL(mip_reg);
> +EXPORT_SYMBOL(host_reg);
> +EXPORT_SYMBOL(mip_port);
> +EXPORT_SYMBOL(mip_addr);
> +EXPORT_SYMBOL(host_addr);

This is asking for collisions with other modules. It would be a lot
better for the future it these became e7000_mip_reg etc I think.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 2.6.8.1 ES7000 subarch update
  2004-09-03 11:15 ` Alan Cox
@ 2004-09-03 12:32   ` Arjan van de Ven
  0 siblings, 0 replies; 5+ messages in thread
From: Arjan van de Ven @ 2004-09-03 12:32 UTC (permalink / raw)
  To: Alan Cox; +Cc: Jason Davis, LKML, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On Fri, 2004-09-03 at 13:15, Alan Cox wrote:
> On Gwe, 2004-09-03 at 00:52, Jason Davis wrote:
> >  int 			mip_port;
> >  unsigned long		mip_addr, host_addr;
> >  
> > +EXPORT_SYMBOL(mip_reg);
> > +EXPORT_SYMBOL(host_reg);
> > +EXPORT_SYMBOL(mip_port);
> > +EXPORT_SYMBOL(mip_addr);
> > +EXPORT_SYMBOL(host_addr);
> 
> This is asking for collisions with other modules. It would be a lot
> better for the future it these became e7000_mip_reg etc I think.

they seem to also be exclusively for a binary only kernel module.....
hot topic.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 2.6.8.1 ES7000 subarch update
       [not found] <3010F4D7BBD5F64C9C2D17B9D17BB37705036A42@USTR-EXCH4.na.uis.unisys.com>
@ 2004-09-10  3:15 ` Jason Davis
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Davis @ 2004-09-10  3:15 UTC (permalink / raw)
  To: LKML, Andrew Morton; +Cc: Christoph Hellwig, Alan Cox

Below is an update to the ES7000 subarch patch submitted last week.

Changes that have been made:
1. ES7000 Management Processor driver hooks removed for the time being
2. Fixed misplaced curly brace on an if statement in es7000_gsi_override()

New description:
The patch below implements an algorithm to determine an unique GSI override for mapping GSIs to IO-APIC pins correctly. GSI overrides are required in order for ES7000 machines to function properly since IRQ to pin mappings are NOT all one-to-one. This patch applies only to the Unisys specific ES7000 machines and has been tested thoroughly on several models of the ES7000 line.

Thanks,
Jason

--- linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000.h	2004-08-14 06:54:50.000000000 -0400
+++ linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000.h	2004-09-07 14:49:56.000000000 -0400
@@ -104,6 +104,13 @@
 #define	MIP_SW_APIC		0x1020b
 #define	MIP_FUNC(VALUE) 	(VALUE & 0xff)
 
+#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
+#define IOAPIC_GSI_BOUND(ioapic) ((ioapic+1) * (nr_ioapic_registers[ioapic]-1))
+#define MAX_GSI_MAPSIZE 32
+#endif
+
+extern unsigned long io_apic_irqs;
+
 extern int parse_unisys_oem (char *oemptr, int oem_entries);
 extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
 extern int es7000_start_cpu(int cpu, unsigned long eip);
--- linux-2.6.8.1-inc/arch/i386/mach-es7000/es7000plat.c	2004-08-14 06:56:22.000000000 -0400
+++ linux-2.6.8.1-es7k/arch/i386/mach-es7000/es7000plat.c	2004-09-09 12:22:26.000000000 -0400
@@ -51,27 +51,74 @@
 int 			mip_port;
 unsigned long		mip_addr, host_addr;
 
+#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
+static unsigned long cycle_irqs = 0;
+static unsigned long free_irqs = 0;
+static int gsi_map[MAX_GSI_MAPSIZE] = { [0 ... MAX_GSI_MAPSIZE-1] = -1 };
+
+/*
+ * GSI override for ES7000 platforms.
+ */
+
+static int __init
+es7000_gsi_override(int ioapic, int gsi)
+{
+	static int newgsi = 0;
+
+	if (gsi_map[gsi] != -1)
+		gsi = gsi_map[gsi];
+	else if (cycle_irqs ^ free_irqs) {
+		newgsi = find_next_bit(&cycle_irqs, IOAPIC_GSI_BOUND(0), newgsi);
+		__set_bit(newgsi, &free_irqs);
+		gsi_map[gsi] = newgsi;
+		gsi = newgsi;
+		newgsi++;
+		Dprintk("es7000_gsi_override: free_irqs = 0x%lx\n", free_irqs);
+	}
+
+	return gsi;
+}
+
 static int __init
 es7000_rename_gsi(int ioapic, int gsi)
 {
+	static int initialized = 0;
+	int i;
+
+	/*
+	 * These should NEVER be true at this point but we'd rather be
+	 * safe than sorry.
+	 */
+	if (acpi_disabled || acpi_pci_disabled || acpi_noirq)
+ 		return gsi;
+
 	if (ioapic)
-		return gsi;
-	else {
-		if (gsi == 0)
-			return 13;
-		if (gsi == 1)
-			return 16;
-		if (gsi == 4)
-			return 17;
-		if (gsi == 6)
-			return 18;
-		if (gsi == 7)
-			return 19;
-		if (gsi == 8)
-			return 20;
-		return gsi;
-        }
+ 		return gsi;
+
+	if (!initialized) {
+		unsigned long tmp_irqs = 0;
+
+		for (i = 0; i < nr_ioapic_registers[0]; i++)
+			__set_bit(mp_irqs[i].mpc_srcbusirq, &tmp_irqs);
+
+		cycle_irqs = (~tmp_irqs & io_apic_irqs & ((1 << IOAPIC_GSI_BOUND(0)) - 1));
+
+		initialized = 1;
+		Dprintk("es7000_rename_gsi: cycle_irqs = 0x%lx\n", cycle_irqs);
+	}
+
+	for (i = 0; i < nr_ioapic_registers[0]; i++) {
+		if (mp_irqs[i].mpc_srcbusirq == gsi) {
+			if (mp_irqs[i].mpc_dstirq == gsi)
+				return gsi;
+			else
+				return es7000_gsi_override(0, gsi);
+		}
+	}
+
+	return gsi;
 }
+#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
 
 /*
  * Parse the OEM Table
@@ -193,7 +240,7 @@
 			}
 		}
 	}
-	printk("ES7000: did not find Unisys ACPI OEM table!\n");
+	Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
 	return -1;
 }


(end-of-patch)

>
>
>-----Original Message-----
>From: Jason Davis [mailto:jason.davis@unisys.com] 
>Sent: Thursday, September 02, 2004 7:52 PM
>To: LKML; Andrew Morton
>Subject: [PATCH] 2.6.8.1 ES7000 subarch update
>
>Howdy -
>
>The patch below adds hooks for the ES7000 Management Processor driver
>and implements an algorithm to determine an available GSI override for
>correctly mapping GSIs to IO-APIC pins. GSI overrides are required for
>the ES7000 platform since IRQ to pin mappings are NOT all one-to-one.
>This patch applies to the Unisys specific ES7000 machines. Extensive
>tests has been done on several models of the ES7000 to verify this
>patch.
>
>Thanks,
>Jason Davis
>
>
> (original patch cut)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-10  3:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 23:52 [PATCH] 2.6.8.1 ES7000 subarch update Jason Davis
2004-09-03  8:28 ` Christoph Hellwig
2004-09-03 11:15 ` Alan Cox
2004-09-03 12:32   ` Arjan van de Ven
     [not found] <3010F4D7BBD5F64C9C2D17B9D17BB37705036A42@USTR-EXCH4.na.uis.unisys.com>
2004-09-10  3:15 ` Jason Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®