Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3725056pxj; Tue, 15 Jun 2021 07:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWYPW3AQUoIjhetPGnaJUV3cRsBMuFczYd/v9xuMxBx7FlI+1yrHfJcvflysaV+dpDCJjJ X-Received: by 2002:a05:6402:188:: with SMTP id r8mr23424667edv.75.1623766953788; Tue, 15 Jun 2021 07:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623766953; cv=none; d=google.com; s=arc-20160816; b=FKck0DILXNmYKX5hZxh6qRKtPYWzSvXWrWhIrAFtEr9j/sZEXrjPofr+gYwIlXbPj3 swDblWNq91P7eGQzTG9EFDpYt//ql1Ylbg4oTjgumLetpeKAAAMkVp2c1k95iKk4kXc8 r9CwuFW1wQq8sWGykS/YNQXOcSUaZoEzHQg8P8DsaH6rYc+mDeHQ4c6iNza74k2o9vRU fP6a9t8hMa4SevkbBhLf64WFqPdmOUmXb4g5lZ3OAmUZzuejLHrC270acxALUHW+La5k MTsBzc/seFnt/HkuJN9tHp/cQfrI3Ax2bOOmG4ZMVdeAJHqvoHKOebxpH8+OzQJ1Mqi/ Oa+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/FJesSbjdD3ax6QLZHwWomAg+hmA/0XqmQi+5t3uBts=; b=Z963T3Cm4e8eN9rKDtEQN5TQkXZ0h9vJgGyGk/OadM0m430+3RFzO1HyLlL1LyWqC2 TR2+1UqpGaidAzsRaPtoWrGDa0GwQEb5kndcZxLith8qr+R5EV8XSa5vVMyc5p2M2I9z X+qGycHi037+SXDajwHNJRgVj/aJIDnDu5I4Wp/o6Vh3qC4e/hBjwDmfYdhIm4o0ApQJ 7KlSFY90Ag4gdJM7Tt5V9FTiGugERisx+BmP1Q4CwivZsz5KoP4bLzH/Tzbb63vq3Sym PldXpQ6acNzKoNt2Pk05vX+e1kt+t5FmxwIT9lv3yy8HQW4k5oMFobYSZIga5eBtfOlr lvZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=QAmzB4gH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar16si12278408ejc.345.2021.06.15.07.22.08; Tue, 15 Jun 2021 07:22:33 -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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=QAmzB4gH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbhFOOT6 (ORCPT + 99 others); Tue, 15 Jun 2021 10:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbhFOOSO (ORCPT ); Tue, 15 Jun 2021 10:18:14 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94D6AC06115B for ; Tue, 15 Jun 2021 07:14:16 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id t13so4205236pgu.11 for ; Tue, 15 Jun 2021 07:14:16 -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=/FJesSbjdD3ax6QLZHwWomAg+hmA/0XqmQi+5t3uBts=; b=QAmzB4gHG7Cy4ZN45ovZfpN6L1SILefQ0L+NxivAp0a6ufJ3shF5BHnlp4wRjjtevl Z7kY9HIEZPuiRINzUexcDU0nWp6ZF+CkmwLIjH/F4xTYMpgJqWG4JL36Su/+tnFQyM38 PQsbmnUUSs6LfqFK6Y5pWTfk0aWhWAYKWk3g51/NT9lXSx9FY82ucMbd7x4whRd3GnDT SNV/a9nSjTPjAT1DTDg/fOVFZMXcOzmVcwqxnUn+YWCFSPuFh8NDIbjMsRQ/k+L1hbNc Fp6wCNh2LQAkqhTBA8ShNGsEatOTf0DgYL0PYQmlXjFQUADRCb0aB401iUdLw5ezIe7M 6dwA== 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=/FJesSbjdD3ax6QLZHwWomAg+hmA/0XqmQi+5t3uBts=; b=qd7YDGlzXpI6Z1UwBTnVvf6K57Fqfbj1q4vKO/t1cGZCUFs2vOQsunv+MLbW5ln0RW MFiP0VYbQGuM879XX/ChuRxTKedIVigtLaS0DG1qITbn6XO0IS1fjqWBdN6kGHOfzx3i SxzGKJbf0DjVKRns2wh6WVxFzzfksdXobE1KhOk3pr/EwAjPCqHZcI87NqjGS1xGNbK+ lC8STc7dOasn1bfjd1ynyAkxnmO5rs8ymTvMZs7D5DUVWwE/aaP1LXdm4+3oS4mC+DWP LEyUIy80CQktlOSwXwIkd/mXZpgTxtqbcYuXEMkj1M4Omv7zmGkNeEjtaw8qv6kVcTGN e1+A== X-Gm-Message-State: AOAM5306DcOTszXabTUcYowXcpPExMnyiT4rGarLPx1ddZZ/Psab+xbq hG2lOreoeuFFUIZ2QFzzibhD X-Received: by 2002:a62:1d0e:0:b029:2d8:30a3:687f with SMTP id d14-20020a621d0e0000b02902d830a3687fmr4531470pfd.17.1623766456186; Tue, 15 Jun 2021 07:14:16 -0700 (PDT) Received: from localhost ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id h8sm2255456pgc.60.2021.06.15.07.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 07:14:15 -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 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 v8 05/10] vdpa: Add an opaque pointer for vdpa_config_ops.dma_map() Date: Tue, 15 Jun 2021 22:13:26 +0800 Message-Id: <20210615141331.407-6-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210615141331.407-1-xieyongji@bytedance.com> References: <20210615141331.407-1-xieyongji@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 98f793bc9376..efd0cb3d964d 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -542,14 +542,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 fb41db3da611..1d5c5c6b6d5d 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -565,7 +565,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 f311d227aa1b..281f768cb597 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -245,7 +245,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 */ -- 2.11.0