From nobody Sun Feb 8 23:03:57 2026 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 1967D32D0D2 for ; Wed, 24 Dec 2025 00:34:30 +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=1766536471; cv=none; b=hYu7NJ276QgkDJBOYg1I0gFToNHXklkgz1Rhn+238ZL51ZMVCGJAC9AkgOeY+/ycUnoQ+1oHN595rM4zweLOSpnSaULEfELE9t7bPRNSE4zhBXL++0MeYc6TSkMurcLfDvMsTM2DRDq3mm53nIG+TgiYh+4lylUZT0yaAjXGhp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766536471; c=relaxed/simple; bh=IidT4HZDDvs6ZEb5kVSZWqtC1LWZBEM8NC7SIUve8E0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TWJTrrfBBu28Q2jAUYReTrSeNtwRZ0ZJPRLK6NcmuA7SsDdMp+uyIR/HM8mvB4nFfr6o1YNty+xkLBhcyIjc5iMMudYOhgDWmFVtyL/bDZPD2pOEeeI6uikwWUM2/HIm0ARfncXueJlBmlotiTuF8msfgZzT2ucLdxkdoDHvw3M= 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=abyvsIDV; 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="abyvsIDV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766536469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vcIwy8OI9pAJA1Qm3y/8ZKj5VUk++bUm82Rcjzz2tlw=; b=abyvsIDVxaPFj4nb8hWhlkRtZUJglBBov8ZUNxEoHFna3CzI2UMbZ0wsOm/gnJ1CpFV3Qh 8fpDYWqGckbSWx0r/DtjMKardMbyrg8m8n9IH08gO2ts5rASU7uYxbMJ3JVaMSLjslcp5F 6+unTDhc/b8froeTbtGVRc1JOHyTsUk= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-xXUvfFokM96ulVKLBjZrog-1; Tue, 23 Dec 2025 19:34:27 -0500 X-MC-Unique: xXUvfFokM96ulVKLBjZrog-1 X-Mimecast-MFC-AGG-ID: xXUvfFokM96ulVKLBjZrog_1766536466 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE7831956050; Wed, 24 Dec 2025 00:34:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.39]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF39719560AB; Wed, 24 Dec 2025 00:34:23 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH V10 18/19] virtio_ring: factor out split detaching logic Date: Wed, 24 Dec 2025 08:33:08 +0800 Message-ID: <20251224003309.23432-19-jasowang@redhat.com> In-Reply-To: <20251224003309.23432-1-jasowang@redhat.com> References: <20251224003309.23432-1-jasowang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 This patch factors out the split core detaching logic that could be reused by in order feature into a dedicated function. Acked-by: Eugenio P=C3=A9rez Reviewed-by: Xuan Zhuo Signed-off-by: Jason Wang --- drivers/virtio/virtio_ring.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 5bb9797c6524..61884e031b94 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -806,8 +806,9 @@ static void detach_indirect_split(struct vring_virtqueu= e *vq, vq->split.desc_state[head].indir_desc =3D NULL; } =20 -static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, - void **ctx) +static unsigned detach_buf_split_in_order(struct vring_virtqueue *vq, + unsigned int head, + void **ctx) { struct vring_desc_extra *extra; unsigned int i; @@ -828,8 +829,6 @@ static void detach_buf_split(struct vring_virtqueue *vq= , unsigned int head, } =20 vring_unmap_one_split(vq, &extra[i]); - vq->split.desc_extra[i].next =3D vq->free_head; - vq->free_head =3D head; =20 /* Plus final descriptor */ vq->vq.num_free++; @@ -838,6 +837,17 @@ static void detach_buf_split(struct vring_virtqueue *v= q, unsigned int head, detach_indirect_split(vq, head); else if (ctx) *ctx =3D vq->split.desc_state[head].indir_desc; + + return i; +} + +static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, + void **ctx) +{ + unsigned int i =3D detach_buf_split_in_order(vq, head, ctx); + + vq->split.desc_extra[i].next =3D vq->free_head; + vq->free_head =3D head; } =20 static bool virtqueue_poll_split(const struct vring_virtqueue *vq, --=20 2.31.1