All of lore.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] runtime platform detection in GENERIC kernels
@ 2003-05-14 15:03 Martin Hicks
  2003-05-14 15:32 ` Alex Williamson
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Martin Hicks @ 2003-05-14 15:03 UTC (permalink / raw)
  To: linux-ia64

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


Hello,

In the process of trying to get a GENERIC kernel running on SGI SN2
hardware we've run into a few instances where knowing what type of
machine we are running on is useful.  Would it be acceptable to make a
macro such as is_sgi_sn2() to check this?

One of the specific situations is in console_init()
(drivers/char/tty_io.c) where SN2 machines must use the sgi-l1_protocol
driver and the rest of the IA64 machines just use the normal serial
driver.  A small check was added:

        mac_scc_console_init();
 #elif defined(CONFIG_PARISC)
        pdc_console_init();
+#elif defined(CONFIG_IA64_GENERIC)
+       if (is_sgi_sn2())
+               sgi_l1_serial_console_init();
+       else
+               serial_console_init();
 #elif defined(CONFIG_SERIAL)
        serial_console_init();
 #endif /* CONFIG_8xx */


The current patch is attached.  It's a first draft.  I'm looking
comments on whether this (or something like it) has any chance
of being accepted, and if so, any comments on the design of
the facility.

mh


-- 
Wild Open Source Inc.                  mort@wildopensource.com



===========================================================================
Index: linux/arch/ia64/kernel/setup.c
===========================================================================

--- /usr/tmp/TmpDir.30939-0/linux/arch/ia64/kernel/setup.c_1.33	Tue May 13 14:41:50 2003
+++ linux/arch/ia64/kernel/setup.c	Tue May 13 14:38:08 2003
@@ -63,6 +63,8 @@
  struct cpuinfo_ia64 _cpu_data[NR_CPUS] __attribute__ ((section ("__special_page_section")));
 #endif
 
+int machine_is_sgi_sn2;
+
 unsigned long ia64_cycles_per_usec;
 struct ia64_boot_param *ia64_boot_param;
 struct screen_info screen_info;
@@ -446,7 +448,11 @@
 	ia64_sal_init(efi.sal_systab);
 
 #ifdef CONFIG_IA64_GENERIC
-	machvec_init(acpi_get_sysname());
+	{
+		char *str = acpi_get_sysname();
+		machvec_init(str);
+		init_is_sgi_sn2(str);
+	}
 #endif
 
 	/*

===========================================================================
Index: linux/include/asm-ia64/system.h
===========================================================================

--- /usr/tmp/TmpDir.30939-0/linux/include/asm-ia64/system.h_1.25	Tue May 13 14:41:50 2003
+++ linux/include/asm-ia64/system.h	Tue May 13 14:40:26 2003
@@ -445,6 +445,20 @@
 #define task_running(rq, p)    (((rq)->curr == (p)) || spin_is_locked(&(p)->switch_lock))
 #define idle_needs_wakeup	0
 
+#ifdef CONFIG_IA64_GENERIC
+extern int machine_is_sgi_sn2;
+#define init_is_sgi_sn2(str) do { 		\
+	if (!strcmp(str,"sn2"))			\
+		machine_is_sgi_sn2=1;		\
+  } while (0)
+
+#define is_sgi_sn2() 	(machine_is_sgi_sn2)
+#elif CONFIG_IA64_SGI_SN
+#define is_sgi_sn2()	1
+#else
+#define is_sgi_sn2()	0
+#endif /* CONFIG_IA64_GENERIC */
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
@ 2003-05-14 15:32 ` Alex Williamson
  2003-05-14 15:47 ` Martin Hicks
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Alex Williamson @ 2003-05-14 15:32 UTC (permalink / raw)
  To: linux-ia64

   Why not just make a runtime strcmp to platform_name?  Then
you could make a generic is_platform("sn2") type function/macro
that everyone could use and you'd get rid of that nasty init
function.  If you realy need to make such a check in a perfmance
path, it should probably be a machvec.  Thanks,

	Alex

> 
> Hello,
> 
> In the process of trying to get a GENERIC kernel running on SGI SN2
> hardware we've run into a few instances where knowing what type of
> machine we are running on is useful.  Would it be acceptable to make a
> macro such as is_sgi_sn2() to check this?
> 
> One of the specific situations is in console_init()
> (drivers/char/tty_io.c) where SN2 machines must use the sgi-l1_protocol
> driver and the rest of the IA64 machines just use the normal serial
> driver.  A small check was added:
> 
>         mac_scc_console_init();
>  #elif defined(CONFIG_PARISC)
>         pdc_console_init();
> +#elif defined(CONFIG_IA64_GENERIC)
> +       if (is_sgi_sn2())
> +               sgi_l1_serial_console_init();
> +       else
> +               serial_console_init();
>  #elif defined(CONFIG_SERIAL)
>         serial_console_init();
>  #endif /* CONFIG_8xx */
> 
> 
> The current patch is attached.  It's a first draft.  I'm looking
> comments on whether this (or something like it) has any chance
> of being accepted, and if so, any comments on the design of
> the facility.
> 
> mh
> 
> 
> -- 
> Wild Open Source Inc.                  mort@wildopensource.com
> 
> 
> 
> ====================================
> => Index: linux/arch/ia64/kernel/setup.c
> ====================================
> => 
> --- /usr/tmp/TmpDir.30939-0/linux/arch/ia64/kernel/setup.c_1.33	Tue May
> 13 14:41:50 2003
> +++ linux/arch/ia64/kernel/setup.c	Tue May 13 14:38:08 2003
> @@ -63,6 +63,8 @@
>   struct cpuinfo_ia64 _cpu_data[NR_CPUS] __attribute__ ((section
> ("__special_page_section")));
>  #endif
>  
> +int machine_is_sgi_sn2;
> +
>  unsigned long ia64_cycles_per_usec;
>  struct ia64_boot_param *ia64_boot_param;
>  struct screen_info screen_info;
> @@ -446,7 +448,11 @@
>  	ia64_sal_init(efi.sal_systab);
>  
>  #ifdef CONFIG_IA64_GENERIC
> -	machvec_init(acpi_get_sysname());
> +	{
> +		char *str = acpi_get_sysname();
> +		machvec_init(str);
> +		init_is_sgi_sn2(str);
> +	}
>  #endif
>  
>  	/*
> 
> ====================================
> => Index: linux/include/asm-ia64/system.h
> ====================================
> => 
> --- /usr/tmp/TmpDir.30939-0/linux/include/asm-ia64/system.h_1.25
> Tue May 13 14:41:50 2003
> +++ linux/include/asm-ia64/system.h	Tue May 13 14:40:26 2003
> @@ -445,6 +445,20 @@
>  #define task_running(rq, p)    (((rq)->curr = (p)) ||
> spin_is_locked(&(p)->switch_lock))
>  #define idle_needs_wakeup	0
>  
> +#ifdef CONFIG_IA64_GENERIC
> +extern int machine_is_sgi_sn2;
> +#define init_is_sgi_sn2(str) do { 		\
> +	if (!strcmp(str,"sn2"))			\
> +		machine_is_sgi_sn2=1;		\
> +  } while (0)
> +
> +#define is_sgi_sn2() 	(machine_is_sgi_sn2)
> +#elif CONFIG_IA64_SGI_SN
> +#define is_sgi_sn2()	1
> +#else
> +#define is_sgi_sn2()	0
> +#endif /* CONFIG_IA64_GENERIC */
> +
>  #endif /* __KERNEL__ */
>  
>  #endif /* __ASSEMBLY__ */
> 



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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
  2003-05-14 15:32 ` Alex Williamson
