Skip to content

Commit cd18345

Browse files
Heinz Graalfsmatosatti
authored andcommitted
KVM: s390: Perform early event mask processing during boot
For processing under KVM it is required to detect the actual SCLP console type in order to set it as preferred console. Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> Acked-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
1 parent 61bde82 commit cd18345

6 files changed

Lines changed: 61 additions & 14 deletions

File tree

‎arch/s390/include/asm/sclp.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ int sclp_chp_configure(struct chp_id chpid);
5555
int sclp_chp_deconfigure(struct chp_id chpid);
5656
int sclp_chp_read_info(struct sclp_chp_info *info);
5757
void sclp_get_ipl_info(struct sclp_ipl_info *info);
58+
bool sclp_has_linemode(void);
59+
bool sclp_has_vt220(void);
5860

5961
#endif /* _ASM_S390_SCLP_H */

‎arch/s390/kernel/setup.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include <asm/kvm_virtio.h>
6464
#include <asm/diag.h>
6565
#include <asm/os_info.h>
66+
#include <asm/sclp.h>
6667
#include "entry.h"
6768

6869
long psw_kernel_bits = PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_PRIMARY |
@@ -138,9 +139,14 @@ __setup("condev=", condev_setup);
138139

139140
static void __init set_preferred_console(void)
140141
{
141-
if (MACHINE_IS_KVM)
142-
add_preferred_console("hvc", 0, NULL);
143-
else if (CONSOLE_IS_3215 || CONSOLE_IS_SCLP)
142+
if (MACHINE_IS_KVM) {
143+
if (sclp_has_vt220())
144+
add_preferred_console("ttyS", 1, NULL);
145+
else if (sclp_has_linemode())
146+
add_preferred_console("ttyS", 0, NULL);
147+
else
148+
add_preferred_console("hvc", 0, NULL);
149+
} else if (CONSOLE_IS_3215 || CONSOLE_IS_SCLP)
144150
add_preferred_console("ttyS", 0, NULL);
145151
else if (CONSOLE_IS_3270)
146152
add_preferred_console("tty3270", 0, NULL);

‎drivers/s390/char/sclp.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,16 +654,6 @@ sclp_remove_processed(struct sccb_header *sccb)
654654

655655
EXPORT_SYMBOL(sclp_remove_processed);
656656

657-
struct init_sccb {
658-
struct sccb_header header;
659-
u16 _reserved;
660-
u16 mask_length;
661-
sccb_mask_t receive_mask;
662-
sccb_mask_t send_mask;
663-
sccb_mask_t sclp_receive_mask;
664-
sccb_mask_t sclp_send_mask;
665-
} __attribute__((packed));
666-
667657
/* Prepare init mask request. Called while sclp_lock is locked. */
668658
static inline void
669659
__sclp_make_init_req(u32 receive_mask, u32 send_mask)

‎drivers/s390/char/sclp.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ struct sccb_header {
8888
u16 response_code;
8989
} __attribute__((packed));
9090

91+
struct init_sccb {
92+
struct sccb_header header;
93+
u16 _reserved;
94+
u16 mask_length;
95+
sccb_mask_t receive_mask;
96+
sccb_mask_t send_mask;
97+
sccb_mask_t sclp_receive_mask;
98+
sccb_mask_t sclp_send_mask;
99+
} __attribute__((packed));
100+
91101
extern u64 sclp_facilities;
92102
#define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
93103
#define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)

‎drivers/s390/char/sclp_cmd.c‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct read_info_sccb {
4848
u8 _reserved5[4096 - 112]; /* 112-4095 */
4949
} __attribute__((packed, aligned(PAGE_SIZE)));
5050

51+
static struct init_sccb __initdata early_event_mask_sccb __aligned(PAGE_SIZE);
5152
static struct read_info_sccb __initdata early_read_info_sccb;
5253
static int __initdata early_read_info_sccb_valid;
5354

@@ -104,6 +105,19 @@ static void __init sclp_read_info_early(void)
104105
}
105106
}
106107

108+
static void __init sclp_event_mask_early(void)
109+
{
110+
struct init_sccb *sccb = &early_event_mask_sccb;
111+
int rc;
112+
113+
do {
114+
memset(sccb, 0, sizeof(*sccb));
115+
sccb->header.length = sizeof(*sccb);
116+
sccb->mask_length = sizeof(sccb_mask_t);
117+
rc = sclp_cmd_sync_early(SCLP_CMDW_WRITE_EVENT_MASK, sccb);
118+
} while (rc == -EBUSY);
119+
}
120+
107121
void __init sclp_facilities_detect(void)
108122
{
109123
struct read_info_sccb *sccb;
@@ -119,6 +133,30 @@ void __init sclp_facilities_detect(void)
119133
rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
120134
rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
121135
rzm <<= 20;
136+
137+
sclp_event_mask_early();
138+
}
139+
140+
bool __init sclp_has_linemode(void)
141+
{
142+
struct init_sccb *sccb = &early_event_mask_sccb;
143+
144+
if (sccb->header.response_code != 0x20)
145+
return 0;
146+
if (sccb->sclp_send_mask & (EVTYP_MSG_MASK | EVTYP_PMSGCMD_MASK))
147+
return 1;
148+
return 0;
149+
}
150+
151+
bool __init sclp_has_vt220(void)
152+
{
153+
struct init_sccb *sccb = &early_event_mask_sccb;
154+
155+
if (sccb->header.response_code != 0x20)
156+
return 0;
157+
if (sccb->sclp_send_mask & EVTYP_VT220MSG_MASK)
158+
return 1;
159+
return 0;
122160
}
123161

124162
unsigned long long sclp_get_rnmax(void)

‎drivers/s390/kvm/kvm_virtio.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <asm/io.h>
2626
#include <asm/kvm_para.h>
2727
#include <asm/kvm_virtio.h>
28+
#include <asm/sclp.h>
2829
#include <asm/setup.h>
2930
#include <asm/irq.h>
3031

@@ -468,7 +469,7 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
468469

469470
static int __init s390_virtio_console_init(void)
470471
{
471-
if (!MACHINE_IS_KVM)
472+
if (sclp_has_vt220() || sclp_has_linemode())
472473
return -ENODEV;
473474
return virtio_cons_early_init(early_put_chars);
474475
}

0 commit comments

Comments
 (0)