From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de
Subject: Re: [RFC PATCH v1 02/31] ARC: irqflags
Date: Tue, 1 Jan 2013 13:14:13 +0530 [thread overview]
Message-ID: <50E293CD.8040004@synopsys.com> (raw)
In-Reply-To: <alpine.LFD.2.02.1211122039100.10000@ionos>
On Tuesday 13 November 2012 01:20 AM, Thomas Gleixner wrote:
> On Wed, 7 Nov 2012, Vineet Gupta wrote:
>> + ******************************************************************
>> + * Inline ASM macros to read/write AUX Regs
>> + * Essentially invocation of lr/sr insns from "C"
>> + */
>> +
>> +#if 1
>
> Leftover ???
Kind of - the gcc builtins sometimes tend to generate good code and sometimes
they don't. I wanted to retain the inline asm version for experimenting sake. But
if it's too ugly, I can get rid of one of them.
>
>> +#define read_aux_reg(reg) __builtin_arc_lr(reg)
>> +
>> +/* gcc builtin sr needs reg param to be long immediate */
>> +#define write_aux_reg(reg_immed, val) \
>> + __builtin_arc_sr((unsigned int)val, reg_immed)
>> +
>> +#else
>> +/*
>> + * Conditionally Enable IRQs
>
> Unconditionally methinks
ofcourse - fixed !
> The following two functions are related to irq chips I guess. So why
> would you want them here ?
>
>> +static inline void arch_mask_irq(unsigned int irq)
>> +{
>> + unsigned int ienb;
>> +
>> + ienb = read_aux_reg(AUX_IENABLE);
>> + ienb &= ~(1 << irq);
>> + write_aux_reg(AUX_IENABLE, ienb);
>> +}
>> +
>> +static inline void arch_unmask_irq(unsigned int irq)
>> +{
>> + unsigned int ienb;
>> +
>> + ienb = read_aux_reg(AUX_IENABLE);
>> + ienb |= (1 << irq);
>> + write_aux_reg(AUX_IENABLE, ienb);
>> +}
>
> The only user is the interrupt controller code, right?
These are the platform agnostic routines which handle the in-core interrupt
controller, hence provided as helpers. The simpler plat-arcfpga (PATCH 12/31) uses
them as it is while a bunch of other platforms (yet to be submitted) might
conditionally use depending upon whether a IRQ is cascaded or not.
>> diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
>> new file mode 100644
>> index 0000000..16fcbe8
>> --- /dev/null
>> +++ b/arch/arc/kernel/irq.c
>> @@ -0,0 +1,32 @@
>> +/*
>> + * Copyright (C) 2011-12 Synopsys, Inc. (www.synopsys.com)
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + */
>> +
>> +#include <linux/interrupt.h>
>> +#include <linux/module.h>
>> +#include <asm/irqflags.h>
>> +#include <asm/arcregs.h>
>> +
>> +void arch_local_irq_enable(void)
>> +{
>> +
>> + unsigned long flags;
>> + flags = arch_local_save_flags();
>> + flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
>> +
>> + /*
>> + * If called from hard ISR (between irq_enter and irq_exit)
>> + * don't allow Level 1. In Soft ISR we allow further Level 1s
>> + */
>> +
>> + if (in_irq())
>> + flags &= ~(STATUS_E1_MASK | STATUS_E2_MASK);
>
> Hmm. This looks weird and the comment is not very helpful. So using my
> crystal ball you want to enforce, that nothing enables interrupts
> while a hard interrupt handler is running, right?
Correct. I'll fix the comment.
>
> Is there a chip limitation which you have to enforce here? If yes,
> then please explain it.
Yes and No. This is from our 2.6.26 days and AFAIKR, it was indeed ARC IDE driver
enabling IRQ from within hard ISR context. The issue however became critical when
I added support for the ARC700 in-core interrupt controller which provides 2
levels of interrupts per IRQ (kind of ARM FIQ): L2 (High priority) could interrupt
L1 (low). The priority management (among other - don't allow L1 if L2 active) is
done with 2 pairs of bits in STATUS32 (CPU flags) register
* A1/A2 (Level-n active)
* E1/E2 (Level-n enabled)
However since the OS is allowed to write to E1/E2 bits, independent of A1/A2, it
is possible to re-enable interrupts even from hard-isr context. When IDE driver
re-enabled L1 interrupts in L2 ISR - we had the basic low level irq handling
messed by because of L1-L2-L1 scenarion
The patch which implements the 2 intc priorities support is separate. It probably
fell of your radar since it was in mini-series #2 of v1 patchset @
https://lkml.org/lkml/2012/11/12/125). Once I respin v2 series for review, would
request you to please take a look at that one as well (currently has a bad hack of
disabling task preemption in a corner case - which of all people, you, would
certainly loathe seeing)
> Btw, all hard interrupt handlers in Linux run with interrupts disabled and
> they are not supposed to reenable interrupts, which is true for almost
> all drivers except for a few archaic IDE drivers. In fact you might
> even WARN about it at least once, so the offending code gets fixed.
Sure - did that in next version.
> Also the code flow is backwards. What about:
>
> unsigned long flags;
>
> if (in_irq())
> return;
>
> flags = ....
>
>
>> + arch_local_irq_restore(flags);
>> +}
>
Indeed fixed in v2. Actually the prev version would *disable* the IRQs if
in_irq(), now we leave status quo and return - but given that we return - they
will not be enabled in first place - so there's no semantical change - assuming
everything goes via local_irq_xxx friends.
Honestly I'm a bit ashamed for having had above crappy snippet for years. Thanks
for taking time to review this and sincere apologies for coming back to you so
late - I was held up with other things including a big ticket item pointed by Arnd
in review (no-legacy syscalls).
> Thanks,
>
> tglx
>
next prev parent reply other threads:[~2013-01-01 7:44 UTC|newest]
Thread overview: 146+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 9:47 [RFC Patch v1 00/31] Synopsys ARC Linux kernel Port Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 01/31] ARC: Generic Headers Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 02/31] ARC: irqflags Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-12 19:50 ` Thomas Gleixner
2012-11-12 19:50 ` Thomas Gleixner
2013-01-01 7:44 ` Vineet Gupta [this message]
2013-01-01 7:44 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 03/31] ARC: atomic/bitops/cmpxchg/barriers Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 04/31] asm-generic headers: uaccess.h to conditionally define segment_eq() Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 05/31] ARC: uaccess friends Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 06/31] asm-generic headers: Allow yet more arch overrides in checksum.h Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 07/31] ARC: checksum/byteorder/swab routines Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-08 7:10 ` Jonas Bonn
2012-11-08 18:52 ` Vineet Gupta
2012-11-08 20:36 ` Jonas Bonn
2012-11-12 13:58 ` Vineet Gupta
2012-11-12 14:12 ` Arnd Bergmann
2012-11-07 9:47 ` [RFC PATCH v1 09/31] ARC: spinlock/rwlock/mutex primitives Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 10/31] ARC: string library Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 11/31] ARC: Low level IRQ/Trap/Exception(non-MMU) Handling Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-16 4:58 ` Al Viro
2012-11-16 4:58 ` Al Viro
2012-12-27 9:00 ` Vineet Gupta
2012-12-27 13:29 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 12/31] ARC: Interrupt Handling Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-12 20:08 ` Thomas Gleixner
2012-11-12 20:08 ` Thomas Gleixner
2013-01-01 10:46 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 13/31] ARC: Non-MMU Exception Handling Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 14/31] ARC: syscall support Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 14:21 ` Arnd Bergmann
2012-11-09 9:50 ` James Hogan
2012-11-13 11:41 ` James Hogan
2012-11-13 12:01 ` Jonas Bonn
2012-11-13 12:01 ` Jonas Bonn
2012-11-13 12:11 ` James Hogan
2012-11-14 12:23 ` Arnd Bergmann
2012-11-14 12:31 ` James Hogan
2012-11-13 10:13 ` Gilad Ben-Yossef
2012-11-13 10:37 ` Arnd Bergmann
2012-11-15 6:15 ` Vineet Gupta
2012-11-15 6:15 ` Vineet Gupta
2012-11-15 12:35 ` Arnd Bergmann
2013-01-17 5:13 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-12 20:29 ` Thomas Gleixner
2013-01-02 7:13 ` Vineet Gupta
2013-01-02 8:45 ` Vineet Gupta
2013-01-04 13:01 ` Frederic Weisbecker
2012-11-07 9:47 ` [RFC PATCH v1 16/31] ARC: Signal handling Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-16 5:26 ` Al Viro
2012-12-28 12:34 ` Vineet Gupta
2012-12-28 12:34 ` Vineet Gupta
2012-12-28 12:42 ` [PATCH 1/2] ARC: [Review] Preparing to fix incorrect syscall restarts due to signals Vineet Gupta
2012-12-28 12:42 ` [PATCH 2/2] ARC: [Review] Prevent incorrect syscall restarts Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 17/31] ARC: Cache Flush Management Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 18/31] ARC: Page Table Management Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 19/31] ARC: MMU Context Management Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 20/31] ARC: MMU Exception Handling Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 21/31] ARC: TLB flush Handling Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 22/31] ARC: Page Fault handling (incl uaccess fixup) Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 23/31] ARC: I/O and DMA Mappings Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 24/31] ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 14:16 ` Arnd Bergmann
2012-11-07 14:16 ` Arnd Bergmann
2013-01-07 13:10 ` Vineet Gupta
2013-01-07 13:46 ` Arnd Bergmann
2013-01-07 14:04 ` Vineet Gupta
2013-01-07 14:36 ` Arnd Bergmann
2013-01-14 7:35 ` early init dt for earlyprintk (was Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART) Vineet Gupta
2013-01-14 9:48 ` James Hogan
2013-01-14 10:09 ` Vineet Gupta
2013-01-14 10:54 ` Arnd Bergmann
2013-01-17 7:29 ` [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART Vineet Gupta
2013-01-17 10:52 ` Arnd Bergmann
2012-11-07 9:47 ` [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script Vineet Gupta
2012-11-07 14:13 ` Arnd Bergmann
[not found] ` <50E4449A.7010606@synopsys.com>
[not found] ` <201301021448.20119.arnd@arndb.de>
2013-01-03 7:58 ` Vineet Gupta
2013-01-03 8:25 ` Arnd Bergmann
2013-01-03 8:25 ` Arnd Bergmann
2013-03-11 12:29 ` SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script) Vineet Gupta
2013-03-11 12:44 ` James Hogan
2013-03-11 12:56 ` Vineet Gupta
2013-03-11 13:07 ` James Hogan
2013-03-11 13:30 ` Arnd Bergmann
2013-03-11 13:48 ` Vineet Gupta
2013-03-11 13:48 ` Vineet Gupta
2013-03-11 14:50 ` Arnd Bergmann
2012-11-15 17:49 ` [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script James Hogan
2012-11-15 17:49 ` James Hogan
2012-11-15 19:30 ` Ralf Baechle
2012-11-16 6:36 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 27/31] ARC: Last bits (stubs) to get to a running kernel with UART Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 28/31] ARC: split ret_from_fork, simplify kernel_thread() Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 29/31] ARC: switch to generic kernel_thread() Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 30/31] ARC: switch to generic kernel_execve() and sys_execve() Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-16 4:08 ` Al Viro
2012-11-16 4:08 ` Al Viro
2012-11-17 14:01 ` Vineet Gupta
2012-11-07 9:47 ` [RFC PATCH v1 31/31] ARC: [plat-arcfpga] defconfig Vineet Gupta
2012-11-07 9:47 ` Vineet Gupta
2012-11-07 14:06 ` Arnd Bergmann
2012-11-12 14:18 ` James Hogan
2012-11-12 14:21 ` Arnd Bergmann
2012-11-07 14:36 ` [RFC Patch v1 00/31] Synopsys ARC Linux kernel Port Arnd Bergmann
2012-11-08 19:09 ` Vineet Gupta
2012-11-07 20:46 ` Gilad Ben-Yossef
2012-11-07 20:46 ` Gilad Ben-Yossef
2012-11-20 13:47 ` Pavel Machek
2012-11-20 13:49 ` Vineet Gupta
2012-11-20 13:59 ` Pavel Machek
2012-11-20 14:17 ` Vineet Gupta
2013-01-18 19:46 ` Pavel Machek
2013-01-18 22:17 ` Arnd Bergmann
2013-01-19 10:15 ` Pavel Machek
2013-01-19 12:32 ` Vineet Gupta
2013-01-19 17:02 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50E293CD.8040004@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).