linux-stable/arch/m68k
Thomas Gleixner 09f90f6685 m68k: Simplify low level interrupt handling code
The low level interrupt entry code of m68k contains the following:

    add_preempt_count(HARDIRQ_OFFSET);

    do_IRQ();
	irq_enter();
	    add_preempt_count(HARDIRQ_OFFSET);
	handle_interrupt();    
	irq_exit();    
	    sub_preempt_count(HARDIRQ_OFFSET);
	    if (in_interrupt())
       	       return; <---- On m68k always taken!
	    if (local_softirq_pending())
       	       do_softirq();

    sub_preempt_count(HARDIRQ_OFFSET);
    if (in_hardirq())
       return;
    if (status_on_stack_has_interrupt_priority_mask > 0)
       return;
    if (local_softirq_pending())
       do_softirq();

    ret_from_exception:
	if (interrupted_context_is_kernel)
	   return:
	....

I tried to find a proper explanation for this, but the changelog is
sparse and there are no mails explaining it further. But obviously
this relates to the interrupt priority levels of the m68k and tries to
be extra clever with nested interrupts. Though this cleverness just
adds code bloat to the interrupt hotpath.

For the common case of non nested interrupts the code runs through two
extra conditionals to the only important one, which checks whether the
return is to kernel or user space.

For the nested case the checks for in_hardirq() and the priority mask
value on stack catch only the case where the nested interrupt happens
inside the hard irq context of the first interrupt. If the nested
interrupt happens while the first interrupt handles soft interrupts,
then these extra checks buy nothing. The nested interrupt will fall
through to the final kernel/user space return check at
ret_from_exception.

Changing the code flow in the following way:

    do_IRQ();
	irq_enter();
	    add_preempt_count(HARDIRQ_OFFSET);
	handle_interrupt();    
	irq_exit();    
	    sub_preempt_count(HARDIRQ_OFFSET);
	    if (in_interrupt())
       	       return;
	    if (local_softirq_pending())
       	       do_softirq();

    ret_from_exception:
	if (interrupted_context_is_kernel)
	   return:

makes the region protected by the hardirq count slightly smaller and
the softirq handling is invoked with a minimal deeper stack. But
otherwise it's completely functional equivalent and saves 104 bytes of
text in arch/m68k/kernel/entry.o.

This modification allows us further to get rid of the limitations
which m68k puts on the preempt_count layout, so we can make the
preempt count bits completely generic.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linux/m68k <linux-m68k@vger.kernel.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1311112052360.30673@ionos.tec.linutronix.de
2013-11-13 20:21:46 +01:00
..
amiga PTR_RET is now PTR_ERR_OR_ZERO(): Replace most. 2013-07-15 11:25:01 +09:30
apollo m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
atari m68k/atari: USB - add platform devices for EtherNAT/NetUSBee ISP1160 HCD 2013-04-16 21:35:41 +02:00
bvme6000 m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
configs m68k/q40: Enable PC parallel port in defconfig 2013-06-24 19:44:30 +02:00
emu m68k/atari: ARAnyM - Always use physical addresses in NatFeat calls 2013-08-23 12:49:01 +02:00
fpsp040
hp300 m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
ifpsp060
include Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-11-12 10:20:12 +09:00
kernel m68k: Simplify low level interrupt handling code 2013-11-13 20:21:46 +01:00
lib m68k/uaccess: Fix asm constraints for userspace access 2013-06-24 19:44:19 +02:00
mac m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
math-emu m68k/math-emu: unsigned issue, 'unsigned long' will never be less than zero 2013-06-24 19:44:19 +02:00
mm arch: mm: pass userspace fault flag to generic fault handler 2013-09-12 15:38:01 -07:00
mvme16x m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
mvme147 m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
platform m68k: Simplify low level interrupt handling code 2013-11-13 20:21:46 +01:00
q40 PTR_RET is now PTR_ERR_OR_ZERO(): Replace most. 2013-07-15 11:25:01 +09:30
sun3 m68k/sun3: remove inline marking of EXPORT_SYMBOL functions 2013-06-24 19:44:18 +02:00
sun3x m68k: set arch_gettimeoffset directly 2012-12-24 09:36:34 -07:00
tools/amiga
install.sh
Kconfig Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
Kconfig.bus m68k/atari: ROM port ISA adapter support 2013-04-16 21:08:11 +02:00
Kconfig.cpu Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu 2013-05-10 07:22:35 -07:00
Kconfig.debug m68k: remove CONFIG_EARLY_PRINTK dependency on CONFIG_EMBEDDED, default to n 2013-06-24 19:44:18 +02:00
Kconfig.devices m68k/atari: EtherNEC - add platform device support 2013-04-16 21:20:14 +02:00
Kconfig.machine m68k: remove 16 unused boards in Kconfig.machine 2013-08-26 16:51:14 +10:00
Makefile m68knommu: add support for the ColdFire 537x family of CPUs 2013-04-29 09:17:58 +10:00