Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp76401ybv; Wed, 5 Feb 2020 01:27:09 -0800 (PST) X-Google-Smtp-Source: APXvYqyhS6ZT1mK5q2VMVMc5xvhjjcPbcqjTWvGBImm5b26g4jHq39RjQ/vtZAy9SG+uHswj/acr X-Received: by 2002:aca:32c3:: with SMTP id y186mr2311811oiy.114.1580894829389; Wed, 05 Feb 2020 01:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580894829; cv=none; d=google.com; s=arc-20160816; b=TLSO9jl+ZCQ7TY2MSsA5CKZzvADKVlRVrTqqkbqpos6KB6XIQE0Z+EnfXsXLANDKSF GJVt+mJC+eitvHY0ou0ovVQQXmdkjOfBFjYFXd5SRldslMB6MoSHbdCHuo13kSne0eao 6dfnLQapCX2sugCyD6aNFRh08rncUO1t/thfU9OJCTYazwz/W3xVCnyBCUueIbsBFjtZ W8dytMRbUBvft43UVXZZGN9vPZGTeLzM0/ECFyyR+DWXlolNzdKTwm+d1aBAefsccwMV QOgFKVZHyzT8aYKD9wpxoA5RI3NZDI5r0vnOhZn77cMFE/Sl32+qhPA6IR8KqWqQNfwF tAsQ== 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:dkim-signature; bh=wSY3Qv6hAFiMJ+ZMELgFgVfUvrY9dNbp0gOuOjqy//g=; b=eIP+FZAlqfwyuHScoglkmyQkHjg9ype13r34akH72kFBC8/72wRN05ZfVDNbr/lOcG L7mUBH+OHval148QfEEBbufiYJs2oEgrPwjJP5m8zPdmaDTmwEtohOMMPfdZpFttWe8W ECis+FZPZYHhJH5gfe/uPykonztrFv5TgPA5ynXFmRwjMesqfEsLXEYyswszwzdoS+de VmaI7VKJhyGVNZCqU9Bv3Mg7J2dWJ28uzN9v84ue/G5N55HTdYPcM1bfCQTqhwRvFwcp uLOjlEXEyYI/ilhHznAdu4BUcTW4xxUn83E244/d3JxwTt6gz88WS9v8dvlEpW5VuqOX JWSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hSirP+bV; 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=pass (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 l20si8168517otr.202.2020.02.05.01.26.57; Wed, 05 Feb 2020 01:27:09 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hSirP+bV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbgBEJYK (ORCPT + 99 others); Wed, 5 Feb 2020 04:24:10 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48456 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728109AbgBEJYK (ORCPT ); Wed, 5 Feb 2020 04:24:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580894649; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wSY3Qv6hAFiMJ+ZMELgFgVfUvrY9dNbp0gOuOjqy//g=; b=hSirP+bVQkqSokdGvewOsk95JplBC4SRu9CJ9kQaZUoLvSga6J5XFC8kNLkuRHAbcm2qqV RkaXm1QHYTmYjEplMBJSSgzkuSBp+kgaHW7C8AakIJ0Xi384azgiHm+MtZr8cgI//uTCwk WmXsSArc+c3iKVtLVlZM5BkUkT66N90= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-T15rbXrFMJS1oeO6Qp6NwA-1; Wed, 05 Feb 2020 04:24:07 -0500 X-MC-Unique: T15rbXrFMJS1oeO6Qp6NwA-1 Received: by mail-qv1-f71.google.com with SMTP id j15so1075390qvp.21 for ; Wed, 05 Feb 2020 01:24:07 -0800 (PST) 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:content-transfer-encoding :in-reply-to; bh=wSY3Qv6hAFiMJ+ZMELgFgVfUvrY9dNbp0gOuOjqy//g=; b=EBdiDRgt8OLPE2GA899zUQgzAmNZUCRZur+kfweMc2cWAaia3DkEOOHJayccHBzbUa epJc4mzaz+QGQzAx1Mn1NRJGqkLfC0haL+gsAbGZRcRzihErsLrWTxv2fzgoZRMq3UjA kvNfFQWY9rsmIcB/oxxqG1o2Y7Y6mxQAq0aZNyCOdzaM8sdtPcO/Gf1xu4HvFMkcKzP3 6bsOHAaYYsz1ok/m41WwgqXm7Er7DAqppiWU3WZoh2nvckicwJXdEv6WiwzVudAxTyTp cfjC+NOy2CaNuDF0KHPTWNvhDJ4qPnXVgVZ5PoaVQtCMCMAMrYHESdH7MGcCjuVZVXk3 ts+Q== X-Gm-Message-State: APjAAAWrfGpVF9OrL6FiJmu7ndMR24Cwt8ltm/+kAXxMGzLTfM6abt0h CHFJ70bgYXRRuTNl+ty1e0HajH0356P22CoM4JxIO5dU5tlYQU1Zs9NNupCsQMbITCpDj374QuU yFlTMgQJ2xMRmlELyeoYM/OgG X-Received: by 2002:ac8:5353:: with SMTP id d19mr31605207qto.313.1580894647316; Wed, 05 Feb 2020 01:24:07 -0800 (PST) X-Received: by 2002:ac8:5353:: with SMTP id d19mr31605178qto.313.1580894647051; Wed, 05 Feb 2020 01:24:07 -0800 (PST) Received: from redhat.com (bzq-79-176-41-183.red.bezeqint.net. [79.176.41.183]) by smtp.gmail.com with ESMTPSA id e130sm12534407qkb.72.2020.02.05.01.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 01:24:06 -0800 (PST) Date: Wed, 5 Feb 2020 04:23:59 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Shahaf Shuler , Tiwei Bie , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , Jason Gunthorpe , "rob.miller@broadcom.com" , "haotian.wang@sifive.com" , "eperezma@redhat.com" , "lulu@redhat.com" , Parav Pandit , "rdunlap@infradead.org" , "hch@infradead.org" , Jiri Pirko , "hanand@xilinx.com" , "mhabets@solarflare.com" , "maxime.coquelin@redhat.com" , "lingshan.zhu@intel.com" , "dan.daly@intel.com" , "cunming.liang@intel.com" , "zhihong.wang@intel.com" Subject: Re: [PATCH] vhost: introduce vDPA based backend Message-ID: <20200205042259-mutt-send-email-mst@kernel.org> References: <20200131033651.103534-1-tiwei.bie@intel.com> <7aab2892-bb19-a06a-a6d3-9c28bc4c3400@redhat.com> <20200205020247.GA368700@___> <112858a4-1a01-f4d7-e41a-1afaaa1cad45@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <112858a4-1a01-f4d7-e41a-1afaaa1cad45@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 05, 2020 at 03:50:14PM +0800, Jason Wang wrote: > > On 2020/2/5 下午3:15, Shahaf Shuler wrote: > > Wednesday, February 5, 2020 4:03 AM, Tiwei Bie: > > > Subject: Re: [PATCH] vhost: introduce vDPA based backend > > > > > > On Tue, Feb 04, 2020 at 11:30:11AM +0800, Jason Wang wrote: > > > > On 2020/1/31 上午11:36, Tiwei Bie wrote: > > > > > This patch introduces a vDPA based vhost backend. This backend is > > > > > built on top of the same interface defined in virtio-vDPA and > > > > > provides a generic vhost interface for userspace to accelerate the > > > > > virtio devices in guest. > > > > > > > > > > This backend is implemented as a vDPA device driver on top of the > > > > > same ops used in virtio-vDPA. It will create char device entry named > > > > > vhost-vdpa/$vdpa_device_index for userspace to use. Userspace can > > > > > use vhost ioctls on top of this char device to setup the backend. > > > > > > > > > > Signed-off-by: Tiwei Bie > > [...] > > > > > > > +static long vhost_vdpa_do_dma_mapping(struct vhost_vdpa *v) { > > > > > + /* TODO: fix this */ > > > > > > > > Before trying to do this it looks to me we need the following during > > > > the probe > > > > > > > > 1) if set_map() is not supported by the vDPA device probe the IOMMU > > > > that is supported by the vDPA device > > > > 2) allocate IOMMU domain > > > > > > > > And then: > > > > > > > > 3) pin pages through GUP and do proper accounting > > > > 4) store GPA->HPA mapping in the umem > > > > 5) generate diffs of memory table and using IOMMU API to setup the dma > > > > mapping in this method > > > > > > > > For 1), I'm not sure parent is sufficient for to doing this or need to > > > > introduce new API like iommu_device in mdev. > > > Agree. We may also need to introduce something like the iommu_device. > > > > > Would it be better for the map/umnap logic to happen inside each device ? > > Devices that needs the IOMMU will call iommu APIs from inside the driver callback. > > > Technically, this can work. But if it can be done by vhost-vpda it will make > the vDPA driver more compact and easier to be implemented. > > > > Devices that has other ways to do the DMA mapping will call the proprietary APIs. > > > To confirm, do you prefer: > > 1) map/unmap > > or > > 2) pass all maps at one time? > > Thanks > > I mean we really already have both right? ATM 1 is used with an iommu and 2 without. I guess we can also have drivers ask for either or both ... -- MST