powerpc/hvsi: Move HVSI protocol definitions to a header file
PATCH 1/4 powerpc/hvsi: Move HVSI protocol definitions to a header file
This moves various HVSI protocol definitions from the hvsi.c driver to a header file that can be used later on by a udbg implementation
--- arch/powerpc/include/asm/hvsi.h | 68 +++++++++++++++++++++++++++++++++++++++ drivers/tty/hvc/hvsi.c | 63 +----------------------------------- 2 files changed, 69 insertions(+), 62 deletions(-) create mode 100644 arch/powerpc/include/asm/hvsi.h
arch/powerpc/include/asm/hvsi.h new file +68 -0
@@ -0,0 +1,68 @@ +#ifndef _HVSI_H +#define _HVSI_H + +#define VS_DATA_PACKET_HEADER 0xff +#define VS_CONTROL_PACKET_HEADER 0xfe +#define VS_QUERY_PACKET_HEADER 0xfd +#define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc + +/* control verbs */ +#define VSV_SET_MODEM_CTL 1/* to service processor only */ +#define VSV_MODEM_CTL_UPDATE 2/* from service processor only */ +#define VSV_CLOSE_PROTOCOL 3 + +/* query verbs */ +#define VSV_SEND_VERSION_NUMBER 1 +#define VSV_SEND_MODEM_CTL_STATUS 2 + +/* yes, these masks are not consecutive. */ +#define HVSI_TSDTR 0x01 +#define HVSI_TSCD 0x20 + +#define HVSI_MAX_OUTGOING_DATA 12 +#define HVSI_VERSION 1 + +struct hvsi_header { +uint8_t type; +uint8_t len; +uint16_t seqno; +} __attribute__((packed)); + +struct hvsi_data { +uint8_t type; +uint8_t len; +uint16_t seqno; +uint8_t data[HVSI_MAX_OUTGOING_DATA ]; +} __attribute__((packed)); + +struct hvsi_control { +uint8_t type; +uint8_t len; +uint16_t seqno; +uint16_t verb; +/* optional depending on verb: */ +uint32_t word; +uint32_t mask; +} __attribute__((packed)); + +struct hvsi_query { +uint8_t type; +uint8_t len; +uint16_t seqno; +uint16_t verb; +} __attribute__((packed)); + +struct hvsi_query_response { +uint8_t type; +uint8_t len; +uint16_t seqno; +uint16_t verb; +uint16_t query_seqno; +union { +uint8_t version; +uint32_t mctrl_word; + } u; +} __attribute__((packed)); + + +#endif /* _HVSI_H */
drivers/tty/hvc/hvsi.c +1 -62
75 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 2/4 powerpc/pseries: Factor HVSI header struct in packet definitions
Embed the struct hvsi_header in the various packet definitions rather than open coding it multiple times. Will help provide stronger type checking.
--- arch/powerpc/include/asm/hvsi.h | 16 ++------- drivers/tty/hvc/hvsi.c | 66 +++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 45 deletions(-)
arch/powerpc/include/asm/hvsi.h +4 -12
@@ -29,16 +29,12 @@ struct hvsi_header { } __attribute__((packed));struct hvsi_data { -uint8_t type; -uint8_t len; -uint16_t seqno; +struct hvsi_header hdr;uint8_t data[HVSI_MAX_OUTGOING_DATA ]; } __attribute__((packed));struct hvsi_control { -uint8_t type; -uint8_t len; -uint16_t seqno; +struct hvsi_header hdr;uint16_t verb;/* optional depending on verb: */ uint32_t word;
@@ -46,16 +42,12 @@ struct hvsi_control { } __attribute__((packed));struct hvsi_query { -uint8_t type; -uint8_t len; -uint16_t seqno; +struct hvsi_header hdr;uint16_t verb; } __attribute__((packed));struct hvsi_query_response { -uint8_t type; -uint8_t len; -uint16_t seqno; +struct hvsi_header hdr;uint16_t verb;uint16_t query_seqno;union {
drivers/tty/hvc/hvsi.c +33 -33
122 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 3/4 powerpc/udbg: Register udbg console generically
In reply to Benjamin HerrenschmidtWhen CONFIG_PPC_EARLY_DEBUG is set, call register_early_udbg_console() early from generic code.
--- arch/powerpc/kernel/udbg.c | 2 ++ arch/powerpc/platforms/pseries/lpar.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/udbg.c +2 -0
@@ -66,6 +66,8 @@ void __init udbg_early_init(void)#ifdef CONFIG_PPC_EARLY_DEBUG console_loglevel =10 ; + +register_early_udbg_console ();#endif }
arch/powerpc/platforms/pseries/lpar.c +0 -2
@@ -193,8 +193,6 @@ void __init udbg_init_debug_lpar(void) udbg_putc = udbg_putcLP; udbg_getc = udbg_getcLP; udbg_getc_poll = udbg_getc_pollLP; - -register_early_udbg_console (); }/* returns 0 if couldn't find or use /chosen/stdout as console */
Signature · 1 line
1.7.1
PATCH 4/4 powerpc/pseries: Re-implement HVSI as part of hvc_vio
In reply to Benjamin HerrenschmidtOn pseries machines, consoles are provided by the hypervisor using a low level get_chars/put_chars type interface. However, this is really just a transport to the service processor which implements them either as "raw" console (networked consoles, HMC, ...) or as "hvsi" serial ports.
The later is a simple packet protocol on top of the raw character interface that is supposed to convey additional "serial port" style semantics. In practice however, all it does is provide a way to read the CD line and set/clear our DTR line, that's it.
We currently implement the "raw" protocol as an hvc console backend (/dev/hvcN) and the "hvsi" protocol using a separate tty driver (/dev/hvsi0).
However this is quite impractical. The arbitrary difference between the two type of devices has been a major source of user (and distro) confusion. Additionally, there's an additional mini -hvsi implementation in the pseries platform code for our low level debug console and early boot kernel messages, which means code duplication, though that low level variant is impractical as it's incapable of doing the initial protocol negociation to establish the link to the FSP.
This essentially replaces the dedicated hvsi driver and the platform udbg code completely by extending the existing hvc_vio backend used in "raw" mode so that:
- It now supports HVSI as well
- We add support for hvc backend providing tiocm{get,set}
- It also provides a udbg interface for early debug and boot console
This is overall less code, though this will only be obvious once we remove the old "hvsi" driver, which is still available for now. When the old driver is enabled, the new code still kicks in for the low level udbg console, replacing the old mini implementation in the platform code, it just doesn't provide the higher level "hvc" interface.
In addition to producing generally simler code, this has several benefits over our current situation:
- The user/distro only has to deal with /dev/hvcN for the hypervisor
console, avoiding all sort of confusion that has plagued us in the past
- The tty, kernel and low level debug console all use the same code
base which supports the full protocol establishment process, thus the console is now available much earlier than it used to be with the old HVSI driver. The kernel console works much earlier and udbg is available much earlier too. Hackers can enable a hard coded very-early debug console as well that works with HVSI (previously that was only supported for the "raw" mode).
I've tried to keep the same semantics as hvsi relative to how I react to things like CD changes, with some subtle differences though:
- I clear DTR on close if HUPCL is set
- Current hvsi triggers a hangup if it detects a up->down transition on CD (you can still open a console with CD down). My new implementation triggers a hangup if the link to the FSP is severed, and severs it upon detecting a up->down transition on CD.
--- arch/powerpc/Kconfig.debug | 15 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 3 + arch/powerpc/platforms/pseries/lpar.c | 189 -------- arch/powerpc/platforms/pseries/pseries.h | 3 +- arch/powerpc/platforms/pseries/setup.c | 2 +- drivers/tty/hvc/Kconfig | 5 + drivers/tty/hvc/Makefile | 3 +- drivers/tty/hvc/hvc_console.c | 23 +- drivers/tty/hvc/hvc_console.h | 4 + drivers/tty/hvc/hvc_vio.c | 725 ++++++++++++++++++++++++++++-- 11 files changed, 747 insertions(+), 226 deletions(-)
arch/powerpc/Kconfig.debug +15 -0
@@ -188,6 +188,13 @@ config PPC_EARLY_DEBUG_LPAR Select this to enable early debugging for a machine with a HVC console on vterm 0. +config PPC_EARLY_DEBUG_LPAR_HVSI + bool "LPAR HVSI Console" + depends on PPC_PSERIES + help + Select this to enable early debugging for a machine with a HVSI + console on a specified vterm. + config PPC_EARLY_DEBUG_G5 bool "Apple G5" depends on PPC_PMAC64
@@ -269,6 +276,14 @@ config PPC_EARLY_DEBUG_USBGECKO endchoice +config PPC_EARLY_DEBUG_HVSI_VTERMNO + hex "vterm number to use with early debug HVSI" + depends on PPC_EARLY_DEBUG_LPAR_HVSI + default "0x30000000" + help + You probably want 0x30000000 for your first serial port and + 0x30000001 for your second one + config PPC_EARLY_DEBUG_44x_PHYSLOW hex "Low 32 bits of early debug UART physical address" depends on PPC_EARLY_DEBUG_44x
arch/powerpc/include/asm/udbg.h +1 -0
@@ -40,6 +40,7 @@ extern void udbg_adb_init_early(void);extern void __init udbg_early_init (void );extern void __init udbg_init_debug_lpar (void ); +extern void __init udbg_init_debug_lpar_hvsi (void );extern void __init udbg_init_pmac_realmode (void );extern void __init udbg_init_maple_realmode (void );extern void __init udbg_init_pas_realmode (void );
arch/powerpc/kernel/udbg.c +3 -0
@@ -31,6 +31,9 @@ void __init udbg_early_init(void)#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR )/* For LPAR machines that have an HVC console on vterm 0 */ udbg_init_debug_lpar (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_LPAR_HVSI ) +/* For LPAR machines that have an HVSI console on vterm 0 */ +udbg_init_debug_lpar_hvsi ();#elif defined(CONFIG_PPC_EARLY_DEBUG_G5 )/* For use on Apple G5 machines */ udbg_init_pmac_realmode ();
arch/powerpc/platforms/pseries/lpar.c +0 -189
195 lines not on this page · raw message
arch/powerpc/platforms/pseries/pseries.h +2 -1
@@ -47,7 +47,8 @@ extern void pSeries_final_fixup(void);/* Poweron flag used for enabling auto ups restart */ extern unsigned long rtas_poweron_auto; -extern void find_udbg_vterm (void ); +/* Provided by HVC VIO */ +extern void hvc_vio_init_early (void );/* Dynamic logical Partitioning/Mobility */ extern void dlpar_free_cc_nodes (struct device_node *);
arch/powerpc/platforms/pseries/setup.c +1 -1
@@ -489,7 +489,7 @@ static void __init pSeries_init_early(void)pr_debug (" -> pSeries_init_early()\n" );if (firmware_has_feature (FW_FEATURE_LPAR )) -find_udbg_vterm (); +hvc_vio_init_early ();if (firmware_has_feature (FW_FEATURE_DABR )) ppc_md.set_dabr = pseries_set_dabr;
drivers/tty/hvc/Kconfig +5 -0
@@ -19,6 +19,11 @@ config HVC_CONSOLE console. This driver allows each pSeries partition to have a console which is accessed via the HMC. +config HVC_OLD_HVSI + bool "Old driver for pSeries serial port (/dev/hvsi*)" + depends on HVC_CONSOLE + default n + config HVC_ISERIES bool "iSeries Hypervisor Virtual Console support" depends on PPC_ISERIES
drivers/tty/hvc/Makefile +2 -1
@@ -1,4 +1,5 @@ -obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o +obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o +obj-$(CONFIG_HVC_OLD_HVSI) += hvsi.o obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o obj-$(CONFIG_HVC_TILE) += hvc_tile.o
drivers/tty/hvc/hvc_console.c +22 -1
@@ -184,7 +184,7 @@ static struct tty_driver *hvc_console_device(struct console *c, int *index) }static int __init hvc_console_setup (struct console *co,char *options) -{ +{if (co->index <0 || co->index >=MAX_NR_HVC_CONSOLES )return -ENODEV ;
@@ -745,6 +745,25 @@ static int khvcd(void *unused)return 0 ; } +static int hvc_tiocmget (struct tty_struct *tty) +{ +struct hvc_struct *hp = tty->driver_data; + +if (!hp || !hp->ops->tiocmget) +return -EINVAL ; +return hp->ops->tiocmget (hp); +} + +static int hvc_tiocmset (struct tty_struct *tty, +unsigned int set,unsigned int clear) +{ +struct hvc_struct *hp = tty->driver_data; + +if (!hp || !hp->ops->tiocmset) +return -EINVAL ; +return hp->ops->tiocmset (hp, set, clear); +} +static const struct tty_operations hvc_ops = { .open = hvc_open, .close = hvc_close,
@@ -753,6 +772,8 @@ static const struct tty_operations hvc_ops = { .unthrottle = hvc_unthrottle, .write_room = hvc_write_room, .chars_in_buffer = hvc_chars_in_buffer, + .tiocmget = hvc_tiocmget, + .tiocmset = hvc_tiocmset, }; struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
drivers/tty/hvc/hvc_console.h +4 -0
@@ -73,6 +73,10 @@ struct hv_ops {int (*notifier_add)(struct hvc_struct *hp,int irq);void (*notifier_del)(struct hvc_struct *hp,int irq);void (*notifier_hangup)(struct hvc_struct *hp,int irq); + +/* tiocmget/set implementation */ +int (*tiocmget)(struct hvc_struct *hp); +int (*tiocmset)(struct hvc_struct *hp,unsigned int set,unsigned int clear); };/* Register a vterm and a slot index for use as a console (console_init) */
drivers/tty/hvc/hvc_vio.c +692 -33
802 lines not on this page · raw message
Signature · 1 line
1.7.1