Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4347126pxv; Tue, 20 Jul 2021 01:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuSSwAinMsyzmB0rRvk5sadijgyBeT4nWiSqToWW390WL3VTu5bccjzguVvgc/82NkSiGA X-Received: by 2002:a17:906:8313:: with SMTP id j19mr32201422ejx.548.1626769074934; Tue, 20 Jul 2021 01:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626769074; cv=none; d=google.com; s=arc-20160816; b=EpvZ7uAHV+7QvFmCd62tIDdVr+gBj+DcaktETg/C9dq0uDisgKH6Lrym/wUvSMWRdv 4gw6orfhmBWmKrC+yBcBNOcyjoSskqA0MjDIVx5wfNvtA8Gyl1/tbe+wkRkKPm+XQNSS c+YrmKQt4pBAz8vqM8gZcwIjnCw/isAfp7uNv/qP8Y4cNuxKG93gvHZYR+oyMsge+5KP fJP+lO3RzNfYS7ZNY6Xiskz7pWBEyX2729xMfgvNTZGMifXk9mHQE8zwPGX+ngqV4x+7 pVqByE77kgxRt8oMNob7xBe6w0BupgHWWYg4W+hYbY9Q6RqES4qz4ycIfgGdZbDUlMrB QpMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iR1FfPEi/dSZlfY2U/ypFz4NVPRyvseiKT4LAhvExgQ=; b=soX2Qkd+0MgdKHztqhnLC/4U68ktAHDKF3GxkP1KNuBCw2i1iJkO7YQ2wl4x5CD5wD KArxpNunn5llN9wKg1izyCwlK1e+AXkhQ+0vLN8zYlQkBM2aVQtkvDDU/xiVPJANZGVM C+SXOwZSDmo3WFXkl0hEzabX+tEwX1ppAR/83aUCQH2tUF+MWEP3QdFYE9zBr6ZwmvmM saQyg7C7NgVCJ4yXKacX8dTC/YIEYUBb4TomAZYe98thglF8QvUZLUhzAHk+EG0xDAWk z1GdadCFmIVhcbcjsyZo3aNFbg4DVcQDvBp06NjhNzKhAhNzwiaOmQl9F8qEYthJinmO cl+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XO6S2pWn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si28599208eje.21.2021.07.20.01.17.30; Tue, 20 Jul 2021 01:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XO6S2pWn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232461AbhGTHev (ORCPT + 99 others); Tue, 20 Jul 2021 03:34:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56284 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234146AbhGTHcy (ORCPT ); Tue, 20 Jul 2021 03:32:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626768812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iR1FfPEi/dSZlfY2U/ypFz4NVPRyvseiKT4LAhvExgQ=; b=XO6S2pWnV11SZ6rNBRq3ZM2q5YJrIbK3E99jQ9SrkJmPZWOMgNZARt+qwOArnTxtzP9aUA X73Cc4iODam6yn6TJ1q3F4yulFmomKgSgMMCK1O7imsStgGvutwpwcICpiSTaBaZg4nlD0 7ndU41E5Sype8MdossjJfi1DkpTitHI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-559-TT8mmK7UPDKLPhbgWUoS_g-1; Tue, 20 Jul 2021 04:13:31 -0400 X-MC-Unique: TT8mmK7UPDKLPhbgWUoS_g-1 Received: by mail-ed1-f72.google.com with SMTP id g23-20020aa7c8570000b02903954c05c938so4921676edt.3 for ; Tue, 20 Jul 2021 01:13:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iR1FfPEi/dSZlfY2U/ypFz4NVPRyvseiKT4LAhvExgQ=; b=EKLmTtxfg4ZwpFmc2I4T3NC6T3rLy4HRjFToNSHDUmpHiTmD08xO4z7dyIXPgLYXTP CXfZsqGnrob1qu4ypYaC8vhxk+DAGIAQJDuUSNV5P0kaeBBUK2yR32KoaIf2+Gyta3ra KeFFqBUsDeD/ed8HaS5san2PFnkoKukqFyW472+qM1ovaEBfkJgWU+pGOpxQM05nP+eW y1NQT76t/tKwlfuiFC9bEeBHFp1rjJRNaSX9rFuBlybF4EBwA6t4NTvrI+7FypyvsEQN rqjdK3r0zCvX+XU2sJ84tcS+sy1gbkJDSIMpUfrZ4CMTWG2J1GECb29C5vCyFAlw/9qP ItLQ== X-Gm-Message-State: AOAM533wIqOs2Z8GF4TRglF3Zqf1VN2W6NckkJk0nATprvut6HU8hsz3 2nY0//p8a2zG3c/SQUOcS8NsVb/L9DTFLm0IM0TXMC7R7xU1ZQO1KWz54qDZRz0mERNB2Ujbe1z s4ZbmJrH3pjnzEckVAqv10Sok X-Received: by 2002:aa7:d8c6:: with SMTP id k6mr39516672eds.374.1626768810120; Tue, 20 Jul 2021 01:13:30 -0700 (PDT) X-Received: by 2002:aa7:d8c6:: with SMTP id k6mr39516657eds.374.1626768809987; Tue, 20 Jul 2021 01:13:29 -0700 (PDT) Received: from steredhat (host-79-18-148-79.retail.telecomitalia.it. [79.18.148.79]) by smtp.gmail.com with ESMTPSA id jw8sm6767787ejc.60.2021.07.20.01.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 01:13:29 -0700 (PDT) Date: Tue, 20 Jul 2021 10:13:27 +0200 From: Stefano Garzarella To: Eli Cohen Cc: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] vdpa/vdpa_sim: Use the negotiated features when calling vringh_init_iotlb Message-ID: <20210720081327.6govoz2jjb6osxjt@steredhat> References: <20210720052533.415991-1-elic@nvidia.com> <20210720065740.56udn3ndebzvu26o@steredhat> <20210720071435.GA4647@mtl-vdi-166.wap.labs.mlnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210720071435.GA4647@mtl-vdi-166.wap.labs.mlnx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 10:14:35AM +0300, Eli Cohen wrote: >On Tue, Jul 20, 2021 at 08:57:40AM +0200, Stefano Garzarella wrote: >> On Tue, Jul 20, 2021 at 08:25:33AM +0300, Eli Cohen wrote: >> > When calling vringh_init_iotlb(), use the negotiated features which >> > might be different than the supported features. >> > >> > Fixes: 2c53d0f64c06f ("vdpasim: vDPA device simulator") >> > Signed-off-by: Eli Cohen >> > --- >> > v0 --> v1: >> > Update "Fixes" line >> > >> > drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c >> > index 14e024de5cbf..89a474c7a096 100644 >> > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c >> > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c >> > @@ -66,7 +66,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) >> > { >> > struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; >> > >> > - vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, >> > + vringh_init_iotlb(&vq->vring, vdpasim->features, >> > VDPASIM_QUEUE_MAX, false, >> > (struct vring_desc *)(uintptr_t)vq->desc_addr, >> > (struct vring_avail *) >> > @@ -86,7 +86,7 @@ static void vdpasim_vq_reset(struct vdpasim *vdpasim, >> > vq->device_addr = 0; >> > vq->cb = NULL; >> > vq->private = NULL; >> > - vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, >> > + vringh_init_iotlb(&vq->vring, vdpasim->features, >> >> vdpasim_vq_reset() is called while resetting the device in vdpasim_reset() >> where we also set `vdpasim->features = 0` after resetting the vqs, so maybe >> it's better to use the supported features here, since the negotiated ones >> are related to the previous instance. >> > >I don't think using supported features is valid. Better to make sure >vringh_init_iotlb() is called after the features have been negotiated. > I think the vringh_init_iotlb() call in vdpasim_vq_reset() is just used to clean up the `struct vringh`, then it will be initialized in vdpasim_queue_ready() when features have already been negotiated. Maybe here we can pass 0 (to the features parameter) if we don't want to use the features supported by the device. Thanks, Stefano