From nobody Sat Oct 4 22:37:52 2025 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 28D2E2D0620 for ; Tue, 12 Aug 2025 23:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755040831; cv=none; b=RdMLSBKzz31QPhfjsnS3Z1SKs2Euj4s4QtMzrsaSGwZVDLlVN6SuX+tAW7IziPfxaAuZV+t9X1EBhrV++bTOvRusHHPvds4JdTdOhgT2dcdkH6dspsmBhQAKRd26YHRCnA3llDee8irKn7k3uW4lfsOZUnLO3CfPJk6tdxHUofY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755040831; c=relaxed/simple; bh=wle9r2gsnhO7JaaLb1bCPkD7qWWf9Zu+D8DM/DNZTjw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: References; b=hNKn86l9Z96+CCGoKM5mH03Sfe7CV+Wyk31pT8Pyhh8eyOfT0poc5wMAKtwI5kXOw+E0d719cMg784o4trGiu0GEMQFixtwOmXLPHuhYeLzPB5o7uUiHUrecI3eGTijwWj++VIka+eDxDWXpeAS98o2xDfI58kNkoWthAca1SgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=X3WmcE+A; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="X3WmcE+A" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20250812232026epoutp029b0d820706846c0903e8adda8d7f2661~bKFUqPaZ02603026030epoutp02z for ; Tue, 12 Aug 2025 23:20:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20250812232026epoutp029b0d820706846c0903e8adda8d7f2661~bKFUqPaZ02603026030epoutp02z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1755040826; bh=eLnMXqyfqg1qktU4SrlD9F/Y1gqGVc8jfzRmVy/nmCI=; h=From:To:Cc:Subject:Date:References:From; b=X3WmcE+ALVT0ddLK6NnAClCAj+pEm8KYoJY3fXeIdyJ7dAfQXdjY9GbL7pO0MTvuH PFO3mfeaEDP7OEHC/oJI2v45xYcDxRqybV1wyK63LXGZEGZm93vdZefwJRNdS46c6/ DM/uK6QBI1sh+zUY96FFUQiDEC4eTSLIoX4hTKLg= Received: from epsnrtp04.localdomain (unknown [182.195.42.156]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPS id 20250812232025epcas5p14d7f42eedf5b2403536eae76232f848d~bKFTxM57n0474904749epcas5p1D; Tue, 12 Aug 2025 23:20:25 +0000 (GMT) Received: from epcas5p4.samsung.com (unknown [182.195.38.92]) by epsnrtp04.localdomain (Postfix) with ESMTP id 4c1nY42bxGz6B9mF; Tue, 12 Aug 2025 23:20:24 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20250812095108epcas5p3aebdbf9e790cd259173d54611652a97b~a-CuL4_aG1911819118epcas5p3b; Tue, 12 Aug 2025 09:51:08 +0000 (GMT) Received: from asg29.. (unknown [109.105.129.29]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250812095107epsmtip14a9258f84c8573280a6948e6f6ea6767~a-Cs27tkY0384203842epsmtip1B; Tue, 12 Aug 2025 09:51:07 +0000 (GMT) From: Ying Gao To: kraxel@redhat.com, mst@redhat.com, jasowang@redhat.com Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, ying123.xu@samsung.com, lei19.wang@samsung.com, liping.qi@samsung.com, junnan01.wu@samsung.com, Ying Gao Subject: [PATCH] virtio_input: Improve freeze handling Date: Tue, 12 Aug 2025 17:51:18 +0800 Message-Id: <20250812095118.3622717-1-ying01.gao@samsung.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMS-MailID: 20250812095108epcas5p3aebdbf9e790cd259173d54611652a97b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P cpgsPolicy: CPGSC10-505,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250812095108epcas5p3aebdbf9e790cd259173d54611652a97b References: When executing suspend to ram, if lacking the operations to reset device and free unused buffers before deleting a vq, resource leaks and inconsistent device status will appear. According to chapter "3.3.1 Driver Requirements: Device Cleanup:" of virtio-specification: Driver MUST ensure a virtqueue isn=E2=80=99t live (by device reset) before removing exposed buffers. Therefore, modify the virtinput_freeze function to reset the device and delete the unused buffers before deleting the virtqueue, just like virtinput_remove does. Co-developed-by: Ying Xu Signed-off-by: Ying Xu Co-developed-by: Junnan Wu Signed-off-by: Junnan Wu Signed-off-by: Ying Gao --- drivers/virtio/virtio_input.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c index a5d63269f20b..d0728285b6ce 100644 --- a/drivers/virtio/virtio_input.c +++ b/drivers/virtio/virtio_input.c @@ -360,11 +360,15 @@ static int virtinput_freeze(struct virtio_device *vde= v) { struct virtio_input *vi =3D vdev->priv; unsigned long flags; + void *buf; =20 spin_lock_irqsave(&vi->lock, flags); vi->ready =3D false; spin_unlock_irqrestore(&vi->lock, flags); =20 + virtio_reset_device(vdev); + while ((buf =3D virtqueue_detach_unused_buf(vi->sts)) !=3D NULL) + kfree(buf); vdev->config->del_vqs(vdev); return 0; } --=20 2.34.1