aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel (follow)
AgeCommit message (Collapse)AuthorFilesLines
2009-08-24sh: Use internal watchdog timer to perform resetJon Frosdick1-0/+20
This patches will trigger a reboot using the watchdog timer instead of double fault. Unlike the previous method, this one actually works in 32 bit mode. Reset should also be cleaner. Signed-off-by: Jon Frosdick <jon.frosdick@st.com> Signed-off-by: Carl Shaw <carl.shaw@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: kgdb: do not reload VBR while handling debugger breackpointGiuseppe Cavallaro1-2/+0
Save the VBR allowing GDB to dump full registers set but do not reload it as soon as the kgdb_handle_exception is invoked. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: Stuart Menefy <stuart.menefy@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: Allow use of GENERIC_IOMAPDavid McKay1-0/+4
The synopsys PCI cell used in the later STMicro chips requires code to be run in order to do IO cycles, rather than just memory mapping the IO space. Rather than extending the existing SH infrastructure to allow this, use the GENERIC_IOMAP implmentation to save re-inventing the wheel. This set of changes allows the SH to be built with GENERIC_IOMAP enabled, it just ifdef's out the functions provided by the GENERIC_IOMAP implementation, and provides a few required missing functions. Signed-off-by: David McKay <david.mckay@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: Improve unwind info for signalsCarl Shaw1-1/+11
GCC does not issue unwind information for function epilogues. Unfortunately we can catch a signal during an epilogue. The signal handler writes the current context and signal return code onto the stack overwriting previous contents. During unwinding, libgcc can try to restore registers from the stack and restores corrupted ones. This can lead to segmentation, misaligned access and sigbus faults. For example, consider the following code: mov.l r12,@-r15 mov.l r14,@-r15 sts.l pr,@-r15 mov r15,r14 <do stuff> mov r14, r15 lds.l @r15+, pr <<< SIGNAL HERE mov.l @r15+, r14 mov.l @r15+, r12 rts Unwind is aware that pr was pushed to stack in prolog, so tries to restore it. Unfortunately it restores the last word of the signal handler code placed on the stack by the kernel. This patch tries to avoid the problem by adding a guard region on the stack between where the function pushes data and where the signal handler pushes its return code. We probably don't see this problem often because exception handling unwinding in an epilogue only occurs due to a pthread cancel signal. Also the kernel signal stack handler alignment of 8 bytes could hide the occurance of this problem sometimes as the stack may not be trampled at a particular required word. This is not guaranteed to always work. It relies on a frame pointer existing for the function (so it can get the correct sp value) which is not always the case for the SH4. Modifications will also be made to libgcc for the case where there is no fp. Signed-off-by: Carl Shaw <carl.shaw@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: cleanup of do_address_error()Andre Draszik1-10/+10
This patch fixes a few problems with the existing code in do_address_error(). a) the variable used to printk()d the offending instruction wasn't initialized correctly. This is a fix to bug 5727 b) behaviour for CONFIG_CPU_SH2A wasn't correct c) the 'ignore address error' behaviour didn't update the PC, causing an infinite loop. Signed-off-by: Andre Draszik <andre.draszik@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: Allow user control over misaligned fixup handlingAndre Draszik1-0/+153
This patch brings the SH4 misaligned trap handler in line with what happens on ARM: Add a /proc/cpu/alignment which can be read from to get alignment trap statistics and written to to influence the behaviour of the alignment trap handling. The value to write is a bitfield, which has the following meaning: 1 warn, 2 fixup, 4 signal In addition, we add a /proc/cpu/kernel_alignment, to enable or disable warnings in case of kernel code causing alignment errors. Signed-off by: Andre Draszik <andre.draszik@st.com> Signed-off-by: Stuart Menefy <stuart.menefy@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24sh: ratelimit unaligned fixupsAndre Draszik1-13/+4
This patch makes sure we see messages about unaligned access fixups every now and then. Else especially userspace apps suffering from bad programming won't ever be noticed... Signed-off by: Andre Draszik <andre.draszik@st.com> Signed-off-by: Stuart Menefy <stuart.menefy@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-23Merge branches 'sh/hwblk' and 'sh/pm-runtime'Paul Mundt8-10/+428
2009-08-23sh: drop static UIO clocks for sh7722, sh7723 and sh7724Magnus Damm3-10/+10
The Runtime PM patch for UIO driver implements coarse grained dynamic power management for UIO devices. With that patch in place we can get rid of the static clock configuration. Which in turn makes it possible for cpuidle to enter deeper sleep. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-23sh: Fix section mismatch in platform bus notifier.Paul Mundt1-3/+2
The runtime PM for SH-Mobile code had platform_bus_notify() as __devinit, which is rather bogus. Kill off the annotation, which subsequently silences the section mismatch warnings. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-23sh: Runtime PM for SuperH Mobile platform bus devicesMagnus Damm2-0/+305
This patch is V3 of the SuperH Mobile Runtime PM platform bus implentation matching Rafael's Runtime PM v16. The code gets invoked from the SuperH specific Runtime PM platform bus functions that override the weak symbols for: - platform_pm_runtime_suspend() - platform_pm_runtime_resume() - platform_pm_runtime_idle() This Runtime PM implementation performs two levels of power management. At the time of platform bus runtime suspend the clock to the device is stopped instantly. Later on if all devices within the power domain has their clocks stopped then the device driver ->runtime_suspend() callbacks are used to save hardware register state for each device. Device driver ->runtime_suspend() calls are scheduled from cpuidle context using platform_pm_runtime_suspend_idle(). When all devices have been fully suspended the processor is allowed to enter deep sleep from cpuidle. The runtime resume operation turns on clocks and also restores registers if needed. It is worth noting that the devices start in a suspended state and the device driver is responsible for calling runtime resume before accessing the actual hardware. In this particular platform bus implementation runtime resume is not allowed from interrupt context. Runtime suspend is however allowed from interrupt context as long as the synchronous functions are avoided. [ updated for v17 -- PFM. ] Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-22sh: unwinder: cacheline align slab cache objects.Paul Mundt1-2/+5
The CIE and FDE structs are big enough and accessed regularly enough in certain configurations to make cacheline alignment useful. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-22Merge branch 'sh/dwarf-unwinder'Paul Mundt6-112/+213
Conflicts: arch/sh/kernel/cpu/sh3/entry.S
2009-08-22sh: unwinder: Use a special bug flag for unwinder traps.Paul Mundt3-30/+18
This simplifies the unwinder trap handling, dropping the use of the special trapa vector and simply piggybacking on top of the BUG support. A new BUGFLAG_UNWINDER is added for flagging the unwinder fault, before continuing on with regular BUG dispatch. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-22Merge branch 'sh/dwarf-unwinder' of git://github.com/mfleming/linux-2.6 into sh/dwarf-unwinderPaul Mundt6-89/+206
2009-08-22sh: Export unwind_stack() to satisfy modular oprofile.Paul Mundt1-0/+2
If the oprofile code is built as a module, unwind_stack() as used by the oprofile backtrace code is not available, causing build breakage. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-21sh: Handle the DWARF op, DW_CFA_undefinedMatt Fleming1-2/+11
Allow a DWARF register to have an undefined value. When applied to the DWARF return address register this lets lets us label a function as having no direct caller, e.g. kernel_thread_helper(). Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: Fix bug calculating the end of the FDE instructionsMatt Fleming1-3/+4
The 'end' member of struct dwarf_fde denotes one byte past the end of the CFA instruction stream for an FDE. The value of 'end' was being calcualted incorrectly, it was being set too high. This resulted in dwarf_cfa_execute_insns() interpreting data past the end of valid instructions, thus causing all sorts of weird crashes. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: Setup the frame pointer in handle_interruptMatt Fleming1-0/+2
When CONFIG_DWARF_UNWINDER is enabled setup r14 in handle_interrupt, so that we can figure out what function was running when we were interrupted. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: unwinder: Introduce UNWINDER_BUG() and UNWINDER_BUG_ON()Matt Fleming5-26/+59
We can't assume that if we execute the unwinder code and the unwinder was already running that it has faulted. Clearly two kernel threads can invoke the unwinder at the same time and may be running simultaneously. The previous approach used BUG() and BUG_ON() in the unwinder code to detect whether the unwinder was incapable of unwinding the stack, and that the next available unwinder should be used instead. A better approach is to explicitly invoke a trap handler to switch unwinders when the current unwinder cannot continue. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: unwinder: Set the flags for DW_CFA_val_offset ops as DWARF_VAL_OFFSETMatt Fleming1-1/+2
The handling of DW_CFA_val_offset ops was incorrectly using the DWARF_REG_OFFSET flag but the register's value cannot be calculated using the DWARF_REG_OFFSET method. Create a new flag to indicate that a different method must be used to calculate the register's value even though there is no implementation for DWARF_VAL_OFFSET yet; it's mainly just a place holder. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: unwinder: Fix memory leak and create our own kmem cacheMatt Fleming1-65/+136
Plug a memory leak in dwarf_unwinder_dump() where we didn't free the memory that we had previously allocated for the DWARF frames and DWARF registers. Now is also a opportune time to implement our own mempool and kmem cache. It's a good idea to have a certain number of frame and register objects in reserve at all times, so that we are guaranteed to have our allocation satisfied even when memory is scarce. Since we have pools to allocate from we can implement the registers for each frame as a linked list as opposed to a sparsely populated array. Whilst it's true that the lookup time for a linked list is larger than for arrays, there's only usually a maximum of 8 registers per frame. So the overhead isn't that much of a concern. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-21sh: Add initial support for SH7757 CPU subtypeYoshihiro Shimoda6-3/+2675
Signed-off-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-20sh: Fix up the CONFIG_FTRACE_SYSCALLS=n build.Paul Mundt1-0/+4
-tip can't be bothered keeping interfaces stable long enough for anyone to use them without having their builds broken without notification, so just ifdef around the problematic symbols until the new interfaces become available upstream. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-18sh: clkfwk: Support additional IFC divisor on SH7724.Kuninori Morimoto1-1/+1
This patch updates the FRQCRA.IFC divisor values for SH7724. Despite not being initially documented, the / 3 mode is also support for the IFC division. Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-18sh: Add a few missing irqflags tracing markers.Matt Fleming2-11/+24
save_regs contains an SR modification without an irqflags annotation, which resulted in a missing TRACE_IRQS_OFF in the interrupt exception path on SH-3/SH4. I've also moved the TRACE_IRQS_OFF/ON annotation when returning from the interrupt to just before we call __restore_all. This seems like the most logical place to put this because the annotation is for when we restore the SR register so we should delay the annotation until as last as possible. We were also missing a TRACE_IRQS_OFF in resume_kernel when CONFIG_PREEMPT is enabled. The end result is that this fixes up the lockdep engine debugging support with CONFIG_PREEMPT enabled on all SH-3/4 parts. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-18sh: SuperH Mobile Software Standby support for cpuidleMagnus Damm1-0/+11
This patch adds "SuperH Mobile Standby Mode [SF]" to the list of cpuidle sleep modes. If the software latency requirements from cpuidle are met together with fulfilled hardware requirements then deep sleep modes can be entered. Tested on sh7722 and sh7724 with "Sleep Mode", "Sleep Mode + SF" and "Software Standby Mode + SF" together with a multimedia work load and flood ping without packet drop. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-18sh: rework SuperH Mobile sleep code exception handlingMagnus Damm2-64/+107
This patch updates the exception handling in the sleep code for SuperH Mobile. With the patch applied the sleep code always rewrites the VBR and resumes from the exception vector, re-initializes hardware and jumps straight to the original interrupt vector. Tested on sh7722 and sh7724 with "Sleep Mode", "Sleep Mode + SF" and "Software Standby Mode + SF" with CONFIG_SUSPEND. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-17sh: unwinder: Move initialization to early_initcall() and tidy up locking.Paul Mundt2-21/+15
This moves the initialization over to an early_initcall(). This fixes up some lockdep interaction issues. At the same time, kill off some superfluous locking in the init path. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-16sh: Add support for DWARF GNU extensionsMatt Fleming1-1/+13
Also, remove the "fix" to DW_CFA_def_cfa_register where we reset the frame's cfa_offset to 0. This action is incorrect when handling DW_CFA_def_cfa_register as the DWARF spec specifically states that the previous contents of cfa_offset should be used with the new register. The reason that I thought cfa_offset should be reset to 0 was because it was being assigned a bogus value prior to executing the DW_CFA_def_cfa_register op. It turns out that the bogus cfa_offset value came from interpreting .cfi_escape pseudo-ops (those used by the GNU extensions) as CFA_DW_def_cfa ops. Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-16sh: Try again at getting the initial return address for an unwindMatt Fleming1-35/+6
The previous hack for calculating the return address for the first frame we unwind (dwarf_unwinder_dump) didn't always work. The problem was that it assumed once it read the rule for calculating the return address, there would be no new rules for calculating it. This isn't true because the way in which the CFA is calculated can change as you progress through a function and the return address is figured out using the CFA. Therefore, the way to calculate the return address can change. So, instead of using some offset from the beginning of dwarf_unwind_stack which is just a flakey approach, and instead of executing instructions from the FDE until the return address is setup, we now figure out the pc in dwarf_unwind_stack() just before we call dwarf_cfa_execute_insns(). Signed-off-by: Matt Fleming <matt@console-pimps.org>
2009-08-16sh: Merge the _32/_64 variants of arch/sh/kernel/Makefile.Paul Mundt3-64/+39
This uses the BITS export as per x86 in order to allow the same Makefile to be used. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15Merge branch 'master' into sh/hwblkPaul Mundt16-60/+1387
2009-08-15Merge branch 'sh/stable-updates'Paul Mundt1-2/+68
2009-08-15sh: sh7724 ddr self-refresh changesMagnus Damm1-2/+68
This patch updates the SuperH Mobile sleep assembly code with support for DBSC memory controller found in the sh7724 processor. Without this fix the memory hooked up to the sh7724 processor will never enter self-refresh mode before suspending to ram. The effect of this is that the memory contents most likeley will be lost upon resume which may or may not be what you want. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: Set the cfa_offset to 0 if we see a DW_CFA_def_cfa_register opMatt Fleming1-0/+1
The way that the CFA is calculated can change as we progress through a function. If we see a DW_CFA_def_cfa_register op we need to reset the frame's cfa_offset value which may have been previously setup. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: delay slot future proofing via EXPMASK on SH-4A parts.Paul Mundt1-1/+33
This implements EXPMASK initialization code for SH-4A parts, where it is possible to disable compat features that will go away in newer cores. Presently this includes disabling support for non-nop instructions in the rte delay slot, as well as a sleep instruction being placed in a delay slot (neither of which the kernel does any longer). As a result of this, any future offenders will have illegal slot exceptions generated for them. Associative writes for the memory-mapped cache array are still left enabled, until such a point that special cache operations for SH-4A are provided to move off of the current (and rather dated) SH-4 versions. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: Make sure rte delay slots are nopped out on all parts.Paul Mundt2-2/+4
Future SH parts do not support any instruction but a nop in the rte delay slot, so make the change for all offending parts. SH-5 is excluded from this, and already has its own set of restrictions with regards to rte delay slot handling. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: stacktrace: Properly terminate the trace entry buffer.Paul Mundt1-0/+4
This inserts a ULONG_MAX entry at the end of the valid entries in the stack trace buffer so the default code doesn't need to scan to the end of available slots. This also makes the trace buffer termination behaviour consistent with the other architectures. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: flag the default unwinder as reliable.Paul Mundt1-1/+1
This flags the default unwinder as reliable, as it tends to be reliable enough for the purposes of the stacktrace buffer. We leave the unreliable cases for the unwind methods that we know to be completely broken. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-15sh: stacktrace: Add reliability checks in address saving ops.Paul Mundt1-0/+6
This adopts the reliability checks from the x86 stacktrace code so known bad addresses are not recorded in the stack trace buffer. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: unwinder: Convert frame allocations to GFP_ATOMIC.Paul Mundt1-2/+2
save_stack_trace_tsk() and friends can be called from atomic context (as triggered by latencytop), and subsequently hit two problematic allocation points that were using GFP_KERNEL (these were dwarf_unwind_stack() and dwarf_frame_alloc_regs()). Convert these over to GFP_ATOMIC and get latencytop working with the DWARF unwinder. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: Delete DWARF_ARCH_UNWIND_OFFSETMatt Fleming1-9/+35
Trying to figure out the best value for DWARF_ARCH_UNWIND_OFFSET is tricky at best. Various things can change the size (and offset from the beginning of the function) of the prologue. Notably, turning on ftrace adds calls to mcount at the beginning of functions, thereby pushing the prologue further into the function. So replace DWARF_ARCH_UNWIND_OFFSET with some code that continues to execute CFA instructions until the value of return address register is defined. This is safe to do because we know that the return address must have been pushed onto the frame before our first function call; we just can't figure out where at compile-time. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: unwinder: Restore put_unaligned() for an unaligned destination.Paul Mundt1-1/+2
The destination address might be unaligned, so set it with put_unaligned() for safety. This restores the previous behaviour, albeit through the proper API. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: unwinder: Fix up usage of unaligned accessors.Paul Mundt1-11/+9
This was using internal symbols for unaligned accesses, bypassing the exposed interface for variable sized safe accesses. This converts all of the __get_unaligned_cpuXX() users over to get_unaligned() directly, relying on the cast to select the proper internal routine. Additionally, the __put_unaligned_cpuXX() case is superfluous given that the destination address is aligned in all of the current cases, so just drop that outright. Furthermore, this switches to the asm/unaligned.h header instead of the asm-generic version, which was silently bypassing the SH-4A optimized unaligned ops. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: Add CFI annotations for exception return.Matt Fleming1-0/+7
Annotate various assembly code paths with CFI assembler directives so that DWARF unwind info is available for the unwinder. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: Setup the frame register in asm codeMatt Fleming2-0/+2
In order to use DWARF unwinder info the frame register has to contain a valid value. Whilst GCC takes care of this for C code, we have to do it ourselves for assembly. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-14sh: dwarf unwinder support.Matt Fleming5-1/+885
This is a first cut at a generic DWARF unwinder for the kernel. It's still lacking DWARF64 support and the DWARF expression support hasn't been tested very well but it is generating proper stacktraces on SH for WARN_ON() and NULL dereferences. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-13sh: Use the new stack unwinder APIMatt Fleming2-13/+9
Instead of implementing our own stack unwinder via dump_trace() we should use the new stack unwinder API because it is more modular. This change allows us to decouple the interface for generating stacktraces from the implementation of a stack unwinder. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-13sh: Allow multiple stack unwinders to be setupMatt Fleming3-3/+165
Provide an interface for registering stack unwinders, where each unwinder is given a rating that describes its accuracy and complexity. The more accurate an unwinder is, the more complex it is. If a the current stack unwinder faults, then the stack unwinder with the next highest accuracy will be used in its place (provided one is available). For example, this allows unwinders, such as the DWARF unwinder, to liberally sprinkle BUG()s to catch badly formed DWARF debug info. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>