Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Huang, Ying
On Tue, 2007-10-30 at 15:58 +, Denys Vlasenko wrote:
> On Tuesday 30 October 2007 05:55, Huang, Ying wrote:
> > +static inline unsigned long native_get_wallclock(void)
> > +{
> > +   unsigned long retval;
> > +
> > +   if (efi_enabled)
> > +   retval = efi_get_time();
> > +   else
> > +   retval = mach_get_cmos_time();
> > +
> > +   return retval;
> > +}
> 
> mach_get_cmos_time() is itself an inline, and a _large_ one
> (~20 LOC with macro and function calls).
> 
> efi_get_time() is an inline too, although strange one:
> it is declared inline *only* in efi.c file:
>   inline unsigned long efi_get_time(void)
> (yes, just inline, not static/extern),
> while efi.h has normal extern for it:
>   extern unsigned long efi_get_time(void);
> 
> Is it supposed to be like that?

efi_get_time is no longer inline in this patch. See efi.c of this patch.

Best Regards,
Huang Ying
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Thomas Gleixner
On Tue, 30 Oct 2007, Denys Vlasenko wrote:
> mach_get_cmos_time() is itself an inline, and a _large_ one
> (~20 LOC with macro and function calls).
> 
> Same here, only mach_set_rtc_mmss is 50 LOC, not 20.

It was:) 

http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-x86.git;a=commit;h=3ea9de98deb42d9ea6d1add58e01b66676017c00

tglx
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Denys Vlasenko
On Tuesday 30 October 2007 05:55, Huang, Ying wrote:
> +static inline unsigned long native_get_wallclock(void)
> +{
> + unsigned long retval;
> +
> + if (efi_enabled)
> + retval = efi_get_time();
> + else
> + retval = mach_get_cmos_time();
> +
> + return retval;
> +}

mach_get_cmos_time() is itself an inline, and a _large_ one
(~20 LOC with macro and function calls).

efi_get_time() is an inline too, although strange one:
it is declared inline *only* in efi.c file:
  inline unsigned long efi_get_time(void)
(yes, just inline, not static/extern),
while efi.h has normal extern for it:
  extern unsigned long efi_get_time(void);

Is it supposed to be like that?

> +static inline int native_set_wallclock(unsigned long nowtime)
> +{
> + int retval;
> +
> + if (efi_enabled)
> + retval = efi_set_rtc_mmss(nowtime);
> + else
> + retval = mach_set_rtc_mmss(nowtime);
> +
> + return retval;
> +}

Same here, only mach_set_rtc_mmss is 50 LOC, not 20.
--
vda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Denys Vlasenko
On Tuesday 30 October 2007 05:55, Huang, Ying wrote:
 +static inline unsigned long native_get_wallclock(void)
 +{
 + unsigned long retval;
 +
 + if (efi_enabled)
 + retval = efi_get_time();
 + else
 + retval = mach_get_cmos_time();
 +
 + return retval;
 +}

mach_get_cmos_time() is itself an inline, and a _large_ one
(~20 LOC with macro and function calls).

efi_get_time() is an inline too, although strange one:
it is declared inline *only* in efi.c file:
  inline unsigned long efi_get_time(void)
(yes, just inline, not static/extern),
while efi.h has normal extern for it:
  extern unsigned long efi_get_time(void);

Is it supposed to be like that?

 +static inline int native_set_wallclock(unsigned long nowtime)
 +{
 + int retval;
 +
 + if (efi_enabled)
 + retval = efi_set_rtc_mmss(nowtime);
 + else
 + retval = mach_set_rtc_mmss(nowtime);
 +
 + return retval;
 +}

Same here, only mach_set_rtc_mmss is 50 LOC, not 20.
--
vda
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Thomas Gleixner
On Tue, 30 Oct 2007, Denys Vlasenko wrote:
 mach_get_cmos_time() is itself an inline, and a _large_ one
 (~20 LOC with macro and function calls).
 
 Same here, only mach_set_rtc_mmss is 50 LOC, not 20.

It was:) 

http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-x86.git;a=commit;h=3ea9de98deb42d9ea6d1add58e01b66676017c00

tglx
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-30 Thread Huang, Ying
On Tue, 2007-10-30 at 15:58 +, Denys Vlasenko wrote:
 On Tuesday 30 October 2007 05:55, Huang, Ying wrote:
  +static inline unsigned long native_get_wallclock(void)
  +{
  +   unsigned long retval;
  +
  +   if (efi_enabled)
  +   retval = efi_get_time();
  +   else
  +   retval = mach_get_cmos_time();
  +
  +   return retval;
  +}
 
 mach_get_cmos_time() is itself an inline, and a _large_ one
 (~20 LOC with macro and function calls).
 
 efi_get_time() is an inline too, although strange one:
 it is declared inline *only* in efi.c file:
   inline unsigned long efi_get_time(void)
 (yes, just inline, not static/extern),
 while efi.h has normal extern for it:
   extern unsigned long efi_get_time(void);
 
 Is it supposed to be like that?

efi_get_time is no longer inline in this patch. See efi.c of this patch.

Best Regards,
Huang Ying
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-29 Thread Huang, Ying
This patch adds support for several EFI runtime services for EFI
x86_64 system.

The EFI support for emergency_restart and RTC clock is added. The EFI
based implementation and legacy BIOS or CMOS based implementation are
put in separate functions and can be chosen with kernel boot options.

Signed-off-by: Chandramouli Narayanan <[EMAIL PROTECTED]>
Signed-off-by: Huang Ying <[EMAIL PROTECTED]>

---

 arch/x86/kernel/reboot_64.c |   19 +-
 arch/x86/kernel/time_64.c   |   47 +++-
 include/asm-x86/emergency-restart.h |8 ++
 include/asm-x86/time.h  |   47 +++-
 include/asm-x86/time_32.h   |   44 +
 include/asm-x86/time_64.h   |7 +
 6 files changed, 107 insertions(+), 65 deletions(-)

Index: linux-2.6.24-rc1/arch/x86/kernel/reboot_64.c
===
--- linux-2.6.24-rc1.orig/arch/x86/kernel/reboot_64.c   2007-10-30 
10:15:03.0 +0800
+++ linux-2.6.24-rc1/arch/x86/kernel/reboot_64.c2007-10-30 
10:22:00.0 +0800
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -26,18 +27,16 @@
 EXPORT_SYMBOL(pm_power_off);
 
 static long no_idt[3];
-static enum { 
-   BOOT_TRIPLE = 't',
-   BOOT_KBD = 'k'
-} reboot_type = BOOT_KBD;
+enum reboot_type reboot_type = BOOT_KBD;
 static int reboot_mode = 0;
 int reboot_force;
 
-/* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
+/* reboot=t[riple] | k[bd] | e[fi] [, [w]arm | [c]old]
warm   Don't set the cold reboot flag
cold   Set the cold reboot flag
triple Force a triple fault (init)
kbdUse the keyboard controller. cold reset (default)
+   efiUse efi reset_system runtime service
force  Avoid anything that could hang.
  */ 
 static int __init reboot_setup(char *str)
@@ -55,6 +54,7 @@
case 't':
case 'b':
case 'k':
+   case 'e':
reboot_type = *str;
break;
case 'f':
@@ -142,7 +142,14 @@
 
reboot_type = BOOT_KBD;
break;
-   }  
+
+   case BOOT_EFI:
+   if (efi_enabled)
+   efi.reset_system(reboot_mode ? EFI_RESET_WARM : 
EFI_RESET_COLD,
+EFI_SUCCESS, 0, NULL);
+   reboot_type = BOOT_KBD;
+   break;
+   }
}  
 }
 
Index: linux-2.6.24-rc1/arch/x86/kernel/time_64.c
===
--- linux-2.6.24-rc1.orig/arch/x86/kernel/time_64.c 2007-10-30 
10:15:03.0 +0800
+++ linux-2.6.24-rc1/arch/x86/kernel/time_64.c  2007-10-30 10:22:04.0 
+0800
@@ -45,12 +45,19 @@
 #include 
 #include 
 #include 
