From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751954AbdIFHRe (ORCPT ); Wed, 6 Sep 2017 03:17:34 -0400 Received: from mail-eopbgr00073.outbound.protection.outlook.com ([40.107.0.73]:54602 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750832AbdIFHR3 (ORCPT ); Wed, 6 Sep 2017 03:17:29 -0400 From: Bharat Bhushan To: Robin Murphy , Marc Zyngier , "robh+dt@kernel.org" , Mark Rutland , "will.deacon@arm.com" , "oss@buserror.net" , Gang Liu , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" Subject: RE: [PATCH] RM64: dts: ls208xa: Add iommu-map property for pci Thread-Topic: [PATCH] RM64: dts: ls208xa: Add iommu-map property for pci Thread-Index: AQHTIjs8I4mAanCpD0a4/V9TcR3UWKKeM5KAgAAItcCAAAzwgIAAB65QgAF79KCAABE2gIAGKyMg Date: Wed, 6 Sep 2017 07:17:24 +0000 Message-ID: References: <1504171424-15536-1-git-send-email-Bharat.Bhushan@nxp.com> <06c57ca4-edaa-df26-b1d9-1906141c5065@arm.com> <10be1849-8071-64fc-5ee2-b6e429c64b9e@arm.com> <901dee07-d1ee-63cc-59a0-bdf37cd7d937@arm.com> In-Reply-To: <901dee07-d1ee-63cc-59a0-bdf37cd7d937@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=bharat.bhushan@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM5PR0401MB2546;6:pt5V0x+n6qycUIcRfaIXXBXwjkK4FF9HSYZsRRjhEVz1XPXmeUL1nihF7eD8B2JCDaKzyM0CSKUVseniWGJyujM7pNEQzpUpmJwaffbE7F/S9lYrsS5eSfWOfH4WkWnaKMVEBDRSyukXng4M/ZFus/pmVoN6+9D/fgv9C3NQvPEdPt3P4EqCZG9NLf2XGpNZbqMH/cjLZOB8JeYKeNXXe97aWeES2X91Jys7y2XN+lyfH+hb+BaqrS6E9a2WjnDTwHZ93OUk+n9ioOyVJs72W2+mr1YK+zIYcsDLaBCwPTlNElrwMicLSa5yqzaHwohhuZVeM5bk40BMJiIDLppCbw==;5:iazlsYniCDcvImSaHj2MIafZa9YE30ktFrdNcddIBItcbWgFfe6Wm74vp52o9Y+PB5cmVVbX37tLgBf5XMzkUQoM/4srb3QssAbKVyKkkztYYcl+B/HCvqDEo8a0F/MHYo27UNE/54IkvegeDdeU1oL/l2Bu9J+BmxAmUWeWAQg=;24:cL5mcjXCXYQhIYKVZzq5Fx4U8P7Dxa9zKuIUL2y21acU/eSM2acpcOxsHGg3eRNXOsFRQBAtnqvTrF4rP8h3PMGx3qZ+gJ17BfMgf35vrD0=;7:Z0NiIIUKp417jCIDYH4I1Lqe1AwVU+xerZpRNcZmWr1sgNv0l1a/m/HRIUKSF65L0hBY5e1EROuzdqd7dulGWimNz3JQAFK/IhjWCNiTTaBT3AS1mf3RMSul1fI+AfG/3WZquUDEd2OJL9q/1MEKkci0IYo6mG6NhlT1alZ2wqG9iStK9R5mFZLqz2b4vh8hbXiMTNTBcabIjSQ2oMixoJEl4f1lLHxYzP7NABlvGMk= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(24454002)(377454003)(13464003)(189002)(199003)(50986999)(53546010)(189998001)(97736004)(101416001)(478600001)(76176999)(54356999)(3280700002)(6506006)(93886005)(6436002)(229853002)(3660700001)(2900100001)(2501003)(5250100002)(14454004)(68736007)(2950100002)(8676002)(7736002)(2906002)(305945005)(81156014)(81166006)(2201001)(99286003)(9686003)(106356001)(105586002)(86362001)(8936002)(6116002)(102836003)(3846002)(33656002)(55016002)(74316002)(7416002)(25786009)(7696004)(53936002)(66066001)(5660300001)(6246003)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0401MB2546;H:AM5PR0401MB2545.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: f06a6815-8746-4956-84b4-08d4f4f752be x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:AM5PR0401MB2546; x-ms-traffictypediagnostic: AM5PR0401MB2546: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(185117386973197)(258649278758335); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0401MB2546;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0401MB2546; x-forefront-prvs: 0422860ED4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2017 07:17:24.6993 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2546 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v867HeSs007977 Hi Robin, > -----Original Message----- > From: Robin Murphy [mailto:robin.murphy@arm.com] > Sent: Friday, September 01, 2017 4:29 PM > To: Bharat Bhushan ; Marc Zyngier > ; robh+dt@kernel.org; Mark Rutland > ; will.deacon@arm.com; oss@buserror.net; Gang > Liu ; devicetree@vger.kernel.org; linux-arm- > kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > catalin.marinas@arm.com > Subject: Re: [PATCH] RM64: dts: ls208xa: Add iommu-map property for pci > > On 01/09/17 11:13, Bharat Bhushan wrote: > > > > > >> -----Original Message----- From: linux-kernel-owner@vger.kernel.org > >> [mailto:linux-kernel- owner@vger.kernel.org] On Behalf Of Bharat > >> Bhushan Sent: Thursday, August 31, 2017 4:53 PM To: Marc Zyngier > >> ; robh+dt@kernel.org; Mark Rutland > >> ; will.deacon@arm.com; oss@buserror.net; > Gang > >> Liu ; devicetree@vger.kernel.org; > >> linux-arm-kernel@lists.infradead.org; linux- kernel@vger.kernel.org; > >> catalin.marinas@arm.com Subject: RE: > >> [PATCH] RM64: dts: ls208xa: Add iommu-map property for pci > >> > >> > >> > >>> -----Original Message----- From: Marc Zyngier > >>> [mailto:marc.zyngier@arm.com] Sent: Thursday, August 31, 2017 > >>> 4:20 PM To: Bharat Bhushan ; > >>> robh+dt@kernel.org; > >> Mark > >>> Rutland ; will.deacon@arm.com; > >> oss@buserror.net; > >>> Gang Liu ; devicetree@vger.kernel.org; > >>> linux-arm-kernel@lists.infradead.org; linux- kernel@vger.kernel.org; > >>> catalin.marinas@arm.com Subject: Re: > >>> [PATCH] RM64: dts: ls208xa: Add iommu-map property for pci > >>> > >>> [Fixing Mark's address...] > >>> > >>> On 31/08/17 11:41, Bharat Bhushan wrote: > >>>> > >>>>> -----Original Message----- From: Marc Zyngier > >>>>> [mailto:marc.zyngier@arm.com] Sent: Thursday, August 31, 2017 > >>>>> 3:02 PM To: Bharat Bhushan ; > >>>>> robh+dt@kernel.org; ark.rutland@arm.com; will.deacon@arm.com; > >>>>> oss@buserror.net; Gang > >>> Liu > >>>>> ; devicetree@vger.kernel.org; linux-arm- > >>>>> kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > >>>>> catalin.marinas@arm.com Subject: Re: [PATCH] RM64: dts: > >>>>> ls208xa: Add iommu-map property for pci > >>>>> > >>>>> On 31/08/17 10:23, Bharat Bhushan wrote: > >>>>>> This patch adds iommu-map property for PCIe, which enables > SMMU > >>>>>> for these devices on LS208xA devices. > >>>>>> > >>>>>> Signed-off-by: Bharat Bhushan --- > >>>>>> arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 4 ++++ 1 file > >>>>>> changed, 4 insertions(+) > >>>>>> > >>>>>> diff --git > >>>>>> a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi > >>>>>> b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi index > >>>>>> 94cdd30..67cf605 100644 --- > >>>>>> a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +++ > >>>>>> b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi @@ -606,6 > >>>>>> +606,7 @@ num-lanes = <4>; bus-range = <0x0 0xff>; > >>>>>> msi-parent = <&its>; + iommu-map = <0 &smmu 0 > 1>; /* This > >>>>>> is fixed-up by > >>>>> u-boot */ > >>>>> > >>>>> What does this do when your version of u-boot doesn't fill this in > >>>>> for > >> you? > >>>> > >>>> Good question, frankly I have not thought of this case before. > >>>> But if we pass length = 0 in above property then no fixup happen > >>>> with happen with older u-boot. In this case > >>>> of_iommu_configure() will return NULL iommu-ops and it switch to > >>>> swio-tlb. Will that work? > >>> I really don't like this. You rely on having invalid data in the DT, > >>> and that seems just wrong. > >>> > >>> Why can't u-boot just generate that property, and we leave the DT > >>> alone? > >> > >> We do not have smmu phandle allowing uboot to generate this. > >> > >>> Or even better, you provide the right information for the few boards > >>> that are based on this SoC, not relying on u-boot for anything that > >>> is in the kernel tree? > >> > >> On our platforms we have a h/w table which converts RID->Device-Id. > >> I will check what will happen if that table is not initialized, can > >> RID be equal to device-id is that case. If that will be allowed than > >> we can give right information that will work with u-boot not updating > >> this property. > > > > U-boot uses a stream-id allocator and programs the h/w mapping table > > (rid to sid mapping table). Also it updates iommu-map property > > accordingly. But If u-boot does not update iommu-map than we cannot > > have a valid full proof solution as stream-id allocation can change in > > u-boot. > > > > So the other option of u-boot generating this entry seems correct > > solution. This requires u-boot to know iommu-phandle, something > > similar to "msi-parent" used for "msi-map" Device-tree binding need > > change to add iommu-phandle/iommu-parent for this. > > From what I know of this hardware, it's going to be rather difficult to concoct > a DT which reflects the initial hardware state accurately *and* works > correctly without updating u-boot in lockstep. IIRC, I believe the accurate > description for an unprogrammed LUT would be "everything comes out on > the default ID, which defaults to 0", i.e.: > > iommu-map-mask = <0x0>; > iommu-map = <0x0 &smmu 0x0 0x1>; These changes are not enough to make PCI devise working with LUT disabled, also needed msi-map maps all requester-id to "0", using "msi-map-mask = 0x0". Why we assume that no "msi-map" property means untranslated requested-id, why not consider that translated to "0". > > (assuming the SMMU has stream-id-mask set appropriately too) > > That's OK except if u-boot updates the map without removing the mask, > whereupon things will go wrong, and I guess that would be the case with > current u-boot :( > > However, the existing MSI description is already bogus - if u-boot didn't > program the LUT, the ITS driver would treat the invalid "msi-parent" property > as this: > > msi-map = <0x0 &its 0x0 0xffff>; > > which means that nobody other than 0:0.0 has working MSIs anyway. We can have following version of u-boot: 1) No LUT setup, does not generate msi-map and does not update/generate iommu-map (older u-boot) For this case the working device tree changes can be: iommu-map-mask = <0>; iommu-map = <0x0 &smmu 0 0x1>; msi-map-mask = <0x0>; msi-map = <0x0 &its 0 0x1>; But these changes will not work with current version of u-boot (below (2)) 2) LUT setup and msi-map generated but no iommu-map generated (current case) I do not see we can have a working device tree for this. Probably generating iommu-map in u-boot is better, with that msi-map and iommu-map will be consistent (below (4)) 3) LUT setup, "msi-map" generated and iommu-map updated We can have below change is device tree. iommu-map = <0x0 &smmu 0 0x1>; But this change will not work with (1) and (2) above. 4) LUT setup, "msi-map" generated and iommu-map also generated by u-boot. There is no iommu-map entry needed in device tree but u-boot need to know iommu phandle. While iommus is supposed to be used in iommu-node and not in pci node. Looking for suggestion Thanks -Bharat > > If you want an obviously-invalid placeholder equivalent to the use of "msi- > parent" then I'd suggest just: > > iommus = <&smmu>; > > which would be ignored by Linux for PCI devices, so provided you didn't > disable bypass at the SMMU things might in theory still work in the "u-boot > does nothing" case. Otherwise, the implied identity map is probably slightly > preferable to the unit-length map, i.e.: > > iommu-map = <0x0 &smmu 0x0 0xffff>; > > which is at least equally broken as MSIs in the same situation. > > Robin.