Received: by 10.192.165.156 with SMTP id m28csp1767516imm; Tue, 17 Apr 2018 05:19:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Sjsjin0alO4igZGeWkQFwgSLIFaddGN1wRvsy8B0+Ga6u2EUzrfcZg6IKHoAIEZpnl5+7 X-Received: by 2002:a17:902:362:: with SMTP id 89-v6mr1886257pld.270.1523967546329; Tue, 17 Apr 2018 05:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523967546; cv=none; d=google.com; s=arc-20160816; b=BbZcOstLQ4M9jq/9lbZveQ6gHkZbbZKKEGkYctF3fKIPJ7SKM2k5bGnBy8/wXV1ejP 717XI2hu/d5WUHTrX3e8v0oAfx87Nk6KaB70ZFhIXilWx4ebBIiAfSE5om0X0S39hMxA IGLI2CLwaswGlZja0QbCK4xrX/BifN8BrOZgr5GFUEcZj+zo0oY3wChQqa0WvoOpXj24 FZp9EpkL8An3VxGxtWjWUQBPy2PMXIPf50aFlbj1FpK8HO3dcaukWTBtFXH3AqSIXd84 2irxcKpA1MmshXs4Xz6Ik/VQH9YpKCvX7e1fXcklFmxHTya9Ku9sHBC3NwF0xhZ8PzV5 m1ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=M+CuD0A9d/bLvEbKkKKzyz6A5AWWgQVNqKxtMOphHVc=; b=JPli2F+KjYyBxUmjH1kzgj5KKPJ+scQXugYDzi/xvcyCxVJCImhz9ioQ4rFwYG1PIc sUkS5vggrG72Y4lbKr22BXeKbL9JapjMAYhmN1AvUF9K+U1zjkBA3nCmcxsNOBCNKcFx BBLBTBwO4ChIb9ryUQ8w4ChcPodqUWA4aD6yA5irQgDmjI5Bo/S9D/OFrjfmYac60xbx m8d6kTg7f1Khbi+qWy/RZzVmornMilAX+3v4OA3syS1JMAVWH5fcB84vCkeAQKvMmStz 7o44/YSBfv69kIA0IQowoy/XE/049NpeLrk/Bm1qQTgr0L4QoyjGwyUpPNoC3PXdtZmX 5vUg== 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 w18si5969523pgv.228.2018.04.17.05.18.52; Tue, 17 Apr 2018 05:19:06 -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 S1752989AbeDQMRq (ORCPT + 99 others); Tue, 17 Apr 2018 08:17:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33684 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752580AbeDQMRo (ORCPT ); Tue, 17 Apr 2018 08:17:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 307E3EB6E1; Tue, 17 Apr 2018 12:17:44 +0000 (UTC) Received: from redhat.com (ovpn-122-168.rdu2.redhat.com [10.10.122.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85D767C41; Tue, 17 Apr 2018 12:17:41 +0000 (UTC) Date: Tue, 17 Apr 2018 15:17:41 +0300 From: "Michael S. Tsirkin" To: Tiwei Bie Cc: Jason Wang , wexu@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, jfreimann@redhat.com Subject: Re: [RFC v2] virtio: support packed ring Message-ID: <20180417151654-mutt-send-email-mst@kernel.org> References: <20180401141216.8969-1-tiwei.bie@intel.com> <20180413071529.f4esh654dakodf4f@debian> <8dee7d62-ac0b-54ba-6bec-4bc4a6fb34e9@redhat.com> <20180417025133.7t7exmizgolr565z@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180417025133.7t7exmizgolr565z@debian> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Apr 2018 12:17:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Apr 2018 12:17:44 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 17, 2018 at 10:51:33AM +0800, Tiwei Bie wrote: > On Tue, Apr 17, 2018 at 10:11:58AM +0800, Jason Wang wrote: > > On 2018年04月13日 15:15, Tiwei Bie wrote: > > > On Fri, Apr 13, 2018 at 12:30:24PM +0800, Jason Wang wrote: > > > > On 2018年04月01日 22:12, Tiwei Bie wrote: > [...] > > > > > +static int detach_buf_packed(struct vring_virtqueue *vq, unsigned int head, > > > > > + void **ctx) > > > > > +{ > > > > > + struct vring_packed_desc *desc; > > > > > + unsigned int i, j; > > > > > + > > > > > + /* Clear data ptr. */ > > > > > + vq->desc_state[head].data = NULL; > > > > > + > > > > > + i = head; > > > > > + > > > > > + for (j = 0; j < vq->desc_state[head].num; j++) { > > > > > + desc = &vq->vring_packed.desc[i]; > > > > > + vring_unmap_one_packed(vq, desc); > > > > > + desc->flags = 0x0; > > > > Looks like this is unnecessary. > > > It's safer to zero it. If we don't zero it, after we > > > call virtqueue_detach_unused_buf_packed() which calls > > > this function, the desc is still available to the > > > device. > > > > Well detach_unused_buf_packed() should be called after device is stopped, > > otherwise even if you try to clear, there will still be a window that device > > may use it. > > This is not about whether the device has been stopped or > not. We don't have other places to re-initialize the ring > descriptors and wrap_counter. So they need to be set to > the correct values when doing detach_unused_buf. > > Best regards, > Tiwei Bie find vqs is the time to do it. -- MST