From nobody Fri Sep 25 16:51:47 2026 Received: from outbound.baidu.com (mx22.baidu.com [220.181.50.185]) by smtp.subspace.kernel.org (Postfix) with SMTP id B773835C69A for ; Thu, 10 Sep 2026 12:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.181.50.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789043977; cv=none; b=reImXBPZEl0JwJU/IrhKCxJhBXEf66rdJANUKKl4ISaEQEHbqnDQYyquYfiPe74Y880bpdMBew/3InqNg5YmhzY99sMsgMiMKb5VDw8IDhOfM8XDJ5oQJlYyIB9sQ20hMbzcyt9ME+IuGq8f5I/dLw7LZEAmyJPAY3xu2DAberM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789043977; c=relaxed/simple; bh=uERe+rPSAVEC5mjAWQyTfYZx4/ngjwuFX0r3iLJVm94=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eMO2npcPdakRdqFmGA6W7qyS0A0nCBY6HuPa3bA/KE0qsw4p/IfADMeSA5wYv9eSSSHh7C/PeyNS+c4redEWmdU8GqJRUgW6FmkvDHKinnPBsVH0RSdYJhIGCo5V33ASHXCueFSCx6NdEbJPEo/E6FkRba7w5kPv854ln7TOUWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; dkim=pass (2048-bit key) header.d=baidu.com header.i=@baidu.com header.b=ZGx34cDC; arc=none smtp.client-ip=220.181.50.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baidu.com header.i=@baidu.com header.b="ZGx34cDC" X-MD-Sfrom: lirongqing@baidu.com X-MD-SrcIP: 172.31.50.47 From: lirongqing To: "Michael S . Tsirkin" , Jason Wang , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Xuan Zhuo , , CC: Li RongQing Subject: [PATCH] virtio_ring: reset IN_ORDER state in virtqueue_init() Date: Thu, 10 Sep 2026 20:39:03 +0800 Message-ID: <20260910123903.1717-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: bjhj-exc11.internal.baidu.com (172.31.3.21) To bjkjy-exc3.internal.baidu.com (172.31.50.47) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baidu.com; s=selector1; t=1789043967; bh=0SgNbr7d64dMOkmaYrpy9GpJle7Mxk78HhOW0m89bLk=; h=From:To:CC:Subject:Date:Message-ID:Content-Type; b=ZGx34cDCOld2IeOQ0O9pe8gMJ48Y46SXIQQvCAhSLcXJn1WbwqDdhEzvH71KPF7EN /av3xS+0h0fyVL3EmKPQfeg1yAq1NdugLem17tK2qFjsrtM8GFE4Lnvo5VpvRJkbVl ErilfH2UUl92wgxs8P+5PRxYEExm8yCDTmLqNzZQguBBZ50Cj3TX7bwTQltlatlTDA HUp4tAabelcYogU/meWkadwt/KZDsPDikuSCuaVmVZz5TWQkuTAOu14Y61he5YCyBg i7s1QvX/fIoZ5powMsr4J76kf98NhnopW+I8YHs6FwORhQ4Z+qhA+Ve9JenT7+U59r CaHPo6JzOFOtg== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li RongQing The IN_ORDER feature uses additional software state to track the next available descriptor and in-flight descriptor batches. virtqueue_init() resets the common virtqueue state, but free_head and batch_last.id are initialized only when the virtqueue is created. When an IN_ORDER virtqueue is reset, these fields can retain state from the previous queue instance. Reset free_head and invalidate batch_last when initializing an IN_ORDER virtqueue. Keep this in virtqueue_init() so the state is initialized consistently for both newly created and reset virtqueues. Fixes: f6a15d854986 ("virtio_ring: add in order support") Signed-off-by: Li RongQing --- drivers/virtio/virtio_ring.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index db678f5..d0dc464 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -559,6 +559,11 @@ static void virtqueue_init(struct vring_virtqueue *vq,= u32 num) vq->in_use =3D false; vq->last_add_time_valid =3D false; #endif + + if (virtqueue_is_in_order(vq)) { + vq->free_head =3D 0; + vq->batch_last.id =3D UINT_MAX; + } } =20 =20 --=20 2.9.4