Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp45282pxu; Wed, 6 Jan 2021 20:46:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMNwtR5cQX0V8obLtqjjkIUVlGdXGr2jOWCaAEPmMtnDOQnJiwKjZYL6WJ2OKhFkiZeHtn X-Received: by 2002:a17:906:5796:: with SMTP id k22mr4886868ejq.435.1609994809919; Wed, 06 Jan 2021 20:46:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609994809; cv=none; d=google.com; s=arc-20160816; b=vhnisyaSP7gBZ675DW8k/oHCxptAdZlEn+FL8A/h9F5iY4Y/WlSMqE63l/BuJWblQ+ +GZPVIbrEB1y+z8q6CDxxSbOxQFTytbTsoeIHoUjdkfQ99Nv2zzWMofsjGqqRCrX3PFP mH0S2wgidvbsEIJQgewg3sbNgTkKbCrCGzbdQuR9OBCDFDVGWA2X9t9eNIWuvf2rMO6d 5OlssQv8Rgxs1yVmGXTV0a/tpFC7DBfr7l4dBlPTjl8Q63K+qsQqKCgbed6MkJvKJVbX UudLJ96UrgPjF91sRy0GsTEd8k66nIfIo0vkxtM7+itWjjBRCN4d04cd6iUtMYptHSAR HB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=4SMZxnk4lplt5DGSC2XSfkOesmNPALMRj/eC+nxqslY=; b=YG++5Qr+JMTO7VVD93SRWEeprTFzX6hm+2m9w2pSKGhX918qO/X76HlNSNh7pdH+vu pI5J7vc91MooPE+aXx5UwKaveNnx8SNBQGvxGi13WmeBnDGH5U/1LQwWqae5O/X4iJGe JUKwVR7u4EPkfdoDWiZIWa/W51d4nCaT+YsMGZXsKvdhgwFZv8/RZEY2NxEmYl0ZCu3c rb+ZCA5Mo+RrGGyB5TMRzoLP1Jhl+Ovaq0mIOCaER5EFxDiXCBA0LVYjPTOdeILr0N7x Th4TVX4b4GyWwVuFOg5gVNy5SVOmkASM1V9muaGVMiaPXLKJC7P8i+I32Z9HBy4h6+Ys vqQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt13si1626348ejb.98.2021.01.06.20.46.26; Wed, 06 Jan 2021 20:46:49 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727256AbhAGEpX (ORCPT + 99 others); Wed, 6 Jan 2021 23:45:23 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:9967 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbhAGEpW (ORCPT ); Wed, 6 Jan 2021 23:45:22 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DBDCF5MDtzhsSy; Thu, 7 Jan 2021 12:43:53 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.184.42) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Thu, 7 Jan 2021 12:44:28 +0800 From: Keqian Zhu To: , , , , , Alex Williamson , Cornelia Huck , Will Deacon , "Marc Zyngier" , Catalin Marinas CC: Mark Rutland , James Morse , Robin Murphy , Joerg Roedel , "Daniel Lezcano" , Thomas Gleixner , Suzuki K Poulose , Julien Thierry , Andrew Morton , Alexios Zavras , , Subject: [PATCH 3/6] vfio/iommu_type1: Initially set the pinned_page_dirty_scope Date: Thu, 7 Jan 2021 12:43:58 +0800 Message-ID: <20210107044401.19828-4-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210107044401.19828-1-zhukeqian1@huawei.com> References: <20210107044401.19828-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For now there are 3 ways to promote the pinned_page_dirty_scope status of vfio_iommu: 1. Through vfio pin interface. 2. Detach a group without pinned_dirty_scope. 3. Attach a group with pinned_dirty_scope. For point 3, the only chance to promote the pinned_page_dirty_scope status is when vfio_iommu is newly created. As we can safely set empty vfio_iommu to be at pinned status, then the point 3 can be removed to reduce operations. Signed-off-by: Keqian Zhu --- drivers/vfio/vfio_iommu_type1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 110ada24ee91..b596c482487b 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2045,11 +2045,8 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, * Non-iommu backed group cannot dirty memory directly, * it can only use interfaces that provide dirty * tracking. - * The iommu scope can only be promoted with the - * addition of a dirty tracking group. */ group->pinned_page_dirty_scope = true; - promote_pinned_page_dirty_scope(iommu); mutex_unlock(&iommu->lock); return 0; @@ -2436,6 +2433,7 @@ static void *vfio_iommu_type1_open(unsigned long arg) INIT_LIST_HEAD(&iommu->iova_list); iommu->dma_list = RB_ROOT; iommu->dma_avail = dma_entry_limit; + iommu->pinned_page_dirty_scope = true; mutex_init(&iommu->lock); BLOCKING_INIT_NOTIFIER_HEAD(&iommu->notifier); -- 2.19.1