From patchwork Tue Aug 31 10:36:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 12466933 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 401E7C432BE for ; Tue, 31 Aug 2021 10:38:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A5B5601FD for ; Tue, 31 Aug 2021 10:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241247AbhHaKjE (ORCPT ); Tue, 31 Aug 2021 06:39:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241142AbhHaKic (ORCPT ); Tue, 31 Aug 2021 06:38:32 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D9BC061224 for ; Tue, 31 Aug 2021 03:37:33 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id z24-20020a17090acb1800b0018e87a24300so2082350pjt.0 for ; Tue, 31 Aug 2021 03:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=diFMdOjfYo6h4zJjyD4SVBR9esxDRufQId7nejSxKj0=; b=h/0vQB1GQ5kCRkKA+OKeKWhYBViHtuUvCnDIgNlp3Rl1rK6gid4kz1WccCKDBoyppj nW8iePM5yv+Le+/mKooLhC75EaJWOeyGbdeeejX6i8j0kFJLr8P11dLVYAJS29EOijwq 7oq8gwD92Ky30Bn9F7GqEmNccFC68IXFEzEbIlQPOGqg20omqhEU+tdYqjMHWpcUwPE0 ptTwep5fbN1B1d4sDCTnnJc34eUZ+aL+51grrhSIeYTmMySTVFU/QH3wKSeBK6GvLP7n vLt+76oCyeThSoaZ0WdNfB79ieaTNYUiDGYPlWdHhEvJNOqc25YMU+LnSJMEdvvfROki ClAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=diFMdOjfYo6h4zJjyD4SVBR9esxDRufQId7nejSxKj0=; b=cmRF4WFNtmjl6M73CsTbwV5Uvqjt2twgyLuuHnUcVx4y0BAgYenFNWaB/WxpRDh6s8 DernB7mtpWt3RgRfYIw5yP4G1s2X6kSE4OKKqtyKpD0cv+WxZ8NXwKKy8ou88qy0iTw4 5Tj4FA2rksivHRnEr+LrCDGbCDUSuOM06/pOZxsRN4YJi8Ks7QJQ3uPv+WdgIUcg18bT t2mxNrWhh+POfU5Fh4JllCxkVBTjQj31owkZt1o6AdSg6gz+6knGdEnJuMKcK6OfvID5 mtO7ecLo39HVonYKXVUd5LbmMyzvslC8WyLFqp47FbXLyxF4UbJrgIiiT+hZRsVqatn0 CfKw== X-Gm-Message-State: AOAM533O2TjiSjzXmagjP23jyM7O8opjyhVnckEFgjAvLlFdqn75Cs9k 6SeEGIPXzjhh9P98Q5UomEQM X-Google-Smtp-Source: ABdhPJzY7oJmp/uIPxSUZgtEg1+HAFTNWko93ZCqe+QEaeViM8cL6hRzsUg06AjLq7lUF781LAQOxg== X-Received: by 2002:a17:90a:bc98:: with SMTP id x24mr4737740pjr.51.1630406252621; Tue, 31 Aug 2021 03:37:32 -0700 (PDT) Received: from localhost ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id n14sm2846617pjm.5.2021.08.31.03.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 03:37:32 -0700 (PDT) From: Xie Yongji To: mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, sgarzare@redhat.com, parav@nvidia.com, hch@infradead.org, christian.brauner@canonical.com, rdunlap@infradead.org, willy@infradead.org, viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org, corbet@lwn.net, mika.penttila@nextfour.com, dan.carpenter@oracle.com, joro@8bytes.org, gregkh@linuxfoundation.org, zhe.he@windriver.com, xiaodong.liu@intel.com, joe@perches.com, robin.murphy@arm.com, will@kernel.org, john.garry@huawei.com Cc: songmuchun@bytedance.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v13 08/13] vdpa: Add an opaque pointer for vdpa_config_ops.dma_map() Date: Tue, 31 Aug 2021 18:36:29 +0800 Message-Id: <20210831103634.33-9-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210831103634.33-1-xieyongji@bytedance.com> References: <20210831103634.33-1-xieyongji@bytedance.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add an opaque pointer for DMA mapping. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 +++--- drivers/vhost/vdpa.c | 2 +- include/linux/vdpa.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index f292bb05d6c9..a70fd2a08ff1 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -555,14 +555,14 @@ static int vdpasim_set_map(struct vdpa_device *vdpa, } static int vdpasim_dma_map(struct vdpa_device *vdpa, u64 iova, u64 size, - u64 pa, u32 perm) + u64 pa, u32 perm, void *opaque) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); int ret; spin_lock(&vdpasim->iommu_lock); - ret = vhost_iotlb_add_range(vdpasim->iommu, iova, iova + size - 1, pa, - perm); + ret = vhost_iotlb_add_range_ctx(vdpasim->iommu, iova, iova + size - 1, + pa, perm, opaque); spin_unlock(&vdpasim->iommu_lock); return ret; diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index ab39805ecff1..ba030150b4b6 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -571,7 +571,7 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, return r; if (ops->dma_map) { - r = ops->dma_map(vdpa, iova, size, pa, perm); + r = ops->dma_map(vdpa, iova, size, pa, perm, NULL); } else if (ops->set_map) { if (!v->in_batch) r = ops->set_map(vdpa, dev->iotlb); diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index e1eae8c7483d..f3014aaca47e 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -270,7 +270,7 @@ struct vdpa_config_ops { /* DMA ops */ 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); + u64 pa, u32 perm, void *opaque); int (*dma_unmap)(struct vdpa_device *vdev, u64 iova, u64 size); /* Free device resources */