Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp341964rwe; Wed, 31 Aug 2022 23:40:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BAq9oVHfyH9PkkBSIOKm+SL/F8d18GY0YgjLHbRLPQ2/UR4JPPZGyA6EpzJw9dvQQGoQx X-Received: by 2002:a05:6402:27d3:b0:43e:5490:27ca with SMTP id c19-20020a05640227d300b0043e549027camr28309914ede.307.1662014458475; Wed, 31 Aug 2022 23:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662014458; cv=none; d=google.com; s=arc-20160816; b=bjusSx3o54Ge5PJpso+FvubGgVCEYdfsaVW05oiKvtcyAZYwMce8GM7rQ3NcZHdn4d ZgnJmtgg7MRvZ3yMaR8IaIkvCI3HI4o8wdxuJBCiYVlRWAIM7b90q8T1XbwE4A2B/UK4 Srq2xvpCO7cBIHLg99z8KORTQcS8E5vOt2SKz9ZLYlMdlzGvg6/QSD1w8mZqr5B68gwJ 790jNudU1yGrn9cwJ11pBNcTjPN9BO3Si5fEYYbnWTo7V6rPXejjjmUXeJJzsmEB8NOL mGb/oI7Jw32NwUD9H10qVfO706p+fuGQArsUmXsxLFDwPg82LnXnp/rnDohpOgQBb9df 3znQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=3E9bq1mOn1CLGs3PhpInDipzX8qriinFMuBQGeMMcPE=; b=I1Kc04rcapaN1WQLvWb3bGzL731JLUHNSl/EE5ssOi8k/XxOVPGPhmSlVIou1ydHxT CHsMGupXvW181Sz57WnDerI0b5ig2nxTSXlxk40BO8pcqvjjgBrv+YQccn7Dc7W2yhJv HEyKuHiqw7j2Ua/J9rBRa2OpEe1S84oHAxgZpytXuKmrGQ3M+gr5vOIZiuQfcwamQLWL qRYlr/Gx3yYhqDmwNiJdvWGBYwNZgva5PEAX+bDanZMoNzUIDRJvKZdYBXYC9UJZuG5C aCKON0R17aywVeqddSHJ8yAvIdt2z5UwBYKvqDyxwGLqsrCK3/CrDQ+QVovxOvoPgu4O 80hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw34-20020a1709066a2200b0073d847c65fdsi10497218ejc.587.2022.08.31.23.40.31; Wed, 31 Aug 2022 23:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233145AbiIAF4U (ORCPT + 99 others); Thu, 1 Sep 2022 01:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233219AbiIAF4S (ORCPT ); Thu, 1 Sep 2022 01:56:18 -0400 Received: from smtp236.sjtu.edu.cn (smtp236.sjtu.edu.cn [202.120.2.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C33BCC36; Wed, 31 Aug 2022 22:56:15 -0700 (PDT) Received: from proxy02.sjtu.edu.cn (smtp188.sjtu.edu.cn [202.120.2.188]) by smtp236.sjtu.edu.cn (Postfix) with ESMTPS id C83A01008B38F; Thu, 1 Sep 2022 13:55:48 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id B499F2009BEAD; Thu, 1 Sep 2022 13:55:48 +0800 (CST) X-Virus-Scanned: amavisd-new at Received: from proxy02.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy02.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id SIB7hdKllpuC; Thu, 1 Sep 2022 13:55:48 +0800 (CST) Received: from localhost.localdomain (unknown [202.120.40.82]) (Authenticated sender: qtxuning1999@sjtu.edu.cn) by proxy02.sjtu.edu.cn (Postfix) with ESMTPSA id 78BC72009BEB0; Thu, 1 Sep 2022 13:55:36 +0800 (CST) From: Guo Zhi To: eperezma@redhat.com, jasowang@redhat.com, sgarzare@redhat.com, mst@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Guo Zhi Subject: [RFC v3 5/7] virtio: unmask F_NEXT flag in desc_extra Date: Thu, 1 Sep 2022 13:54:32 +0800 Message-Id: <20220901055434.824-6-qtxuning1999@sjtu.edu.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220901055434.824-1-qtxuning1999@sjtu.edu.cn> References: <20220901055434.824-1-qtxuning1999@sjtu.edu.cn> X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We didn't unmask F_NEXT flag in desc_extra in the end of a chain, unmask it so that we can access desc_extra to get next information. Signed-off-by: Guo Zhi --- drivers/virtio/virtio_ring.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index a5ec724c01d8..00aa4b7a49c2 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -567,7 +567,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, } /* Last one doesn't continue. */ desc[prev].flags &= cpu_to_virtio16(_vq->vdev, ~VRING_DESC_F_NEXT); - if (!indirect && vq->use_dma_api) + if (!indirect) vq->split.desc_extra[prev & (vq->split.vring.num - 1)].flags &= ~VRING_DESC_F_NEXT; @@ -584,6 +584,8 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, total_sg * sizeof(struct vring_desc), VRING_DESC_F_INDIRECT, false); + vq->split.desc_extra[head & (vq->split.vring.num - 1)].flags &= + ~VRING_DESC_F_NEXT; } /* We're using some buffers from the free list. */ @@ -685,7 +687,6 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, void **ctx) { unsigned int i, j; - __virtio16 nextflag = cpu_to_virtio16(vq->vq.vdev, VRING_DESC_F_NEXT); /* Clear data ptr. */ vq->split.desc_state[head].data = NULL; @@ -693,7 +694,7 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head, /* Put back on free list: unmap first-level descriptors and find end */ i = head; - while (vq->split.vring.desc[i].flags & nextflag) { + while (vq->split.desc_extra[i].flags & VRING_DESC_F_NEXT) { vring_unmap_one_split(vq, i); i = vq->split.desc_extra[i].next; vq->vq.num_free++; -- 2.17.1