Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp249133pxj; Fri, 7 May 2021 07:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzW+hw9HKTf0m8lCCjzIKui2jVn8OiwCd5yLTYfURVuatTGuzWwO8LQioV8K45F905Vq2u X-Received: by 2002:a63:4c66:: with SMTP id m38mr10433985pgl.157.1620399201628; Fri, 07 May 2021 07:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620399201; cv=none; d=google.com; s=arc-20160816; b=LtS3/G4eDr/vbOz0riYA9btArNtIQlCz01uBgMe28yyoCO5WypbhaqMC/VIowlXzhd rmcodsTi6PbvPqmBHS9n4SumKGmYNYVYwVqAkXyuucP9CTsJwGd32S9KB4kZnhUHVcbs X7oYmN/rR/W9m1xzgpREIGzAzB0fWaCBvoIlqzzv3GSRjv4eaxt2E7ow9+QWzoT42cuD PWvN5HJAs0beLM/f3bZ3gETSgVHJ/LtDLRs06S5TlD+SA9I/tRJpBmeSvEVLnBBkzzKu GOY6+Qeoso2Ub79M5PDsfiDPKZoFgf8FdYc9qw5NtMK+WVWaQivFEig6RtUrFPVBU8NQ Lf3w== 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=ZIZXoFRygYJyXDX6aQhdhVGFytYA+yjJhlIU/UqbVlw=; b=PR5vhjwJpQQH3kcZO7YpH6LbMB3cHf3weCgBsgLLxMUZEyeeOUzx5/1EkTH0+ai4ot azWhSC6BQFxc4VoXGHuWYZCPR6nhN5v7g6aQC2ZwDGBBcmjCsvdHi3LdDCTLByGe98+y H6vpbyumXxiWesFvFdNd5BLA21X5X7IsGn/fv23CrC1+cr/pIuu7E6TIeBsd4NX5+m68 kGPYDBGrDabeNFh0cGvWey9jO9cPDeq4Whfs92iV4UBnFcMQVTjZer2tkq/2qLIItnsa +tVB7lMnBfg5Fm+3XzKU+RLZYiEhHEJ2NbjBRx6xlhRb3o5uYjus1LRYKtGzZjXrYj5p eHZA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si6021085plx.381.2021.05.07.07.53.09; Fri, 07 May 2021 07:53:21 -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; 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236886AbhEGKY5 (ORCPT + 99 others); Fri, 7 May 2021 06:24:57 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:18348 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236081AbhEGKYR (ORCPT ); Fri, 7 May 2021 06:24:17 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Fc5zw3scPzCr6L; Fri, 7 May 2021 18:20:12 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.224) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Fri, 7 May 2021 18:22:40 +0800 From: Keqian Zhu To: , , , Robin Murphy , "Will Deacon" , Joerg Roedel , "Jean-Philippe Brucker" , Lu Baolu , "Yi Sun" , Tian Kevin CC: Alex Williamson , Kirti Wankhede , Cornelia Huck , Jonathan Cameron , , , , Subject: [RFC PATCH v4 11/13] iommu/arm-smmu-v3: Realize sync_dirty_log iommu ops Date: Fri, 7 May 2021 18:22:09 +0800 Message-ID: <20210507102211.8836-12-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210507102211.8836-1-zhukeqian1@huawei.com> References: <20210507102211.8836-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kunkun Jiang This realizes sync_dirty_log iommu ops based on sync_dirty_log io-pgtable ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 6de81d6ab652..3d3c0f8e2446 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2721,6 +2721,35 @@ static int arm_smmu_switch_dirty_log(struct iommu_domain *domain, bool enable, return 0; } +static int arm_smmu_sync_dirty_log(struct iommu_domain *domain, + unsigned long iova, size_t size, + unsigned long *bitmap, + unsigned long base_iova, + unsigned long bitmap_pgshift) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops; + struct arm_smmu_device *smmu = smmu_domain->smmu; + + if (!(smmu->features & ARM_SMMU_FEAT_HD)) + return -ENODEV; + if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) + return -EINVAL; + + if (!ops || !ops->sync_dirty_log) { + pr_err("io-pgtable don't realize sync dirty log\n"); + return -ENODEV; + } + + /* + * Flush iotlb to ensure all inflight transactions are completed. + * See doc IHI0070Da 3.13.4 "HTTU behavior summary". + */ + arm_smmu_flush_iotlb_all(domain); + return ops->sync_dirty_log(ops, iova, size, bitmap, base_iova, + bitmap_pgshift); +} + static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) { return iommu_fwspec_add_ids(dev, args->args, 1); @@ -2820,6 +2849,7 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .enable_nesting = arm_smmu_enable_nesting, .switch_dirty_log = arm_smmu_switch_dirty_log, + .sync_dirty_log = arm_smmu_sync_dirty_log, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions, -- 2.19.1