Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754112AbdCFOGR (ORCPT ); Mon, 6 Mar 2017 09:06:17 -0500 Received: from mail-co1nam03on0074.outbound.protection.outlook.com ([104.47.40.74]:24032 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753701AbdCFN7H (ORCPT ); Mon, 6 Mar 2017 08:59:07 -0500 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=cavium.com; From: Robert Richter To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Robert Richter , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/arm-smmu: Report smmu type in dmesg Date: Mon, 6 Mar 2017 14:58:32 +0100 Message-Id: <20170306135833.21455-1-rrichter@cavium.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [92.224.60.20] X-ClientProxiedBy: DB6PR1001CA0015.EURPRD10.PROD.OUTLOOK.COM (10.171.79.25) To BY2PR07MB2343.namprd07.prod.outlook.com (10.166.114.145) X-MS-Office365-Filtering-Correlation-Id: 799d5a9e-a847-4bbb-c6c9-08d46498efc6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR07MB2343; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2343;3:Stb5r16J0tepFf1oZiEzshxpTtEtM1UvdsxBjQaz4rZqfgGSRu5VRLCSwivKXklW+ZPOY8whFS2s8gnMijCcEmrLndzLnPPIehbP26HA+A+iQHrBjCwKRPrt/ikpnPfHj/mGDPb0Z/1sr4fKJHg1eAQjy6uLTbXRiE30lCFxOVK+iwt0+JUhFo6BViYa8dOdP0O8rvyBdaWb62B7XglZHx6VFWSUyzrBDgb++4lhUdWI4K6m/5xlmtLYbx0HgFya9c3PAq81u0cAvDcJazTW5A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XmnSiJ6n+z7w1tv/P/03buG8Oywi/AcFH4RKQ2KRaXoWtiV/dVb577jaczQQo8Pfs1hgV6xVfVE5YyyguKksDNvzdOJi3WN08INel2i42HAYghCjap6Hf6Cgq/ETWUEh7eN1FcvD9qypF/9FNLyTksuaRlEvDjZFSZ/PUt8NkuvKrWl37DTk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123558025)(20161123562025)(6072148);SRVR:BY2PR07MB2343;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB2343; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2343;4:iuBDtkw5hbOltLjS941C1EHsLms2soD44n2ypSvA7OvAu6TEmjKwq80Z7Ve90zb/r+nZ6cUjP62ZDadYdgRwWAXDCqJPzYFvpWTFWUjIGLEp+5zDtjmsLOxilNVIVubUiLc5hx33OvZ0wMOgOPrBL9YXsLmiDWHMx5fBLoA4Anx6bR1w3T5DA63LC+4PhRkLe5AHoV68EncHn99yJSxre9FZ3D4zwAW5bH0RRI1GJpYCtV/GjMlX32vzbNgP/5HZWsYonxJwROjOuc0+NEIGxdfJfiVo2pVoNCKZ4FfUUd2KxJ39MjaVXgkpSXVibnfsE7uHo5U0nGKOkepvteRkkGNVTW7muqMnoRBdlLrz3yv7D1n0xu02TOoxu6+38D3/tNBwG7Q5P0eIlGIYnciEUm+QDoKI6r5yLRmKeXlIgO8uAXDPiyYrCmq4k8Kmq2OjKZVm+Rs7R9KLTe9wxhgkn5pCVbA6ZxVciy3uWiRcPK7h0XVPtMIKSAFBA5fVSnCZhw7GzUFx7o4I6bsVRSbJZbFZjVGvAU4UKsyXI12JmkWMaNUC0xMaFTjBgeVWjtDSa8Juqn2gzfU5j9O51yW0DIi//FVmLUN7SnATADuYxCA= X-Forefront-PRVS: 0238AEEDB0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(53936002)(38730400002)(50226002)(50986999)(6666003)(8676002)(81166006)(4326008)(25786008)(47776003)(66066001)(6116002)(189998001)(305945005)(3846002)(7736002)(5003940100001)(6512007)(5660300001)(50466002)(92566002)(36756003)(2906002)(1076002)(42186005)(6506006)(33646002)(48376002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB2343;H:rric.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2343;23:yQIoJYCzXIb5GXxj6O+ksvf6B/qIsAPbVk+tRnP1YUwG/pHMhb6h7ZiitXXWXjM12exJAPeftdZIguLf7a1iubE2WzbJtaQLgaANlF7TB45uZravyRNi3llGxycdh9lv8BCxmMwFls0eOPNEiIMX4oHd79HBiVWkA+2eU5kAfSZSCRATjkelovSZ6sPetxVRuU9VynbQ/+VEUDwJpUpGroZ58lqD0/wZ56t4faDMSG8kdkcDAbvmKcCaMUaQRxFMPA/u5IkdklJnbPc8f290fLbj4r+Mttb+jx+S0HWIIjRQNVhDHJMcXOJMnf/nt2qTpMiopsscM8uE71IADVp4o2AdPrFcRY7pu2QO+VRbMOgR/ceAvrbyPHbjl/KuZXYYSBAu/ezpEdXql7GIUZOcDlywNOVw1mdaV8HrwaYpMSHXP3vNDvQDi5ln8ugdHdqECVAh2rhExj1roSx0yTDMn92O+j/3PXZCqwCcFtYhJTQXNB0asQEuY0F00PMULrA4o96mGa/SQ2s702D5P58+ap6p2A32tb2vlwfK75PF8Q8xWG7n+l0mAOTqDXsf9Q15fTBfmFE/AWRkxlBHENyvp+Cj4u+muXDyni6U0edBXgEjgknibdQxfYb6EKAcNqdjEZrnQmohh8uLt+CilXF0jLp9bUKaSioC3QFgGp98RT9GReBtoomYJs5a6RmnqxDXBTl1GxkVSh3dUwZHP6mdNSXQRr0De9/C8UPgib7KD7X8rH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fF9QCKNZRut7QHAW+y37j7aO2jbmJ/ZY6XL5SjaxTfgMkma1enzvyIgZ2N0hl9Dw5e674CqSBCt++PT9UuIvGZ+efk83vLwFksikLCaiHR/t1C/PyhUWufJ+mX9xxnRuPuix2gmnQW1uDwX+6RTcL4ypLcT3UJm2zxpuhfn0JQA== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2017 13:58:56.9326 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB2343 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4873 Lines: 146 The ARM SMMU detection especially depends from system firmware. For better diagnostic, log the detected type in dmesg. 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(-) 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; 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"); +ARM_SMMU_TYPE(arm_mmu500, ARM_SMMU_V2, ARM_MMU500, "arm-mmu500"); +ARM_SMMU_TYPE(cavium_smmuv2, ARM_SMMU_V2, CAVIUM_SMMUV2, "cavium-smmuv2"); static const struct of_device_id arm_smmu_of_match[] = { { .compatible = "arm,smmu-v1", .data = &smmu_generic_v1 }, @@ -1981,29 +1983,19 @@ static const struct of_device_id arm_smmu_of_match[] = { MODULE_DEVICE_TABLE(of, arm_smmu_of_match); #ifdef CONFIG_ACPI -static int acpi_smmu_get_data(u32 model, struct arm_smmu_device *smmu) +static struct arm_smmu_type *acpi_smmu_get_type(u32 model) { - int ret = 0; - switch (model) { case ACPI_IORT_SMMU_V1: case ACPI_IORT_SMMU_CORELINK_MMU400: - smmu->version = ARM_SMMU_V1; - smmu->model = GENERIC_SMMU; - break; + return &smmu_generic_v1; case ACPI_IORT_SMMU_V2: - smmu->version = ARM_SMMU_V2; - smmu->model = GENERIC_SMMU; - break; + return &smmu_generic_v2; case ACPI_IORT_SMMU_CORELINK_MMU500: - smmu->version = ARM_SMMU_V2; - smmu->model = ARM_MMU500; - break; - default: - ret = -ENODEV; + return &arm_mmu500; } - return ret; + return NULL; } static int arm_smmu_device_acpi_probe(struct platform_device *pdev, @@ -2013,14 +2005,18 @@ static int arm_smmu_device_acpi_probe(struct platform_device *pdev, struct acpi_iort_node *node = *(struct acpi_iort_node **)dev_get_platdata(dev); struct acpi_iort_smmu *iort_smmu; - int ret; + struct arm_smmu_type *type; /* Retrieve SMMU1/2 specific data */ iort_smmu = (struct acpi_iort_smmu *)node->node_data; - ret = acpi_smmu_get_data(iort_smmu->model, smmu); - if (ret < 0) - return ret; + type = acpi_smmu_get_type(iort_smmu->model); + if (!type) + return -ENODEV; + + smmu->version = type->version; + smmu->model = type->model; + smmu->name = type->name; /* Ignore the configuration access interrupt */ smmu->num_global_irqs = 1; @@ -2041,8 +2037,8 @@ static inline int arm_smmu_device_acpi_probe(struct platform_device *pdev, static int arm_smmu_device_dt_probe(struct platform_device *pdev, struct arm_smmu_device *smmu) { - const struct arm_smmu_match_data *data; struct device *dev = &pdev->dev; + const struct arm_smmu_type *type; bool legacy_binding; if (of_property_read_u32(dev->of_node, "#global-interrupts", @@ -2051,9 +2047,10 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, return -ENODEV; } - data = of_device_get_match_data(dev); - smmu->version = data->version; - smmu->model = data->model; + type = of_device_get_match_data(dev); + smmu->version = type->version; + smmu->model = type->model; + smmu->name = type->name; parse_driver_options(smmu); @@ -2098,6 +2095,8 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (err) return err; + dev_notice(dev, "%s detected", smmu->name); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ioaddr = res->start; smmu->base = devm_ioremap_resource(dev, res); -- 2.11.0