From patchwork Tue Nov 28 09:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 13470754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3965C4167B for ; Tue, 28 Nov 2023 09:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d0mEzg1mG9K3jhEmtKxCpbnNROyD4ITBReQ2fMvRZ+Y=; b=UilufN0bKUjTt4 FxtrNrFKcmRwYcGNhC3Dfhdy/rXowQeKSPAnjvRPOqrgZiKPRqB/ReH2F4DRQ/PXzbEPM5bDj7TUl 79FuIjW/yYyBus9UkKVrBejbgRMAkYR3/fqNbAg+8eT50D82Ft6LOHtNTFUt+8z8UBTn4k8zVewql XMN4eDx69eEm9PFi0FLOMgPhoKYF0mVibGniuJz94+sibJ2x04BmmTEiYZbzsvBMgSZSk9EUgnm59 2CXScsB0108E8sYIxoXRtRH0746UWlquU/Ynuqg9xYi4rwonfP7Zgu/cr6d8QqPxXsc0uO3QufV1s zZF5MzqoK9qWfhX1BdTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7uk0-004moP-0N; Tue, 28 Nov 2023 09:50:52 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7ujs-004mks-0s for linux-arm-kernel@lists.infradead.org; Tue, 28 Nov 2023 09:50:45 +0000 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Sfcz708twz67bpd; Tue, 28 Nov 2023 17:46:11 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 8975C140135; Tue, 28 Nov 2023 17:50:42 +0800 (CST) Received: from A2006125610.china.huawei.com (10.202.227.178) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 28 Nov 2023 09:50:35 +0000 From: Shameer Kolothum To: , CC: , , , , , , , , , , , Subject: [PATCH 4/5] iommu/arm-smmu-v3: Add set_dirty_tracking() support Date: Tue, 28 Nov 2023 09:49:39 +0000 Message-ID: <20231128094940.1344-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20231128094940.1344-1-shameerali.kolothum.thodi@huawei.com> References: <20231128094940.1344-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.178] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231128_015044_452480_DFE9AD71 X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Joao Martins Dirty tracking will always be enabled with DBM=1 modifier enabled by default when HD is supported. Signed-off-by: Joao Martins Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 22 +++++++++++++++++++++ 1 file changed, 22 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 8331a2c70a0c..c5eabdc29ba5 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3402,6 +3402,27 @@ static int arm_smmu_read_and_clear_dirty(struct iommu_domain *domain, return ret; } +static int arm_smmu_set_dirty_tracking(struct iommu_domain *domain, + bool enabled) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops; + + if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) + return -EINVAL; + + if (!ops) { + pr_err_once("io-pgtable don't support dirty tracking\n"); + return -ENODEV; + } + + /* + * Always enabled and the dirty bitmap is cleared prior to + * set_dirty_tracking(). + */ + return 0; +} + static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) { return iommu_fwspec_add_ids(dev, args->args, 1); @@ -3529,6 +3550,7 @@ static struct iommu_ops arm_smmu_ops = { static struct iommu_dirty_ops arm_smmu_dirty_ops = { .read_and_clear_dirty = arm_smmu_read_and_clear_dirty, + .set_dirty_tracking = arm_smmu_set_dirty_tracking, }; /* Probing and initialisation functions */