From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8038C433E0 for ; Wed, 23 Dec 2020 08:37:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B75B22257 for ; Wed, 23 Dec 2020 08:37:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B75B22257 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B86588D0021; Wed, 23 Dec 2020 03:37:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B76258D0022; Wed, 23 Dec 2020 03:37:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C7F98D0021; Wed, 23 Dec 2020 03:37:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id 86DF08D0015 for ; Wed, 23 Dec 2020 03:37:08 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4EA89181AEF21 for ; Wed, 23 Dec 2020 08:37:08 +0000 (UTC) X-FDA: 77623892136.23.art19_060a80827467 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 3395137604 for ; Wed, 23 Dec 2020 08:37:08 +0000 (UTC) X-HE-Tag: art19_060a80827467 X-Filterd-Recvd-Size: 5199 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Dec 2020 08:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608712627; 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=3qFyz9h7VZheiEP40gklGEtshCv6pLXIEhugrg/rlew=; b=PgjnKbMzr6w9Os/BUJwa+Ro0NSx7tVlMRp1O2+VmmjeGP48hWB7S2fPw8zFPrp5pFBkrCT qQ6THfDhutKlsTfkFXTJN/miVx4vTHcIZjMsIX8Gk6MFGv4HjkXFyh7tCqFJ2pbAo4GwqZ pnqo/i+AeBP/brfgRRRbPwEqbiUWzbU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-Pbr5_DBoMqGoFC2SlLc90Q-1; Wed, 23 Dec 2020 03:37:02 -0500 X-MC-Unique: Pbr5_DBoMqGoFC2SlLc90Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 893CD180A096; Wed, 23 Dec 2020 08:37:00 +0000 (UTC) Received: from [10.72.12.54] (ovpn-12-54.pek2.redhat.com [10.72.12.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCDED60C6A; Wed, 23 Dec 2020 08:36:48 +0000 (UTC) Subject: Re: [RFC v2 08/13] vdpa: Introduce process_iotlb_msg() in vdpa_config_ops To: Xie Yongji , mst@redhat.com, stefanha@redhat.com, sgarzare@redhat.com, parav@nvidia.com, akpm@linux-foundation.org, rdunlap@infradead.org, willy@infradead.org, viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org, corbet@lwn.net Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20201222145221.711-1-xieyongji@bytedance.com> <20201222145221.711-9-xieyongji@bytedance.com> From: Jason Wang Message-ID: <5b36bc51-1e19-2b59-6287-66aed435c8ed@redhat.com> Date: Wed, 23 Dec 2020 16:36:47 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201222145221.711-9-xieyongji@bytedance.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2020/12/22 =E4=B8=8B=E5=8D=8810:52, Xie Yongji wrote: > This patch introduces a new method in the vdpa_config_ops to > support processing the raw vhost memory mapping message in the > vDPA device driver. > > Signed-off-by: Xie Yongji > --- > drivers/vhost/vdpa.c | 5 ++++- > include/linux/vdpa.h | 7 +++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 448be7875b6d..ccbb391e38be 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -728,6 +728,9 @@ static int vhost_vdpa_process_iotlb_msg(struct vhos= t_dev *dev, > if (r) > return r; > =20 > + if (ops->process_iotlb_msg) > + return ops->process_iotlb_msg(vdpa, msg); > + > switch (msg->type) { > case VHOST_IOTLB_UPDATE: > r =3D vhost_vdpa_process_iotlb_update(v, msg); > @@ -770,7 +773,7 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdp= a *v) > int ret; > =20 > /* Device want to do DMA by itself */ > - if (ops->set_map || ops->dma_map) > + if (ops->set_map || ops->dma_map || ops->process_iotlb_msg) > return 0; > =20 > bus =3D dma_dev->bus; > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > index 656fe264234e..7bccedf22f4b 100644 > --- a/include/linux/vdpa.h > +++ b/include/linux/vdpa.h > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > #include > #include > =20 > @@ -172,6 +173,10 @@ struct vdpa_iova_range { > * @vdev: vdpa device > * Returns the iova range supported by > * the device. > + * @process_iotlb_msg: Process vhost memory mapping message (optional= ) > + * Only used for VDUSE device now > + * @vdev: vdpa device > + * @msg: vhost memory mapping message > * @set_map: Set device memory mapping (optional) > * Needed for device that using device > * specific DMA translation (on-chip IOMMU) > @@ -240,6 +245,8 @@ struct vdpa_config_ops { > struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev); > =20 > /* DMA ops */ > + int (*process_iotlb_msg)(struct vdpa_device *vdev, > + struct vhost_iotlb_msg *msg); > int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb); > int (*dma_map)(struct vdpa_device *vdev, u64 iova, u64 size, > u64 pa, u32 perm); Is there any reason that it can't be done via dma_map/dma_unmap or set_ma= p? Thanks