+#include 
 
 DEFINE_SPINLOCK(rtc_lock);
 EXPORT_SYMBOL(rtc_lock);
 
 volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
 
+static int set_rtc_mmss(unsigned long nowtime);
+static unsigned long read_cmos_clock(void);
+
+unsigned long (*get_wallclock)(void) = read_cmos_clock;
+int (*set_wallclock)(unsigned long nowtime) = set_rtc_mmss;
+
 unsigned long profile_pc(struct pt_regs *regs)
 {
unsigned long pc = instruction_pointer(regs);
@@ -84,13 +91,6 @@
unsigned char control, freq_select;
 
 /*
- * IRQs are disabled when we're called from the timer interrupt,
- * no need for spin_lock_irqsave()
- */
-
-   spin_lock(_lock);
-
-/*
  * Tell the clock it's being set and stop it.
  */
 
@@ -138,14 +138,23 @@
CMOS_WRITE(control, RTC_CONTROL);
CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
 
-   spin_unlock(_lock);
-
return retval;
 }
 
 int update_persistent_clock(struct timespec now)
 {
-   return set_rtc_mmss(now.tv_sec);
+   int retval;
+
+/*
+ * IRQs are disabled when we're called from the timer interrupt,
+ * no need for spin_lock_irqsave()
+ */
+
+   spin_lock(_lock);
+   retval = set_wallclock(now.tv_sec);
+   spin_unlock(_lock);
+
+   return retval;
 }
 
 static irqreturn_t timer_event_interrupt(int irq, void *dev_id)
@@ -157,14 +166,11 @@
return IRQ_HANDLED;
 }
 
-unsigned long read_persistent_clock(void)
+static unsigned long read_cmos_clock(void)
 {
unsigned int year, mon, day, hour, min, sec;
-   unsigned long flags;
unsigned century = 0;
 
-   spin_lock_irqsave(_lock, flags);
-
do {
sec = CMOS_READ(RTC_SECONDS);
min = CMOS_READ(RTC_MINUTES);
@@ -179,8 +185,6 @@
 #endif
} while (sec != CMOS_READ(RTC_SECONDS));
 
-   spin_unlock_irqrestore(_lock, flags);
-
/*
 * We know that x86-64 always uses BCD format, no need to check the
 * config register.
@@ -208,6 +212,17 @@

[PATCH 2/4 -v5] x86_64 EFI runtime service support: EFI runtime services

2007-10-29 Thread Huang, Ying
This patch adds support for several EFI runtime services for EFI
x86_64 system.

The EFI support for emergency_restart and RTC clock is added. The EFI
based implementation and legacy BIOS or CMOS based implementation are
put in separate functions and can be chosen with kernel boot options.

Signed-off-by: Chandramouli Narayanan [EMAIL PROTECTED]
Signed-off-by: Huang Ying [EMAIL PROTECTED]

---

 arch/x86/kernel/reboot_64.c |   19 +-
 arch/x86/kernel/time_64.c   |   47 +++-
 include/asm-x86/emergency-restart.h |8 ++
 include/asm-x86/time.h  |   47 +++-
 include/asm-x86/time_32.h   |   44 +
 include/asm-x86/time_64.h   |7 +
 6 files changed, 107 insertions(+), 65 deletions(-)

Index: linux-2.6.24-rc1/arch/x86/kernel/reboot_64.c
===
--- linux-2.6.24-rc1.orig/arch/x86/kernel/reboot_64.c   2007-10-30 
10:15:03.0 +0800
+++ linux-2.6.24-rc1/arch/x86/kernel/reboot_64.c2007-10-30 
10:22:00.0 +0800
@@ -9,6 +9,7 @@
 #include linux/pm.h
 #include linux/kdebug.h
 #include linux/sched.h
+#include linux/efi.h
 #include asm/io.h
 #include asm/delay.h
 #include asm/desc.h
@@ -26,18 +27,16 @@
 EXPORT_SYMBOL(pm_power_off);
 
 static long no_idt[3];
-static enum { 
-   BOOT_TRIPLE = 't',
-   BOOT_KBD = 'k'
-} reboot_type = BOOT_KBD;
+enum reboot_type reboot_type = BOOT_KBD;
 static int reboot_mode = 0;
 int reboot_force;
 
-/* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
+/* reboot=t[riple] | k[bd] | e[fi] [, [w]arm | [c]old]
warm   Don't set the cold reboot flag
cold   Set the cold reboot flag
triple Force a triple fault (init)
kbdUse the keyboard controller. cold reset (default)
+   efiUse efi reset_system runtime service
force  Avoid anything that could hang.
  */ 
 static int __init reboot_setup(char *str)
@@ -55,6 +54,7 @@
case 't':
case 'b':
case 'k':
+   case 'e':
reboot_type = *str;
break;
case 'f':
@@ -142,7 +142,14 @@
 
reboot_type = BOOT_KBD;
break;
-   }  
+
+   case BOOT_EFI:
+   if (efi_enabled)
+   efi.reset_system(reboot_mode ? EFI_RESET_WARM : 
EFI_RESET_COLD,
+EFI_SUCCESS, 0, NULL);
+   reboot_type = BOOT_KBD;
+   break;
+   }
}  
 }
 
