Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3360820ybl; Sun, 11 Aug 2019 22:06:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqnByjCCbOFa3d4R7zOUM2eEI09/dC0SYgfgc7j4s9pvZTfKY/S/5TmL8AkqHiblZU7sGK X-Received: by 2002:a65:534c:: with SMTP id w12mr28711770pgr.51.1565586400625; Sun, 11 Aug 2019 22:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565586400; cv=none; d=google.com; s=arc-20160816; b=wuNG+aJHhZQT6MdLu3ZvvQUby3PFMJE26VaHJ0Da4X0CGky5svgxaygS2PNEp0UpUL WR1chF6okQy9Ykcl5UGhjZQb7gKNql0s02RCQcSc4qK1tZ+PUy9iye8udc/ecxsPUplw WKWV3CJ31nifKDFLkTf9ScHVOYFYJWBYSvsifSvH91AHGupCK3Yyfw3mZTEu8jw5U0Qu BwrKRvNLXWOAKWU8BlWEr9tMCejRvDk0x1dl2EPPshPWX9Bq1WUg/04RrxR0RfSv8Qzj 06hWnpjM4Nmf9wbblJvx+LsEilnIuO9ijKDHgEFJ5SwWn4tHDDmS5+tdmgfqgIw11pqh K4TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=j2sBsKBHxeDqIKfClreDvcFUXhIO1/8ffTGOlqjfpJI=; b=y/j518pbrAn2rfFV1C3PrKfkPKMrK40uTvf759cHr8TqitpknfvQ7sa3LUtaTqJfaY FvzKR4/Z9/Osie9lT3SRT3V6xJ8qDnjChPqzN6MK6gg/r88eVCc/DqeqsvyOjwCW+8Pe TGzjWjJnidRb/tR7Z9q76HpAd6+Q0h1w0tMVu8HUQl4SbA2vBKNxbmhMx6GP+YEKX42H 9J9bhkMj7z7F6++YcxZgPOhp0ZU+E7m9ZedB5QGKPz3+WGQuAY3TN7Gfh/5+6lesQobT jOMk+4sISDTmfmljqBOi7is+7XogipDAnHh9zuXL9JmsDAV50qVvvazlE+MnZxafvp56 C+tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17si28069315pgn.433.2019.08.11.22.06.25; Sun, 11 Aug 2019 22:06:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfHLFFd (ORCPT + 99 others); Mon, 12 Aug 2019 01:05:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49492 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbfHLFFc (ORCPT ); Mon, 12 Aug 2019 01:05:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F1063B551; Mon, 12 Aug 2019 05:05:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B0E45D6D0; Mon, 12 Aug 2019 05:05:32 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 553374A460; Mon, 12 Aug 2019 05:05:32 +0000 (UTC) Date: Mon, 12 Aug 2019 01:05:31 -0400 (EDT) From: Pankaj Gupta To: "Michael S. Tsirkin" Cc: amit@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, virtualization@lists.linux-foundation.org, jasowang@redhat.com, linux-kernel@vger.kernel.org, xiaohli@redhat.com Message-ID: <904809366.7828013.1565586331773.JavaMail.zimbra@redhat.com> In-Reply-To: <20190810141213-mutt-send-email-mst@kernel.org> References: <20190809064847.28918-1-pagupta@redhat.com> <20190809064847.28918-3-pagupta@redhat.com> <20190810141213-mutt-send-email-mst@kernel.org> Subject: Re: [PATCH v3 2/2] virtio: decrement avail idx with buffer detach for packed ring MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.116.104, 10.4.195.22] Thread-Topic: virtio: decrement avail idx with buffer detach for packed ring Thread-Index: MiSZup5kLcvoPG95SMeU4GQP1njEJA== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 12 Aug 2019 05:05:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Fri, Aug 09, 2019 at 12:18:47PM +0530, Pankaj Gupta wrote: > > This patch decrements 'next_avail_idx' count when detaching a buffer > > from vq for packed ring code. Split ring code already does this in > > virtqueue_detach_unused_buf_split function. This updates the > > 'next_avail_idx' to the previous correct index after an unused buffer > > is detatched from the vq. > > > > Signed-off-by: Pankaj Gupta > > I would make this patch 1, not patch 2, otherwise > patch 1 corrupts the ring. Sure. Will post this patch as patch 1 in next version. Thanks, Pankaj > > > > --- > > drivers/virtio/virtio_ring.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > index c8be1c4f5b55..7c69181113e2 100644 > > --- a/drivers/virtio/virtio_ring.c > > +++ b/drivers/virtio/virtio_ring.c > > @@ -1537,6 +1537,12 @@ static void > > *virtqueue_detach_unused_buf_packed(struct virtqueue *_vq) > > /* detach_buf clears data, so grab it now. */ > > buf = vq->packed.desc_state[i].data; > > detach_buf_packed(vq, i, NULL); > > + vq->packed.next_avail_idx--; > > + if (vq->packed.next_avail_idx < 0) { > > + vq->packed.next_avail_idx = vq->packed.vring.num - 1; > > + vq->packed.avail_wrap_counter ^= 1; > > + } > > + > > END_USE(vq); > > return buf; > > } > > -- > > 2.20.1 >