Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755587AbdCGOXr (ORCPT ); Tue, 7 Mar 2017 09:23:47 -0500 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:14944 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755307AbdCGOWz (ORCPT ); Tue, 7 Mar 2017 09:22:55 -0500 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=cavium.com; Date: Tue, 7 Mar 2017 15:06:07 +0100 From: Robert Richter To: Robin Murphy Cc: Will Deacon , Joerg Roedel , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/arm-smmu: Report smmu type in dmesg Message-ID: <20170307140607.GY16822@rric.localdomain> References: <20170306135833.21455-1-rrichter@cavium.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.224.62.163] X-ClientProxiedBy: AM5PR0101CA0007.eurprd01.prod.exchangelabs.com (10.169.240.17) To BY2PR07MB2344.namprd07.prod.outlook.com (10.166.114.146) X-MS-Office365-Filtering-Correlation-Id: dcdfa281-4565-43a3-f3f0-08d465631f7a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR07MB2344; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2344;3:XeaVjiDIHi4alaKYczwklSvyPmxIhCszgI2PEN8eVTdoNaTFqQjRzJ5Z5JfPhp/7aWJ6iHE/amArrda13cakoLcjOq239v4jo16NchVRlMY7+87XOXG+zkiyuJkrvXc0GAqMqnQEP5IbRkTTS1BQti6jsKG4hs/aoq0f3rab6stmNy/udtDZlfZMZEyom6g9lRqhxnnOTzUvbbSVGwr1ToMj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v6VGm0x6SUh0775sxz/7ziYNRO6qw7Py9JgUEcsNRH4BzLplYBVSqddLI4F2fOJikuyR5xqeOmfR47bqHJ81iQTglXkV/ghBhX8uHYzAk9l3Fu+bPWGPUXfOOm4dQ4PIiKpCpFpqDPHmBucIYCxriIBpcD2QSn5omhvL7/G/QMICwPRBnQAIivJyRsHit4AXBZRNFc0UN+Hu2Hk5umS8NJDi26ZDkA+bGWgJwZG7omh3mBKd7ohBe+Fc2CqFBKTkSabu8MsK0GndQXgNNT+8mS9qqrC5vfELSJRCRV+E X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(20161123558025)(6072148);SRVR:BY2PR07MB2344;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB2344; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2344;4:1VzcpRgQ48P4vs63bLZ6OyxY3jXBjqDsfeb/RC0VFK7eXHkgO/EaI7KPzCDUPoOPsS3VNNBpZzCFBJXMJaaeTOalRM31y5Dv+RcusrPL7aIIBXDPYRD0e4Wt0/VV51t55tuhUvnmbsU1DfS4udRIXMUvALu0Twvvw+bptNaV9J8TKc5X0VYwvJVZt/3WPYBRZcQEEVuDM0CdV0gYcLimjsFWDwBHQHOuRCoV3sIlF0evLzMndGnL6IOgOvxjvWMH2IneK08jO+ZqSgsfZvAxxQRcRpFNeCkLQU16Ts3Lktv8KbI7NP1MCb4mjmBriE2FCcrHL7GU83JGao00rvntaQkDtdVIyN75KKS8wF9P/7sTV8urwyy7o+qzUTM5SM7p+s11783syXSHMBCJ5zS8FCcquWqjvsfgH35t9x0Jm3tKze5Mr12uswqvzsnxMdrm729Ii2BtbVFR9DXreLwTnIYk8pkk521SbSf1/tfOubaH7/sQNsZlM5IDDXw4bjz3tcijkGlN1Ac5/cMnbpPu8DxW4wWDuReMFnh222KnjaW53+DeyDEWLrVjP3UiIR+Qr6w/LvYmuIset6+AK1NSS7INbOBbUrrVa26PZv2It1M= X-Forefront-PRVS: 0239D46DB6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(24454002)(51914003)(38730400002)(345774005)(6246003)(53546006)(6916009)(2950100002)(5660300001)(110136004)(229853002)(33656002)(6666003)(9686003)(86362001)(53936002)(6116002)(3846002)(42186005)(4001350100001)(23676002)(54356999)(54906002)(1076002)(50986999)(189998001)(2906002)(25786008)(305945005)(50466002)(83506001)(6506006)(4326008)(2870700001)(7736002)(66066001)(81166006)(55016002)(47776003)(8676002)(76176999)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB2344;H:rric.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjA3TUIyMzQ0OzIzOnJTTk1sS3dTU2krNUM2OWVHY0xBc0huM1Yw?= =?utf-8?B?a0pEZGU2TVAreGJlU2JVSmJ6NDJyRHpMdlFOUkZzWXgwRXR3ZFMvL3BMemUv?= =?utf-8?B?dDcydGpyaFU5b3BrbHE2dDFVWEFSMjJIN1RSeGQ1emhzKzk0SFE2L3dzRDdO?= =?utf-8?B?Mk9LV09qVUF6amVlSkYrbWlncGtwRCtNc1lWRGxHOEFHZHZvdm5Ma2wwNnVq?= =?utf-8?B?OHNSV2l4YitzaEsrUU5pZUdCNzZ3UTNOcm9WY0FqbmFSZXFPOGV3Z0hoMCtK?= =?utf-8?B?NDVpRGgzNFBBaE53aThKWCtSSFBSeC84aFU1NUo0QXpOYnJRcTMwbGNDN015?= =?utf-8?B?YVA0Nzd4N29HWmJTVjlYWkJ5TisrR1M2bzlWYzRRalJFN0xKQU1MNFFFMnlt?= =?utf-8?B?QlNPQ1FjWGU5YzNxNHZrTUpSZDZuN0kwc0RlQ3VSM3FtT0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wFF+2HQYT7uKD2laLD5TWg2qayOdzWerzqJSkzncp8sn7DQtMOGmo1FHp/qFZjEa6rIKQ7Iw+PaeXrK6H2ieCBqNNNQYNnX2qt3BfB/D/TiV0hszaXKrkow3LuBJbSlFREzgA1zk6w5ldqvq5DxytyoKmML+UyTafDBaXd9lU2ZO6fEhfOcuHI0QToiyeeJ2g/YPJJnwqj6fZK0MLl9KgucE9kT87nlQwePMqx7p1qmpaG2uvx2iiM/3JG8FiovI31Cd2jnStMKh51jI8Y5JyLmrrIgPo8csS5jMz/TQZQvFZCJZ0jR2B7xuZoShAykawD1Q== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2017 14:06:15.4776 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB2344 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4909 Lines: 115 On 06.03.17 18:22:08, Robin Murphy wrote: > On 06/03/17 13:58, Robert Richter wrote: > > The ARM SMMU detection especially depends from system firmware. For > > better diagnostic, log the detected type in dmesg. > > This paragraph especially depends from grammar. I think. Thanks for the mail on you. :) > > > The smmu type's name is now stored in struct arm_smmu_type and ACPI > > code is modified to use that struct too. Rename ARM_SMMU_MATCH_DATA() > > macro to ARM_SMMU_TYPE() for better readability. > > > > Signed-off-by: Robert Richter > > --- > > drivers/iommu/arm-smmu.c | 61 ++++++++++++++++++++++++------------------------ > > 1 file changed, 30 insertions(+), 31 deletions(-) > > That seems a relatively invasive diffstat for the sake of printing a > string once at boot time to what I can only assume is a small audience > of firmware developers who find "cat > /sys/firmware/devicetree/base/iommu*/compatible" (or the ACPI > equivalent) too hard ;) Reading firmware data is not really a solution as you don't know what the driver is doing with it. The actual background of this patch is to be sure a certain workaround was enabled in the kernel. ARM's cpu errata framework does this nicely. In case of smmus we just have the internal model implementation type which is not visible in the logs. Right now, there is no way to figure that out without knowing fw specifics and kernel sources. The change is big but most of it is a reasonable rework anyway. I didn't want to split that into a series of patches. But I could do that. > Assuming there is a really good reason somewhere to justify this, I > still wonder if a simple self-contained "smmu->model to string" function > wouldn't do, if we really want to do this? Maybe it's not quite that > simple if the generic case needs to key off smmu->version as well, but > still. Arguably, just searching the of_match_table by model/version and > printing the corresponding DT compatible would do the job (given an > MMU-400 model to disambiguate those). Whatever you prefer. To me a dynamic search makes things more complex for no benefit. And providing DT names in an ACPI context is confusing either. > Either way it ought to be replacing the "SMMUv%d with:" message in > arm_smmu_device_cfg_probe() - this driver is noisy enough already > without starting to repeat itself. > > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > > index abf6496843a6..5c793b3d3173 100644 > > --- a/drivers/iommu/arm-smmu.c > > +++ b/drivers/iommu/arm-smmu.c > > @@ -366,6 +366,7 @@ struct arm_smmu_device { > > u32 options; > > enum arm_smmu_arch_version version; > > enum arm_smmu_implementation model; > > + const char *name; > > If we are going to add a pointer to static implementation data, it may > as well be a "const arm_smmu_type *type" pointer to subsume version and > model as well. The name still may change but not the particular string. Both work for me. > > > > > u32 num_context_banks; > > u32 num_s2_context_banks; > > @@ -1955,19 +1956,20 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) > > return 0; > > } > > > > -struct arm_smmu_match_data { > > +struct arm_smmu_type { > > enum arm_smmu_arch_version version; > > enum arm_smmu_implementation model; > > + const char *name; > > }; > > > > -#define ARM_SMMU_MATCH_DATA(name, ver, imp) \ > > -static struct arm_smmu_match_data name = { .version = ver, .model = imp } > > +#define ARM_SMMU_TYPE(var, ver, imp, _name) \ > > +static struct arm_smmu_type var = { .version = ver, .model = imp, .name = _name } > > > > -ARM_SMMU_MATCH_DATA(smmu_generic_v1, ARM_SMMU_V1, GENERIC_SMMU); > > -ARM_SMMU_MATCH_DATA(smmu_generic_v2, ARM_SMMU_V2, GENERIC_SMMU); > > -ARM_SMMU_MATCH_DATA(arm_mmu401, ARM_SMMU_V1_64K, GENERIC_SMMU); > > -ARM_SMMU_MATCH_DATA(arm_mmu500, ARM_SMMU_V2, ARM_MMU500); > > -ARM_SMMU_MATCH_DATA(cavium_smmuv2, ARM_SMMU_V2, CAVIUM_SMMUV2); > > +ARM_SMMU_TYPE(smmu_generic_v1, ARM_SMMU_V1, GENERIC_SMMU, "smmu-generic-v1"); > > +ARM_SMMU_TYPE(smmu_generic_v2, ARM_SMMU_V2, GENERIC_SMMU, "smmu-generic-v2"); > > +ARM_SMMU_TYPE(arm_mmu401, ARM_SMMU_V1_64K, GENERIC_SMMU, "arm-mmu401"); > > Strictly, I think you mean "ARMĀ® CoreLinkā„¢ MMU-401". Printing the name > of a driver-internal structure looks like someone left a debugging hack in. > > > +ARM_SMMU_TYPE(arm_mmu500, ARM_SMMU_V2, ARM_MMU500, "arm-mmu500"); > > And similarly. Of course, I'm not actually suggesting that using the > full marketing names of things is a great idea, but then again if we do > go naming specific IPs, and anyone gets sniffy about using the names > "properly", then guess what's going to get removed again? You'll always > find me firmly in the "easier not to go there" camp. A change of naming is unrelated to this patch. I leave this up to you. Thank you for review. -Robert