* [PATCH 01/12] kernel/debug: Mask KGDB NMI upon entry
From: Anton Vorontsov @ 2012-09-11 9:34 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120911093042.GA12471@lizard>
The new arch callback should manage NMIs that usually cause KGDB to
enter. That is, not all NMIs should be enabled/disabled, but only
those that issue kgdb_handle_exception().
We must mask it as serial-line interrupt can be used as an NMI, so
if the original KGDB-entry cause was say a breakpoint, then every
input to KDB console will cause KGDB to reenter, which we don't want.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
include/linux/kgdb.h | 23 +++++++++++++++++++++++
kernel/debug/debug_core.c | 36 +++++++++++++++++++++++++++++++++---
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index c4d2fc1..3b111a6 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -221,6 +221,29 @@ extern int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt);
*/
extern void kgdb_arch_late(void);
+/**
+ * kgdb_arch_enable_nmi - Enable or disable KGDB-entry NMI
+ * @on: Flag to either enable or disable an NMI
+ *
+ * This is an architecture-specific "back-end" for kgdb_enable_nmi(). The
+ * call does not count disable/enable requests, do not use it directly.
+ */
+extern void kgdb_arch_enable_nmi(bool on);
+
+/**
+ * kgdb_enable_nmi - Enable or disable KGDB-entry NMI
+ * @on: Flag to either enable or disable an NMI
+ *
+ * This function manages NMIs that usually cause KGDB to enter. That is,
+ * not all NMIs should be enabled or disabled, but only those that issue
+ * kgdb_handle_exception().
+ *
+ * The call counts disable requests, and thus allows to nest disables.
+ * But trying to enable already enabled NMI is an error. The call returns
+ * 1 if NMI has been actually enabled after the call, and a value <= 0 if
+ * it is still disabled.
+ */
+extern int kgdb_enable_nmi(bool on);
/**
* struct kgdb_arch - Describe architecture specific values.
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0557f24..b621d1e 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -214,6 +214,30 @@ int __weak kgdb_skipexception(int exception, struct pt_regs *regs)
return 0;
}
+void __weak kgdb_arch_enable_nmi(bool on)
+{
+}
+
+int kgdb_enable_nmi(bool on)
+{
+ static atomic_t cnt;
+ int ret;
+
+ ret = atomic_add_return(on ? 1 : -1, &cnt);
+ if (ret > 1 && on) {
+ /*
+ * There should be only one instance that calls this function
+ * in "enable, disable" order. All other users must call
+ * disable first, then enable. If not, something is wrong.
+ */
+ WARN_ON(1);
+ return 1;
+ }
+
+ kgdb_arch_enable_nmi(ret > 0);
+ return ret;
+}
+
/*
* Some architectures need cache flushes when we set/clear a
* breakpoint:
@@ -672,6 +696,9 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
{
struct kgdb_state kgdb_var;
struct kgdb_state *ks = &kgdb_var;
+ int ret = 0;
+
+ kgdb_enable_nmi(0);
ks->cpu = raw_smp_processor_id();
ks->ex_vector = evector;
@@ -681,11 +708,14 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
ks->linux_regs = regs;
if (kgdb_reenter_check(ks))
- return 0; /* Ouch, double exception ! */
+ goto out; /* Ouch, double exception ! */
if (kgdb_info[ks->cpu].enter_kgdb != 0)
- return 0;
+ goto out;
- return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
+ ret = kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
+out:
+ kgdb_enable_nmi(1);
+ return ret;
}
int kgdb_nmicallback(int cpu, void *regs)
--
1.7.11.5
^ permalink raw reply related
* [PATCH v6 0/12] KGDB/KDB FIQ (NMI) debugger
From: Anton Vorontsov @ 2012-09-11 9:30 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
Hi all,
Here is a new revision, mostly tty reworks. The new tty_port stuff is a
bliss: no more per-driver mutex, no more counting for open(),
well-separated initialization callbacks (I hope I got them right :-).
But since I now use a lot of new tty_port stuff, I had to rebase the
patch set on top of tty-next, so there's no point in cherry-picking
anymore.
So, in v6:
- Converted the NMI tty driver to use tty_port helpers, per Alan Cox's
suggestions;
- In uart's poll_init callback fixed a race, spotted by Alan;
- Use test_bit instead of touching port->flags directly;
These patches can be found in the following repo (based on tty-next):
git://git.infradead.org/users/cbou/linux-nmi-kdb.git master
Old changelogs and rationale for these patches can be found here:
v1-v5: http://lkml.org/lkml/2012/9/10/2
Thanks,
--
arch/arm/Kconfig | 19 ++
arch/arm/common/vic.c | 28 +++
arch/arm/include/asm/hardware/vic.h | 2 +
arch/arm/include/asm/kgdb.h | 8 +
arch/arm/kernel/Makefile | 1 +
arch/arm/kernel/entry-armv.S | 167 +------------
arch/arm/kernel/entry-header.S | 170 +++++++++++++
arch/arm/kernel/kgdb_fiq.c | 99 ++++++++
arch/arm/kernel/kgdb_fiq_entry.S | 87 +++++++
arch/arm/mach-versatile/Makefile | 1 +
arch/arm/mach-versatile/kgdb_fiq.c | 31 +++
drivers/tty/serial/Kconfig | 19 ++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/amba-pl011.c | 66 ++++-
drivers/tty/serial/kgdb_nmi.c | 391 ++++++++++++++++++++++++++++++
drivers/tty/serial/kgdboc.c | 16 ++
drivers/tty/serial/serial_core.c | 32 +++
include/linux/kdb.h | 29 ++-
include/linux/kgdb.h | 34 +++
include/linux/serial_core.h | 2 +
include/linux/tty_driver.h | 1 +
kernel/debug/debug_core.c | 36 ++-
kernel/debug/kdb/kdb_main.c | 29 +++
23 files changed, 1076 insertions(+), 193 deletions(-)
^ permalink raw reply
* [PATCH] serial: mxs-auart: put the device in the error path
From: Huang Shijie @ 2012-09-11 7:30 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, shawn.guo, Huang Shijie
In-Reply-To: <20120910230005.GA15782@kroah.com>
The mxs_auart_probe() gets the device by the get_device().
So we should put the device in the error path to balance the
device's reference counter.
Signed-off-by: Huang Shijie <b32955@freescale.com>
---
drivers/tty/serial/mxs-auart.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 6898413..6db3baa 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -781,6 +781,7 @@ out_free_irq:
auart_port[pdev->id] = NULL;
free_irq(s->irq, s);
out_free_clk:
+ put_device(s->dev);
clk_put(s->clk);
out_free:
kfree(s);
--
1.7.0.4
^ permalink raw reply related
* [PATCH 09/17] serial/8250: Limit the omap workarounds to omap1
From: Tony Lindgren @ 2012-09-11 5:31 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: Greg Kroah-Hartman, linux-omap, linux-serial, Alan Cox
In-Reply-To: <20120911052934.29637.9190.stgit@muffinssi.local>
These workarounds do not apply for CONFIG_ARCH_OMAP2PLUS at all,
so let's make it just CONFIG_ARCH_OMAP1.
This is needed to for ARM common zImage changes for
omap2+ to avoid including plat and mach headers.
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/8250/8250.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 8123f78..5b3f2fe 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -2336,7 +2336,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
serial_port_out(port, UART_EFR, efr);
}
-#ifdef CONFIG_ARCH_OMAP
+#ifdef CONFIG_ARCH_OMAP1
/* Workaround to enable 115200 baud on OMAP1510 internal ports */
if (cpu_is_omap1510() && is_omap_port(up)) {
if (baud == 115200) {
@@ -2426,7 +2426,7 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
{
if (pt->port.iotype == UPIO_AU)
return 0x1000;
-#ifdef CONFIG_ARCH_OMAP
+#ifdef CONFIG_ARCH_OMAP1
if (is_omap_port(pt))
return 0x16 << pt->port.regshift;
#endif
^ permalink raw reply related
* Re: [PATCH] serial: mxs-auart: put the device when exit or error
From: Greg KH @ 2012-09-10 23:00 UTC (permalink / raw)
To: Huang Shijie
Cc: alan, linux-serial, linux-arm-kernel, linux-kernel, shawn.guo
In-Reply-To: <1346985187-30459-1-git-send-email-b32955@freescale.com>
On Fri, Sep 07, 2012 at 10:33:07AM +0800, Huang Shijie wrote:
> We call the get_device() in the mxs_auart_probe().
> For the balance of the reference count, we should put the
> device in the mxs_auart_remove() or in the error path of
> probe.
>
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
> drivers/tty/serial/mxs-auart.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
I already applied the previous version, so can you make up a patch
against the tty-next tree that fixes it up properly based on this patch?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 08/14] tty/serial/kgdboc: Add and wire up clear_irqs callback
From: Anton Vorontsov @ 2012-09-10 20:13 UTC (permalink / raw)
To: Alan Cox
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910201918.1e3c8fd0@pyramind.ukuu.org.uk>
On Mon, Sep 10, 2012 at 08:19:18PM +0100, Alan Cox wrote:
> On Mon, 10 Sep 2012 10:57:04 -0700
> Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
>
> > On Mon, Sep 10, 2012 at 12:16:24PM +0100, Alan Cox wrote:
> > > > serial port, the CPU receives NMI exception, and we fall into KDB
> > > > shell. So, it is our "debug console", and it is able to interrupt
> > > > (and thus debug) even IRQ handlers themselves.
> > >
> > > You seem to have an assumption of single core here. What happens if
> > > the NMI hits CPU #0 and the serial IRQ hits CPU #1 simultaneously ?
> >
> > If you can't redirect all serial IRQs to NMI context, e.g. sometimes you get
> > NMIs, sometimes IRQs, then your NMI handling is not deterministic, and surely
> > this is not supported.
>
> This seems like arch specific magic leaking into the tty code. Surely
> this should be buried in the depths of the platform IRQ code ?
I'd not call this arch-specific. It's task-specific, and the task is quite
peculiar, true, but still nothing to do with arch.
If the arch is not able to turn serial IRQs into NMIs, then surely that arch is
not able to implement serial-triggered NMI/KDB-shell, so we don't support that
arch.
And we don't have any other way to accoplish the same: we need to clear the
serial interrupts, not some arch-specific interrupts. It is the serial device
that causes NMI, not some arch's magic. So we just provide the knob to manage
the device's functionality.
We do have a separate arch-specific NMI-masking knob that works at CPU level,
but if we mask NMI source at CPU level, we have to keep it always masked,
otherwise we'll keep reentering NMI. So, we really have to clear serial's
interrupt line.
That's why I came with clear_irqs callback, it has defined semantics for the
serial driver, and zero knowledge about any underlaying architecture or task.
Thanks,
Anton.
^ permalink raw reply
* Re: [PATCH 06/14] tty/serial/core: Introduce poll_init callback
From: Alan Cox @ 2012-09-10 19:18 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910175725.GA13673@lizard>
> > What stops a parallel open or close changing ASYNC_INITIALIZED after you
> > test and before you lock ?
>
> Yeah, I should do the whole thing under the mutex.
Can you use test_bit() as well. I'm trying to gradually push all the code
that way so people habitually use set_bit() and we don't get any (more)
races where some compile situations and architectures otherwise create
load to register
register ored with constant
write back
> Not related to this particular issue, but the fact that close() can powerdown
> the hardware is quite bad. Today it is always possible to use open,close
> sequence on /dev/ttyXXXX, and polling would break if close() deinitializes the
> hardware (e.g. via uart_change_pm()).
One of the long term goals of tty_port has always ben to have an object
with the lifetime of the physical port so this kind of thing can be fixed.
> In console= case, serial core handles the issue via uart_console(), checking if
> the port is used for console, preventing it to power down the hardware. We can
> do the same, or make tty_find_polling_driver() refcount individual ports/lines.
> But the issue is orthogonal to this particular patch, although needs to be
> fixed some day.
Agreed - however you'll need a separate refcount than the main tty one
for this, because we still need to do a hangup() on the final "tty" close
even if the hardware is 'pinned' for a debugger.
Alan
^ permalink raw reply
* Re: [PATCH 08/14] tty/serial/kgdboc: Add and wire up clear_irqs callback
From: Alan Cox @ 2012-09-10 19:19 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910175704.GA11392@lizard>
On Mon, 10 Sep 2012 10:57:04 -0700
Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
> On Mon, Sep 10, 2012 at 12:16:24PM +0100, Alan Cox wrote:
> > > serial port, the CPU receives NMI exception, and we fall into KDB
> > > shell. So, it is our "debug console", and it is able to interrupt
> > > (and thus debug) even IRQ handlers themselves.
> >
> > You seem to have an assumption of single core here. What happens if
> > the NMI hits CPU #0 and the serial IRQ hits CPU #1 simultaneously ?
>
> If you can't redirect all serial IRQs to NMI context, e.g. sometimes you get
> NMIs, sometimes IRQs, then your NMI handling is not deterministic, and surely
> this is not supported.
This seems like arch specific magic leaking into the tty code. Surely
this should be buried in the depths of the platform IRQ code ?
Alan
^ permalink raw reply
* Re: [PATCH 08/14] tty/serial/kgdboc: Add and wire up clear_irqs callback
From: Anton Vorontsov @ 2012-09-10 17:57 UTC (permalink / raw)
To: Alan Cox
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910121624.226c1a88@pyramind.ukuu.org.uk>
On Mon, Sep 10, 2012 at 12:16:24PM +0100, Alan Cox wrote:
> > serial port, the CPU receives NMI exception, and we fall into KDB
> > shell. So, it is our "debug console", and it is able to interrupt
> > (and thus debug) even IRQ handlers themselves.
>
> You seem to have an assumption of single core here. What happens if
> the NMI hits CPU #0 and the serial IRQ hits CPU #1 simultaneously ?
If you can't redirect all serial IRQs to NMI context, e.g. sometimes you get
NMIs, sometimes IRQs, then your NMI handling is not deterministic, and surely
this is not supported.
The whole concept of clearing IRQs is needed if serial IRQ is routed to the
NMI/FIQ (on all CPUs), which by definition guarantees that serial IRQ routine
is never triggered. We "steal" all and every serial port's IRQs.
Thanks!
^ permalink raw reply
* Re: [PATCH 09/14] tty/serial/amba-pl011: Implement clear_irqs callback
From: Anton Vorontsov @ 2012-09-10 17:56 UTC (permalink / raw)
To: Alan Cox
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910121702.550b8a90@pyramind.ukuu.org.uk>
On Mon, Sep 10, 2012 at 12:17:02PM +0100, Alan Cox wrote:
[...]
> > +static void pl011_clear_irqs(struct uart_port *port)
> > +{
> > + struct uart_amba_port *uap = (struct uart_amba_port *)port;
> > + unsigned char __iomem *regs = uap->port.membase;
> > +
> > + writew(readw(regs + UART011_MIS), regs + UART011_ICR);
> > + /*
> > + * There is no way to clear TXIM, this is "ready to transmit IRQ", so
> > + * we simply mask it. ops->start_tx will unmask it.
> > + */
>
> Not if you race here with the transmit start it won't.
True, the race is possible. But I guess there will be no harm: only non-polling
code uses ->start_tx(), but then we don't care, the port is used for NMI
debugger, so the worst that can happen, is that we'll get another NMI just
after the race, and so we'll mask it again.
And once we release the port from KDB, we never call this function anymore
(since normal IRQ routine will be called instead).
I guess I need to add some commens about this.
Thanks!
^ permalink raw reply
* Re: [PATCH 06/14] tty/serial/core: Introduce poll_init callback
From: Anton Vorontsov @ 2012-09-10 17:57 UTC (permalink / raw)
To: Alan Cox
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910121320.03c9dfc7@pyramind.ukuu.org.uk>
On Mon, Sep 10, 2012 at 12:13:20PM +0100, Alan Cox wrote:
> > + tport = &state->port;
> > + if (!(tport->flags & ASYNC_INITIALIZED) && port->ops->poll_init) {
> > + mutex_lock(&tport->mutex);
> > + ret = port->ops->poll_init(port);
> > + /*
> > + * We don't set ASYNCB_INITIALIZED as we only initialized the
> > + * hw, e.g. state->xmit is still uninitialized.
> > + */
> > + mutex_unlock(&tport->mutex);
> > + if (ret)
> > + return ret;
> > + }
>
> What stops a parallel open or close changing ASYNC_INITIALIZED after you
> test and before you lock ?
Yeah, I should do the whole thing under the mutex.
Not related to this particular issue, but the fact that close() can powerdown
the hardware is quite bad. Today it is always possible to use open,close
sequence on /dev/ttyXXXX, and polling would break if close() deinitializes the
hardware (e.g. via uart_change_pm()).
In console= case, serial core handles the issue via uart_console(), checking if
the port is used for console, preventing it to power down the hardware. We can
do the same, or make tty_find_polling_driver() refcount individual ports/lines.
But the issue is orthogonal to this particular patch, although needs to be
fixed some day.
Thanks!
Anton.
^ permalink raw reply
* Re: [PATCH 10/14] tty/serial: Add kgdb_nmi driver
From: Anton Vorontsov @ 2012-09-10 17:54 UTC (permalink / raw)
To: Alan Cox
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910121105.724f982f@pyramind.ukuu.org.uk>
On Mon, Sep 10, 2012 at 12:11:05PM +0100, Alan Cox wrote:
> On Sun, 9 Sep 2012 21:14:12 -0700
> Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
>
> > This special driver makes it possible to temporary use NMI debugger port
> > as a normal console by issuing 'nmi_console' command (assuming that the
> > port is attached to KGDB).
>
> No ref counting, no tty port, no compliance with the tty behaviour.
> Concept looks fine but it needs porting to reflect a kernel newer than
> about 2.6.18 8)
:-)
I'll look into tty_port helpers, much thanks for the review!
> I would take a quick look at the tty_port helpers and also check v -next
> which makes the tty_port mandatory. That'll pretty much cover your needs
> for locking, semantics and the like.
^ permalink raw reply
* NICE DAY
From: DR.NED OKOH @ 2012-09-10 14:17 UTC (permalink / raw)
Good day my dear,
I am writing to acknowledged you that this is the second time we are notifying you about your payment worth of US$16.5m USD,with foreign Remittance payment department office which is due to be released into your Account As we begin the first fiscal payment of the year 2012.Please send the information below as needed for your fund release to you OK.
1)Your Full Name__________________________ _____________
2)Your Address_______________________ ______________________________
3)Your Age___________________________ _______________________
4)Your Direct Telephone Number________________________ ________________
5)Fax Number________________________ _________________
6)Occupation____________________ __________________________
We sincerely apologies for our late contact with you, We are committed to serve you better OK and you have been advice to get back to me immediately for more details OK.
Yours in service
Dr.Ned Okoh
^ permalink raw reply
* Re: [PATCH] Powerpc 8xx CPM_UART delay in receive
From: Alan Cox @ 2012-09-10 13:10 UTC (permalink / raw)
To: leroy christophe
Cc: Alan Cox, Vitaly Bordug, Marcelo Tosatti, linux-kernel,
linux-serial, linuxppc-dev
In-Reply-To: <504D922C.1030407@c-s.fr>
> * a value of 1 for all rates below 2400 (On 8250, fifo is set to 1
> for such rates)
> * a value of 2 for 2400 and 4800
> * a value of 4 for 9600 (which is the default on the 8250 for all
> rates above 2400)
> * a value of 8 for 19200
> * a value of 16 for 38400 and above (on UCC_UART, maxidl is set to
> 16, never 32)
That would seem sensible.
Alan
^ permalink raw reply
* Re: [PATCH 09/14] tty/serial/amba-pl011: Implement clear_irqs callback
From: Alan Cox @ 2012-09-10 11:17 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910041404.GI29537@lizard>
On Sun, 9 Sep 2012 21:14:04 -0700
Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
> It's all pretty straightforward, except for TXIM interrupt. The interrupt
> has meaning "ready to transmit", so it's almost always raised, and the
> only way to silence it is to mask it. But that's OK, ops->start_tx will
> unmask it.
>
> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
> ---
> drivers/tty/serial/amba-pl011.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 88e2df2..7522d97 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -1308,6 +1308,18 @@ static void pl011_put_poll_char(struct uart_port *port,
> writew(ch, uap->port.membase + UART01x_DR);
> }
>
> +static void pl011_clear_irqs(struct uart_port *port)
> +{
> + struct uart_amba_port *uap = (struct uart_amba_port *)port;
> + unsigned char __iomem *regs = uap->port.membase;
> +
> + writew(readw(regs + UART011_MIS), regs + UART011_ICR);
> + /*
> + * There is no way to clear TXIM, this is "ready to transmit IRQ", so
> + * we simply mask it. ops->start_tx will unmask it.
> + */
Not if you race here with the transmit start it won't.
^ permalink raw reply
* Re: [PATCH 08/14] tty/serial/kgdboc: Add and wire up clear_irqs callback
From: Alan Cox @ 2012-09-10 11:16 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910041357.GH29537@lizard>
> serial port, the CPU receives NMI exception, and we fall into KDB shell.
> So, it is our "debug console", and it is able to interrupt (and thus
> debug) even IRQ handlers themselves.
You seem to have an assumption of single core here. What happens if the
NMI hits CPU #0 and the serial IRQ hits CPU #1 simultaneously ?
Alan
^ permalink raw reply
* Re: [PATCH 06/14] tty/serial/core: Introduce poll_init callback
From: Alan Cox @ 2012-09-10 11:13 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910041335.GF29537@lizard>
> + tport = &state->port;
> + if (!(tport->flags & ASYNC_INITIALIZED) && port->ops->poll_init) {
> + mutex_lock(&tport->mutex);
> + ret = port->ops->poll_init(port);
> + /*
> + * We don't set ASYNCB_INITIALIZED as we only initialized the
> + * hw, e.g. state->xmit is still uninitialized.
> + */
> + mutex_unlock(&tport->mutex);
> + if (ret)
> + return ret;
> + }
What stops a parallel open or close changing ASYNC_INITIALIZED after you
test and before you lock ?
Alan
^ permalink raw reply
* Re: [PATCH 10/14] tty/serial: Add kgdb_nmi driver
From: Alan Cox @ 2012-09-10 11:11 UTC (permalink / raw)
To: Anton Vorontsov
Cc: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox, Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910041412.GJ29537@lizard>
On Sun, 9 Sep 2012 21:14:12 -0700
Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
> This special driver makes it possible to temporary use NMI debugger port
> as a normal console by issuing 'nmi_console' command (assuming that the
> port is attached to KGDB).
No ref counting, no tty port, no compliance with the tty behaviour.
Concept looks fine but it needs porting to reflect a kernel newer than
about 2.6.18 8)
I would take a quick look at the tty_port helpers and also check v -next
which makes the tty_port mandatory. That'll pretty much cover your needs
for locking, semantics and the like.
Alan
^ permalink raw reply
* Re: [PATCH] Powerpc 8xx CPM_UART delay in receive
From: leroy christophe @ 2012-09-10 7:09 UTC (permalink / raw)
To: Alan Cox
Cc: Marcelo Tosatti, linux-kernel, linux-serial, linuxppc-dev,
Alan Cox
In-Reply-To: <20120816162136.059b64b4@bob.linux.org.uk>
Le 16/08/2012 17:21, Alan Cox a écrit :
>> MAX_IDL: Maximum idle characters. When a character is received, the
>> receiver begins counting idle characters. If MAX_IDL idle characters
>> are received before the next data character, an idle timeout occurs
>> and the buffer is closed,
>> generating a maskable interrupt request to the core to receive the
>> data from the buffer. Thus, MAX_IDL offers a way to demarcate frames.
>> To disable the feature, clear MAX_IDL. The bit length of an idle
>> character is calculated as follows: 1 + data length (5–9) + 1 (if
>> parity is used)
>> + number of stop bits (1–2). For 8 data bits, no parity, and 1 stop
>> bit, the character length is 10 bits
>
> So if you have slightly bursty high speed data as its quite typical
> before your change you would get one interrupt per buffer of 32 bytes,
> with it you'll get a lot more interrupts.
>
> You have two available hints about the way to set this - one of them is
> the baud rate (low baud rates mean the fifo isn't a big win and the
> latency is high), the other is the low_latency flag if the driver
> supports the low latency feature (and arguably you can still use a
> request for it as a hint even if you refuse the actual feature).
>
> So I think a reasonable approach would be set the idle timeout down for
> low baud rates or if low_latency is requested.
>
>> generated if there is at least one word in the FIFO and for a time
>> equivalent to the transmission of four characters
> Which is a bit more reasonable than one, although problematic at low
> speed (hence the fifo on/off).
>
What would then thing about:
* a value of 1 for all rates below 2400 (On 8250, fifo is set to 1 for
such rates)
* a value of 2 for 2400 and 4800
* a value of 4 for 9600 (which is the default on the 8250 for all rates
above 2400)
* a value of 8 for 19200
* a value of 16 for 38400 and above (on UCC_UART, maxidl is set to 16,
never 32)
Christophe
^ permalink raw reply
* [PATCH 04/14] kdb: Implement disable_nmi command
From: Anton Vorontsov @ 2012-09-10 4:13 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
This command disables NMI-entry. If NMI source has been previously shared
with a serial console ("debug port"), this effectively releases the port
from KDB exclusive use, and makes the console available for normal use.
Of course, NMI can be reenabled, enable_nmi modparam is used for that:
echo 1 > /sys/module/kdb/parameters/enable_nmi
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
kernel/debug/kdb/kdb_main.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 31df170..9fadff1 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -21,6 +21,7 @@
#include <linux/smp.h>
#include <linux/utsname.h>
#include <linux/vmalloc.h>
+#include <linux/atomic.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/init.h>
@@ -2107,6 +2108,32 @@ static int kdb_dmesg(int argc, const char **argv)
return 0;
}
#endif /* CONFIG_PRINTK */
+
+/* Make sure we balance enable/disable calls, must disable first. */
+static atomic_t kdb_nmi_disabled;
+
+static int kdb_disable_nmi(int argc, const char *argv[])
+{
+ if (atomic_read(&kdb_nmi_disabled))
+ return 0;
+ atomic_set(&kdb_nmi_disabled, 1);
+ kgdb_enable_nmi(0);
+ return 0;
+}
+
+static int kdb_param_enable_nmi(const char *val, const struct kernel_param *kp)
+{
+ if (!atomic_add_unless(&kdb_nmi_disabled, -1, 0))
+ return -EINVAL;
+ kgdb_enable_nmi(1);
+ return 0;
+}
+
+static const struct kernel_param_ops kdb_param_ops_enable_nmi = {
+ .set = kdb_param_enable_nmi,
+};
+module_param_cb(enable_nmi, &kdb_param_ops_enable_nmi, NULL, 0600);
+
/*
* kdb_cpu - This function implements the 'cpu' command.
* cpu [<cpunum>]
@@ -2851,6 +2878,8 @@ static void __init kdb_inittab(void)
kdb_register_repeat("dmesg", kdb_dmesg, "[lines]",
"Display syslog buffer", 0, KDB_REPEAT_NONE);
#endif
+ kdb_register_repeat("disable_nmi", kdb_disable_nmi, "",
+ "Disable NMI entry to KDB", 0, KDB_REPEAT_NONE);
kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"",
"Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE);
kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>",
--
1.7.11.5
^ permalink raw reply related
* [PATCH 03/14] kernel/debug: Mask KGDB NMI upon entry
From: Anton Vorontsov @ 2012-09-10 4:12 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
The new arch callback should manage NMIs that usually cause KGDB to
enter. That is, not all NMIs should be enabled/disabled, but only
those that issue kgdb_handle_exception().
We must mask it as serial-line interrupt can be used as an NMI, so
if the original KGDB-entry cause was say a breakpoint, then every
input to KDB console will cause KGDB to reenter, which we don't want.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
include/linux/kgdb.h | 23 +++++++++++++++++++++++
kernel/debug/debug_core.c | 36 +++++++++++++++++++++++++++++++++---
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index c4d2fc1..3b111a6 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -221,6 +221,29 @@ extern int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt);
*/
extern void kgdb_arch_late(void);
+/**
+ * kgdb_arch_enable_nmi - Enable or disable KGDB-entry NMI
+ * @on: Flag to either enable or disable an NMI
+ *
+ * This is an architecture-specific "back-end" for kgdb_enable_nmi(). The
+ * call does not count disable/enable requests, do not use it directly.
+ */
+extern void kgdb_arch_enable_nmi(bool on);
+
+/**
+ * kgdb_enable_nmi - Enable or disable KGDB-entry NMI
+ * @on: Flag to either enable or disable an NMI
+ *
+ * This function manages NMIs that usually cause KGDB to enter. That is,
+ * not all NMIs should be enabled or disabled, but only those that issue
+ * kgdb_handle_exception().
+ *
+ * The call counts disable requests, and thus allows to nest disables.
+ * But trying to enable already enabled NMI is an error. The call returns
+ * 1 if NMI has been actually enabled after the call, and a value <= 0 if
+ * it is still disabled.
+ */
+extern int kgdb_enable_nmi(bool on);
/**
* struct kgdb_arch - Describe architecture specific values.
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0557f24..b621d1e 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -214,6 +214,30 @@ int __weak kgdb_skipexception(int exception, struct pt_regs *regs)
return 0;
}
+void __weak kgdb_arch_enable_nmi(bool on)
+{
+}
+
+int kgdb_enable_nmi(bool on)
+{
+ static atomic_t cnt;
+ int ret;
+
+ ret = atomic_add_return(on ? 1 : -1, &cnt);
+ if (ret > 1 && on) {
+ /*
+ * There should be only one instance that calls this function
+ * in "enable, disable" order. All other users must call
+ * disable first, then enable. If not, something is wrong.
+ */
+ WARN_ON(1);
+ return 1;
+ }
+
+ kgdb_arch_enable_nmi(ret > 0);
+ return ret;
+}
+
/*
* Some architectures need cache flushes when we set/clear a
* breakpoint:
@@ -672,6 +696,9 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
{
struct kgdb_state kgdb_var;
struct kgdb_state *ks = &kgdb_var;
+ int ret = 0;
+
+ kgdb_enable_nmi(0);
ks->cpu = raw_smp_processor_id();
ks->ex_vector = evector;
@@ -681,11 +708,14 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
ks->linux_regs = regs;
if (kgdb_reenter_check(ks))
- return 0; /* Ouch, double exception ! */
+ goto out; /* Ouch, double exception ! */
if (kgdb_info[ks->cpu].enter_kgdb != 0)
- return 0;
+ goto out;
- return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
+ ret = kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
+out:
+ kgdb_enable_nmi(1);
+ return ret;
}
int kgdb_nmicallback(int cpu, void *regs)
--
1.7.11.5
^ permalink raw reply related
* [PATCH 14/14] ARM: versatile: Make able to use UART ports for KGDB FIQ debugger
From: Anton Vorontsov @ 2012-09-10 4:14 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
If enabled, kernel will able to enter KGDB upon serial line activity on
UART ports.
Note that even with this patch and CONFIG_KGDB_FIQ is enabled, you still
need to pass kgdb_fiq.enable=1 kernel command line option, otherwise UART
will behave in a normal way.
By default UART0 is used, but this can be changed via kgdb_fiq.uart_num
kernel command line option.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-versatile/Makefile | 1 +
arch/arm/mach-versatile/kgdb_fiq.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 arch/arm/mach-versatile/kgdb_fiq.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 66f4f81..5972886 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -336,6 +336,7 @@ config ARCH_VERSATILE
select PLAT_VERSATILE_CLCD
select PLAT_VERSATILE_FPGA_IRQ
select ARM_TIMER_SP804
+ select ARCH_MIGHT_HAVE_KGDB_FIQ
help
This enables support for ARM Ltd Versatile board.
diff --git a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile
index 81fa3fe..bfd761f 100644
--- a/arch/arm/mach-versatile/Makefile
+++ b/arch/arm/mach-versatile/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARCH_VERSATILE_PB) += versatile_pb.o
obj-$(CONFIG_MACH_VERSATILE_AB) += versatile_ab.o
obj-$(CONFIG_MACH_VERSATILE_DT) += versatile_dt.o
obj-$(CONFIG_PCI) += pci.o
+obj-$(CONFIG_KGDB_FIQ) += kgdb_fiq.o
diff --git a/arch/arm/mach-versatile/kgdb_fiq.c b/arch/arm/mach-versatile/kgdb_fiq.c
new file mode 100644
index 0000000..3cdf71d
--- /dev/null
+++ b/arch/arm/mach-versatile/kgdb_fiq.c
@@ -0,0 +1,31 @@
+/*
+ * KGDB FIQ board support
+ *
+ * Copyright 2012 Linaro Ltd.
+ * Anton Vorontsov <anton.vorontsov@linaro.org>
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/kgdb.h>
+#include <mach/hardware.h>
+#include <mach/platform.h>
+#include <asm/hardware/vic.h>
+
+static int kgdb_fiq;
+module_param_named(uart_num, kgdb_fiq, int, 0600);
+MODULE_PARM_DESC(uart_num, "UART<number> port to use for KGDB FIQ");
+
+static int __init kgdb_fiq_init(void)
+{
+ WARN_ON(kgdb_fiq > INT_UARTINT2 - INT_UARTINT0);
+
+ return kgdb_register_fiq(INT_UARTINT0 + kgdb_fiq,
+ vic_fiq_select,
+ vic_is_fiq_rised);
+}
+console_initcall(kgdb_fiq_init);
--
1.7.11.5
^ permalink raw reply related
* [PATCH 13/14] ARM: VIC: Add a couple of low-level FIQ management helpers
From: Anton Vorontsov @ 2012-09-10 4:14 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
Just a couple of calls to manage VIC FIQ routing. We'll use them for
KGDB FIQ support on ARM Versatile machines.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
arch/arm/common/vic.c | 28 ++++++++++++++++++++++++++++
arch/arm/include/asm/hardware/vic.h | 2 ++
2 files changed, 30 insertions(+)
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index e0d5388..df2fc82 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -66,6 +66,34 @@ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR];
static int vic_id;
+static void __iomem *vic_base(struct irq_data *d)
+{
+ return (void __iomem *)irq_data_get_irq_chip_data(d);
+}
+
+void vic_fiq_select(unsigned int irq, bool on)
+{
+ void __iomem *base = vic_base(&irq_to_desc(irq)->irq_data);
+ void __iomem *sel = base + VIC_INT_SELECT;
+ u32 msk = 1 << irq;
+ u32 val;
+
+ pr_debug("rerouting VIC vector %d to %s\n", irq, on ? "FIQ" : "IRQ");
+
+ val = readl(sel);
+ val &= ~msk;
+ if (on)
+ val |= msk;
+ writel(val, sel);
+}
+
+bool vic_is_fiq_rised(unsigned int irq)
+{
+ void __iomem *base = vic_base(&irq_to_desc(irq)->irq_data);
+
+ return readl(base + VIC_FIQ_STATUS) & (1 << irq);
+}
+
/**
* vic_init2 - common initialisation code
* @base: Base of the VIC.
diff --git a/arch/arm/include/asm/hardware/vic.h b/arch/arm/include/asm/hardware/vic.h
index e14af1a..2728975 100644
--- a/arch/arm/include/asm/hardware/vic.h
+++ b/arch/arm/include/asm/hardware/vic.h
@@ -52,6 +52,8 @@ void __vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources,
void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources, u32 resume_sources);
int vic_of_init(struct device_node *node, struct device_node *parent);
void vic_handle_irq(struct pt_regs *regs);
+void vic_fiq_select(unsigned int irq, bool on);
+bool vic_is_fiq_rised(unsigned int irq);
#endif /* __ASSEMBLY__ */
#endif
--
1.7.11.5
^ permalink raw reply related
* [PATCH 01/14] serial/amba-pl011: fix ages old copy-paste errors
From: Anton Vorontsov @ 2012-09-10 4:11 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
From: Linus Walleij <linus.walleij@linaro.org>
The PL011 driver has a number of symbols referring to "pl01x"
(probably once shared with the pl010 driver) and some even named
"pl010" (probably a pure copy-paste artifact). Lets name all
local static functions with the prefix pl011_* for clarity.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
The patch was taken from the TTY tree.
If this patch rejects because 'already applied', this means that your
tree is probably based on TTY tree or -next (e.g. -mm). In which case
you don't need this patch, just drop it.
If your tree is based on Linus' tree, you need this patch to not bring
horrible conflicts into -next.
drivers/tty/serial/amba-pl011.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index d3553b5..92b1ac8 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1215,14 +1215,14 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
return IRQ_RETVAL(handled);
}
-static unsigned int pl01x_tx_empty(struct uart_port *port)
+static unsigned int pl011_tx_empty(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int status = readw(uap->port.membase + UART01x_FR);
return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT;
}
-static unsigned int pl01x_get_mctrl(struct uart_port *port)
+static unsigned int pl011_get_mctrl(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int result = 0;
@@ -1285,7 +1285,7 @@ static void pl011_break_ctl(struct uart_port *port, int break_state)
}
#ifdef CONFIG_CONSOLE_POLL
-static int pl010_get_poll_char(struct uart_port *port)
+static int pl011_get_poll_char(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int status;
@@ -1297,7 +1297,7 @@ static int pl010_get_poll_char(struct uart_port *port)
return readw(uap->port.membase + UART01x_DR);
}
-static void pl010_put_poll_char(struct uart_port *port,
+static void pl011_put_poll_char(struct uart_port *port,
unsigned char ch)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1637,7 +1637,7 @@ static const char *pl011_type(struct uart_port *port)
/*
* Release the memory region(s) being used by 'port'
*/
-static void pl010_release_port(struct uart_port *port)
+static void pl011_release_port(struct uart_port *port)
{
release_mem_region(port->mapbase, SZ_4K);
}
@@ -1645,7 +1645,7 @@ static void pl010_release_port(struct uart_port *port)
/*
* Request the memory region(s) being used by 'port'
*/
-static int pl010_request_port(struct uart_port *port)
+static int pl011_request_port(struct uart_port *port)
{
return request_mem_region(port->mapbase, SZ_4K, "uart-pl011")
!= NULL ? 0 : -EBUSY;
@@ -1654,18 +1654,18 @@ static int pl010_request_port(struct uart_port *port)
/*
* Configure/autoconfigure the port.
*/
-static void pl010_config_port(struct uart_port *port, int flags)
+static void pl011_config_port(struct uart_port *port, int flags)
{
if (flags & UART_CONFIG_TYPE) {
port->type = PORT_AMBA;
- pl010_request_port(port);
+ pl011_request_port(port);
}
}
/*
* verify the new serial_struct (for TIOCSSERIAL).
*/
-static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
+static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
{
int ret = 0;
if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
@@ -1678,9 +1678,9 @@ static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
}
static struct uart_ops amba_pl011_pops = {
- .tx_empty = pl01x_tx_empty,
+ .tx_empty = pl011_tx_empty,
.set_mctrl = pl011_set_mctrl,
- .get_mctrl = pl01x_get_mctrl,
+ .get_mctrl = pl011_get_mctrl,
.stop_tx = pl011_stop_tx,
.start_tx = pl011_start_tx,
.stop_rx = pl011_stop_rx,
@@ -1691,13 +1691,13 @@ static struct uart_ops amba_pl011_pops = {
.flush_buffer = pl011_dma_flush_buffer,
.set_termios = pl011_set_termios,
.type = pl011_type,
- .release_port = pl010_release_port,
- .request_port = pl010_request_port,
- .config_port = pl010_config_port,
- .verify_port = pl010_verify_port,
+ .release_port = pl011_release_port,
+ .request_port = pl011_request_port,
+ .config_port = pl011_config_port,
+ .verify_port = pl011_verify_port,
#ifdef CONFIG_CONSOLE_POLL
- .poll_get_char = pl010_get_poll_char,
- .poll_put_char = pl010_put_poll_char,
+ .poll_get_char = pl011_get_poll_char,
+ .poll_put_char = pl011_put_poll_char,
#endif
};
--
1.7.11.5
^ permalink raw reply related
* [PATCH 12/14] ARM: Add KGDB/KDB FIQ debugger generic code
From: Anton Vorontsov @ 2012-09-10 4:14 UTC (permalink / raw)
To: Andrew Morton, Russell King, Jason Wessel, Greg Kroah-Hartman,
Alan Cox
Cc: Arve Hjønnevåg, Colin Cross, Brian Swetland,
John Stultz, linux-kernel, linux-arm-kernel, linaro-kernel,
patches, kernel-team, kgdb-bugreport, linux-serial
In-Reply-To: <20120910040802.GA1261@lizard>
The FIQ debugger may be used to debug situations when the kernel stuck
in uninterruptable sections, e.g. the kernel infinitely loops or
deadlocked in an interrupt or with interrupts disabled.
By default KGDB FIQ is disabled in runtime, but can be enabled with
kgdb_fiq.enable=1 kernel command line option.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
arch/arm/Kconfig | 18 ++++++++
arch/arm/include/asm/kgdb.h | 8 ++++
arch/arm/kernel/Makefile | 1 +
arch/arm/kernel/kgdb_fiq.c | 99 ++++++++++++++++++++++++++++++++++++++++
arch/arm/kernel/kgdb_fiq_entry.S | 87 +++++++++++++++++++++++++++++++++++
5 files changed, 213 insertions(+)
create mode 100644 arch/arm/kernel/kgdb_fiq.c
create mode 100644 arch/arm/kernel/kgdb_fiq_entry.S
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c5f9ae5..66f4f81 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -171,6 +171,24 @@ config GENERIC_ISA_DMA
config FIQ
bool
+config ARCH_MIGHT_HAVE_KGDB_FIQ
+ bool
+
+config KGDB_FIQ
+ bool "KGDB/KDB FIQ debugger"
+ depends on KGDB_KDB && ARCH_MIGHT_HAVE_KGDB_FIQ && !THUMB2_KERNEL
+ select FIQ
+ help
+ The FIQ debugger may be used to debug situations when the
+ kernel stuck in uninterruptable sections, e.g. the kernel
+ infinitely loops or deadlocked in an interrupt or with
+ interrupts disabled.
+
+ By default KGDB FIQ is disabled in runtime, but can be
+ enabled with kgdb_fiq.enable=1 kernel command line option.
+
+ If unsure, say N.
+
config NEED_RET_TO_USER
bool
diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
index 48066ce..807e547 100644
--- a/arch/arm/include/asm/kgdb.h
+++ b/arch/arm/include/asm/kgdb.h
@@ -11,6 +11,8 @@
#define __ARM_KGDB_H__
#include <linux/ptrace.h>
+#include <linux/linkage.h>
+#include <asm/exception.h>
/*
* GDB assumes that we're a user process being debugged, so
@@ -47,6 +49,12 @@ static inline void arch_kgdb_breakpoint(void)
extern void kgdb_handle_bus_error(void);
extern int kgdb_fault_expected;
+extern char kgdb_fiq_handler;
+extern char kgdb_fiq_handler_end;
+asmlinkage void __exception_irq_entry kgdb_fiq_do_handle(struct pt_regs *regs);
+extern int __init kgdb_register_fiq(unsigned int mach_kgdb_fiq,
+ void (*mach_kgdb_enable_fiq)(unsigned int irq, bool on),
+ bool (*mach_is_kgdb_fiq)(unsigned int irq));
#endif /* !__ASSEMBLY__ */
/*
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 7ad2d5c..5aa079b 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_ATAGS_PROC) += atags.o
obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
obj-$(CONFIG_ARM_THUMBEE) += thumbee.o
obj-$(CONFIG_KGDB) += kgdb.o
+obj-$(CONFIG_KGDB_FIQ) += kgdb_fiq_entry.o kgdb_fiq.o
obj-$(CONFIG_ARM_UNWIND) += unwind.o
obj-$(CONFIG_HAVE_TCM) += tcm.o
obj-$(CONFIG_OF) += devtree.o
diff --git a/arch/arm/kernel/kgdb_fiq.c b/arch/arm/kernel/kgdb_fiq.c
new file mode 100644
index 0000000..8443af1
--- /dev/null
+++ b/arch/arm/kernel/kgdb_fiq.c
@@ -0,0 +1,99 @@
+/*
+ * KGDB FIQ
+ *
+ * Copyright 2010 Google, Inc.
+ * Arve Hjønnevåg <arve@android.com>
+ * Colin Cross <ccross@android.com>
+ * Copyright 2012 Linaro Ltd.
+ * Anton Vorontsov <anton.vorontsov@linaro.org>
+ *
+ * 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/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/hardirq.h>
+#include <linux/kdb.h>
+#include <linux/kgdb.h>
+#include <asm/fiq.h>
+#include <asm/exception.h>
+
+static int kgdb_fiq_enabled;
+module_param_named(enable, kgdb_fiq_enabled, int, 0600);
+MODULE_PARM_DESC(enable, "set to 1 to enable FIQ KGDB");
+
+static unsigned int kgdb_fiq;
+static bool (*is_kgdb_fiq)(unsigned int irq);
+
+asmlinkage void __exception_irq_entry kgdb_fiq_do_handle(struct pt_regs *regs)
+{
+ if (!is_kgdb_fiq(kgdb_fiq))
+ return;
+ if (!kgdb_nmi_poll_knock())
+ return;
+
+ nmi_enter();
+ kgdb_handle_exception(1, 0, 0, regs);
+ nmi_exit();
+}
+
+static struct fiq_handler kgdb_fiq_desc = {
+ .name = "kgdb",
+};
+
+static long kgdb_fiq_setup_stack(void *info)
+{
+ struct pt_regs regs;
+
+ regs.ARM_sp = __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER) +
+ THREAD_START_SP;
+ WARN_ON(!regs.ARM_sp);
+
+ set_fiq_regs(®s);
+ return 0;
+}
+
+static void (*kgdb_enable_fiq)(unsigned int irq, bool on);
+
+void kgdb_arch_enable_nmi(bool on)
+{
+ if (!kgdb_enable_fiq)
+ return;
+ kgdb_enable_fiq(kgdb_fiq, on);
+}
+
+int __init kgdb_register_fiq(unsigned int mach_kgdb_fiq,
+ void (*mach_kgdb_enable_fiq)(unsigned int irq, bool on),
+ bool (*mach_is_kgdb_fiq)(unsigned int irq))
+{
+ int err;
+ int cpu;
+
+ if (!kgdb_fiq_enabled)
+ return -ENODEV;
+ if (kgdb_fiq)
+ return -EBUSY;
+
+ kgdb_fiq = mach_kgdb_fiq;
+ kgdb_enable_fiq = mach_kgdb_enable_fiq;
+ is_kgdb_fiq = mach_is_kgdb_fiq;
+
+ err = claim_fiq(&kgdb_fiq_desc);
+ if (err) {
+ pr_warn("%s: unable to claim fiq", __func__);
+ return err;
+ }
+
+ for_each_possible_cpu(cpu)
+ work_on_cpu(cpu, kgdb_fiq_setup_stack, NULL);
+
+ set_fiq_handler(&kgdb_fiq_handler,
+ &kgdb_fiq_handler_end - &kgdb_fiq_handler);
+
+ return 0;
+}
diff --git a/arch/arm/kernel/kgdb_fiq_entry.S b/arch/arm/kernel/kgdb_fiq_entry.S
new file mode 100644
index 0000000..d6becca
--- /dev/null
+++ b/arch/arm/kernel/kgdb_fiq_entry.S
@@ -0,0 +1,87 @@
+/*
+ * KGDB FIQ entry
+ *
+ * Copyright 1996,1997,1998 Russell King.
+ * Copyright 2012 Linaro Ltd.
+ * Anton Vorontsov <anton.vorontsov@linaro.org>
+ *
+ * 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/linkage.h>
+#include <asm/assembler.h>
+#include <asm/memory.h>
+#include <asm/unwind.h>
+#include "entry-header.S"
+
+ .text
+
+@ This is needed for usr_entry/alignment_trap
+.LCcralign:
+ .long cr_alignment
+.LCdohandle:
+ .long kgdb_fiq_do_handle
+
+ .macro fiq_handler
+ ldr r1, =.LCdohandle
+ mov r0, sp
+ adr lr, BSYM(9997f)
+ ldr pc, [r1]
+9997:
+ .endm
+
+ .align 5
+__fiq_svc:
+ svc_entry
+ fiq_handler
+ mov r0, sp
+ ldmib r0, {r1 - r14}
+ msr cpsr_c, #FIQ_MODE | PSR_I_BIT | PSR_F_BIT
+ add r8, r0, #S_PC
+ ldr r9, [r0, #S_PSR]
+ msr spsr_cxsf, r9
+ ldr r0, [r0, #S_R0]
+ ldmia r8, {pc}^
+
+ UNWIND(.fnend )
+ENDPROC(__fiq_svc)
+ .ltorg
+
+ .align 5
+__fiq_usr:
+ usr_entry
+ kuser_cmpxchg_check
+ fiq_handler
+ get_thread_info tsk
+ mov why, #0
+ b ret_to_user_from_irq
+ UNWIND(.fnend )
+ENDPROC(__fiq_usr)
+ .ltorg
+
+ .global kgdb_fiq_handler
+kgdb_fiq_handler:
+
+ vector_stub fiq, FIQ_MODE, 4
+
+ .long __fiq_usr @ 0 (USR_26 / USR_32)
+ .long __fiq_svc @ 1 (FIQ_26 / FIQ_32)
+ .long __fiq_svc @ 2 (IRQ_26 / IRQ_32)
+ .long __fiq_svc @ 3 (SVC_26 / SVC_32)
+ .long __fiq_svc @ 4
+ .long __fiq_svc @ 5
+ .long __fiq_svc @ 6
+ .long __fiq_svc @ 7
+ .long __fiq_svc @ 8
+ .long __fiq_svc @ 9
+ .long __fiq_svc @ a
+ .long __fiq_svc @ b
+ .long __fiq_svc @ c
+ .long __fiq_svc @ d
+ .long __fiq_svc @ e
+ .long __fiq_svc @ f
+
+ .global kgdb_fiq_handler_end
+kgdb_fiq_handler_end:
--
1.7.11.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox