From patchwork Wed Sep 30 14:22:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 7299001 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05181BEEA4 for ; Wed, 30 Sep 2015 14:22:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B664620684 for ; Wed, 30 Sep 2015 14:22:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3439420676 for ; Wed, 30 Sep 2015 14:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754422AbbI3OWa (ORCPT ); Wed, 30 Sep 2015 10:22:30 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33617 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753844AbbI3OW2 (ORCPT ); Wed, 30 Sep 2015 10:22:28 -0400 Received: by pacex6 with SMTP id ex6so42406524pac.0 for ; Wed, 30 Sep 2015 07:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:subject; bh=G+nnCQTaQcJWCoh07svBZIN1qXG11m0FPmKnyHWpK7E=; b=iBXeJMM37lrYGitZN69p57f3bocSod72Rl5R26S0FqE+/UDldBTQWhCyx8bSlTEAly eUe+vWXv1mrB8azJVbts3r/C876t5aF/Wc2JdXA/d8IGpIeRifK8YNmMPbDwb530rItB yiOZiXytfZgmW6sL4uClPN+q83SdHV17aYMoEDlbh5RJ7WVCOheHvjLRS++6nt5jONif 1e0+NJUa0hNoRKXMoAnWQxA97ie2ApB5O6K1uQIDZduZrvlbtwoh61ROzcLbzdZWx5wS OMK/yI3J3pcV03mU9SJBZwMleh7CCZEBNm6Me8jvF06SLf/x8mhyCrmMYpNwKx2DMgJi nKnQ== X-Received: by 10.66.229.67 with SMTP id so3mr5378791pac.66.1443622947672; Wed, 30 Sep 2015 07:22:27 -0700 (PDT) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id x6sm1099371pbt.3.2015.09.30.07.22.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 07:22:26 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , laurent.pinchart+renesas@ideasonboard.com Date: Wed, 30 Sep 2015 23:22:42 +0900 Message-Id: <20150930142242.25755.81946.sendpatchset@little-apple> Subject: [PATCH] Gen2 IPMMU and DU prototype Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Here is a simple hack to enable the IPMMU on R-Car Gen2. The VGA port on r8a7790 Lager may be driven by the DU and the IPMMU via the modetest utility to output some test image. Actually the r8a7790 DU device is connected to the IPMMU using two separate uTLBs, but the DU driver is currently supporting all DU instances using a single device. To make testing easily the r8a7790 DU driver code is with this patch hacked to just cover a single DU instance with a single IPMMU uTLB. The map/umap debug printk() will show you if the IPMMU is used or not. Another way could be to XOR the physical address in the map routine to adjust the test image. Several sources have told me that the DU on Lager is not working as expected. With this hack (with or without IPMMU) at least the VGA output seems fine. So it would be good to look into HDMI and LVDS as well as unmodified VGA support for the DU on the Lager board. Also, we need to figure out how to modify the DU driver to support multiple uTLBs. Not for upstream merge. Not-Yet-Signed-off-by: Magnus Damm --- arch/arm/boot/dts/r8a7790.dtsi | 3 ++- arch/arm/boot/dts/r8a7791.dtsi | 3 ++- arch/arm/mm/dma-mapping.c | 4 ++-- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 6 +++--- drivers/iommu/ipmmu-vmsa.c | 8 ++++++-- drivers/of/device.c | 6 +++--- 6 files changed, 18 insertions(+), 12 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/arch/arm/boot/dts/r8a7790.dtsi +++ work/arch/arm/boot/dts/r8a7790.dtsi 2015-09-29 15:04:37.540513000 +0900 @@ -882,6 +882,7 @@ <&mstp7_clks R8A7790_CLK_LVDS0>, <&mstp7_clks R8A7790_CLK_LVDS1>; clock-names = "du.0", "du.1", "du.2", "lvds.0", "lvds.1"; + iommus = <&ipmmu_mx 15>; status = "disabled"; ports { @@ -1805,7 +1806,7 @@ interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>, <0 221 IRQ_TYPE_LEVEL_HIGH>; #iommu-cells = <1>; - status = "disabled"; + status = "okay"; }; ipmmu_rt: mmu@ffc80000 { --- 0001/arch/arm/boot/dts/r8a7791.dtsi +++ work/arch/arm/boot/dts/r8a7791.dtsi 2015-09-29 14:15:26.610513000 +0900 @@ -919,6 +919,7 @@ <&mstp7_clks R8A7791_CLK_DU1>, <&mstp7_clks R8A7791_CLK_LVDS0>; clock-names = "du.0", "du.1", "lvds.0"; + iommus = <&ipmmu_mx 15>; status = "disabled"; ports { @@ -1618,7 +1619,7 @@ interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>, <0 221 IRQ_TYPE_LEVEL_HIGH>; #iommu-cells = <1>; - status = "disabled"; + status = "okay"; }; ipmmu_rt: mmu@ffc80000 { --- 0001/arch/arm/mm/dma-mapping.c +++ work/arch/arm/mm/dma-mapping.c 2015-09-29 14:58:51.150513000 +0900 @@ -1998,7 +1998,7 @@ static int __arm_iommu_attach_device(str kref_get(&mapping->kref); to_dma_iommu_mapping(dev) = mapping; - pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev)); + pr_info("Attached IOMMU controller to %s device.\n", dev_name(dev)); return 0; } @@ -2043,7 +2043,7 @@ static void __arm_iommu_detach_device(st kref_put(&mapping->kref, release_iommu_mapping); to_dma_iommu_mapping(dev) = NULL; - pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev)); + pr_info("Detached IOMMU controller from %s device.\n", dev_name(dev)); } /** --- 0001/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ work/drivers/gpu/drm/rcar-du/rcar_du_drv.c 2015-09-29 15:05:31.520513000 +0900 @@ -60,13 +60,13 @@ static const struct rcar_du_device_info .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_EXT_CTRL_REGS, .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES, - .num_crtcs = 3, + .num_crtcs = 2, .routes = { /* R8A7790 has one RGB output, two LVDS outputs and one * (currently unsupported) TCON output. */ [RCAR_DU_OUTPUT_DPAD0] = { - .possible_crtcs = BIT(2) | BIT(1) | BIT(0), + .possible_crtcs = BIT(1) | BIT(0), .encoder_type = DRM_MODE_ENCODER_NONE, .port = 0, }, @@ -76,7 +76,7 @@ static const struct rcar_du_device_info .port = 1, }, [RCAR_DU_OUTPUT_LVDS1] = { - .possible_crtcs = BIT(2) | BIT(1), + .possible_crtcs = BIT(1), .encoder_type = DRM_MODE_ENCODER_LVDS, .port = 2, }, --- 0001/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2015-09-29 15:12:31.610513000 +0900 @@ -7,7 +7,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. */ - +#define DEBUG #include #include #include @@ -544,9 +544,11 @@ static int ipmmu_map(struct iommu_domain { struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); + printk("xxx map 0x%08lx <-> %pad %zu\n", iova, &paddr, size); + if (!domain) return -ENODEV; - + return domain->iop->map(domain->iop, iova, paddr, size, prot); } @@ -555,6 +557,8 @@ static size_t ipmmu_unmap(struct iommu_d { struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); + printk("xxx unmap 0x%08lx %zu\n", iova, size); + return domain->iop->unmap(domain->iop, iova, size); } --- 0001/drivers/of/device.c +++ work/drivers/of/device.c 2015-09-29 15:00:10.680513000 +0900 @@ -124,7 +124,7 @@ void of_dma_configure(struct device *dev dev_err(dev, "Adjusted size 0x%llx invalid\n", size); return; } - dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset); + dev_info(dev, "dma_pfn_offset(%#08lx)\n", offset); } dev->dma_pfn_offset = offset; @@ -139,11 +139,11 @@ void of_dma_configure(struct device *dev DMA_BIT_MASK(ilog2(dma_addr + size))); coherent = of_dma_is_coherent(np); - dev_dbg(dev, "device is%sdma coherent\n", + dev_info(dev, "device is%sdma coherent\n", coherent ? " " : " not "); iommu = of_iommu_configure(dev, np); - dev_dbg(dev, "device is%sbehind an iommu\n", + dev_info(dev, "device is%sbehind an iommu\n", iommu ? " " : " not "); arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);