From: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>
To: oberpar@linux.ibm.com, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com,
brueckner@linux.ibm.com, mjrosato@linux.ibm.com,
farman@linux.ibm.com,
maximilian.immanuel.brandtner@protonmail.com
Subject: [PATCH v2 2/2] s390/sclp: Implement resize for sclp-vt220 console
Date: Tue, 22 Sep 2026 11:59:03 +0200 [thread overview]
Message-ID: <20260922095903.1595794-3-maxbr@linux.ibm.com> (raw)
In-Reply-To: <20260922095903.1595794-1-maxbr@linux.ibm.com>
Add support for sclp vt220 resize events to enable host-initiated
terminal resizing when using the sclp-vt220 console.
This allows QEMU to dynamically resize the console. On older kernel
versions, these events are safely ignored as the kernel drops events
with undefined tty codes.
Signed-off-by: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
---
drivers/s390/char/sclp_vt220.c | 64 +++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 6dd176049..f5bdca7a8 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -27,6 +27,7 @@
#include <linux/init.h>
#include <linux/reboot.h>
#include <linux/slab.h>
+#include <linux/workqueue.h>
#include <linux/uaccess.h>
#include "sclp.h"
@@ -58,6 +59,11 @@ struct sclp_vt220_evbuf {
char data[];
} __packed;
+struct sclp_vt220_resize_data_t {
+ u16 rows;
+ u16 cols;
+} __packed;
+
#define SCLP_VT220_MAX_CHARS_PER_BUFFER (PAGE_SIZE - \
sizeof(struct sclp_vt220_request) - \
sizeof(struct sclp_vt220_sccb))
@@ -98,6 +104,15 @@ static int __initdata sclp_vt220_init_count;
* another buffer */
static int sclp_vt220_flush_later;
+/* Work struct required for scheduling resize */
+static struct work_struct sclp_vt220_resize_work;
+
+/* Current vt220 terminal winsize */
+static struct winsize sclp_vt220_winsize = {
+ .ws_row = 24,
+ .ws_col = 80,
+};
+
static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf);
static int __sclp_vt220_emit(struct sclp_vt220_request *request);
static void sclp_vt220_emit_current(void);
@@ -477,6 +492,7 @@ sclp_vt220_write(struct tty_struct *tty, const u8 *buf, size_t count)
#define SCLP_VT220_SESSION_ENDED 0x01
#define SCLP_VT220_SESSION_STARTED 0x80
#define SCLP_VT220_SESSION_DATA 0x00
+#define SCLP_VT220_SESSION_RESIZE 0x08
#ifdef CONFIG_MAGIC_SYSRQ
@@ -525,6 +541,38 @@ static void sclp_vt220_handle_input(const char *buffer, unsigned int count)
#endif
+static void sclp_vt220_resize(struct work_struct *work)
+{
+ struct tty_struct *tty;
+ struct winsize ws;
+
+ spin_lock_irq(&sclp_vt220_lock);
+ ws = sclp_vt220_winsize;
+ spin_unlock_irq(&sclp_vt220_lock);
+
+ tty = tty_port_tty_get(&sclp_vt220_port);
+ if (!tty)
+ return;
+
+ tty_do_resize(tty, &ws);
+ tty_kref_put(tty);
+}
+
+static void sclp_vt220_resize_sched(void *buffer, unsigned int count)
+{
+ struct sclp_vt220_resize_data_t *data = buffer;
+ unsigned long flags;
+
+ if (count < sizeof(*data))
+ return;
+
+ spin_lock_irqsave(&sclp_vt220_lock, flags);
+ sclp_vt220_winsize.ws_row = data->rows;
+ sclp_vt220_winsize.ws_col = data->cols;
+ schedule_work(&sclp_vt220_resize_work);
+ spin_unlock_irqrestore(&sclp_vt220_lock, flags);
+}
+
/*
* Called by the SCLP to report incoming event buffers.
*/
@@ -546,6 +594,9 @@ static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
sclp_vt220_handle_input(buffer->data, count);
tty_flip_buffer_push(&sclp_vt220_port);
break;
+ case SCLP_VT220_SESSION_RESIZE:
+ sclp_vt220_resize_sched(buffer->data, count);
+ break;
}
}
@@ -555,12 +606,15 @@ static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
static int
sclp_vt220_open(struct tty_struct *tty, struct file *filp)
{
+ struct winsize ws;
+
if (tty->count == 1) {
+ spin_lock_irq(&sclp_vt220_lock);
+ ws = sclp_vt220_winsize;
+ spin_unlock_irq(&sclp_vt220_lock);
+
tty_port_tty_set(&sclp_vt220_port, tty);
- if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
- tty->winsize.ws_row = 24;
- tty->winsize.ws_col = 80;
- }
+ tty_do_resize(tty, &ws);
}
return 0;
}
@@ -754,6 +808,8 @@ static int __init sclp_vt220_tty_init(void)
rc = tty_register_driver(driver);
if (rc)
goto out_init;
+
+ INIT_WORK(&sclp_vt220_resize_work, sclp_vt220_resize);
rc = sclp_register(&sclp_vt220_register_input);
if (rc)
goto out_reg;
--
2.54.0
prev parent reply other threads:[~2026-09-22 9:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 9:59 [PATCH v2 0/2] s390/sclp: Resize " Maximilian Immanuel Brandtner
2026-09-22 9:59 ` [PATCH v2 1/2] s390/sclp: Introduce dedicated sclp-vt220 event buffer type Maximilian Immanuel Brandtner
2026-09-22 9:59 ` Maximilian Immanuel Brandtner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922095903.1595794-3-maxbr@linux.ibm.com \
--to=maxbr@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=maximilian.immanuel.brandtner@protonmail.com \
--cc=mjrosato@linux.ibm.com \
--cc=oberpar@linux.ibm.com \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®