From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2016B30FBA for ; Thu, 30 Nov 2023 09:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Sgqsc3yRJz1L99B; Thu, 30 Nov 2023 17:00:36 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 Nov 2023 17:01:31 +0800 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.035; Thu, 30 Nov 2023 09:01:30 +0000 From: Shameerali Kolothum Thodi To: Jason Gunthorpe CC: "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "robin.murphy@arm.com" , "will@kernel.org" , "joro@8bytes.org" , "kevin.tian@intel.com" , "nicolinc@nvidia.com" , "mshavit@google.com" , "eric.auger@redhat.com" , "joao.m.martins@oracle.com" , jiangkunkun , zhukeqian , Linuxarm Subject: RE: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in domain attach/alloc Thread-Topic: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in domain attach/alloc Thread-Index: AQHaIeBhbjwQvTzWckukoTe4aRA5yLCRtmUAgADdCCA= Date: Thu, 30 Nov 2023 09:01:29 +0000 Message-ID: References: <20231128094940.1344-1-shameerali.kolothum.thodi@huawei.com> <20231128094940.1344-6-shameerali.kolothum.thodi@huawei.com> <20231129194850.GD436702@nvidia.com> In-Reply-To: <20231129194850.GD436702@nvidia.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected > -----Original Message----- > From: Jason Gunthorpe > Sent: Wednesday, November 29, 2023 7:49 PM > To: Shameerali Kolothum Thodi > Cc: iommu@lists.linux.dev; linux-arm-kernel@lists.infradead.org; > robin.murphy@arm.com; will@kernel.org; joro@8bytes.org; > kevin.tian@intel.com; nicolinc@nvidia.com; mshavit@google.com; > eric.auger@redhat.com; joao.m.martins@oracle.com; jiangkunkun > ; zhukeqian ; Linuxarm > > Subject: Re: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in dom= ain > attach/alloc >=20 > On Tue, Nov 28, 2023 at 09:49:40AM +0000, Shameer Kolothum wrote: > > @@ -2701,6 +2703,9 @@ static int arm_smmu_attach_dev(struct > iommu_domain *domain, struct device *dev) > > master =3D dev_iommu_priv_get(dev); > > smmu =3D master->smmu; > > > > + if (domain->dirty_ops && !arm_smmu_dbm_capable(smmu)) > > + return -EINVAL; > > + >=20 > This is not necessary, a domain can be attached to a single smmu and > finalize was run on that smmu already. So dirty ops should only be set > if this is a S1 domain finalized ona smmu that was dbm capable. >=20 > Otherwise none of this makes any sense. >=20 > > @@ -3104,6 +3115,9 @@ arm_smmu_domain_alloc_user(struct device *dev, > u32 flags, > > > > smmu_domain->domain.type =3D IOMMU_DOMAIN_UNMANAGED; > > smmu_domain->domain.ops =3D arm_smmu_ops.default_domain_ops; > > + if (enforce_dirty) > > + smmu_domain->domain.dirty_ops =3D &arm_smmu_dirty_ops; >=20 > Ah, this seems in the wrong place, perhaps that is the confusion > everywhere? >=20 > If the finalize actually enables dirty tracking in the pgtbl_ops then > it should set the diryty_ops, they should not be set in alloc_user. >=20 > Specifically, a S2 domain should never have dirty_ops set. >=20 > IOW if domain.dirty_ops !=3D NULL then pgtbl_ops !=3D NULL && pgtbl_ops- > >read_and_clear_dirty >=20 > Thus no need to have all the other prints/etc then. >=20 > So I'd move this into finalize. Ok. Make sense. I will move it. >=20 > > @@ -4152,11 +4166,13 @@ static void arm_smmu_get_httu(struct > arm_smmu_device *smmu, u32 reg) > > > > if (smmu->dev->of_node) > > smmu->features |=3D features; > > - else if (features !=3D fw_features) > > + else if (features !=3D fw_features) { > > /* ACPI IORT sets the HTTU bits */ > > dev_warn(smmu->dev, > > - "IDR0.HTTU overridden by FW configuration (0x%x)\n", > > + "IDR0.HTTU not overridden by FW configuration > (0x%x)\n", > > fw_features); > > + smmu->features |=3D features; > > + } > > } >=20 > Is this hunk misplaced? Oops... My bad. Added for testing.=20 Thanks, Shameer From mboxrd@z Thu Jan 1 00:00:00 1970 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 2B712C4167B for ; Thu, 30 Nov 2023 09:02:12 +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:In-Reply-To:References: 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=ctuyml2nC3TrGEk6W1paKqMU4Qd0/fyyJqrkIEl6h6A=; b=06tM9x0l1JcT3P jAXdPZA5biweyvTYAfb4VVeGxsCHmjBKRxkVRxhdJGvEIwpdSHAYd8VYUUzR7buT5Ac84+DlMYSeT /PFSe1fSPWdNSYEiR3mWmQG0MktmWb8z/aZPlW8he+814/g36nYdcJBRMoQxUfIGcLm+rAiej1Pt7 vwEsUaoZCPnndq8Wrls85ng0hYgX1F+WpCaW8PBZg19/GpN8kJ0sd0J5SPUmQgano6TDegw9R9uw8 /RGRQUpgJiVef+UNiTUWijZ5ntua6qdPaJSlgmROSUnJNjscm3s2mCHInQdPzlmcNWv+XJKFM1YTX JBjfPQL6+p1yGtOLizjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cva-00AGxT-1i; Thu, 30 Nov 2023 09:01:46 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cvX-00AGwj-0K for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2023 09:01:44 +0000 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Sgqsc3yRJz1L99B; Thu, 30 Nov 2023 17:00:36 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 Nov 2023 17:01:31 +0800 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.035; Thu, 30 Nov 2023 09:01:30 +0000 From: Shameerali Kolothum Thodi To: Jason Gunthorpe CC: "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "robin.murphy@arm.com" , "will@kernel.org" , "joro@8bytes.org" , "kevin.tian@intel.com" , "nicolinc@nvidia.com" , "mshavit@google.com" , "eric.auger@redhat.com" , "joao.m.martins@oracle.com" , jiangkunkun , zhukeqian , Linuxarm Subject: RE: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in domain attach/alloc Thread-Topic: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in domain attach/alloc Thread-Index: AQHaIeBhbjwQvTzWckukoTe4aRA5yLCRtmUAgADdCCA= Date: Thu, 30 Nov 2023 09:01:29 +0000 Message-ID: References: <20231128094940.1344-1-shameerali.kolothum.thodi@huawei.com> <20231128094940.1344-6-shameerali.kolothum.thodi@huawei.com> <20231129194850.GD436702@nvidia.com> In-Reply-To: <20231129194850.GD436702@nvidia.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.28] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_010143_469560_5CF15A58 X-CRM114-Status: GOOD ( 19.65 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Jason Gunthorpe > Sent: Wednesday, November 29, 2023 7:49 PM > To: Shameerali Kolothum Thodi > Cc: iommu@lists.linux.dev; linux-arm-kernel@lists.infradead.org; > robin.murphy@arm.com; will@kernel.org; joro@8bytes.org; > kevin.tian@intel.com; nicolinc@nvidia.com; mshavit@google.com; > eric.auger@redhat.com; joao.m.martins@oracle.com; jiangkunkun > ; zhukeqian ; Linuxarm > > Subject: Re: [PATCH 5/5] iommu/arm-smmu-v3: Enforce dirty tracking in domain > attach/alloc > > On Tue, Nov 28, 2023 at 09:49:40AM +0000, Shameer Kolothum wrote: > > @@ -2701,6 +2703,9 @@ static int arm_smmu_attach_dev(struct > iommu_domain *domain, struct device *dev) > > master = dev_iommu_priv_get(dev); > > smmu = master->smmu; > > > > + if (domain->dirty_ops && !arm_smmu_dbm_capable(smmu)) > > + return -EINVAL; > > + > > This is not necessary, a domain can be attached to a single smmu and > finalize was run on that smmu already. So dirty ops should only be set > if this is a S1 domain finalized ona smmu that was dbm capable. > > Otherwise none of this makes any sense. > > > @@ -3104,6 +3115,9 @@ arm_smmu_domain_alloc_user(struct device *dev, > u32 flags, > > > > smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED; > > smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops; > > + if (enforce_dirty) > > + smmu_domain->domain.dirty_ops = &arm_smmu_dirty_ops; > > Ah, this seems in the wrong place, perhaps that is the confusion > everywhere? > > If the finalize actually enables dirty tracking in the pgtbl_ops then > it should set the diryty_ops, they should not be set in alloc_user. > > Specifically, a S2 domain should never have dirty_ops set. > > IOW if domain.dirty_ops != NULL then pgtbl_ops != NULL && pgtbl_ops- > >read_and_clear_dirty > > Thus no need to have all the other prints/etc then. > > So I'd move this into finalize. Ok. Make sense. I will move it. > > > @@ -4152,11 +4166,13 @@ static void arm_smmu_get_httu(struct > arm_smmu_device *smmu, u32 reg) > > > > if (smmu->dev->of_node) > > smmu->features |= features; > > - else if (features != fw_features) > > + else if (features != fw_features) { > > /* ACPI IORT sets the HTTU bits */ > > dev_warn(smmu->dev, > > - "IDR0.HTTU overridden by FW configuration (0x%x)\n", > > + "IDR0.HTTU not overridden by FW configuration > (0x%x)\n", > > fw_features); > > + smmu->features |= features; > > + } > > } > > Is this hunk misplaced? Oops... My bad. Added for testing. Thanks, Shameer _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel