Skip to content

Commit f1e4553

Browse files
committed
Merge tag 'kgdb-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux
Pull kgdb updates from Daniel Thompson: "By far the biggest change in this cycle are the changes that allow much earlier debug of systems that are hooked up via UART by taking advantage of the earlycon framework to implement the kgdb I/O hooks before handing over to the regular polling I/O drivers once they are available. When discussing Doug's work we also found and fixed an broken raw_smp_processor_id() sequence in in_dbg_master(). Also included are a collection of much smaller fixes and tweaks: a couple of tweaks to ged rid of doc gen or coccicheck warnings, future proof some internal calculations that made implicit power-of-2 assumptions and eliminate some rather weird handling of magic environment variables in kdb" * tag 'kgdb-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux: kdb: Remove the misfeature 'KDBFLAGS' kdb: Cleanup math with KDB_CMD_HISTORY_COUNT serial: amba-pl011: Support kgdboc_earlycon serial: 8250_early: Support kgdboc_earlycon serial: qcom_geni_serial: Support kgdboc_earlycon serial: kgdboc: Allow earlycon initialization to be deferred Documentation: kgdboc: Document new kgdboc_earlycon parameter kgdb: Don't call the deinit under spinlock kgdboc: Disable all the early code when kgdboc is a module kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles kgdboc: Remove useless #ifdef CONFIG_KGDB_SERIAL_CONSOLE in kgdboc kgdb: Prevent infinite recursive entries to the debugger kgdb: Delay "kgdbwait" to dbg_late_init() by default kgdboc: Use a platform device to handle tty drivers showing up late Revert "kgdboc: disable the console lock when in kgdb" kgdb: Disable WARN_CONSOLE_UNLOCKED for all kgdb kgdb: Return true in kgdb_nmi_poll_knock() kgdb: Drop malformed kernel doc comment kgdb: Fix spurious true from in_dbg_master()
2 parents 38696e3 + c893de1 commit f1e4553

File tree

12 files changed

+490
-56
lines changed

12 files changed

+490
-56
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,11 @@
11901190
This is designed to be used in conjunction with
11911191
the boot argument: earlyprintk=vga
11921192

1193+
This parameter works in place of the kgdboc parameter
1194+
but can only be used if the backing tty is available
1195+
very early in the boot process. For early debugging
1196+
via a serial port see kgdboc_earlycon instead.
1197+
11931198
edd= [EDD]
11941199
Format: {"off" | "on" | "skip[mbr]"}
11951200

@@ -2112,6 +2117,21 @@
21122117
kms, kbd format: kms,kbd
21132118
kms, kbd and serial format: kms,kbd,<ser_dev>[,baud]
21142119

2120+
kgdboc_earlycon= [KGDB,HW]
2121+
If the boot console provides the ability to read
2122+
characters and can work in polling mode, you can use
2123+
this parameter to tell kgdb to use it as a backend
2124+
until the normal console is registered. Intended to
2125+
be used together with the kgdboc parameter which
2126+
specifies the normal console to transition to.
2127+
2128+
The name of the early console should be specified
2129+
as the value of this parameter. Note that the name of
2130+
the early console might be different than the tty
2131+
name passed to kgdboc. It's OK to leave the value
2132+
blank and the first boot console that implements
2133+
read() will be picked.
2134+
21152135
kgdbwait [KGDB] Stop kernel execution and enter the
21162136
kernel debugger at the earliest opportunity.
21172137

Documentation/dev-tools/kgdb.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,30 @@ don't like this are to hack gdb to send the :kbd:`SysRq-G` for you as well as
274274
on the initial connect, or to use a debugger proxy that allows an
275275
unmodified gdb to do the debugging.
276276