@ 2003-05-14 15:47 ` Martin Hicks
  2003-05-14 20:49 ` Jes Sorensen
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Hicks @ 2003-05-14 15:47 UTC (permalink / raw)
  To: linux-ia64

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



On Wed, May 14, 2003 at 09:32:53AM -0600, Alex Williamson wrote:
> 
>    Why not just make a runtime strcmp to platform_name?  Then
> you could make a generic is_platform("sn2") type function/macro
> that everyone could use and you'd get rid of that nasty init
> function.  If you realy need to make such a check in a perfmance
> path, it should probably be a machvec.  Thanks,

That sounds fine to me.  I was certainly aiming to keep this
in non-performance critical regions.  I'd actually like to
restrict its use to init decisions, such as which serial
console driver to use.

mh

-- 
Wild Open Source Inc.                  mort@wildopensource.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
  2003-05-14 15:32 ` Alex Williamson
  2003-05-14 15:47 ` Martin Hicks
@ 2003-05-14 20:49 ` Jes Sorensen
  2003-05-16 19:21 ` Martin Hicks
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jes Sorensen @ 2003-05-14 20:49 UTC (permalink / raw)
  To: linux-ia64

>>>>> "Alex" = Alex Williamson <alex_williamson@hp.com> writes:

Alex>    Why not just make a runtime strcmp to platform_name?  Then
Alex> you could make a generic is_platform("sn2") type function/macro
Alex> that everyone could use and you'd get rid of that nasty init
Alex> function.  If you realy need to make such a check in a perfmance
Alex> path, it should probably be a machvec.  Thanks,

