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 6B9EA2248A4 for ; Thu, 24 Jul 2025 06:41:02 +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=1753339267; cv=none; b=CcNYEdbl8MBlew83pdnud8x0xkk0ujJ3rKsLo9B2mASVwCAD6cflpYXx8qfOtkA/xdVfsME8v8VLlT0AfcDj0NBsJQisyDfEe29j4zf/fNhYsxCBTnqn3yN9/LNZPqP6M9LYbU6izHvNkKz3/79T0GDiYXN5yOu16e8c8mIcIBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753339267; c=relaxed/simple; bh=s+CQBYZNnaJ8oGWROxcoiNNgZmeBC+LHXQTaDibu7js=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=srpwetzKFDoLy+5t/nKUP1XaTKYyDPXt94QQf5IIScLvPk+NBL37MbqLlRUu75WtRwx9S0e3H7GO4wXPKeYofPpkl3ys5gxwmCpBKvfDdmeoPZt3NTU/GgGr2tqZNpI5hM3GiUm9QPm3mpGPfAXHWE53wm5R1hLeG33wKGKq9NQ= 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=fg/Io4x5; 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="fg/Io4x5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753339261; 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=4IWMeoU2L7LbWevh/6kUc/KaIDdl28mkB1hOWnyA09c=; b=fg/Io4x5woVH9SlYf6Pbi4H2jUEXX2ch0ii68XWqnhihgpoXj6ess7lJSYWCpUnex+KEJb bxgZPpIfe0tSrwr/utTnVkCaefMHJ6u+TvWIx9HTLhGZFa8IQjhZR80BRiFpArT38s3YuV fx5wgUlP7I2GpygiWc7j6w81XRW6Hq4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-P_bIubVyMQeDgjpqzI-wwg-1; Thu, 24 Jul 2025 02:40:57 -0400 X-MC-Unique: P_bIubVyMQeDgjpqzI-wwg-1 X-Mimecast-MFC-AGG-ID: P_bIubVyMQeDgjpqzI-wwg_1753339256 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C386180028C; Thu, 24 Jul 2025 06:40:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.231]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C2AC0180035E; Thu, 24 Jul 2025 06:40:52 +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 V4 07/19] virtio: switch to use vring_virtqueue for virtqueue_add variants Date: Thu, 24 Jul 2025 14:40:05 +0800 Message-ID: <20250724064017.26058-8-jasowang@redhat.com> In-Reply-To: <20250724064017.26058-1-jasowang@redhat.com> References: <20250724064017.26058-1-jasowang@redhat.com> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Those variants are used internally so let's switch to use vring_virtqueue as parameter to be consistent with other internal virtqueue helpers. Acked-by: Eugenio Pérez Reviewed-by: Xuan Zhuo Signed-off-by: Jason Wang --- drivers/virtio/virtio_ring.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index b7489d19d8ae..f66ba25a50b1 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -812,11 +812,10 @@ static bool more_used_split(const struct vring_virtqueue *vq) return virtqueue_poll_split(vq, vq->last_used_idx); } -static void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq, +static void *virtqueue_get_buf_ctx_split(struct vring_virtqueue *vq, unsigned int *len, void **ctx) { - struct vring_virtqueue *vq = to_vvq(_vq); void *ret; unsigned int i; u16 last_used; @@ -838,9 +837,9 @@ static void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq, virtio_rmb(vq->weak_barriers); last_used = (vq->last_used_idx & (vq->split.vring.num - 1)); - i = virtio32_to_cpu(_vq->vdev, + i = virtio32_to_cpu(vq->vq.vdev, vq->split.vring.used->ring[last_used].id); - *len = virtio32_to_cpu(_vq->vdev, + *len = virtio32_to_cpu(vq->vq.vdev, vq->split.vring.used->ring[last_used].len); if (unlikely(i >= vq->split.vring.num)) { @@ -862,7 +861,7 @@ static void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq, if (!(vq->split.avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) virtio_store_mb(vq->weak_barriers, &vring_used_event(&vq->split.vring), - cpu_to_virtio16(_vq->vdev, vq->last_used_idx)); + cpu_to_virtio16(vq->vq.vdev, vq->last_used_idx)); LAST_ADD_TIME_INVALID(vq); @@ -1721,11 +1720,10 @@ static bool more_used_packed(const struct vring_virtqueue *vq) return virtqueue_poll_packed(vq, READ_ONCE(vq->last_used_idx)); } -static void *virtqueue_get_buf_ctx_packed(struct virtqueue *_vq, +static void *virtqueue_get_buf_ctx_packed(struct vring_virtqueue *vq, unsigned int *len, void **ctx) { - struct vring_virtqueue *vq = to_vvq(_vq); u16 last_used, id, last_used_idx; bool used_wrap_counter; void *ret; @@ -2525,8 +2523,8 @@ void *virtqueue_get_buf_ctx(struct virtqueue *_vq, unsigned int *len, { struct vring_virtqueue *vq = to_vvq(_vq); - return vq->packed_ring ? virtqueue_get_buf_ctx_packed(_vq, len, ctx) : - virtqueue_get_buf_ctx_split(_vq, len, ctx); + return vq->packed_ring ? virtqueue_get_buf_ctx_packed(vq, len, ctx) : + virtqueue_get_buf_ctx_split(vq, len, ctx); } EXPORT_SYMBOL_GPL(virtqueue_get_buf_ctx); -- 2.39.5