Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3647710pxb; Mon, 30 Aug 2021 07:24:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM2/gFqFYdLznNGa30JF35DdGHT3p3WhQUMpuHFtbB+EENVmOiVh3TaLBMFgsoJHWXTBKk X-Received: by 2002:a17:906:2541:: with SMTP id j1mr26608813ejb.128.1630333482945; Mon, 30 Aug 2021 07:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630333482; cv=none; d=google.com; s=arc-20160816; b=cB/wA0tPFkEyxmO7RaVjuQXbQu2C/sNuwxVOxyPU/4lfA73uc2AIl/J+y8FUoJN5qj J6Lvn2dZWwJPmYl1IbHpmYG0a2qqHpNTtHTkgn09JqtIKSdGXEOfVOAkjJQRhwXbu5AZ Yr3wCQEBxKQg+FjcNt94vnbNV9GvgqX8LD3bty5OIDD6oSdvYkI1v7vKVk0FEcVeOUsB hhQ2HNAwINIjF0yKQi/rm5izdSWEJdpbqxUJ7TD2ql7EdCD1bY4ZPgmDsp1CdbD6ytJy rh9ffewrJE8SBtjbLVSOs4/GIypjiZ3aWRGwDj5cQmflOhuUiybVNrPjynAa/HkaTT2g BFYQ== 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=CGl/RjOOzzXlpDeA69Ku950YCkBGnktZEIYihkRI6vQ=; b=P2tXK46SdCHW5mU0DoanR4WckVGHZ8cp1rl+UkshA7NLYviOKEHZhWgjDgw3ujrt6U AIdZT4csmG4fzHLVZAuuzpDhuiQCXyQO8B8oaoCRGni65iqOPolBYAfLTlMu4zGhPwV3 uJ9p412GqkV2aTATX4nmFHtQfdxr2ynCASTSaQXt2alxW1BRTXlnk5YY3+0fiHHnMw7I VjBnMHleiMx262L8svuZeNN4J2VDgS+6m9hpFNeXlYAU/z8E6IvL2l5iI5EnFKGw2OAh tLj42TGjoBGuaJyu2c4zBEQCJB4A9gSCfeSQz/9ue+aPz0PpoBAWY0V0pbYEDk358HKs 4bJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=tibPBMhI; 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 gs43si8796803ejc.673.2021.08.30.07.24.18; Mon, 30 Aug 2021 07:24:42 -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=tibPBMhI; 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 S237368AbhH3OXW (ORCPT + 99 others); Mon, 30 Aug 2021 10:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237255AbhH3OXN (ORCPT ); Mon, 30 Aug 2021 10:23:13 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4F9EC06179A for ; Mon, 30 Aug 2021 07:22:19 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id d3-20020a17090ae28300b0019629c96f25so103304pjz.2 for ; Mon, 30 Aug 2021 07:22:19 -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=CGl/RjOOzzXlpDeA69Ku950YCkBGnktZEIYihkRI6vQ=; b=tibPBMhIaRriUsXr6UvYFrpkHTmiHH8BwwDZ73qL9GEPkZVJns9p5SBywP8Ixihl+U SH8fV2HRPmWHPpGh9QYEAZrhRsKA86TZweD1v//TIlE2DB7JCAp1r4kKWvvaaBGVdek3 nORzFVHdUcGbxJYAA7whpMJgDbGs0VmoGSj2hsTqIxRT/xBZAJ1DHMNzJciRahkIepwn Is4OSP0WQnAidGh4fp3EtLNmEqY+PR3DyY45FkAvU+xHXE0uc+Hsp85w+zhmoALlVfUM e1epu00WR9Ged9deYmMy1YGZSip8U27WwOTbHVXKtzE2iq99FPnKHe6AkHKhjdngOc2z DqOQ== 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=CGl/RjOOzzXlpDeA69Ku950YCkBGnktZEIYihkRI6vQ=; b=BilT75TjsYD5LwPMksi8689r8IEq4qi2J3TA7YI1ms8VsXyohe5cU83G2hJF+jywqe bXNTtfjS6sSaWbbfMRfcroBw4tvsToY8SDJnb013Vro+t2zA+4WTs4gwTvD87MkXL9YX fOXaxLkQafY6WlE4RUsWzcIAaJx6QKUD8FFPyNAAk69ylabtYTy8IeTuu9ivKoyaIDro iKoN6yc3tLSXcBYZHS4xv+yNn2pNopmdGp/MZdpBrHFnrbejeL3V2p+wROlzocP1BWom DBfp3kYvZQI2usrdpPYEbgjX7k4y5EQs3QZb1wWJAqnYOQpYWXo/HOb8IpmFAxTsH0lW pIDQ== X-Gm-Message-State: AOAM531D0zDFgLjcifrG2ojrwySp+1boBwOYA16xcaV3EkhySpaweqqd vS+ovUtzQ8yRG579MT8GOjzWlA/0ZprQzTo= X-Received: by 2002:a17:902:7584:b0:12d:8cb5:c7b8 with SMTP id j4-20020a170902758400b0012d8cb5c7b8mr22002872pll.84.1630333339417; Mon, 30 Aug 2021 07:22:19 -0700 (PDT) Received: from localhost ([139.177.225.237]) by smtp.gmail.com with ESMTPSA id r15sm11290126pfh.45.2021.08.30.07.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 07:22:18 -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 v12 07/13] vhost-iotlb: Add an opaque pointer for vhost IOTLB Date: Mon, 30 Aug 2021 22:17:31 +0800 Message-Id: <20210830141737.181-8-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830141737.181-1-xieyongji@bytedance.com> References: <20210830141737.181-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 vhost IOTLB. And introduce vhost_iotlb_add_range_ctx() to accept it. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vhost/iotlb.c | 20 ++++++++++++++++---- include/linux/vhost_iotlb.h | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/iotlb.c b/drivers/vhost/iotlb.c index 0582079e4bcc..670d56c879e5 100644 --- a/drivers/vhost/iotlb.c +++ b/drivers/vhost/iotlb.c @@ -36,19 +36,21 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb, EXPORT_SYMBOL_GPL(vhost_iotlb_map_free); /** - * vhost_iotlb_add_range - add a new range to vhost IOTLB + * vhost_iotlb_add_range_ctx - add a new range to vhost IOTLB * @iotlb: the IOTLB * @start: start of the IOVA range * @last: last of IOVA range * @addr: the address that is mapped to @start * @perm: access permission of this range + * @opaque: the opaque pointer for the new mapping * * Returns an error last is smaller than start or memory allocation * fails */ -int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, - u64 start, u64 last, - u64 addr, unsigned int perm) +int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, + u64 start, u64 last, + u64 addr, unsigned int perm, + void *opaque) { struct vhost_iotlb_map *map; @@ -71,6 +73,7 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, map->last = last; map->addr = addr; map->perm = perm; + map->opaque = opaque; iotlb->nmaps++; vhost_iotlb_itree_insert(map, &iotlb->root); @@ -80,6 +83,15 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, return 0; } +EXPORT_SYMBOL_GPL(vhost_iotlb_add_range_ctx); + +int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, + u64 start, u64 last, + u64 addr, unsigned int perm) +{ + return vhost_iotlb_add_range_ctx(iotlb, start, last, + addr, perm, NULL); +} EXPORT_SYMBOL_GPL(vhost_iotlb_add_range); /** diff --git a/include/linux/vhost_iotlb.h b/include/linux/vhost_iotlb.h index 6b09b786a762..2d0e2f52f938 100644 --- a/include/linux/vhost_iotlb.h +++ b/include/linux/vhost_iotlb.h @@ -17,6 +17,7 @@ struct vhost_iotlb_map { u32 perm; u32 flags_padding; u64 __subtree_last; + void *opaque; }; #define VHOST_IOTLB_FLAG_RETIRE 0x1 @@ -29,6 +30,8 @@ struct vhost_iotlb { unsigned int flags; }; +int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, u64 start, u64 last, + u64 addr, unsigned int perm, void *opaque); int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last, u64 addr, unsigned int perm); void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last); -- 2.11.0