Hi Alex,

I think the main reason for this was to cache the strcmp result in an
integer to make it faster.

Cheers,
Jes


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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
                   ` (2 preceding siblings ...)
  2003-05-14 20:49 ` Jes Sorensen
@ 2003-05-16 19:21 ` Martin Hicks
  2003-05-16 19:35 ` Alex Williamson
  2003-05-20 19:56 ` Martin Hicks
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Hicks @ 2003-05-16 19:21 UTC (permalink / raw)
  To: linux-ia64


On Wed, May 14, 2003 at 09:32:53AM -0600, Alex Williamson wrote:
> 
>    Why not just make a runtime strcmp to platform_name?  Then
> you could make a generic is_platform("sn2") type function/macro
> that everyone could use and you'd get rid of that nasty init
> function.  If you realy need to make such a check in a perfmance
> path, it should probably be a machvec.  Thanks,
> 


Here is the next iteration, based on your suggestions.  It also caches
the result of the first acpi_get_sysname() call, since this really
shouldn't change while the machine is running.

This is against the linux-ia64-2.5 bk tree.

It does include the sn2 platform detection in acpi_get_sysname(), which
may be duplicated in jbarnes' 2.5 patch.

mh

-- 
Wild Open Source Inc.                  mort@wildopensource.com


=== arch/ia64/kernel/acpi.c 1.40 vs edited ==--- 1.40/arch/ia64/kernel/acpi.c	Sat May 10 03:28:45 2003
+++ edited/arch/ia64/kernel/acpi.c	Fri May 16 17:23:28 2003
@@ -73,31 +73,43 @@
 	struct acpi20_table_rsdp *rsdp;
 	struct acpi_table_xsdt *xsdt;
 	struct acpi_table_header *hdr;
+	static char *sysname;
+
+	if (sysname)
+		return sysname;
 
 	rsdp_phys = acpi_find_rsdp();
 	if (!rsdp_phys) {
 		printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n");
-		return "dig";
+		sysname = "dig";
+		return sysname;
 	}
 
 	rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys);
 	if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
 		printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
-		return "dig";
+		sysname = "dig";
+		return sysname;
 	}
 
 	xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address);
 	hdr = &xsdt->header;
 	if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) {
 		printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
-		return "dig";
+		sysname = "dig";
+		return sysname;
 	}
 
 	if (!strcmp(hdr->oem_id, "HP")) {
-		return "hpzx1";
+		sysname = "hpzx1";
+		return sysname;
+	} else if (!strcmp(hdr->oem_id, "SGI")) {
+		sysname = "sn2";
+		return sysname;
 	}
 
-	return "dig";
+	sysname = "sn2";
+	return sysname;
 #else
 # if defined (CONFIG_IA64_HP_SIM)
 	return "hpsim";
=== include/asm-ia64/system.h 1.37 vs edited ==--- 1.37/include/asm-ia64/system.h	Thu May 15 05:45:02 2003
+++ edited/include/asm-ia64/system.h	Fri May 16 16:50:51 2003
@@ -29,6 +29,7 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/string.h>
 
 struct pci_vector_struct {
 	__u16 segment;	/* PCI Segment number */
@@ -275,6 +276,14 @@
 } while (0)
 #define finish_arch_switch(rq, prev)	spin_unlock_irq(&(prev)->switch_lock)
 #define task_running(rq, p) 		((rq)->curr = (p) || spin_is_locked(&(p)->switch_lock))
+
+extern const char * acpi_get_sysname(void);
+static inline int ia64_platform_is(const char *str) 
+{
+	if (!strcmp(str,acpi_get_sysname()))	
+		return 1;
+	return 0;
+}
 
 #endif /* __KERNEL__ */
 


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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
                   ` (3 preceding siblings ...)
  2003-05-16 19:21 ` Martin Hicks
@ 2003-05-16 19:35 ` Alex Williamson
  2003-05-20 19:56 ` Martin Hicks
  5 siblings, 0 replies; 7+ messages in thread
From: Alex Williamson @ 2003-05-16 19:35 UTC (permalink / raw)
  To: linux-ia64

Martin Hicks wrote:
> Here is the next iteration, based on your suggestions.  It also caches
> the result of the first acpi_get_sysname() call, since this really
> shouldn't change while the machine is running.
>

Martin,

   Everything is already in place to make this much easier.
I was thinking something more like this:

#define ia64_platform_is(x) (strcmp(x,platform_name) = 0)

The name is stored in the machvec, so you don't need to cache
it anywhere else.

	Alex

--
Alex Williamson                             HP Linux & Open Source Lab


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

* Re: [Linux-ia64] runtime platform detection in GENERIC kernels
  2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
                   ` (4 preceding siblings ...)
  2003-05-16 19:35 ` Alex Williamson
@ 2003-05-20 19:56 ` Martin Hicks
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Hicks @ 2003-05-20 19:56 UTC (permalink / raw)
  To: linux-ia64


