From patchwork Wed Dec 26 01:54:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1910481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 14546DF23A for ; Wed, 26 Dec 2012 02:01:16 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TngFV-0002hH-KT; Wed, 26 Dec 2012 01:57:38 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TngCd-0000tG-KN for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 01:54:42 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MFM001IT7XPIIE0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 10:54:26 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EA.46.01231.2D85AD05; Wed, 26 Dec 2012 10:54:26 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-c6-50da58d20c50 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 4A.46.01231.2D85AD05; Wed, 26 Dec 2012 10:54:26 +0900 (KST) Received: from DOPULLIPCHO06 ([12.23.118.152]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MFM000CY7YQXN30@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 10:54:26 +0900 (KST) From: Cho KyongHo To: 'Linux ARM Kernel' , 'Linux IOMMU' , 'Linux Kernel' , 'Linux Samsung SOC' Subject: [PATCH v6 11/12] iommu/exynos: add literal name of System MMU for debugging Date: Wed, 26 Dec 2012 10:54:26 +0900 Message-id: <003e01cde30b$ef82bb00$ce883100$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3jC+9VPiB0na4IQwKl/fER3uj6lw== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsVy+t8zI91LEbcCDLp7zC02Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfGhR1/mApWalbMmzedtYFxt2IXIyeHhICJxJZXr9khbDGJC/fW s3UxcnEICSxjlHh4awEbTNHfidMYIRKLGCW2bmpjhnCWM0k0nr3IBFLFJqAlsXrucUYQW0Tg LqPEy/M8IEXMAn8ZJT6dOQS2Q1ggTOL30vtANgcHi4CqxJL5ViBhXgFbiekvtzNC2IISPybf YwGxmQUMJN7P6mOFsOUlNq95ywzSKiGgLvHory7EKj2JXVM6ocpFJPa9eAc2hkVAQOLb5EMs EOWyEpsOgJ0sIdDNLvH0+W4miMckJQ6uuMEygVFsFpLNs5BsnoVk8ywkKxYwsqxiFE0tSC4o TkrPNdQrTswtLs1L10vOz93ECIkVqR2MKxssDjEKcDAq8fBu/H4zQIg1say4MvcQowQHs5II r/NHoBBvSmJlVWpRfnxRaU5q8SFGH6DLJzJLiSbnA+M4ryTe0NjYxMzE1MTc0tTcFIewkjhv s0dKgJBAemJJanZqakFqEcw4Jg5OqQbGSVJfjFtSmKrelfd4pGv+s/nLM03J5vWRQ5dERc7v vBXg7f/PJLrk1Ja3es1cWaLrDnosOKvx4syfu1wr+D0Z1546rdLi8S1yRVrAYg21FRf0a+Ik Fx54FPFWZ9ujrpoU1meB7GuYbzNGO1os+XWl6tjXpmvVl7ieTlDg0DjQ+Nrox6zT/653KbEU ZyQaajEXFScCAPG9Ls/CAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsVy+t9jAd1LEbcCDD7PMrTY9PgaqwOjx+Yl 9QGMUQ2MNhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlA U5UUyhJzSoFCAYnFxUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhHWMGRd2/GEqWKlZMW/edNYG xt2KXYycHBICJhJ/J05jhLDFJC7cW8/WxcjFISSwiFFi66Y2ZghnOZNE49mLTCBVbAJaEqvn HgfrEBG4yyjx8jwPSBGzwF9GiU9nDrGDJIQFwiR+L70PZHNwsAioSiyZbwUS5hWwlZj+cjsj hC0o8WPyPRYQm1nAQOL9rD5WCFteYvOat8wgrRIC6hKP/upCrNKT2DWlE6pcRGLfi3eMExgF ZiGZNAvJpFlIJs1C0rKAkWUVo2hqQXJBcVJ6rqFecWJucWleul5yfu4mRnAkPpPawbiyweIQ owAHoxIP78bvNwOEWBPLiitzDzFKcDArifA6fwQK8aYkVlalFuXHF5XmpBYfYvQB+nMis5Ro cj4wSeSVxBsam5gZWRqZWRiZmJvjEFYS5232SAkQEkhPLEnNTk0tSC2CGcfEwSnVwKj52NLX 59qpld4h62v8nrzceTv2rwnTmdkXL6osfMATvuajhPA2/gqRtI4XOwu9L8lwHbB4/1bjjdd6 acH1c6anNzRsdLfecUzy9pn/BVXc2epsgstb5h74ymZUKxZ0+a/V3L2NWz6un59y03EKc7NA KpN7XX51V9XHgr/a3Y6Z6+Zfr7rFzajEUpyRaKjFXFScCACS8aMX8QIAAA== X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121225_205440_169865_6A8BA3A7 X-CRM114-Status: GOOD ( 17.05 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 T_MANY_HDRS_LCASE Odd capitalization of multiple message headers Cc: 'Kukjin Kim' , 'Hyunwoong Kim' , 'Prathyush' , 'Joerg Roedel' , 'Subash Patel' , 'Rahul Sharma' X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This commit adds System MMU name to the driver data of each System MMU. It is used by fault information. Signed-off-by: KyongHo Cho --- drivers/iommu/exynos-iommu.c | 72 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 70921e9..9753e0e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -180,6 +181,7 @@ struct exynos_iommu_domain { short *lv2entcnt; /* free lv2 entry counter for each section */ spinlock_t lock; /* lock for this structure */ spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */ + const char *fault_info; /* debugging information for fault */ }; /* exynos_iommu_owner @@ -224,6 +226,7 @@ struct sysmmu_drvdata { struct iommu_domain *domain; unsigned long pgtable; bool runtime_active; + const char **mmuname; void __iomem *sfrbases[0]; }; @@ -601,25 +604,29 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) { /* SYSMMU is in blocked when interrupt occurred. */ struct sysmmu_drvdata *data = dev_id; - struct resource *irqres; - struct platform_device *pdev; + struct exynos_iommu_owner *owner = NULL; enum exynos_sysmmu_inttype itype = SYSMMU_FAULT_UNKNOWN; unsigned long addr = -1; - int i, ret = -ENOSYS; - spin_lock(&data->lock); + if (data->master) + owner = data->master->archdata.iommu; + + if (owner) + spin_lock(&owner->lock); WARN_ON(!is_sysmmu_active(data)); - pdev = to_platform_device(data->sysmmu); - for (i = 0; i < (pdev->num_resources / 2); i++) { - irqres = platform_get_resource(pdev, IORESOURCE_IRQ, i); + for (i = 0; i < data->nsfrs; i++) { + struct resource *irqres; + irqres = platform_get_resource( + to_platform_device(data->sysmmu), + IORESOURCE_IRQ, i); if (irqres && ((int)irqres->start == irq)) break; } - if (i < pdev->num_resources) { + if (i < data->nsfrs) { itype = (enum exynos_sysmmu_inttype) __ffs(__raw_readl(data->sfrbases[i] + REG_INT_STATUS)); if (WARN_ON(!((itype >= 0) && (itype < SYSMMU_FAULT_UNKNOWN)))) @@ -629,11 +636,17 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) data->sfrbases[i] + fault_reg_offset[itype]); } - if (data->domain) + if ((itype >= SYSMMU_FAULTS_NUM) || (itype < SYSMMU_PAGEFAULT)) + itype = SYSMMU_FAULT_UNKNOWN; + + if (data->domain) { + struct exynos_iommu_domain *priv = data->domain->priv; + priv->fault_info = data->mmuname[i]; ret = report_iommu_fault(data->domain, data->master, addr, itype); - else + } else { __show_fault_information(__va(data->pgtable), itype, addr); + } if (ret == -ENOSYS) pr_err("NO SYSTEM MMU FAULT HANDLER REGISTERED FOR %s\n", @@ -651,7 +664,8 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) sysmmu_unblock(data->sfrbases[i]); - spin_unlock(&data->lock); + if (owner) + spin_unlock(&owner->lock); return IRQ_HANDLED; } @@ -1028,6 +1042,30 @@ err_dev_put: return ret; } +static void __init __sysmmu_init_mmuname(struct device *sysmmu, + struct sysmmu_drvdata *drvdata) +{ + int i; + const char *mmuname; + + if (of_property_count_strings(sysmmu->of_node, "mmuname") != + drvdata->nsfrs) + return; + + drvdata->mmuname = (void *)drvdata->sfrbases + + sizeof(drvdata->sfrbases[0]) * drvdata->nsfrs; + + for (i = 0; i < drvdata->nsfrs; i++) { + if (of_property_read_string_index(sysmmu->of_node, + "mmuname", i, &mmuname)) + dev_err(sysmmu, "Failed read mmuname[%d]\n", i); + else + drvdata->mmuname[i] = kstrdup(mmuname, GFP_KERNEL); + if (!drvdata->mmuname[i]) + drvdata->mmuname[i] = "noname"; + } +} + static int __init exynos_sysmmu_probe(struct platform_device *pdev) { int i, ret; @@ -1039,9 +1077,14 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) return -ENODEV; } + ret = of_property_count_strings(pdev->dev.of_node, "mmuname"); + if (ret != (int)(pdev->num_resources / 2)) + ret = 0; + data = devm_kzalloc(dev, sizeof(*data) - + sizeof(*data->sfrbases) * (pdev->num_resources / 2), + + sizeof(*data->sfrbases) * (pdev->num_resources / 2) + + sizeof(*data->mmuname) * ret, GFP_KERNEL); if (!data) { dev_err(dev, "Not enough memory\n"); @@ -1084,6 +1127,8 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) ret = __sysmmu_setup(dev, data); if (!ret) { + __sysmmu_init_mmuname(dev, data); + data->sysmmu = dev; spin_lock_init(&data->lock); @@ -1211,7 +1256,8 @@ static int exynos_iommu_fault_handler(struct iommu_domain *domain, { struct exynos_iommu_domain *priv = domain->priv; - dev_err(dev, "System MMU Generated FAULT!\n\n"); + dev_err(dev, "System MMU '%s' Generated FAULT!\n\n", + priv->fault_info ? priv->fault_info : ""); __show_fault_information(priv->pgtable, iova, flags); return -ENOSYS;