How to build the kernel without any optimization?

2010-08-21 Thread Shawn Jin
Hi,

I'm tracing the execution of ds1307_probe() and find that some of
variables or function arguments cannot be printed in gdb because they
are optimized out or not in the current context. This really gives
some headache. Is there a way to build the kernel without any
optimization? What gcc option shall I disable or add?

I already added the following to arch/powerpc/Makefile.

# Prevent GDB from jumping around in the code when trying to single step
ifeq ($(CONFIG_DEBUG_KERNEL),y)
KBUILD_CFLAGS   += -fno-schedule-insns -fno-schedule-insns2
endif

Thanks,
-Shawn.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: How to build the kernel without any optimization?

2010-08-21 Thread Nicholas Mc Guire
On Fri, 20 Aug 2010, Shawn Jin wrote:

 Hi,
 
 I'm tracing the execution of ds1307_probe() and find that some of
 variables or function arguments cannot be printed in gdb because they
 are optimized out or not in the current context. This really gives
 some headache. Is there a way to build the kernel without any
 optimization? What gcc option shall I disable or add?
 
 I already added the following to arch/powerpc/Makefile.
 
 # Prevent GDB from jumping around in the code when trying to single step
 ifeq ($(CONFIG_DEBUG_KERNEL),y)
 KBUILD_CFLAGS   += -fno-schedule-insns -fno-schedule-insns2
 endif


much of the kernel can not be build without optimization - what you 
can do though is slectively try to disable optimization for specific
files by putting 

 CFLAGS_REMOVE_objfilenam.o = -SOME_OPT

in the Makefile. I think that is safer than what you did above as this would
always depend on the order of options that ultimately get passed to gcc.

hofrat 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] pmu: add compat_pmu_ioctl

2010-08-21 Thread Andreas Schwab
The ioctls are actually compatible, but due to historical mistake the
numbers differ between 32bit and 64bit.

Signed-off-by: Andreas Schwab sch...@linux-m68k.org
---
 drivers/macintosh/via-pmu.c |   41 +
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 35bc273..610f247 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2349,11 +2349,52 @@ static long pmu_unlocked_ioctl(struct file *filp,
return ret;
 }
 
+#ifdef CONFIG_COMPAT
+#define PMU_IOC_GET_BACKLIGHT32_IOR('B', 1, u32)
+#define PMU_IOC_SET_BACKLIGHT32_IOW('B', 2, u32)
+#define PMU_IOC_GET_MODEL32_IOR('B', 3, u32)
+#define PMU_IOC_HAS_ADB32  _IOR('B', 4, u32)
+#define PMU_IOC_CAN_SLEEP32_IOR('B', 5, u32)
+#define PMU_IOC_GRAB_BACKLIGHT32 _IOR('B', 6, u32)
+
+static long compat_pmu_ioctl (struct file *filp, u_int cmd, u_long arg)
+{
+   switch (cmd) {
+   case PMU_IOC_SLEEP:
+   break;
+   case PMU_IOC_GET_BACKLIGHT32:
+   cmd = PMU_IOC_GET_BACKLIGHT;
+   break;
+   case PMU_IOC_SET_BACKLIGHT32:
+   cmd = PMU_IOC_SET_BACKLIGHT;
+   break;
+   case PMU_IOC_GET_MODEL32:
+   cmd = PMU_IOC_GET_MODEL;
+   break;
+   case PMU_IOC_HAS_ADB32:
+   cmd = PMU_IOC_HAS_ADB;
+   break;
+   case PMU_IOC_CAN_SLEEP32:
+   cmd = PMU_IOC_CAN_SLEEP;
+   break;
+   case PMU_IOC_GRAB_BACKLIGHT32:
+   cmd = PMU_IOC_GRAB_BACKLIGHT;
+   break;
+   default:
+   return -ENOIOCTLCMD;
+   }
+   return pmu_unlocked_ioctl(filp, cmd, arg);
+}
+#endif
+
 static const struct file_operations pmu_device_fops = {
.read   = pmu_read,
.write  = pmu_write,
.poll   = pmu_fpoll,
.unlocked_ioctl = pmu_unlocked_ioctl,
+#ifdef CONFIG_COMPAT
+   .compat_ioctl   = compat_pmu_ioctl,
+#endif
.open   = pmu_open,
.release= pmu_release,
 };
-- 
1.7.2.2


-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc: remove fpscr use from [kvm_]cvt_{fd,df}

2010-08-21 Thread Andreas Schwab
Neither lfs nor stfs touch the fpscr, so remove the restore/save of it
around them.

Signed-off-by: Andreas Schwab sch...@linux-m68k.org
---
 arch/powerpc/include/asm/kvm_fpu.h   |4 +-
 arch/powerpc/include/asm/system.h|4 +-
 arch/powerpc/kernel/align.c  |4 +-
 arch/powerpc/kernel/fpu.S|   10 ---
 arch/powerpc/kvm/book3s_paired_singles.c |   44 +
 arch/powerpc/kvm/fpu.S   |8 -
 6 files changed, 26 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_fpu.h 