On Fri, May 16, 2003 at 01:35:52PM -0600, Alex Williamson wrote:
> Martin Hicks wrote:
> > Here is the next iteration, based on your suggestions.  It also caches
> > the result of the first acpi_get_sysname() call, since this really
> > shouldn't change while the machine is running.
> >
> 
> Martin,
> 
>    Everything is already in place to make this much easier.
> I was thinking something more like this:
> 
> #define ia64_platform_is(x) (strcmp(x,platform_name) = 0)
> 
> The name is stored in the machvec, so you don't need to cache
> it anywhere else.

Patch attached against Bjorn's 2.4 bk tree.

-- 
Wild Open Source Inc.                  mort@wildopensource.com

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1122  -> 1.1123 
#	include/asm-ia64/system.h	1.15    -> 1.16   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/05/20	mort@green.i.bork.org	1.1123
# Add a small macro ia64_platform_is(platform) which checks
# if the platform is indeed "platform".
# --------------------------------------------
#
diff -Nru a/include/asm-ia64/system.h b/include/asm-ia64/system.h
--- a/include/asm-ia64/system.h	Tue May 20 19:54:44 2003
+++ b/include/asm-ia64/system.h	Tue May 20 19:54:44 2003
@@ -27,6 +27,7 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/string.h>
 
 struct pci_vector_struct {
 	__u16 segment;	/* PCI Segment number */
@@ -290,6 +291,8 @@
 	__switch_to(prev,next,last);					\
 } while (0)
 #endif
+
+#define ia64_platform_is(x) (!strcmp(x, platform_name))
 
 #endif /* __KERNEL__ */
 



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

end of thread, other threads:[~2003-05-20 19:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-14 15:03 [Linux-ia64] runtime platform detection in GENERIC kernels Martin Hicks
2003-05-14 15:32 ` Alex Williamson
2003-05-14 15:47 ` Martin Hicks
2003-05-14 20:49 ` Jes Sorensen
2003-05-16 19:21 ` Martin Hicks
2003-05-16 19:35 ` Alex Williamson
2003-05-20 19:56 ` Martin Hicks

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.