From patchwork Tue Apr 13 08:54:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhukeqian X-Patchwork-Id: 12199679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DAE0C43460 for ; Tue, 13 Apr 2021 09:00:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E266613AE for ; Tue, 13 Apr 2021 09:00:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E266613AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=R9nRQSik8Net/Mc3sdqWfki7KYj8amQkpyhW12Ip1iU=; b=GWgVIxbVVloEaFjNr98KC76wb tikLbKj2mUJRAU+XK0XPmlvdPqnew6ec0uXgscQFClbkG8nCis30177WI0vsO134lLdIbMcVjqX08 qU8DpuJRewUG4oCv8zUmzeFsWjpNfys6IEKNGPObmhp7Arqf8sQwXcx92B2d2HR+arEzlqcaFLBYw /bHsdxfn1K2ve+sA1BY8jKkeH+m7P69snl2RoPMskyzkK+tXSgzn/hUhFTlmEThDt15DoMzZfxPNU bmQ/pXf240dgwGPV98CnLrgam0jQSSHhXjaIQfzDer8nLKkO8Bt/LOaUYHqBWxrGCmo/B9RPq+08/ QpsXkPJuQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lWEsC-008cIt-H3; Tue, 13 Apr 2021 08:58:16 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWEpX-008c5C-Dn for linux-arm-kernel@desiato.infradead.org; Tue, 13 Apr 2021 08:56:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hJVbbJRwM27RSmW2GX3jHQC7+BaVHvhiGLdCLNH3xJs=; b=vT+ZB+IMq9ClzzDyR2yRXBmnTX cN8t5+IXmTJewqVuynGkVRsfl/DS/MD/CQlbXoavdtPcjxMFtFKcdqT9PJFdVF+lw5ZEphP63oVfJ 5wBj+0+jr2YyjD3J6N7aPbIMw5XLE1jO4nTrBFs79NFysQYA+dEouGAbirlKgpg9e8SH6LDZGkMZh kjMN9bIdANAAPEpiOsiOgzLTJFIvVWXS7gYWfWHMzJ3Df3shhlxoCjOLr3Apw+sl8ekK1+lbDdZtY d9wxxudp269qLLlb8WV5vFrNI5+vajLPOIxVDuhb4X4aE6w0BP0yWwMZwZBLk6N+fUVM70Xutkj+U rgFkddZg==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWEpU-006qkB-ND for linux-arm-kernel@lists.infradead.org; Tue, 13 Apr 2021 08:55:30 +0000 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FKK9q0Tz9zPqkj; Tue, 13 Apr 2021 16:52:31 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.224) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Tue, 13 Apr 2021 16:55:16 +0800 From: Keqian Zhu To: , , , Robin Murphy , "Will Deacon" , Joerg Roedel , Yi Sun , Jean-Philippe Brucker , Jonathan Cameron , Tian Kevin , Lu Baolu CC: Alex Williamson , Cornelia Huck , Kirti Wankhede , , , , Subject: [PATCH v3 12/12] iommu/arm-smmu-v3: Add HWDBM device feature reporting Date: Tue, 13 Apr 2021 16:54:57 +0800 Message-ID: <20210413085457.25400-13-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210413085457.25400-1-zhukeqian1@huawei.com> References: <20210413085457.25400-1-zhukeqian1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210413_015528_944722_95BD3D9F X-CRM114-Status: GOOD ( 11.63 ) 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: Kunkun Jiang We have implemented these interfaces required to support iommu dirty log tracking. The last step is reporting this feature to upper user, then the user can perform higher policy base on it. There is a new dev feature named IOMMU_DEV_FEAT_HWDBM in iommu layer. For arm smmuv3, it is equal to ARM_SMMU_FEAT_HD and it is enabled by default if supported. Other types of IOMMU can enable it by default or when user invokes enable_feature. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++++++ 1 file changed, 6 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 59bb1d198631..2d716ee5621f 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2712,6 +2712,9 @@ static bool arm_smmu_dev_has_feature(struct device *dev, switch (feat) { case IOMMU_DEV_FEAT_SVA: return arm_smmu_master_sva_supported(master); + case IOMMU_DEV_FEAT_HWDBM: + /* No requirement for device, require HTTU HD of smmu */ + return !!(master->smmu->features & ARM_SMMU_FEAT_HD); default: return false; } @@ -2728,6 +2731,9 @@ static bool arm_smmu_dev_feature_enabled(struct device *dev, switch (feat) { case IOMMU_DEV_FEAT_SVA: return arm_smmu_master_sva_enabled(master); + case IOMMU_DEV_FEAT_HWDBM: + /* HTTU HD is enabled if supported */ + return arm_smmu_dev_has_feature(dev, feat); default: return false; }