Index: linux-2.6.24-rc1/arch/x86/kernel/time_64.c
===
--- linux-2.6.24-rc1.orig/arch/x86/kernel/time_64.c 2007-10-30 
10:15:03.0 +0800
+++ linux-2.6.24-rc1/arch/x86/kernel/time_64.c  2007-10-30 10:22:04.0 
+0800
@@ -45,12 +45,19 @@
 #include asm/mpspec.h
 #include asm/nmi.h
 #include asm/vgtod.h
+#include asm/time.h
 
 DEFINE_SPINLOCK(rtc_lock);
 EXPORT_SYMBOL(rtc_lock);
 
 volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
 
+static int set_rtc_mmss(unsigned long nowtime);
+static unsigned long read_cmos_clock(void);
+
+unsigned long (*get_wallclock)(void) = read_cmos_clock;
+int (*set_wallclock)(unsigned long nowtime) = set_rtc_mmss;
+
 unsigned long profile_pc(struct pt_regs *regs)
 {
unsigned long pc = instruction_pointer(regs);
@@ -84,13 +91,6 @@
unsigned char control, freq_select;
 
 /*
- * IRQs are disabled when we're called from the timer interrupt,
- * no need for spin_lock_irqsave()
- */
-
-   spin_lock(rtc_lock);
-
-/*
  * Tell the clock it's being set and stop it.
  */
 
@@ -138,14 +138,23 @@
CMOS_WRITE(control, RTC_CONTROL);
CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
 
-   spin_unlock(rtc_lock);
-
return retval;
 }
 
 int update_persistent_clock(struct timespec now)
 {
-   return set_rtc_mmss(now.tv_sec);
+   int retval;
+
+/*
+ * IRQs are disabled when we're called from the timer interrupt,
+ * no need for spin_lock_irqsave()
+ */
+
+   spin_lock(rtc_lock);
+   retval = set_wallclock(now.tv_sec);
+   spin_unlock(rtc_lock);
+
+   return retval;
 }
 
 static irqreturn_t timer_event_interrupt(int irq, void *dev_id)
@@ -157,14 +166,11 @@
return IRQ_HANDLED;
 }
 
-unsigned long read_persistent_clock(void)
+static unsigned long read_cmos_clock(void)
 {
unsigned int year, mon, day, hour, min, sec;
-   unsigned long flags;
unsigned century = 0;
 
-   spin_lock_irqsave(rtc_lock, flags);
-
do {
sec = CMOS_READ(RTC_SECONDS);
min = CMOS_READ(RTC_MINUTES);
@@ -179,8 +185,6 @@
 #endif
} while (sec != CMOS_READ(RTC_SECONDS));
 
-   spin_unlock_irqrestore(rtc_lock, flags);
-
/*