277+
Kernel parameter: ``kgdboc_earlycon``
278+
-------------------------------------
279+
280+
If you specify the kernel parameter ``kgdboc_earlycon`` and your serial
281+
driver registers a boot console that supports polling (doesn't need
282+
interrupts and implements a nonblocking read() function) kgdb will attempt
283+
to work using the boot console until it can transition to the regular
284+
tty driver specified by the ``kgdboc`` parameter.
285+
286+
Normally there is only one boot console (especially that implements the
287+
read() function) so just adding ``kgdboc_earlycon`` on its own is
288+
sufficient to make this work. If you have more than one boot console you
289+
can add the boot console's name to differentiate. Note that names that
290+
are registered through the boot console layer and the tty layer are not
291+
the same for the same port.
292+
293+
For instance, on one board to be explicit you might do::
294+
295+
kgdboc_earlycon=qcom_geni kgdboc=ttyMSM0
296+
297+
If the only boot console on the device was "qcom_geni", you could simplify::
298+
299+
kgdboc_earlycon kgdboc=ttyMSM0
300+
277301
Kernel parameter: ``kgdbwait``
278302
------------------------------
279303

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ config X86
6060
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
6161
select ARCH_HAS_DEBUG_VIRTUAL
6262
select ARCH_HAS_DEVMEM_IS_ALLOWED
63+
select ARCH_HAS_EARLY_DEBUG if KGDB
6364
select ARCH_HAS_ELF_RANDOMIZE
6465
select ARCH_HAS_FAST_MULTIPLIER
6566
select ARCH_HAS_FILTER_PGPROT

drivers/tty/serial/8250/8250_early.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ static void early_serial8250_write(struct console *console,
109109
uart_console_write(port, s, count, serial_putc);
110110
}
111111

112+
#ifdef CONFIG_CONSOLE_POLL
113+
static int early_serial8250_read(struct console *console,
114+
char *s, unsigned int count)
115+
{
116+
struct earlycon_device *device = console->data;
117+
struct uart_port *port = &device->port;
118+
unsigned int status;
119+
int num_read = 0;
120+
121+
while (num_read < count) {
122+
status = serial8250_early_in(port, UART_LSR);
123+
if (!(status & UART_LSR_DR))
124+
break;
125+
s[num_read++] = serial8250_early_in(port, UART_RX);
126+
}
127+
128+
return num_read;
129+
}
130+
#else
131+
#define early_serial8250_read NULL
132+
#endif
133+
112134
static void __init init_port(struct earlycon_device *device)
113135
{
114136
struct uart_port *port = &device->port;
@@ -149,6 +171,7 @@ int __init early_serial8250_setup(struct earlycon_device *device,
149171
init_port(device);
150172

151173
device->con->write = early_serial8250_write;
174+
device->con->read = early_serial8250_read;
152175
return 0;
153176
}
154177
EARLYCON_DECLARE(uart8250, early_serial8250_setup);

drivers/tty/serial/amba-pl011.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,37 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n)
24352435
uart_console_write(&dev->port, s, n, pl011_putc);
24362436
}
24372437

2438+
#ifdef CONFIG_CONSOLE_POLL
2439+
static int pl011_getc(struct uart_port *port)
2440+
{
2441+
if (readl(port->membase + UART01x_FR) & UART01x_FR_RXFE)
2442+
return NO_POLL_CHAR;
2443+
2444+
if (port->iotype == UPIO_MEM32)
2445+
return readl(port->membase + UART01x_DR);
2446+
else
2447+
return readb(port->membase + UART01x_DR);
2448+
}
2449+
2450+
static int pl011_early_read(struct console *con, char *s, unsigned int n)
2451+
{
2452+
struct earlycon_device *dev = con->data;
2453+
int ch, num_read = 0;
2454+
2455+
while (num_read < n) {
2456+
ch = pl011_getc(&dev->port);
2457+
if (ch == NO_POLL_CHAR)
2458+
break;
2459+
2460+
s[num_read++] = ch;
2461+
}
2462+
2463+
return num_read;
2464+
}
2465+
#else
2466+
#define pl011_early_read NULL
2467+
#endif
2468+
24382469
/*
24392470
* On non-ACPI systems, earlycon is enabled by specifying
24402471
* "earlycon=pl011,<address>" on the kernel command line.
@@ -2454,6 +2485,7 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
24542485
return -ENODEV;
24552486

24562487
device->con->write = pl011_early_write;
2488+
device->con->read = pl011_early_read;
24572489

24582490
return 0;
24592491
}

0 commit comments

Comments
 (0)