From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A989368D49 for ; Thu, 11 Jun 2026 07:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781163527; cv=none; b=fWi68uHBH7rjNua0cqN6uKVArnh6cMpBgqwts5+11g+DFJLeJW5cKxTJtdom61BIATbk9GNm2CejaejTZ1M7dDalh45JIg5hE8nCODvJWw/Nho30+CUDcR1EYKgpscX1BFyVIT7q7vLCp9WG0HW/rq0RFTfCR0XbRm05VA2zSKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781163527; c=relaxed/simple; bh=dMsWjHb6aAJItRl535L6hOIGhAdKxck1LCp2PQr9fQM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j2CDjIG5KqvdgYad/jgsJs1rZQZlD8/y9bUeVDAPjj4tev8Tt/kIfKhcFUwCjfaMM+tWI/cBN9EMX5gJqGC7G1ALnvn8er21dwjOWr2Ig7qAO/tN225kp1bm0qSd+ssr6ZgkmrLcYjeJaN3SOlXvVvkKkuwpskBD7QwqZytpJqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aN4/iR/s; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=et23Ys+Z; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aN4/iR/s"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="et23Ys+Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781163525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x3kwt3xhLgRIYCqA/0pE+1oYC80jUr6ZU3WTeNTnVpM=; b=aN4/iR/szqEcXrDEdMPKp3v3k6fmSn58XhTRuuQBBNgM/kTDakPvWF4I7JRjboB7MyuU+n nYQZJk/Coa0R4oUhPzBRjaBqo5iDtXRVKY6TlLcGQtAAQLdusyL61IvOU/vMhTR8jAyAHO GJaF1jC1/C5mfrUzqfll7XduToq6Tk4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-0pBhoef3P1aLs4KyeEBDkQ-1; Thu, 11 Jun 2026 03:38:43 -0400 X-MC-Unique: 0pBhoef3P1aLs4KyeEBDkQ-1 X-Mimecast-MFC-AGG-ID: 0pBhoef3P1aLs4KyeEBDkQ_1781163522 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490b7959b9fso75692345e9.2 for ; Thu, 11 Jun 2026 00:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781163522; x=1781768322; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x3kwt3xhLgRIYCqA/0pE+1oYC80jUr6ZU3WTeNTnVpM=; b=et23Ys+ZmdREhbhrcir2hNFSI6wAjBFrEqyeE5OyQNdAl9ON57EnbqMfNqdCo0PUlq ctzpEAuXMg5Bc0O4t421TMAno1pBWs0mPOBiMVrzl6nvtSexkLwUlHap4uOvdCE7WWHu 42kx8Y6MRiAny/NW/n8suCAKEUGoilttD62mR/RhtLG1XrmxqxGAINl+0pAKDJLiqKru nbRV24naQvPAwR7OKYxYgfvqZ21VpFZjVgl8LLOxeS5h8Uvfmh41d+gKWldiMLlECxO1 v1cxxN4vU48F3e62F9IlPRpsfCzoKLa4sXoLI4MiwNZb82IdK1rsqUPgZFovv+aAKv97 baog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781163522; x=1781768322; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x3kwt3xhLgRIYCqA/0pE+1oYC80jUr6ZU3WTeNTnVpM=; b=qnp5SlYiPhj3QUf0bTZunJJXq0RMTXA1bHgEFB95cGQYwIFifkAJrkk6afP7CEI1w7 IrTJBFz8nZSiDezbQpBOz7NwOwoeS1eTO1oSfb2oY1FUlSi8WyBTP2q2Axxma3Uea8Hp A7VxTV1QNWnEylHcUmyLuTM2LVFdlnntljj8hZezZCALZcb2PlTJE18iZ21a++hwP9f+ mbEnVECCS3qG/hv6napwI2NeUqEc/QHXncG9nhGH5xyM2r6OG1aXA8XvbF3tZlFkwuiI XbaBXEfvRCfCJCiN8ZhElIIYMDNPB5tAK+GHAkh9TQcSPWloU5jMcoIJZO4cSZ213GFC FUhA== X-Forwarded-Encrypted: i=1; AFNElJ9brrfe0vIJWZ8IRr9uN4ng6JWIr6jIR0PMvCZ6UaAwmxaKR4e4pIvg5SI3ZiloYcyOpjCRfIwt2SGP4DE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5k80N7HaPP32p1+I8muK2ZGmP5fyRBa1L77xvxhD1llIBIOuB +/GjDh2XjXiueZmLZRJ8iQIlvdqvP4/daoL7VK/qdJ6NbaXC850KoA6PR6lzZ5XOtHQM8SOzE3N NRX1ZxbGE3c3BUZSQ3Swwrb0DFDBRhu5r0IaAcTnXZ4oeMdaXbaMVTGIdre8hWq2pYA== X-Gm-Gg: Acq92OHFUTE3ZIXAa89/5uRepvgL+VYIq7XO6eqBf2Nuxdz7D1qshkMHS1xajT/3cgl st/hT5EE7Q7tUvmR6TLU265UwlyFvTwzblriyBT8sfgSHkyCc/ChcPc1Qz07Uxp9dEW3qfwcctW g/lRcjsZv5vo8f/bPsthezaSvPnEKFUJZfegGtGtQns8x4Wovqe866ZUycfVapTayQxPUHqpauh sDD0jd7QazcDZjRfKkml5+l1GO4zATwpIqyos3QMUQErhPwdixFsLNmjQ6VttoYmSm+v0CBwos9 9HiWR4qnji6phINWBb3hqwQGX0JGWsVp6mgOjYI7SpCDLXUe+ZdQRjirdfni3mhtkYa/QYhiHYe AO+9+3P2INO54qiw69nyvyha39b0YuffhGDSRTdkm3ndwzfbOIxIGJA== X-Received: by 2002:a05:600c:4453:b0:490:cb90:3e00 with SMTP id 5b1f17b1804b1-490e55fbd7fmr18677465e9.14.1781163522293; Thu, 11 Jun 2026 00:38:42 -0700 (PDT) X-Received: by 2002:a05:600c:4453:b0:490:cb90:3e00 with SMTP id 5b1f17b1804b1-490e55fbd7fmr18677045e9.14.1781163521767; Thu, 11 Jun 2026 00:38:41 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f35fb24sm84547530f8f.34.2026.06.11.00.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 00:38:41 -0700 (PDT) Date: Thu, 11 Jun 2026 03:38:38 -0400 From: "Michael S. Tsirkin" To: Filip Hejsek Cc: Amit Shah , Arnd Bergmann , Greg Kroah-Hartman , Rusty Russell , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] virtio_console: read size from config space during device init Message-ID: <20260611033747-mutt-send-email-mst@kernel.org> References: <20260223-virtio-console-fix-v1-1-0cf08303b428@gmail.com> <20260610030318-mutt-send-email-mst@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 11, 2026 at 08:57:57AM +0200, Filip Hejsek wrote: > On Wed, 2026-06-10 at 03:04 -0400, Michael S. Tsirkin wrote: > > On Mon, Feb 23, 2026 at 06:37:02PM +0100, Filip Hejsek wrote: > > > Previously, the size was only read upon receiving the config interrupt. > > > This interrupt is sent when the size changes. However, we also need to > > > read the initial size. > > > > > > Also make sure to only read the size from config if F_SIZE is enabled. > > > > > > Fixes: 9778829cffd4 ("virtio: console: Store each console's size in the console structure") > > > Signed-off-by: Filip Hejsek > > > --- > > > This is a resend of [1], which hasn't received any response. > > > > > > I found this bug while developing patches for QEMU that add virtio > > > console resize support. If you want to test this, you can get my QEMU > > > patches from [2]. You will need to disable multiport > > > using `-device virtio-serial,max_ports=1`. > > > > > > [1]: https://lore.kernel.org/all/20251224-virtio-console-fix-v1-1-69d0349692dc@gmail.com/ > > > [2]: https://lore.kernel.org/all/20250921-console-resize-v5-0-89e3c6727060@gmail.com/ > > > > > > I'll also repeat my questions from the previous submission here. These are > > > things that confused me when I was trying to understand the surrounding code, > > > but should in no way prevent merging this patch. > > > > > > - Why does use_multiport use __virtio_test_bit instead of > > > virtio_has_feature? > > > > > > - The VIRTIO_CONSOLE_RESIZE handler sets irq_requested to 1, which I > > > think makes no sense? > > > --- > > > drivers/char/virtio_console.c | 52 ++++++++++++++++++++++++++----------------- > > > 1 file changed, 31 insertions(+), 21 deletions(-) > > > > > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > > > index 088182e54d..c355f6d392 100644 > > > --- a/drivers/char/virtio_console.c > > > +++ b/drivers/char/virtio_console.c > > > @@ -1771,32 +1771,40 @@ static void config_intr(struct virtio_device *vdev) > > > schedule_work(&portdev->config_work); > > > } > > > > > > -static void config_work_handler(struct work_struct *work) > > > +static void update_size_from_config(struct ports_device *portdev) > > > { > > > - struct ports_device *portdev; > > > + struct virtio_device *vdev; > > > + struct port *port; > > > + u16 rows, cols; > > > > > > - portdev = container_of(work, struct ports_device, config_work); > > > - if (!use_multiport(portdev)) { > > > - struct virtio_device *vdev; > > > - struct port *port; > > > - u16 rows, cols; > > > + vdev = portdev->vdev; > > > > > > - vdev = portdev->vdev; > > > - virtio_cread(vdev, struct virtio_console_config, cols, &cols); > > > - virtio_cread(vdev, struct virtio_console_config, rows, &rows); > > > + /* > > > + * We'll use this way of resizing only for legacy support. > > > + * For multiport devices, use control messages to indicate > > > + * console size changes so that it can be done per-port. > > > + * > > > + * Don't test F_SIZE at all if we're rproc: not a valid feature. > > > + */ > > > + if (is_rproc_serial(vdev) || > > > > Wait a second. Why is there this rproc test here? > > Was not in the original code and commit log says nothing about it. > > > > Previously, this code was in config_work_handler(), which was never > called for rproc_serial (it's scheduled from config_intr(), which is > the config_changed handler only for virtio_console). > > Now update_size_from_config() is called unconditionally from > virtcons_probe(), so it will be called for rproc_serial too, which > doesn't have the F_SIZE feature. So why not test it? What does "not a valid feature" mean? I dislike transport code leaking into devices. > > > > > + use_multiport(portdev) || > > > + !virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) > > > + return; > > > > > > - port = find_port_by_id(portdev, 0); > > > - set_console_size(port, rows, cols); > > > + virtio_cread(vdev, struct virtio_console_config, cols, &cols); > > > + virtio_cread(vdev, struct virtio_console_config, rows, &rows); > > > > > > - /* > > > - * We'll use this way of resizing only for legacy > > > - * support. For newer userspace > > > - * (VIRTIO_CONSOLE_F_MULTPORT+), use control messages > > > - * to indicate console size changes so that it can be > > > - * done per-port. > > > - */ > > > - resize_console(port); > > > - } > > > + port = find_port_by_id(portdev, 0); > > > + set_console_size(port, rows, cols); > > > + resize_console(port); > > > +} > > > + > > > +static void config_work_handler(struct work_struct *work) > > > +{ > > > + struct ports_device *portdev; > > > + > > > + portdev = container_of(work, struct ports_device, config_work); > > > + update_size_from_config(portdev); > > > } > > > > > > static int init_vqs(struct ports_device *portdev) > > > @@ -2054,6 +2062,8 @@ static int virtcons_probe(struct virtio_device *vdev) > > > __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, > > > VIRTIO_CONSOLE_DEVICE_READY, 1); > > > > > > + update_size_from_config(portdev); > > > + > > > return 0; > > > > > > free_chrdev: > > > > > > --- > > > base-commit: b927546677c876e26eba308550207c2ddf812a43 > > > change-id: 20251224-virtio-console-fix-3d46980ef569 > > > > > > Best regards, > > > -- > > > Filip Hejsek