From patchwork Mon Mar 6 13:58:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 9606203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F0DF60414 for ; Mon, 6 Mar 2017 13:59:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F9D127BE5 for ; Mon, 6 Mar 2017 13:59:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5457528418; Mon, 6 Mar 2017 13:59:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C46227BE5 for ; Mon, 6 Mar 2017 13:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/emgrKnYDAbog+grDttzW4iI8hK5kns5RBukEY+Tsvg=; b=Jf4p8DgOWtZZfd ndMjGODptgy1l/lsSi9yxrpyrpPhn0uC1oQB6fg2XAEY6EJDMWxbDX9ljfC7m6n6rgMhAx3jes4EF GUogfQbrpEmeccSEt66nqfE8fcfQGWZ2tXUjGtVddHbQs1iliHSN4hP5ez05mkjbhAhjVgWN0ApIQ ARcNf25mWYk+FOuygyuO2kSgUrTFbzt+l+H2gn2Llsxlw3g1h5nqGUU2WxikkMC8eP1AoqNSQ4PYm CaHQGkyDavf6jxsJUoqpYRMI0JEy3AJQRrYuYBtVgGX9j07jpJLl6qZuqxIvedKEizjugo8gmRge7 ZHFj+DmriCuCLzaYSi8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cktAc-0002Eh-Qj; Mon, 06 Mar 2017 13:59:26 +0000 Received: from mail-co1nam03on0050.outbound.protection.outlook.com ([104.47.40.50] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cktAY-0001lX-4o for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2017 13:59:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YhoHQSMgBWNJQS835fHAc7XNttRhbF8C2AgDtbfsy9Q=; b=jNAwG20F9jz/I+i7ohLICthqTQttK4KaG8oNWGoMY0vj6srFxpL2lTqdBlNC2vNvUti6er86ShREJIPwoV24PMvDGZUCzeKtkYsFeGICHCwWQ5QO3bjTWMg3nDYm/H2fwOZ1L42iJkrrRSRVEgFwwJRI2QfXXa6dUJhfYbg7CaE= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=cavium.com; Received: from rric.localdomain (92.224.60.20) by BY2PR07MB2343.namprd07.prod.outlook.com (10.166.114.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Mon, 6 Mar 2017 13:58:56 +0000 From: Robert Richter To: Will Deacon , Robin Murphy , Joerg Roedel 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 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==; 25:tuGm5BhEwuF7CF9rPuzaXuy+xKzeL9fRQpKbxqJa8VsBmQnSoMTiPmomT2m8I4dExAWjLO0Lik2V0I1+qbJzbMkTcbk4vz7cUkQy7Y7+UVbI1N+nfjt8DC/o/RN1hcuTUroAK1xPImpPwIXzids7u++wdyFMJp4wCHkyCY4WCi4betICc+Z4vkd14NV93mG0uCeMxAVSvwK4Tsir8TZG4I7bKE1qLsoxuT2XvpG8xaK+wW+RGiEpdUi0yjzX2wITBl+2XgRJixegqqJExdEOtjXfZlN9epsWMY3rjtP08cqgg/TfHhE2mqCCWFVjA1C7BhNT/ywx7Pr4YPBdrQS/2LGNJwwp7CDGNfLNkdluMnvanchMEK7TWrjtPS8UJapzsXtqcs4CWV9QXB29MOHydFtYWZMcpf3ITwpM+56hSmTE1t46QPjZ4I4ebCeJy2Ee8guYIqvR2E/JaQ6WQ8wtlg== X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB2343; 31:X/SPAm/sD2aA2K2ECaUOKNj7fxbzJPndn4ICwhDbLDmcoDgW/4vm51XCQAIktN0q1LpSsUsxnR4Fby+KYgECxv0yOh8xQQZiQyi06yzxx11Ve2JVd80C/a7v9FnXnJrfBJB7GVcZZzusjMlTGldwcjuWiqPGw510EOb/bPMCV9OBp15UirpdGB5R3zpZOXZy9oISrvnvSOTtGvhG+kJitY15y2yQFXlkL0fJEIVtKBM=; 20:XHYtNzHbY9zdFsjkPpcxBy8+7IWcV4kfPw1wMDw0ChB8R+Up/dLf0IWxFM8YSR2p0cptkX4FYXOWOkWGormE3fmnv2yNJRzVoPcqk98iW9xEksOK67jmPT6A/vuvPtwhM1yr+59FvxLxHnpjOtt/fGXeihkJN7nSE3MOGlDgOXYRCQQHzJgGt0PXjNCBlIjhyF+CnBGPfJZPrfsPI0lhhsylnpQy38P+WUptB/Zil7u7EUk5EmiVLiqjUGtptT5hjclHapVyEti3eFzWvpEMut/0az692zs76Pn0GS1olU32LINes+yo7CH7F1iwKCnbM5LKYdnOpKBXXmnSiJ6n+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: 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Vu9hD0fj3EONqPQRaA+ykIQ9c0o21Nel0TYkxfYiUrfvw7lhnDM+YxbgOERMSnJU1qA8hksTBB9NjfN60tzX4g3LTqwCdub9TCVkL2rLKSrErM4ddWwNAkZGsnXbIysaOZ0jDdwdjbeHrAYdILxPs32om9NzTSiwkOoW6wHYBr04Y2xY1RPrlW6tJeOk1UzkQ6rYSMEgiAJ2QoOEORIbV/WpV2/P5MbH8wQIVQ==; 5:cWpNKfPi2MxHtvfR3c22XxZ9qt0/SlvqoJbjA3Dz/HRSxrgg9YZ6ulRV+EqCiGcPI54hKHf+XxzdTnFkB8uqwcsoxDGCKvHDSiwRkdLdkT1Jq/clVXMg+9f8AKxMMy7nqQGg266fHqdhykv/QzcVXg==; 24:okUnHzrcHnaYuAlQSEcE68oC5ifXauKhZ0Nq3z3NO1N6nBqd19N9eBJ0rMA6Hri/5gjlr3o+NMHj8jaG+udF3G2Z4tDLFj4UL5or9htqiWU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB2343; 7:QHj2FhKt45DU7SaVyOtky+ryt5o2M2OFXjQLOpy6DznIJ5/QI8Ge0nnnBhpWFj64QbVGi2OQUF/0YzzUGFrX7y/D+YRE4O4Ca+mn6katwHYDhjcIDtMGURZUCLPUHEA4mgYR+43imetlW382go5QlLaWDGsgrxZD3IlngCYaqTEfF9QCKNZRut7QHAW+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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170306_055922_314258_3B53D975 X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robert Richter , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);