parisc: Add unlocked functions for pdc_iodc_getc() and pdc_iodc_print()
Helge Deller
maintainerPATCH 1/2 parisc: Add unlocked functions for pdc_iodc_getc() and pdc_iodc_print()
The built-in kernel debugger (kgdb) deadlocks if we use spinlocks (which should protect against concurrent firmware calls) to get keyboard input or to output to the console. Since we are in debugger mode anyway, we can simply avoid using this protection mechanism, which is why this patch adds unlocked keyboard input/console output functions which will be used by a follow-up patch.
In addition save some static bytes by reusing pdc_result[] as iodc_retbuf[] and by reducing the memory footprint of iodc_dbuf[].
--- arch/parisc/include/asm/pdc.h | 2 + arch/parisc/kernel/firmware.c | 70 +++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 27 deletions(-)
arch/parisc/include/asm/pdc.h +2 -0
@@ -83,7 +83,9 @@ int pdc_soft_power_button(int sw_control);void pdc_io_reset (void );void pdc_io_reset_devices (void );int pdc_iodc_getc (void ); +int pdc_iodc_getc_unlocked (void );int pdc_iodc_print (const unsigned char *str,unsigned count); +int pdc_iodc_print_unlocked (const unsigned char *str,unsigned count);void pdc_emergency_unlock (void ); int pdc_sti_call(unsigned long func, unsigned long flags,
arch/parisc/kernel/firmware.c +43 -27
116 lines not on this page · raw message
--
2.38.1
Helge Deller
maintainerPATCH 2/2 parisc: Fix kgdb keyboard input in pdc early console driver
Commit 027c3d345e2a ("parisc: Convert PDC console to an early console") broke (physical) keyboard input for kgdb due to the spinlocks used in the PDC console function.
Fix it by using using PDC calls which are not protected by spinlocks.
--- arch/parisc/kernel/pdc_cons.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
arch/parisc/kernel/pdc_cons.c +2 -12
@@ -12,29 +12,19 @@#include <asm/page.h> /* for PAGE0 */ #include <asm/pdc.h> /* for iodc_call() proto and friends */ -static DEFINE_SPINLOCK (pdc_console_lock); -static void pdc_console_write (struct console *co,const char *s,unsigned count) {int i =0 ; -unsigned long flags; -spin_lock_irqsave (&pdc_console_lock, flags);do { i +=pdc_iodc_print (s + i, count - i); }while (i < count); -spin_unlock_irqrestore (&pdc_console_lock, flags); }#ifdef CONFIG_KGDB static int kgdb_pdc_read_char (void ) { -int c; -unsigned long flags; - -spin_lock_irqsave (&pdc_console_lock, flags); - c =pdc_iodc_getc (); -spin_unlock_irqrestore (&pdc_console_lock, flags); +int c =pdc_iodc_getc_unlocked ();return (c <=0 ) ?NO_POLL_CHAR : c; }
@@ -42,7 +32,7 @@ static int kgdb_pdc_read_char(void)static void kgdb_pdc_write_char (u8 chr) {if (PAGE0 ->mem_cons.cl_class !=CL_DUPLEX ) -pdc_console_write (NULL , &chr,1 ); +pdc_iodc_print_unlocked (&chr,1 ); }static struct kgdb_io kgdb_pdc_io_ops = {
--
2.38.1
Helge Deller
maintainerRe: [PATCH 2/2] parisc: Fix kgdb keyboard input in pdc early console driver
Quoted 7 lines · Helge Deller
Commit
027c3d345e2a("parisc: Convert PDC console to an early console") broke (physical) keyboard input for kgdb due to the spinlocks used in the PDC console function.
Fix it by using using PDC calls which are not protected by spinlocks.Fixes 027c3d345e2a ("parisc: Convert PDC console to an early console")Signed-off-by Helge Deller <[email protected]>
I dropped this series as it didn't fixed my problem:
The USB keyboard on my C3000 probably needs a USB reset when a HPMC occurs to get it working again.
Helge
Quoted 51 lines
--- arch/parisc/kernel/pdc_cons.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)arch/parisc/kernel/pdc_cons.c +2
-13@@ -12,29 +12,19 @@#include <asm/page.h> /* for PAGE0 */ #include <asm/pdc.h> /* for iodc_call() proto and friends */ -static DEFINE_SPINLOCK (pdc_console_lock); -static void pdc_console_write (struct console *co,const char *s,unsigned count) {int i =0 ; -unsigned long flags; -spin_lock_irqsave (&pdc_console_lock, flags);do { i +=pdc_iodc_print (s + i, count - i); }while (i < count); -spin_unlock_irqrestore (&pdc_console_lock, flags); }#ifdef CONFIG_KGDB static int kgdb_pdc_read_char (void ) { -int c; -unsigned long flags; - -spin_lock_irqsave (&pdc_console_lock, flags); - c =pdc_iodc_getc (); -spin_unlock_irqrestore (&pdc_console_lock, flags); +int c =pdc_iodc_getc_unlocked ();return (c <=0 ) ?NO_POLL_CHAR : c; }@@ -42,7 +32,7 @@ static int kgdb_pdc_read_char(void)static void kgdb_pdc_write_char (u8 chr) {if (PAGE0 ->mem_cons.cl_class !=CL_DUPLEX ) -pdc_console_write (NULL , &chr,1 ); +pdc_iodc_print_unlocked (&chr,1 ); }static struct kgdb_io kgdb_pdc_io_ops = { --2.38.1