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 33A55381B0C for ; Wed, 10 Jun 2026 07:05:05 +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=1781075107; cv=none; b=oyZyDm6wDySw/JhC00KpolE794EydPmqljLoseMNEQU8FC91tq/j5aQhJW1THkbT+qoWVFCNbO54dBwuZ2yyQfLcupKQxIFDG0o9MIPBTq+O9iqNJjSp+2dMNpvSulyUzvLWwa6ctK3rC/80656HxKko52FvI8sbHLiiaVBhLBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781075107; c=relaxed/simple; bh=ge4IbTXF7lJt7meGHPQpdprqP2LXCoO+5g49xZWAU6Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eIUmE5fc4+kkgyyO8+PDK5CMMW16t/aK2de9cEAgGqSYmthMGuoLazA6p1ThkPRU1368Cx9gAFbyioNCxgwfEYBtfwDkwseO+tWt54HETmp7itey01wxIWhDIpdPjJHkGulS9E2lT7Y66yQnQYuLbJVkKFr2ARJthTZi2caxCdo= 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=Gn3UNicd; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=PbUjzvYK; 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="Gn3UNicd"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="PbUjzvYK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781075105; 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=TzZZUYoa0+tHSBbViTShLqw2qniezPA5sWOCkhRUcwk=; b=Gn3UNicdRzsr/q8ZaD3UurfaM6PV3BJz6ZwX4CGqNCttGDSBWHkOo6WJQ0yLPEd1L8seUk mJEuWwbIf6A9YEDCJ+fgDcuMQXKTWS+MWmTBo3HqCGgzyExPkAXytOZ/obBx8rrMQv0eml wXT3olq8VyNCl4lnzJrdRAiboDyPSeQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-1z83CyJVM8631nVn-V9hFw-1; Wed, 10 Jun 2026 03:05:01 -0400 X-MC-Unique: 1z83CyJVM8631nVn-V9hFw-1 X-Mimecast-MFC-AGG-ID: 1z83CyJVM8631nVn-V9hFw_1781075101 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-45eebc943bfso3436533f8f.0 for ; Wed, 10 Jun 2026 00:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781075100; x=1781679900; 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=TzZZUYoa0+tHSBbViTShLqw2qniezPA5sWOCkhRUcwk=; b=PbUjzvYKwlgLtgUeMiwPOBpMpO9OCR/keOxIYaMgkn8nGArntavUkgzVeBGK+Uo4XG jxb7tOQITaKYX4sporXNsJwiHErnCA/6n2Arr+SAxZ3afnSY5kS3HVniFKq+hxCL44C7 FVJr+Albf8VXhPZ9gLTxObTsYpdvptetY6G/1fljs8sA+bdlgA97ZhTA4hBwUNmySxZ3 9NUtqjsciFYVYAX7AT2tBedmGulvxbrUPHstWT8nogFaXEciH6ehciQ4QIp+tXFa6jqW TTQ/wY4RmersL5P90BMaFvY5I4pwWtGS2ODduXrQzdXKth4fSSBaneWotV4hkZxnr2UG 6ktg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781075100; x=1781679900; 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=TzZZUYoa0+tHSBbViTShLqw2qniezPA5sWOCkhRUcwk=; b=iyIcBYd4GSJVwUXEgL+TOTxMXu9NmexkqoJ/Ou1y1H5GomDzuQUDp8LloaUWd08Zpn 7gvBLrC6/XDU2MKWsAMo5SqN44VFjDXNZ2gWD7Leyam1ZTonmd+2+X13PHvUh6mVQLCT ithcny5qfIkiRLLNcrHFQVCk/kwprsIb7OC7Wn6E74c5cie7hMgRBhS9FKUQ0OrP6O30 jTdJVzv2iBZXK+jlwa0SrRi5XAJeLWZztKiu/lV4qLJ+QSsk08fn4ZkUgxVIbTjXWygz OYZsCORgXrz++6zDDo1UcLebS5/5o56sCf2QSsF0a/J3+UTM4K1jiYnby7rykCa2IOmt /sRw== X-Forwarded-Encrypted: i=1; AFNElJ/oW4rVLR4u8XR9zhJWJonZWJ0DgE+SgrZXFYzeg6jJ3VB+4e72+3PG/LJ9pcGfw1YPhWQxgew/XFjLbP0=@vger.kernel.org X-Gm-Message-State: AOJu0YyKm5yM+eFPqIsK+GBKCFRoZJSLjRm6lgD2lAGriwomNUie1xGo EQNqWf67PcdGLxHWBIMJZDuV8XBppFXm5XDH6ty6BgQtTjqM1JOfH70SfVcDv+QC6Z5YWJzHjIe KWIM9QL0UXiN+JSe+Dibu19jY1g77NFcmYptAMAPkdyxG2IcSq81OnL8VTTSr0kaGJA== X-Gm-Gg: Acq92OG4G4+zDxaCtVYarA3wBOz9r/qHH0ivZy3k3QU7kSRB1tILjOEf1ZhRMchCoXi MTQXKdqZsbsM93K4aZd3sbnTumf1xoCDEcQRmaqn6IeEUAX5e5rMTYCD/z7zIxUS/ke8JIgu9ld SzSjlwJnY671pC7HtWfolticggXtnGLqet5FgyNwB9f59D/Ou+S30c40Gof71QqBzrk4drkKbXE 52Xtfk65iR4iJnddUWhNn1sy9EGusilu/8Bfb+7kkLqpZOvQpbg/kMp1zgJyLJL5MP2ouY6n8Q1 VfZ51RcrHdHEzlmoHQW6J/lAfTmEgwgwMH8CKbulvTioMOmrVJ2A/HBop1HIrBooLPw0Q+JoA9x nHtHWnkTUd5IuqbU6jdTYq0S6eVrCMfv0ri41Prvi1AxJFYEJE6iavA== X-Received: by 2002:a05:6000:4b07:b0:460:11a7:f818 with SMTP id ffacd0b85a97d-46032b81463mr29422298f8f.9.1781075100472; Wed, 10 Jun 2026 00:05:00 -0700 (PDT) X-Received: by 2002:a05:6000:4b07:b0:460:11a7:f818 with SMTP id ffacd0b85a97d-46032b81463mr29422251f8f.9.1781075099941; Wed, 10 Jun 2026 00:04:59 -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-4601f0a43e9sm68805871f8f.0.2026.06.10.00.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 00:04:59 -0700 (PDT) Date: Wed, 10 Jun 2026 03:04:56 -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: <20260610030318-mutt-send-email-mst@kernel.org> References: <20260223-virtio-console-fix-v1-1-0cf08303b428@gmail.com> 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: <20260223-virtio-console-fix-v1-1-0cf08303b428@gmail.com> 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. > + 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