Gen3 IPMMU and DU prototype
Subsystems (8)
Magnus Damm
maintainerPATCH 1/1 Gen3 IPMMU and DU prototype
From: Magnus Damm <[email protected]>
Here is yet another IPMMU hack but this time for Gen3.
The VGA port on r8a7795 Salvator-X may be used to test the IPMMU via the DU and the modetest utility. At this point this patch does not work as expected, but something seems to happen at least.
On the r8a7795 Salvator-X board the VGA port is driven by DU and VSPD instances. The IPMMU on r8a7795 seems to be tied to via uTLBS not to the VSPD instances directy but instead by going through FCPVD instances. These FCPVD instances may require some setup and they have their own MSTP bits to just make things more fun.
To keep things simple this prototype patch modifies the DU driver to only use a single crtc and a single VSPD with a single uTLB. When IPMMU is enabled the idea is that the map/umap debug printk() will show how the pages are mapped. Unfortunately I have not been able to get the same result as on Gen2 so when the IPMMU is enabled then the test image is incorrect.
From what I can tell the biggest challenges when it comes to enabling IPMMU together with DU, VSPD and FCPVD on Gen3 seems to be:
- FCPVD needs software support (collides with Gen2 VSP1 space).
- The DU driver must be adjusted somehow to be able to pass separate device pointers to dma_alloc_writecombine() so the correct IPMMU uTLB will be used. See HACK below.
I'll try to separate and clean up some portions of the IPMMU driver changes below and validate both on Gen2 and Gen3. Especially the probe ordering and IRQ handling should be possible to reuse.
This prototype patch is not for upstream merge.
---
Built on top of vsp1-kms-gen3-20150929 plus...
The following from linux-next:
iommu/iova: Avoid over-allocating when size-aligned
iommu: iova: Move iova cache management to the iova library
iommu: iova: Export symbols
iommu: Make the iova library a module
And the following patches are picked from mailing lists:
[PATCH v5 1/3] iommu: Implement common IOMMU ops for DMA mapping [PATCH v5 2/3] arm64: Add IOMMU dma_ops
[PATCH v5 3/3] arm64: Hook up IOMMU dma_ops
arch/arm64/boot/dts/renesas/r8a7795.dtsi | 16 +++ drivers/clk/shmobile/clk-mstp.c | 14 +++ drivers/gpu/drm/rcar-du/rcar_du_drv.c | 4 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 2 drivers/iommu/Kconfig | 6 - drivers/iommu/ipmmu-vmsa.c | 135 ++++++++++++++---------------- drivers/media/platform/vsp1/vsp1_wpf.c | 2 7 files changed, 102 insertions(+), 77 deletions(-)
arch/arm64/boot/dts/renesas/r8a7795.dtsi +15 -1
@@ -430,6 +430,7 @@ R8A7795_CLK_VSPI2 R8A7795_CLK_VSPI1 R8A7795_CLK_VSPI0 >; + force-enable = <0 1 2 3>; }; mstp7_clks: mstp7@e615014c {
@@ -488,6 +489,15 @@ /* Empty node for now */ }; + ipmmuvi: mmu@febd0000 { + compatible = "renesas,ipmmu-vmsa"; + reg = <0 0xfebd0000 0 0x1000>; + interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>; + #iommu-cells = <1>; + status = "okay"; + }; + scif0: serial@e6e60000 { compatible = "renesas,scif-r8a7795", "renesas,scif"; reg = <0 0xe6e60000 0 64>;
@@ -624,6 +634,7 @@ reg = <0 0xfea20000 0 0x8000>; interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>; clocks = <&mstp6_clks R8A7795_CLK_VSPD0>; + iommus = <&ipmmuvi 8>; renesas,has-bru; renesas,has-lif;
@@ -637,6 +648,7 @@ reg = <0 0xfea28000 0 0x8000>; interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>; clocks = <&mstp6_clks R8A7795_CLK_VSPD1>; + iommus = <&ipmmuvi 9>; renesas,has-bru; renesas,has-lif;
@@ -650,6 +662,7 @@ reg = <0 0xfea30000 0 0x8000>; interrupts = <GIC_SPI 468 IRQ_TYPE_LEVEL_HIGH>; clocks = <&mstp6_clks R8A7795_CLK_VSPD2>; + iommus = <&ipmmuvi 10>; renesas,has-bru; renesas,has-lif;
@@ -663,6 +676,7 @@ reg = <0 0xfea38000 0 0x8000>; interrupts = <GIC_SPI 469 IRQ_TYPE_LEVEL_HIGH>; clocks = <&mstp6_clks R8A7795_CLK_VSPD3>; + iommus = <&ipmmuvi 11>; renesas,has-bru; renesas,has-lif;
@@ -688,7 +702,7 @@ clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0"; status = "disabled"; - vsps = <&vspd0 &vspd1 &vspd2 &vspd3>; + vsps = <&vspd0>; ports { #address-cells = <1>;
drivers/clk/shmobile/clk-mstp.c +14 -0
@@ -244,6 +244,20 @@ static void __init cpg_mstp_clocks_init(kfree (allocated_name); } +for (i =0 ; i <MSTP_MAX_CLOCKS ; ++i) { +u32 clkidx; +u32 value; + +if (of_property_read_u32_index (np,"force-enable" , + i, &clkidx) <0 ) +break ; + +/* enable bit */ + value =clk_readl (group->smstpcr); + value &= ~(1 << clkidx); +clk_writel (value, group->smstpcr); + } +of_clk_add_provider (np, of_clk_src_onecell_get, &group->data); }CLK_OF_DECLARE (cpg_mstp_clks,"renesas,cpg-mstp-clocks" , cpg_mstp_clocks_init);
drivers/gpu/drm/rcar-du/rcar_du_drv.c +2 -2
@@ -138,13 +138,13 @@ static const struct rcar_du_device_info .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_EXT_CTRL_REGS | RCAR_DU_FEATURE_VSP1_SOURCE, - .num_crtcs = 4, + .num_crtcs = 1, .routes = {/* R8A7795 has one RGB output, one LVDS output and two * (currently unsupported) HDMI outputs. */ [RCAR_DU_OUTPUT_DPAD0] = { - .possible_crtcs = BIT(3), + .possible_crtcs = BIT(0), .encoder_type = DRM_MODE_ENCODER_NONE, .port = 0, },
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2 -0
@@ -329,6 +329,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp vsp->vsp = &pdev->dev; + rcdu->ddev->dev = vsp->vsp;// HACK + ret =vsp1_du_init (vsp->vsp);if (ret <0 )return ret;
drivers/iommu/Kconfig +3 -3
@@ -43,7 +43,7 @@ config IOMMU_IO_PGTABLE_LPAE_SELFTEST endmenu config IOMMU_IOVA - tristate + bool config OF_IOMMU def_bool y
@@ -331,8 +331,8 @@ config SHMOBILE_IOMMU_L1SIZE config IPMMU_VMSA bool "Renesas VMSA-compatible IPMMU" - depends on ARM_LPAE - depends on ARCH_SHMOBILE || COMPILE_TEST + depends on ARM_LPAE || ARM64 + depends on ARCH_SHMOBILE || ARCH_RENESAS || COMPILE_TEST select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU
drivers/iommu/ipmmu-vmsa.c +65 -70
268 lines not on this page · raw message
drivers/media/platform/vsp1/vsp1_wpf.c +1 -1
@@ -158,7 +158,7 @@ static int wpf_s_stream(struct v4l2_subdif (vsp1->info->uapi)mutex_lock (wpf->ctrls.lock); outfmt |= wpf->alpha->cur.val <<VI6_WPF_OUTFMT_PDV_SHIFT ; -vsp1_wpf_write (wpf,VI6_WPF_OUTFMT , outfmt); +vsp1_wpf_write (wpf,VI6_WPF_OUTFMT , outfmt | (1 <<20 ));if (vsp1->info->uapi)mutex_unlock (wpf->ctrls.lock);