b/arch/powerpc/include/asm/kvm_fpu.h
index c3d4f05..92daae1 100644
--- a/arch/powerpc/include/asm/kvm_fpu.h
+++ b/arch/powerpc/include/asm/kvm_fpu.h
@@ -82,7 +82,7 @@ FPD_THREE_IN(fmadd)
 FPD_THREE_IN(fnmsub)
 FPD_THREE_IN(fnmadd)
 
-extern void kvm_cvt_fd(u32 *from, u64 *to, u64 *fpscr);
-extern void kvm_cvt_df(u64 *from, u32 *to, u64 *fpscr);
+extern void kvm_cvt_fd(u32 *from, u64 *to);
+extern void kvm_cvt_df(u64 *from, u32 *to);
 
 #endif
diff --git a/arch/powerpc/include/asm/system.h 
b/arch/powerpc/include/asm/system.h
index 6c294ac..0b3fe78 100644
--- a/arch/powerpc/include/asm/system.h
+++ b/arch/powerpc/include/asm/system.h
@@ -154,8 +154,8 @@ extern void enable_kernel_spe(void);
 extern void giveup_spe(struct task_struct *);
 extern void load_up_spe(struct task_struct *);
 extern int fix_alignment(struct pt_regs *);
-extern void cvt_fd(float *from, double *to, struct thread_struct *thread);
-extern void cvt_df(double *from, float *to, struct thread_struct *thread);
+extern void cvt_fd(float *from, double *to);
+extern void cvt_df(double *from, float *to);
 
 #ifndef CONFIG_SMP
 extern void discard_lazy_cpu_state(void);
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index b876e98..8184ee9 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -889,7 +889,7 @@ int fix_alignment(struct pt_regs *regs)
 #ifdef CONFIG_PPC_FPU
preempt_disable();
enable_kernel_fp();
-   cvt_df(data.dd, (float *)data.v[4], current-thread);
+   cvt_df(data.dd, (float *)data.v[4]);
preempt_enable();
 #else
return 0;
@@ -933,7 +933,7 @@ int fix_alignment(struct pt_regs *regs)
 #ifdef CONFIG_PPC_FPU
preempt_disable();
enable_kernel_fp();
-   cvt_fd((float *)data.v[4], data.dd, current-thread);
+   cvt_fd((float *)data.v[4], data.dd);
preempt_enable();
 #else
return 0;
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index fc8f5b1..e86c040 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -163,24 +163,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
 /*
  * These are used in the alignment trap handler when emulating
  * single-precision loads and stores.
- * We restore and save the fpscr so the task gets the same result
- * and exceptions as if the cpu had performed the load or store.
  */
 
 _GLOBAL(cvt_fd)
-   lfd 0,THREAD_FPSCR(r5)  /* load up fpscr value */
-   MTFSF_L(0)
lfs 0,0(r3)
stfd0,0(r4)
-   mffs0
-   stfd0,THREAD_FPSCR(r5)  /* save new fpscr value */
blr
 
 _GLOBAL(cvt_df)
-   lfd 0,THREAD_FPSCR(r5)  /* load up fpscr value */
-   MTFSF_L(0)
lfd 0,0(r3)
stfs0,0(r4)
-   mffs0
-   stfd0,THREAD_FPSCR(r5)  /* save new fpscr value */
blr
diff --git a/arch/powerpc/kvm/book3s_paired_singles.c 
b/arch/powerpc/kvm/book3s_paired_singles.c
index 474f2e2..35a701f 100644
--- a/arch/powerpc/kvm/book3s_paired_singles.c
+++ b/arch/powerpc/kvm/book3s_paired_singles.c
@@ -159,7 +159,7 @@
 
 static inline void kvmppc_sync_qpr(struct kvm_vcpu *vcpu, int rt)
 {
-   kvm_cvt_df(vcpu-arch.fpr[rt], vcpu-arch.qpr[rt], vcpu-arch.fpscr);
+   kvm_cvt_df(vcpu-arch.fpr[rt], vcpu-arch.qpr[rt]);
 }
 
 static void kvmppc_inject_pf(struct kvm_vcpu *vcpu, ulong eaddr, bool is_store)
@@ -204,7 +204,7 @@ static int kvmppc_emulate_fpr_load(struct kvm_run *run, 
struct kvm_vcpu *vcpu,
/* put in registers */
switch (ls_type) {
case FPU_LS_SINGLE:
-   kvm_cvt_fd((u32*)tmp, vcpu-arch.fpr[rs], vcpu-arch.fpscr);
+   kvm_cvt_fd((u32*)tmp, vcpu-arch.fpr[rs]);
vcpu-arch.qpr[rs] = *((u32*)tmp);
break;
case FPU_LS_DOUBLE:
@@ -230,7 +230,7 @@ static int kvmppc_emulate_fpr_store(struct kvm_run *run, 
struct kvm_vcpu *vcpu,
 
switch (ls_type) {
case FPU_LS_SINGLE:
-   kvm_cvt_df(vcpu-arch.fpr[rs], (u32*)tmp, vcpu-arch.fpscr);
+   kvm_cvt_df(vcpu-arch.fpr[rs], (u32*)tmp);
val = *((u32*)tmp);
len = sizeof(u32);
break;
@@ -296,7 +296,7 @@ static int