Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4589321pxu; Wed, 9 Dec 2020 23:45:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEebgJHdNQEeIVg0tdKum1BG7u/6o1otsbjYU7/7vD54WfYvlU4GYKW1whmP8Ky88KgbVH X-Received: by 2002:a17:906:7b82:: with SMTP id s2mr5221778ejo.435.1607586321117; Wed, 09 Dec 2020 23:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607586321; cv=none; d=google.com; s=arc-20160816; b=PZpzqAEK1WbjH0l4Mkl54GpGCkjC3j+kG+7nC6Hu7yDXkhMcy19sUCsItH/jEB4Gll zuZzH5JQeSzw5a82wFE7qeDuf8sMBI7yCXlwZ/hvUaZMBEbEjSK40XOsXVn7YWtbJQpb yRDYC4lEhFigSD3qYcfBIS6/Jx1C2y1Z2/Wp5bYMZIrfjVS1VT+pIr2ZS8ygaKn4cobo N95rtI2veIgat3Wa3fDDi9iL8lduRAG2M7cbmvDJxsTgdarfyQnaub1yR0NcbZ7byzlt kHSo/2WY1/A+pJh5G8xKJUlHACP7x8EptEQa0AxnoznCilVQqFx8uMzUV/dIYPK7pfhj fmkA== 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=7A8jtZV9hc3g5YDKFnymg7a5oqPCquv2GvkOz68nEAg=; b=d6qqbrcoKAlCAlYz4NK1ZMy6TqIYQP+Wm7gSmBDEg/Wy+txjM6dyxUfhwYY7KS9kWs C9sCrxxXWRKlqSIiE+o8YC1owSC2aj5wnpOxiFhsoryNDS9rVzH6dDjM/o17g6c3j525 gugEZ4omePkJ/Uk+cFMCp/a5f/W5qhtjpHv2CirhCECiSpZ/tTSQX7WCf6yZS2XGqmN7 sa5E2t+WSf+oHwETRwzS5irZCSZKbuSnSV9NwRD8wzcw9wyQ9fhYJX5WL4FHd5CMma/+ yS4K5/9lh13uwXZuq4bUwhrncyQ9hm3esuhbjQI37mpMwwJHl6HayPcPKdNGDMnd/PKD 7d9A== 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 f21si2202782eds.396.2020.12.09.23.44.56; Wed, 09 Dec 2020 23:45:21 -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 S1733105AbgLJHgl (ORCPT + 99 others); Thu, 10 Dec 2020 02:36:41 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9862 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733123AbgLJHgT (ORCPT ); Thu, 10 Dec 2020 02:36:19 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Cs5Kg6mXDz7CCV; Thu, 10 Dec 2020 15:35:03 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.37) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Thu, 10 Dec 2020 15:35:26 +0800 From: Keqian Zhu To: , , , , , Alex Williamson , Cornelia Huck , Marc Zyngier , Will Deacon , Robin Murphy CC: Joerg Roedel , Catalin Marinas , James Morse , Suzuki K Poulose , Sean Christopherson , Julien Thierry , Mark Brown , "Thomas Gleixner" , Andrew Morton , Alexios Zavras , , , Keqian Zhu Subject: [PATCH 2/7] vfio: iommu_type1: Initially set the pinned_page_dirty_scope Date: Thu, 10 Dec 2020 15:34:20 +0800 Message-ID: <20201210073425.25960-3-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20201210073425.25960-1-zhukeqian1@huawei.com> References: <20201210073425.25960-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there are 3 ways to promote the pinned_page_dirty_scope status of vfio_iommu: 1. Through pin interface. 2. Detach a group without dirty tracking. 3. Attach a group with dirty tracking. For point 3, the only chance to change the pinned status is that the vfio_iommu is newly created. Consider that we can safely set the pinned status when create a new vfio_iommu, as we do it, the point 3 can be removed to reduce operations. Signed-off-by: Keqian Zhu --- drivers/vfio/vfio_iommu_type1.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index f129d24a6ec3..c52bcefba96b 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2064,12 +2064,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; - if (!iommu->pinned_page_dirty_scope) - update_pinned_page_dirty_scope(iommu); mutex_unlock(&iommu->lock); return 0; @@ -2457,6 +2453,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.23.0