aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2019-06-27 19:34:25 -0400
committerDave Airlie <airlied@redhat.com>2019-06-27 20:16:40 -0400
commit53e155f2bbd42df7e8bea87be78f0d60fe9fa122 (patch)
tree8d646dc1f8e5e03d654ce45c610b70f4ebaa8641
parent14808a12bdbdc21143eba70ea07830197b3a04ff (diff)
parent648fdc3f6475d96de287a849a31d89e79ba7669c (diff)
Merge tag 'drm-msm-next-2019-06-25' of https://gitlab.freedesktop.org/drm/msm into drm-next
+ usual progress on cleanups + dsi vs EPROBE_DEFER fixes + msm8998 (snapdragon 835 support) + a540 gpu support (mesa support already landed) + dsi, dsi-phy support + mdp5 and dpu interconnect (bus/memory scaling) support + initial prep work for per-context pagetables (at least the parts that don't have external dependencies like iommu/arm-smmu) There is one more patch for fixing DSI cmd mode panels (part of a set of patches to get things working on nexus5), but it would be conflicty with 1cff7440a86e04a613665803b42034 in drm-next without rebasing or back-merge, and since it doesn't conflict with anything in msm-next, I think it best if Sean merges that through drm-mix-fixes instead. (In other news, I've been making some progress w/ getting efifb working properly on sdm850 laptop without horrible hacks, and drm/msm + clk stuff not totally falling over when bootloader enables display and things are already running when driver probes.. but not quite ready yet, hopefully we can post some of that for 5.4.. should help for both the sdm835 and sdm850 laptops.) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rob Clark <robdclark@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/CAF6AEGsj3N4XzDLSDoa+4RHZ9wXObYmhcep0M3LjnRg48BeLvg@mail.gmail.com
-rw-r--r--Documentation/devicetree/bindings/display/msm/dpu.txt10
-rw-r--r--Documentation/devicetree/bindings/display/msm/dsi.txt1
-rw-r--r--drivers/gpu/drm/msm/adreno/a3xx_gpu.c24
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx.xml.h28
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx_debugfs.c8
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx_gpu.c40
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx_power.c76
-rw-r--r--drivers/gpu/drm/msm/adreno/a6xx_gmu.c70
-rw-r--r--drivers/gpu/drm/msm/adreno/a6xx_gmu.h1
-rw-r--r--drivers/gpu/drm/msm/adreno/a6xx_gpu.c16
-rw-r--r--drivers/gpu/drm/msm/adreno/a6xx_gpu.h2
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_device.c20
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c8
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.h6
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c176
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h4
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c14
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c5
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c110
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c6
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c46
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h6
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c57
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c6
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_trace.h22
-rw-r--r--drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c4
-rw-r--r--drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c3
-rw-r--r--drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c2
-rw-r--r--drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c38
-rw-r--r--drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c3
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi.c2
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi.h7
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_cfg.c21
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_cfg.h1
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_host.c19
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_manager.c149
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy.c6
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy.h5
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c30
-rw-r--r--drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c106
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c34
-rw-r--r--drivers/gpu/drm/msm/msm_drv.h1
-rw-r--r--drivers/gpu/drm/msm/msm_fb.c2
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c6
-rw-r--r--drivers/gpu/drm/msm/msm_gem.h1
-rw-r--r--drivers/gpu/drm/msm/msm_gem_submit.c13
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.c5
-rw-r--r--drivers/gpu/drm/msm/msm_iommu.c2
-rw-r--r--drivers/gpu/drm/msm/msm_perf.c15
-rw-r--r--drivers/gpu/drm/msm/msm_rd.c16
50 files changed, 715 insertions, 538 deletions
diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt b/Documentation/devicetree/bindings/display/msm/dpu.txt
index ad2e8830324e..a61dd40f3792 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -28,6 +28,11 @@ Required properties:
28- #address-cells: number of address cells for the MDSS children. Should be 1. 28- #address-cells: number of address cells for the MDSS children. Should be 1.
29- #size-cells: Should be 1. 29- #size-cells: Should be 1.
30- ranges: parent bus address space is the same as the child bus address space. 30- ranges: parent bus address space is the same as the child bus address space.
31- interconnects : interconnect path specifier for MDSS according to
32 Documentation/devicetree/bindings/interconnect/interconnect.txt. Should be
33 2 paths corresponding to 2 AXI ports.
34- interconnect-names : MDSS will have 2 port names to differentiate between the
35 2 interconnect paths defined with interconnect specifier.
31 36
32Optional properties: 37Optional properties:
33- assigned-clocks: list of clock specifiers for clocks needing rate assignment 38- assigned-clocks: list of clock specifiers for clocks needing rate assignment
@@ -86,6 +91,11 @@ Example:
86 interrupt-controller; 91 interrupt-controller;
87 #interrupt-cells = <1>; 92 #interrupt-cells = <1>;
88 93
94 interconnects = <&rsc_hlos MASTER_MDP0 &rsc_hlos SLAVE_EBI1>,
95 <&rsc_hlos MASTER_MDP1 &rsc_hlos SLAVE_EBI1>;
96
97 interconnect-names = "mdp0-mem", "mdp1-mem";
98
89 iommus = <&apps_iommu 0>; 99 iommus = <&apps_iommu 0>;
90 100
91 #address-cells = <2>; 101 #address-cells = <2>;
diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt b/Documentation/devicetree/bindings/display/msm/dsi.txt
index 9ae946942720..af95586c898f 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -88,6 +88,7 @@ Required properties:
88 * "qcom,dsi-phy-28nm-8960" 88 * "qcom,dsi-phy-28nm-8960"
89 * "qcom,dsi-phy-14nm" 89 * "qcom,dsi-phy-14nm"
90 * "qcom,dsi-phy-10nm" 90 * "qcom,dsi-phy-10nm"
91 * "qcom,dsi-phy-10nm-8998"
91- reg: Physical base address and length of the registers of PLL, PHY. Some 92- reg: Physical base address and length of the registers of PLL, PHY. Some
92 revisions require the PHY regulator base address, whereas others require the 93 revisions require the PHY regulator base address, whereas others require the
93 PHY lane base address. See below for each PHY revision. 94 PHY lane base address. See below for each PHY revision.
diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index c3b4bc6e4155..13078c4975ff 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -395,19 +395,17 @@ static const unsigned int a3xx_registers[] = {
395 0x2200, 0x2212, 0x2214, 0x2217, 0x221a, 0x221a, 0x2240, 0x227e, 395 0x2200, 0x2212, 0x2214, 0x2217, 0x221a, 0x221a, 0x2240, 0x227e,
396 0x2280, 0x228b, 0x22c0, 0x22c0, 0x22c4, 0x22ce, 0x22d0, 0x22d8, 396 0x2280, 0x228b, 0x22c0, 0x22c0, 0x22c4, 0x22ce, 0x22d0, 0x22d8,
397 0x22df, 0x22e6, 0x22e8, 0x22e9, 0x22ec, 0x22ec, 0x22f0, 0x22f7, 397 0x22df, 0x22e6, 0x22e8, 0x22e9, 0x22ec, 0x22ec, 0x22f0, 0x22f7,
398 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2348, 0x2349, 0x2350, 0x2356, 398 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2440, 0x2440, 0x2444, 0x2444,
399 0x2360, 0x2360, 0x2440, 0x2440, 0x2444, 0x2444, 0x2448, 0x244d, 399 0x2448, 0x244d, 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470,
400 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470, 0x2472, 0x2472, 400 0x2472, 0x2472, 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3,
401 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3, 0x24e4, 0x24ef, 401 0x24e4, 0x24ef, 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e,
402 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e, 0x2510, 0x2511, 402 0x2510, 0x2511, 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea,
403 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea, 0x25ec, 0x25ed, 403 0x25ec, 0x25ed, 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617,
404 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617, 0x261a, 0x261a, 404 0x261a, 0x261a, 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0,
405 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0, 0x26c4, 0x26ce, 405 0x26c4, 0x26ce, 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9,
406 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9, 0x26ec, 0x26ec, 406 0x26ec, 0x26ec, 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743,
407 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743, 0x2748, 0x2749, 407 0x300c, 0x300e, 0x301c, 0x301d, 0x302a, 0x302a, 0x302c, 0x302d,
408 0x2750, 0x2756, 0x2760, 0x2760, 0x300c, 0x300e, 0x301c, 0x301d, 408 0x3030, 0x3031, 0x3034, 0x3036, 0x303c, 0x303c, 0x305e, 0x305f,
409 0x302a, 0x302a, 0x302c, 0x302d, 0x3030, 0x3031, 0x3034, 0x3036,
410 0x303c, 0x303c, 0x305e, 0x305f,
411 ~0 /* sentinel */ 409 ~0 /* sentinel */
412}; 410};
413 411
diff --git a/drivers/gpu/drm/msm/adreno/a5xx.xml.h b/drivers/gpu/drm/msm/adreno/a5xx.xml.h
index cf4fe14ddd6e..4a61d4e72c98 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a5xx.xml.h
@@ -8,19 +8,19 @@ http://github.com/freedreno/envytools/
8git clone https://github.com/freedreno/envytools.git 8git clone https://github.com/freedreno/envytools.git
9 9
10The rules-ng-ng source files this header was generated from are: 10The rules-ng-ng source files this header was generated from are:
11- /home/robclark/src/envytools/rnndb/adreno.xml ( 501 bytes, from 2018-07-03 19:37:13) 11- /home/ubuntu/envytools/envytools/rnndb/./adreno.xml ( 501 bytes, from 2019-05-29 01:28:15)
12- /home/robclark/src/envytools/rnndb/freedreno_copyright.xml ( 1572 bytes, from 2018-07-03 19:37:13) 12- /home/ubuntu/envytools/envytools/rnndb/freedreno_copyright.xml ( 1572 bytes, from 2019-05-29 01:28:15)
13- /home/robclark/src/envytools/rnndb/adreno/a2xx.xml ( 42463 bytes, from 2018-11-19 13:44:03) 13- /home/ubuntu/envytools/envytools/rnndb/adreno/a2xx.xml ( 79608 bytes, from 2019-05-29 01:28:15)
14- /home/robclark/src/envytools/rnndb/adreno/adreno_common.xml ( 14201 bytes, from 2018-12-02 17:29:54) 14- /home/ubuntu/envytools/envytools/rnndb/adreno/adreno_common.xml ( 14239 bytes, from 2019-05-29 01:28:15)
15- /home/robclark/src/envytools/rnndb/adreno/adreno_pm4.xml ( 43052 bytes, from 2018-12-02 17:29:54) 15- /home/ubuntu/envytools/envytools/rnndb/adreno/adreno_pm4.xml ( 43155 bytes, from 2019-05-29 01:28:15)
16- /home/robclark/src/envytools/rnndb/adreno/a3xx.xml ( 83840 bytes, from 2018-07-03 19:37:13) 16- /home/ubuntu/envytools/envytools/rnndb/adreno/a3xx.xml ( 83840 bytes, from 2019-05-29 01:28:15)
17- /home/robclark/src/envytools/rnndb/adreno/a4xx.xml ( 112086 bytes, from 2018-07-03 19:37:13) 17- /home/ubuntu/envytools/envytools/rnndb/adreno/a4xx.xml ( 112086 bytes, from 2019-05-29 01:28:15)
18- /home/robclark/src/envytools/rnndb/adreno/a5xx.xml ( 147240 bytes, from 2018-12-02 17:29:54) 18- /home/ubuntu/envytools/envytools/rnndb/adreno/a5xx.xml ( 147291 bytes, from 2019-05-29 14:51:41)
19- /home/robclark/src/envytools/rnndb/adreno/a6xx.xml ( 140790 bytes, from 2018-12-02 17:29:54) 19- /home/ubuntu/envytools/envytools/rnndb/adreno/a6xx.xml ( 148461 bytes, from 2019-05-29 01:28:15)
20- /home/robclark/src/envytools/rnndb/adreno/a6xx_gmu.xml ( 10431 bytes, from 2018-09-14 13:03:07) 20- /home/ubuntu/envytools/envytools/rnndb/adreno/a6xx_gmu.xml ( 10431 bytes, from 2019-05-29 01:28:15)
21- /home/robclark/src/envytools/rnndb/adreno/ocmem.xml ( 1773 bytes, from 2018-07-03 19:37:13) 21- /home/ubuntu/envytools/envytools/rnndb/adreno/ocmem.xml ( 1773 bytes, from 2019-05-29 01:28:15)
22 22
23Copyright (C) 2013-2018 by the following authors: 23Copyright (C) 2013-2019 by the following authors:
24- Rob Clark <robdclark@gmail.com> (robclark) 24- Rob Clark <robdclark@gmail.com> (robclark)
25- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin) 25- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
26 26
@@ -2148,6 +2148,8 @@ static inline uint32_t A5XX_VSC_RESOLVE_CNTL_Y(uint32_t val)
2148 2148
2149#define REG_A5XX_HLSQ_TIMEOUT_THRESHOLD_1 0x00000e01 2149#define REG_A5XX_HLSQ_TIMEOUT_THRESHOLD_1 0x00000e01
2150 2150
2151#define REG_A5XX_HLSQ_DBG_ECO_CNTL 0x00000e04
2152
2151#define REG_A5XX_HLSQ_ADDR_MODE_CNTL 0x00000e05 2153#define REG_A5XX_HLSQ_ADDR_MODE_CNTL 0x00000e05
2152 2154
2153#define REG_A5XX_HLSQ_MODE_CNTL 0x00000e06 2155#define REG_A5XX_HLSQ_MODE_CNTL 0x00000e06
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_debugfs.c b/drivers/gpu/drm/msm/adreno/a5xx_debugfs.c
index 3041c500c5cd..9f2dd76bd67a 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_debugfs.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_debugfs.c
@@ -149,7 +149,6 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_set, "%llx\n");
149int a5xx_debugfs_init(struct msm_gpu *gpu, struct drm_minor *minor) 149int a5xx_debugfs_init(struct msm_gpu *gpu, struct drm_minor *minor)
150{ 150{
151 struct drm_device *dev; 151 struct drm_device *dev;
152 struct dentry *ent;
153 int ret; 152 int ret;
154 153
155 if (!minor) 154 if (!minor)
@@ -166,11 +165,8 @@ int a5xx_debugfs_init(struct msm_gpu *gpu, struct drm_minor *minor)
166 return ret; 165 return ret;
167 } 166 }
168 167
169 ent = debugfs_create_file("reset", S_IWUGO, 168 debugfs_create_file("reset", S_IWUGO, minor->debugfs_root, dev,
170 minor->debugfs_root, 169 &reset_fops);
171 dev, &reset_fops);
172 if (!ent)
173 return -ENOMEM;
174 170
175 return 0; 171 return 0;
176} 172}
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index a3c778df23a8..1671db47aa57 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -309,12 +309,18 @@ static const struct {
309 309
310void a5xx_set_hwcg(struct msm_gpu *gpu, bool state) 310void a5xx_set_hwcg(struct msm_gpu *gpu, bool state)
311{ 311{
312 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
312 unsigned int i; 313 unsigned int i;
313 314
314 for (i = 0; i < ARRAY_SIZE(a5xx_hwcg); i++) 315 for (i = 0; i < ARRAY_SIZE(a5xx_hwcg); i++)
315 gpu_write(gpu, a5xx_hwcg[i].offset, 316 gpu_write(gpu, a5xx_hwcg[i].offset,
316 state ? a5xx_hwcg[i].value : 0); 317 state ? a5xx_hwcg[i].value : 0);
317 318
319 if (adreno_is_a540(adreno_gpu)) {
320 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_DELAY_GPMU, state ? 0x00000770 : 0);
321 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_HYST_GPMU, state ? 0x00000004 : 0);
322 }
323
318 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, state ? 0xAAA8AA00 : 0); 324 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, state ? 0xAAA8AA00 : 0);
319 gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, state ? 0x182 : 0x180); 325 gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, state ? 0x182 : 0x180);
320} 326}
@@ -498,6 +504,9 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
498 504
499 gpu_write(gpu, REG_A5XX_VBIF_ROUND_ROBIN_QOS_ARB, 0x00000003); 505 gpu_write(gpu, REG_A5XX_VBIF_ROUND_ROBIN_QOS_ARB, 0x00000003);
500 506
507 if (adreno_is_a540(adreno_gpu))
508 gpu_write(gpu, REG_A5XX_VBIF_GATE_OFF_WRREQ_EN, 0x00000009);
509
501 /* Make all blocks contribute to the GPU BUSY perf counter */ 510 /* Make all blocks contribute to the GPU BUSY perf counter */
502 gpu_write(gpu, REG_A5XX_RBBM_PERFCTR_GPU_BUSY_MASKED, 0xFFFFFFFF); 511 gpu_write(gpu, REG_A5XX_RBBM_PERFCTR_GPU_BUSY_MASKED, 0xFFFFFFFF);
503 512
@@ -558,7 +567,10 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
558 gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MAX_HI, 0x00000000); 567 gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MAX_HI, 0x00000000);
559 568
560 gpu_write(gpu, REG_A5XX_CP_MEQ_THRESHOLDS, 0x40); 569 gpu_write(gpu, REG_A5XX_CP_MEQ_THRESHOLDS, 0x40);
561 gpu_write(gpu, REG_A5XX_CP_MERCIU_SIZE, 0x40); 570 if (adreno_is_a530(adreno_gpu))
571 gpu_write(gpu, REG_A5XX_CP_MERCIU_SIZE, 0x40);
572 if (adreno_is_a540(adreno_gpu))
573 gpu_write(gpu, REG_A5XX_CP_MERCIU_SIZE, 0x400);
562 gpu_write(gpu, REG_A5XX_CP_ROQ_THRESHOLDS_2, 0x80000060); 574 gpu_write(gpu, REG_A5XX_CP_ROQ_THRESHOLDS_2, 0x80000060);
563 gpu_write(gpu, REG_A5XX_CP_ROQ_THRESHOLDS_1, 0x40201B16); 575 gpu_write(gpu, REG_A5XX_CP_ROQ_THRESHOLDS_1, 0x40201B16);
564 576
@@ -583,6 +595,8 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
583 /* Set the highest bank bit */ 595 /* Set the highest bank bit */
584 gpu_write(gpu, REG_A5XX_TPL1_MODE_CNTL, 2 << 7); 596 gpu_write(gpu, REG_A5XX_TPL1_MODE_CNTL, 2 << 7);
585 gpu_write(gpu, REG_A5XX_RB_MODE_CNTL, 2 << 1); 597 gpu_write(gpu, REG_A5XX_RB_MODE_CNTL, 2 << 1);
598 if (adreno_is_a540(adreno_gpu))
599 gpu_write(gpu, REG_A5XX_UCHE_DBG_ECO_CNTL_2, 2);
586 600
587 /* Protect registers from the CP */ 601 /* Protect registers from the CP */
588 gpu_write(gpu, REG_A5XX_CP_PROTECT_CNTL, 0x00000007); 602 gpu_write(gpu, REG_A5XX_CP_PROTECT_CNTL, 0x00000007);
@@ -633,6 +647,30 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
633 REG_A5XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 0x00000000); 647 REG_A5XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 0x00000000);
634 gpu_write(gpu, REG_A5XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 0x00000000); 648 gpu_write(gpu, REG_A5XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 0x00000000);
635 649
650 /* Put the GPU into 64 bit by default */
651 gpu_write(gpu, REG_A5XX_CP_ADDR_MODE_CNTL, 0x1);
652 gpu_write(gpu, REG_A5XX_VSC_ADDR_MODE_CNTL, 0x1);
653 gpu_write(gpu, REG_A5XX_GRAS_ADDR_MODE_CNTL, 0x1);
654 gpu_write(gpu, REG_A5XX_RB_ADDR_MODE_CNTL, 0x1);
655 gpu_write(gpu, REG_A5XX_PC_ADDR_MODE_CNTL, 0x1);
656 gpu_write(gpu, REG_A5XX_HLSQ_ADDR_MODE_CNTL, 0x1);
657 gpu_write(gpu, REG_A5XX_VFD_ADDR_MODE_CNTL, 0x1);
658 gpu_write(gpu, REG_A5XX_VPC_ADDR_MODE_CNTL, 0x1);
659 gpu_write(gpu, REG_A5XX_UCHE_ADDR_MODE_CNTL, 0x1);
660 gpu_write(gpu, REG_A5XX_SP_ADDR_MODE_CNTL, 0x1);
661 gpu_write(gpu, REG_A5XX_TPL1_ADDR_MODE_CNTL, 0x1);
662 gpu_write(gpu, REG_A5XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL, 0x1);
663
664 /*
665 * VPC corner case with local memory load kill leads to corrupt
666 * internal state. Normal Disable does not work for all a5x chips.
667 * So do the following setting to disable it.
668 */
669 if (adreno_gpu->info->quirks & ADRENO_QUIRK_LMLOADKILL_DISABLE) {
670 gpu_rmw(gpu, REG_A5XX_VPC_DBG_ECO_CNTL, 0, BIT(23));
671 gpu_rmw(gpu, REG_A5XX_HLSQ_DBG_ECO_CNTL, BIT(18), 0);
672 }
673
636 ret = adreno_hw_init(gpu); 674 ret = adreno_hw_init(gpu);
637 if (ret) 675 if (ret)
638 return ret; 676 return ret;
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_power.c b/drivers/gpu/drm/msm/adreno/a5xx_power.c
index 0ebfe2bb5707..a3a06db675ba 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_power.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_power.c
@@ -23,6 +23,18 @@
23#define AGC_POWER_CONFIG_PRODUCTION_ID 1 23#define AGC_POWER_CONFIG_PRODUCTION_ID 1
24#define AGC_INIT_MSG_VALUE 0xBABEFACE 24#define AGC_INIT_MSG_VALUE 0xBABEFACE
25 25
26/* AGC_LM_CONFIG (A540+) */
27#define AGC_LM_CONFIG (136/4)
28#define AGC_LM_CONFIG_GPU_VERSION_SHIFT 17
29#define AGC_LM_CONFIG_ENABLE_GPMU_ADAPTIVE 1
30#define AGC_LM_CONFIG_THROTTLE_DISABLE (2 << 8)
31#define AGC_LM_CONFIG_ISENSE_ENABLE (1 << 4)
32#define AGC_LM_CONFIG_ENABLE_ERROR (3 << 4)
33#define AGC_LM_CONFIG_LLM_ENABLED (1 << 16)
34#define AGC_LM_CONFIG_BCL_DISABLED (1 << 24)
35
36#define AGC_LEVEL_CONFIG (140/4)
37
26static struct { 38static struct {
27 uint32_t reg; 39 uint32_t reg;
28 uint32_t value; 40 uint32_t value;
@@ -107,7 +119,7 @@ static inline uint32_t _get_mvolts(struct msm_gpu *gpu, uint32_t freq)
107} 119}
108 120
109/* Setup thermal limit management */ 121/* Setup thermal limit management */
110static void a5xx_lm_setup(struct msm_gpu *gpu) 122static void a530_lm_setup(struct msm_gpu *gpu)
111{ 123{
112 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); 124 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
113 struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu); 125 struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);
@@ -156,6 +168,45 @@ static void a5xx_lm_setup(struct msm_gpu *gpu)
156 gpu_write(gpu, AGC_INIT_MSG_MAGIC, AGC_INIT_MSG_VALUE); 168 gpu_write(gpu, AGC_INIT_MSG_MAGIC, AGC_INIT_MSG_VALUE);
157} 169}
158 170
171#define PAYLOAD_SIZE(_size) ((_size) * sizeof(u32))
172#define LM_DCVS_LIMIT 1
173#define LEVEL_CONFIG ~(0x303)
174
175static void a540_lm_setup(struct msm_gpu *gpu)
176{
177 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
178 u32 config;
179
180 /* The battery current limiter isn't enabled for A540 */
181 config = AGC_LM_CONFIG_BCL_DISABLED;
182 config |= adreno_gpu->rev.patchid << AGC_LM_CONFIG_GPU_VERSION_SHIFT;
183
184 /* For now disable GPMU side throttling */
185 config |= AGC_LM_CONFIG_THROTTLE_DISABLE;
186
187 /* Until we get clock scaling 0 is always the active power level */
188 gpu_write(gpu, REG_A5XX_GPMU_GPMU_VOLTAGE, 0x80000000 | 0);
189
190 /* Fixed at 6000 for now */
191 gpu_write(gpu, REG_A5XX_GPMU_GPMU_PWR_THRESHOLD, 0x80000000 | 6000);
192
193 gpu_write(gpu, AGC_MSG_STATE, 0x80000001);
194 gpu_write(gpu, AGC_MSG_COMMAND, AGC_POWER_CONFIG_PRODUCTION_ID);
195
196 gpu_write(gpu, AGC_MSG_PAYLOAD(0), 5448);
197 gpu_write(gpu, AGC_MSG_PAYLOAD(1), 1);
198
199 gpu_write(gpu, AGC_MSG_PAYLOAD(2), _get_mvolts(gpu, gpu->fast_rate));
200 gpu_write(gpu, AGC_MSG_PAYLOAD(3), gpu->fast_rate / 1000000);
201
202 gpu_write(gpu, AGC_MSG_PAYLOAD(AGC_LM_CONFIG), config);
203 gpu_write(gpu, AGC_MSG_PAYLOAD(AGC_LEVEL_CONFIG), LEVEL_CONFIG);
204 gpu_write(gpu, AGC_MSG_PAYLOAD_SIZE,
205 PAYLOAD_SIZE(AGC_LEVEL_CONFIG + 1));
206
207 gpu_write(gpu, AGC_INIT_MSG_MAGIC, AGC_INIT_MSG_VALUE);
208}
209
159/* Enable SP/TP cpower collapse */ 210/* Enable SP/TP cpower collapse */
160static void a5xx_pc_init(struct msm_gpu *gpu) 211static void a5xx_pc_init(struct msm_gpu *gpu)
161{ 212{
@@ -197,7 +248,8 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu)
197 return -EINVAL; 248 return -EINVAL;
198 } 249 }
199 250
200 gpu_write(gpu, REG_A5XX_GPMU_WFI_CONFIG, 0x4014); 251 if (adreno_is_a530(adreno_gpu))
252 gpu_write(gpu, REG_A5XX_GPMU_WFI_CONFIG, 0x4014);
201 253
202 /* Kick off the GPMU */ 254 /* Kick off the GPMU */
203 gpu_write(gpu, REG_A5XX_GPMU_CM3_SYSRESET, 0x0); 255 gpu_write(gpu, REG_A5XX_GPMU_CM3_SYSRESET, 0x0);
@@ -211,12 +263,26 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu)
211 DRM_ERROR("%s: GPMU firmware initialization timed out\n", 263 DRM_ERROR("%s: GPMU firmware initialization timed out\n",
212 gpu->name); 264 gpu->name);
213 265
266 if (!adreno_is_a530(adreno_gpu)) {
267 u32 val = gpu_read(gpu, REG_A5XX_GPMU_GENERAL_1);
268
269 if (val)
270 DRM_ERROR("%s: GPMU firmware initialization failed: %d\n",
271 gpu->name, val);
272 }
273
214 return 0; 274 return 0;
215} 275}
216 276
217/* Enable limits management */ 277/* Enable limits management */
218static void a5xx_lm_enable(struct msm_gpu *gpu) 278static void a5xx_lm_enable(struct msm_gpu *gpu)
219{ 279{
280 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
281
282 /* This init sequence only applies to A530 */
283 if (!adreno_is_a530(adreno_gpu))
284 return;
285
220 gpu_write(gpu, REG_A5XX_GDPM_INT_MASK, 0x0); 286 gpu_write(gpu, REG_A5XX_GDPM_INT_MASK, 0x0);
221 gpu_write(gpu, REG_A5XX_GDPM_INT_EN, 0x0A); 287 gpu_write(gpu, REG_A5XX_GDPM_INT_EN, 0x0A);
222 gpu_write(gpu, REG_A5XX_GPMU_GPMU_VOLTAGE_INTR_EN_MASK, 0x01); 288 gpu_write(gpu, REG_A5XX_GPMU_GPMU_VOLTAGE_INTR_EN_MASK, 0x01);
@@ -228,10 +294,14 @@ static void a5xx_lm_enable(struct msm_gpu *gpu)
228 294
229int a5xx_power_init(struct msm_gpu *gpu) 295int a5xx_power_init(struct msm_gpu *gpu)
230{ 296{
297 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
231 int ret; 298 int ret;
232 299
233 /* Set up the limits management */ 300 /* Set up the limits management */
234 a5xx_lm_setup(gpu); 301 if (adreno_is_a530(adreno_gpu))
302 a530_lm_setup(gpu);
303 else
304 a540_lm_setup(gpu);
235 305
236 /* Set up SP/TP power collpase */ 306 /* Set up SP/TP power collpase */
237 a5xx_pc_init(gpu); 307 a5xx_pc_init(gpu);
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 38e2cfa9cec7..2ca470eb5cb8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -74,7 +74,7 @@ bool a6xx_gmu_sptprac_is_on(struct a6xx_gmu *gmu)
74 u32 val; 74 u32 val;
75 75
76 /* This can be called from gpu state code so make sure GMU is valid */ 76 /* This can be called from gpu state code so make sure GMU is valid */
77 if (IS_ERR_OR_NULL(gmu->mmio)) 77 if (!gmu->initialized)
78 return false; 78 return false;
79 79
80 val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS); 80 val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
@@ -90,7 +90,7 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
90 u32 val; 90 u32 val;
91 91
92 /* This can be called from gpu state code so make sure GMU is valid */ 92 /* This can be called from gpu state code so make sure GMU is valid */
93 if (IS_ERR_OR_NULL(gmu->mmio)) 93 if (!gmu->initialized)
94 return false; 94 return false;
95 95
96 val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS); 96 val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
@@ -504,8 +504,10 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
504 wmb(); 504 wmb();
505 505
506err: 506err:
507 devm_iounmap(gmu->dev, pdcptr); 507 if (!IS_ERR_OR_NULL(pdcptr))
508 devm_iounmap(gmu->dev, seqptr); 508 iounmap(pdcptr);
509 if (!IS_ERR_OR_NULL(seqptr))
510 iounmap(seqptr);
509} 511}
510 512
511/* 513/*
@@ -695,7 +697,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
695 struct a6xx_gmu *gmu = &a6xx_gpu->gmu; 697 struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
696 int status, ret; 698 int status, ret;
697 699
698 if (WARN(!gmu->mmio, "The GMU is not set up yet\n")) 700 if (WARN(!gmu->initialized, "The GMU is not set up yet\n"))
699 return 0; 701 return 0;
700 702
701 gmu->hung = false; 703 gmu->hung = false;
@@ -765,7 +767,7 @@ bool a6xx_gmu_isidle(struct a6xx_gmu *gmu)
765{ 767{
766 u32 reg; 768 u32 reg;
767 769
768 if (!gmu->mmio) 770 if (!gmu->initialized)
769 return true; 771 return true;
770 772
771 reg = gmu_read(gmu, REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS); 773 reg = gmu_read(gmu, REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS);
@@ -1195,7 +1197,7 @@ static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev,
1195 return ERR_PTR(-EINVAL); 1197 return ERR_PTR(-EINVAL);
1196 } 1198 }
1197 1199
1198 ret = devm_ioremap(&pdev->dev, res->start, resource_size(res)); 1200 ret = ioremap(res->start, resource_size(res));
1199 if (!ret) { 1201 if (!ret) {
1200 DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name); 1202 DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name);
1201 return ERR_PTR(-EINVAL); 1203 return ERR_PTR(-EINVAL);
@@ -1211,10 +1213,10 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, struct platform_device *pdev,
1211 1213
1212 irq = platform_get_irq_byname(pdev, name); 1214 irq = platform_get_irq_byname(pdev, name);
1213 1215
1214 ret = devm_request_irq(&pdev->dev, irq, handler, IRQF_TRIGGER_HIGH, 1216 ret = request_irq(irq, handler, IRQF_TRIGGER_HIGH, name, gmu);
1215 name, gmu);
1216 if (ret) { 1217 if (ret) {
1217 DRM_DEV_ERROR(&pdev->dev, "Unable to get interrupt %s\n", name); 1218 DRM_DEV_ERROR(&pdev->dev, "Unable to get interrupt %s %d\n",
1219 name, ret);
1218 return ret; 1220 return ret;
1219 } 1221 }
1220 1222
@@ -1227,27 +1229,35 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
1227{ 1229{
1228 struct a6xx_gmu *gmu = &a6xx_gpu->gmu; 1230 struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
1229 1231
1230 if (IS_ERR_OR_NULL(gmu->mmio)) 1232 if (!gmu->initialized)
1231 return; 1233 return;
1232 1234
1233 a6xx_gmu_stop(a6xx_gpu); 1235 pm_runtime_force_suspend(gmu->dev);
1234
1235 pm_runtime_disable(gmu->dev);
1236 1236
1237 if (!IS_ERR_OR_NULL(gmu->gxpd)) { 1237 if (!IS_ERR_OR_NULL(gmu->gxpd)) {
1238 pm_runtime_disable(gmu->gxpd); 1238 pm_runtime_disable(gmu->gxpd);
1239 dev_pm_domain_detach(gmu->gxpd, false); 1239 dev_pm_domain_detach(gmu->gxpd, false);
1240 } 1240 }
1241 1241
1242 a6xx_gmu_irq_disable(gmu); 1242 iounmap(gmu->mmio);
1243 gmu->mmio = NULL;
1244
1243 a6xx_gmu_memory_free(gmu, gmu->hfi); 1245 a6xx_gmu_memory_free(gmu, gmu->hfi);
1244 1246
1245 iommu_detach_device(gmu->domain, gmu->dev); 1247 iommu_detach_device(gmu->domain, gmu->dev);
1246 1248
1247 iommu_domain_free(gmu->domain); 1249 iommu_domain_free(gmu->domain);
1250
1251 free_irq(gmu->gmu_irq, gmu);
1252 free_irq(gmu->hfi_irq, gmu);
1253
1254 /* Drop reference taken in of_find_device_by_node */
1255 put_device(gmu->dev);
1256
1257 gmu->initialized = false;
1248} 1258}
1249 1259
1250int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node) 1260int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
1251{ 1261{
1252 struct a6xx_gmu *gmu = &a6xx_gpu->gmu; 1262 struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
1253 struct platform_device *pdev = of_find_device_by_node(node); 1263 struct platform_device *pdev = of_find_device_by_node(node);
@@ -1268,34 +1278,34 @@ int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
1268 /* Get the list of clocks */ 1278 /* Get the list of clocks */
1269 ret = a6xx_gmu_clocks_probe(gmu); 1279 ret = a6xx_gmu_clocks_probe(gmu);
1270 if (ret) 1280 if (ret)
1271 return ret; 1281 goto err_put_device;
1272 1282
1273 /* Set up the IOMMU context bank */ 1283 /* Set up the IOMMU context bank */
1274 ret = a6xx_gmu_memory_probe(gmu); 1284 ret = a6xx_gmu_memory_probe(gmu);
1275 if (ret) 1285 if (ret)
1276 return ret; 1286 goto err_put_device;
1277 1287
1278 /* Allocate memory for for the HFI queues */ 1288 /* Allocate memory for for the HFI queues */
1279 gmu->hfi = a6xx_gmu_memory_alloc(gmu, SZ_16K); 1289 gmu->hfi = a6xx_gmu_memory_alloc(gmu, SZ_16K);
1280 if (IS_ERR(gmu->hfi)) 1290 if (IS_ERR(gmu->hfi))
1281 goto err; 1291 goto err_memory;
1282 1292
1283 /* Allocate memory for the GMU debug region */ 1293 /* Allocate memory for the GMU debug region */
1284 gmu->debug = a6xx_gmu_memory_alloc(gmu, SZ_16K); 1294 gmu->debug = a6xx_gmu_memory_alloc(gmu, SZ_16K);
1285 if (IS_ERR(gmu->debug)) 1295 if (IS_ERR(gmu->debug))
1286 goto err; 1296 goto err_memory;
1287 1297
1288 /* Map the GMU registers */ 1298 /* Map the GMU registers */
1289 gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu"); 1299 gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu");
1290 if (IS_ERR(gmu->mmio)) 1300 if (IS_ERR(gmu->mmio))
1291 goto err; 1301 goto err_memory;
1292 1302
1293 /* Get the HFI and GMU interrupts */ 1303 /* Get the HFI and GMU interrupts */
1294 gmu->hfi_irq = a6xx_gmu_get_irq(gmu, pdev, "hfi", a6xx_hfi_irq); 1304 gmu->hfi_irq = a6xx_gmu_get_irq(gmu, pdev, "hfi", a6xx_hfi_irq);
1295 gmu->gmu_irq = a6xx_gmu_get_irq(gmu, pdev, "gmu", a6xx_gmu_irq); 1305 gmu->gmu_irq = a6xx_gmu_get_irq(gmu, pdev, "gmu", a6xx_gmu_irq);
1296 1306
1297 if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0) 1307 if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0)
1298 goto err; 1308 goto err_mmio;
1299 1309
1300 /* 1310 /*
1301 * Get a link to the GX power domain to reset the GPU in case of GMU 1311 * Get a link to the GX power domain to reset the GPU in case of GMU
@@ -1309,8 +1319,15 @@ int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
1309 /* Set up the HFI queues */ 1319 /* Set up the HFI queues */
1310 a6xx_hfi_init(gmu); 1320 a6xx_hfi_init(gmu);
1311 1321
1322 gmu->initialized = true;
1323
1312 return 0; 1324 return 0;
1313err: 1325
1326err_mmio:
1327 iounmap(gmu->mmio);
1328 free_irq(gmu->gmu_irq, gmu);
1329 free_irq(gmu->hfi_irq, gmu);
1330err_memory:
1314 a6xx_gmu_memory_free(gmu, gmu->hfi); 1331 a6xx_gmu_memory_free(gmu, gmu->hfi);
1315 1332
1316 if (gmu->domain) { 1333 if (gmu->domain) {
@@ -1318,6 +1335,11 @@ err:
1318 1335
1319 iommu_domain_free(gmu->domain); 1336 iommu_domain_free(gmu->domain);
1320 } 1337 }
1338 ret = -ENODEV;
1321 1339
1322 return -ENODEV; 1340err_put_device:
1341 /* Drop reference taken in of_find_device_by_node */
1342 put_device(gmu->dev);
1343
1344 return ret;
1323} 1345}
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h
index bedd8e6a63aa..39a26dd63674 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h
@@ -75,6 +75,7 @@ struct a6xx_gmu {
75 75
76 struct a6xx_hfi_queue queues[2]; 76 struct a6xx_hfi_queue queues[2];
77 77
78 bool initialized;
78 bool hung; 79 bool hung;
79}; 80};
80 81
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index e74dce474250..be39cf01e51e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -391,6 +391,20 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
391 REG_A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 0x00000000); 391 REG_A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 0x00000000);
392 gpu_write(gpu, REG_A6XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 0x00000000); 392 gpu_write(gpu, REG_A6XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 0x00000000);
393 393
394 /* Turn on 64 bit addressing for all blocks */
395 gpu_write(gpu, REG_A6XX_CP_ADDR_MODE_CNTL, 0x1);
396 gpu_write(gpu, REG_A6XX_VSC_ADDR_MODE_CNTL, 0x1);
397 gpu_write(gpu, REG_A6XX_GRAS_ADDR_MODE_CNTL, 0x1);
398 gpu_write(gpu, REG_A6XX_RB_ADDR_MODE_CNTL, 0x1);
399 gpu_write(gpu, REG_A6XX_PC_ADDR_MODE_CNTL, 0x1);
400 gpu_write(gpu, REG_A6XX_HLSQ_ADDR_MODE_CNTL, 0x1);
401 gpu_write(gpu, REG_A6XX_VFD_ADDR_MODE_CNTL, 0x1);
402 gpu_write(gpu, REG_A6XX_VPC_ADDR_MODE_CNTL, 0x1);
403 gpu_write(gpu, REG_A6XX_UCHE_ADDR_MODE_CNTL, 0x1);
404 gpu_write(gpu, REG_A6XX_SP_ADDR_MODE_CNTL, 0x1);
405 gpu_write(gpu, REG_A6XX_TPL1_ADDR_MODE_CNTL, 0x1);
406 gpu_write(gpu, REG_A6XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL, 0x1);
407
394 /* enable hardware clockgating */ 408 /* enable hardware clockgating */
395 a6xx_set_hwcg(gpu, true); 409 a6xx_set_hwcg(gpu, true);
396 410
@@ -854,7 +868,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
854 /* FIXME: How do we gracefully handle this? */ 868 /* FIXME: How do we gracefully handle this? */
855 BUG_ON(!node); 869 BUG_ON(!node);
856 870
857 ret = a6xx_gmu_probe(a6xx_gpu, node); 871 ret = a6xx_gmu_init(a6xx_gpu, node);
858 if (ret) { 872 if (ret) {
859 a6xx_destroy(&(a6xx_gpu->base.base)); 873 a6xx_destroy(&(a6xx_gpu->base.base));
860 return ERR_PTR(ret); 874 return ERR_PTR(ret);
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
index b46279eb18c5..64399554f2dd 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
@@ -53,7 +53,7 @@ bool a6xx_gmu_isidle(struct a6xx_gmu *gmu);
53int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); 53int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);
54void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); 54void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);
55 55
56int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node); 56int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node);
57void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu); 57void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu);
58 58
59void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq); 59void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index b907245d3d96..5bcc169c1189 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -145,6 +145,24 @@ static const struct adreno_info gpulist[] = {
145 .init = a5xx_gpu_init, 145 .init = a5xx_gpu_init,
146 .zapfw = "a530_zap.mdt", 146 .zapfw = "a530_zap.mdt",
147 }, { 147 }, {
148 .rev = ADRENO_REV(5, 4, 0, 2),
149 .revn = 540,
150 .name = "A540",
151 .fw = {
152 [ADRENO_FW_PM4] = "a530_pm4.fw",
153 [ADRENO_FW_PFP] = "a530_pfp.fw",
154 [ADRENO_FW_GPMU] = "a540_gpmu.fw2",
155 },
156 .gmem = SZ_1M,
157 /*
158 * Increase inactive period to 250 to avoid bouncing
159 * the GDSC which appears to make it grumpy
160 */
161 .inactive_period = 250,
162 .quirks = ADRENO_QUIRK_LMLOADKILL_DISABLE,
163 .init = a5xx_gpu_init,
164 .zapfw = "a540_zap.mdt",
165 }, {
148 .rev = ADRENO_REV(6, 3, 0, ANY_ID), 166 .rev = ADRENO_REV(6, 3, 0, ANY_ID),
149 .revn = 630, 167 .revn = 630,
150 .name = "A630", 168 .name = "A630",
@@ -351,7 +369,7 @@ static void adreno_unbind(struct device *dev, struct device *master,
351{ 369{
352 struct msm_gpu *gpu = dev_get_drvdata(dev); 370 struct msm_gpu *gpu = dev_get_drvdata(dev);
353 371
354 gpu->funcs->pm_suspend(gpu); 372 pm_runtime_force_suspend(dev);
355 gpu->funcs->destroy(gpu); 373 gpu->funcs->destroy(gpu);
356 374
357 set_gpu_pdev(dev_get_drvdata(master), NULL); 375 set_gpu_pdev(dev_get_drvdata(master), NULL);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 6f7f4114afcf..3db8e499d4c5 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -67,7 +67,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
67 return ret; 67 return ret;
68 68
69 mem_phys = r.start; 69 mem_phys = r.start;
70 mem_size = resource_size(&r);
71 70
72 /* Request the MDT file for the firmware */ 71 /* Request the MDT file for the firmware */
73 fw = adreno_request_fw(to_adreno_gpu(gpu), fwname); 72 fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
@@ -83,6 +82,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
83 goto out; 82 goto out;
84 } 83 }
85 84
85 if (mem_size > resource_size(&r)) {
86 DRM_DEV_ERROR(dev,
87 "memory region is too small to load the MDT\n");
88 ret = -E2BIG;
89 goto out;
90 }
91
86 /* Allocate memory for the firmware image */ 92 /* Allocate memory for the firmware image */
87 mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC); 93 mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
88 if (!mem_region) { 94 if (!mem_region) {
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index 0925606ec9b5..d67c1a69c49a 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -61,6 +61,7 @@ enum {
61enum adreno_quirks { 61enum adreno_quirks {
62 ADRENO_QUIRK_TWO_PASS_USE_WFI = 1, 62 ADRENO_QUIRK_TWO_PASS_USE_WFI = 1,
63 ADRENO_QUIRK_FAULT_DETECT_MASK = 2, 63 ADRENO_QUIRK_FAULT_DETECT_MASK = 2,
64 ADRENO_QUIRK_LMLOADKILL_DISABLE = 3,
64}; 65};
65 66
66struct adreno_rev { 67struct adreno_rev {
@@ -221,6 +222,11 @@ static inline int adreno_is_a530(struct adreno_gpu *gpu)
221 return gpu->revn == 530; 222 return gpu->revn == 530;
222} 223}
223 224
225static inline int adreno_is_a540(struct adreno_gpu *gpu)
226{
227 return gpu->revn == 540;
228}
229
224int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value); 230int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value);
225const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu, 231const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu,
226 const char *fwname); 232 const char *fwname);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index cd6bde12029e..5cda96875e03 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -69,7 +69,6 @@ static void _dpu_core_perf_calc_crtc(struct dpu_kms *kms,
69 struct dpu_core_perf_params *perf) 69 struct dpu_core_perf_params *perf)
70{ 70{
71 struct dpu_crtc_state *dpu_cstate; 71 struct dpu_crtc_state *dpu_cstate;
72 int i;
73 72
74 if (!kms || !kms->catalog || !crtc || !state || !perf) { 73 if (!kms || !kms->catalog || !crtc || !state || !perf) {
75 DPU_ERROR("invalid parameters\n"); 74 DPU_ERROR("invalid parameters\n");
@@ -80,35 +79,24 @@ static void _dpu_core_perf_calc_crtc(struct dpu_kms *kms,
80 memset(perf, 0, sizeof(struct dpu_core_perf_params)); 79 memset(perf, 0, sizeof(struct dpu_core_perf_params));
81 80
82 if (!dpu_cstate->bw_control) { 81 if (!dpu_cstate->bw_control) {
83 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 82 perf->bw_ctl = kms->catalog->perf.max_bw_high *
84 perf->bw_ctl[i] = kms->catalog->perf.max_bw_high *
85 1000ULL; 83 1000ULL;
86 perf->max_per_pipe_ib[i] = perf->bw_ctl[i]; 84 perf->max_per_pipe_ib = perf->bw_ctl;
87 }
88 perf->core_clk_rate = kms->perf.max_core_clk_rate; 85 perf->core_clk_rate = kms->perf.max_core_clk_rate;
89 } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) { 86 } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_MINIMUM) {
90 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 87 perf->bw_ctl = 0;
91 perf->bw_ctl[i] = 0; 88 perf->max_per_pipe_ib = 0;
92 perf->max_per_pipe_ib[i] = 0;
93 }
94 perf->core_clk_rate = 0; 89 perf->core_clk_rate = 0;
95 } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) { 90 } else if (kms->perf.perf_tune.mode == DPU_PERF_MODE_FIXED) {
96 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 91 perf->bw_ctl = kms->perf.fix_core_ab_vote;
97 perf->bw_ctl[i] = kms->perf.fix_core_ab_vote; 92 perf->max_per_pipe_ib = kms->perf.fix_core_ib_vote;
98 perf->max_per_pipe_ib[i] = kms->perf.fix_core_ib_vote;
99 }
100 perf->core_clk_rate = kms->perf.fix_core_clk_rate; 93 perf->core_clk_rate = kms->perf.fix_core_clk_rate;
101 } 94 }
102 95
103 DPU_DEBUG( 96 DPU_DEBUG(
104 "crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu llcc_ib=%llu llcc_ab=%llu mem_ib=%llu mem_ab=%llu\n", 97 "crtc=%d clk_rate=%llu core_ib=%llu core_ab=%llu\n",
105 crtc->base.id, perf->core_clk_rate, 98 crtc->base.id, perf->core_clk_rate,
106 perf->max_per_pipe_ib[DPU_CORE_PERF_DATA_BUS_ID_MNOC], 99 perf->max_per_pipe_ib, perf->bw_ctl);
107 perf->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_MNOC],
108 perf->max_per_pipe_ib[DPU_CORE_PERF_DATA_BUS_ID_LLCC],
109 perf->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_LLCC],
110 perf->max_per_pipe_ib[DPU_CORE_PERF_DATA_BUS_ID_EBI],
111 perf->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_EBI]);
112} 100}
113 101
114int dpu_core_perf_crtc_check(struct drm_crtc *crtc, 102int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
@@ -121,7 +109,6 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
121 struct dpu_crtc_state *dpu_cstate; 109 struct dpu_crtc_state *dpu_cstate;
122 struct drm_crtc *tmp_crtc; 110 struct drm_crtc *tmp_crtc;
123 struct dpu_kms *kms; 111 struct dpu_kms *kms;
124 int i;
125 112
126 if (!crtc || !state) { 113 if (!crtc || !state) {
127 DPU_ERROR("invalid crtc\n"); 114 DPU_ERROR("invalid crtc\n");
@@ -143,31 +130,25 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
143 /* obtain new values */ 130 /* obtain new values */
144 _dpu_core_perf_calc_crtc(kms, crtc, state, &dpu_cstate->new_perf); 131 _dpu_core_perf_calc_crtc(kms, crtc, state, &dpu_cstate->new_perf);
145 132
146 for (i = DPU_CORE_PERF_DATA_BUS_ID_MNOC; 133 bw_sum_of_intfs = dpu_cstate->new_perf.bw_ctl;
147 i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 134 curr_client_type = dpu_crtc_get_client_type(crtc);
148 bw_sum_of_intfs = dpu_cstate->new_perf.bw_ctl[i];
149 curr_client_type = dpu_crtc_get_client_type(crtc);
150 135
151 drm_for_each_crtc(tmp_crtc, crtc->dev) { 136 drm_for_each_crtc(tmp_crtc, crtc->dev) {
152 if (tmp_crtc->enabled && 137 if (tmp_crtc->enabled &&
153 (dpu_crtc_get_client_type(tmp_crtc) == 138 (dpu_crtc_get_client_type(tmp_crtc) ==
154 curr_client_type) && 139 curr_client_type) && (tmp_crtc != crtc)) {
155 (tmp_crtc != crtc)) { 140 struct dpu_crtc_state *tmp_cstate =
156 struct dpu_crtc_state *tmp_cstate = 141 to_dpu_crtc_state(tmp_crtc->state);
157 to_dpu_crtc_state(tmp_crtc->state); 142
158 143 DPU_DEBUG("crtc:%d bw:%llu ctrl:%d\n",
159 DPU_DEBUG("crtc:%d bw:%llu ctrl:%d\n", 144 tmp_crtc->base.id, tmp_cstate->new_perf.bw_ctl,
160 tmp_crtc->base.id, 145 tmp_cstate->bw_control);
161 tmp_cstate->new_perf.bw_ctl[i], 146 /*
162 tmp_cstate->bw_control); 147 * For bw check only use the bw if the
163 /* 148 * atomic property has been already set
164 * For bw check only use the bw if the 149 */
165 * atomic property has been already set 150 if (tmp_cstate->bw_control)
166 */ 151 bw_sum_of_intfs += tmp_cstate->new_perf.bw_ctl;
167 if (tmp_cstate->bw_control)
168 bw_sum_of_intfs +=
169 tmp_cstate->new_perf.bw_ctl[i];
170 }
171 } 152 }
172 153
173 /* convert bandwidth to kb */ 154 /* convert bandwidth to kb */
@@ -198,9 +179,9 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
198} 179}
199 180
200static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms, 181static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms,
201 struct drm_crtc *crtc, u32 bus_id) 182 struct drm_crtc *crtc)
202{ 183{
203 struct dpu_core_perf_params perf = { { 0 } }; 184 struct dpu_core_perf_params perf = { 0 };
204 enum dpu_crtc_client_type curr_client_type 185 enum dpu_crtc_client_type curr_client_type
205 = dpu_crtc_get_client_type(crtc); 186 = dpu_crtc_get_client_type(crtc);
206 struct drm_crtc *tmp_crtc; 187 struct drm_crtc *tmp_crtc;
@@ -213,13 +194,11 @@ static int _dpu_core_perf_crtc_update_bus(struct dpu_kms *kms,
213 dpu_crtc_get_client_type(tmp_crtc)) { 194 dpu_crtc_get_client_type(tmp_crtc)) {
214 dpu_cstate = to_dpu_crtc_state(tmp_crtc->state); 195 dpu_cstate = to_dpu_crtc_state(tmp_crtc->state);
215 196
216 perf.max_per_pipe_ib[bus_id] = 197 perf.max_per_pipe_ib = max(perf.max_per_pipe_ib,
217 max(perf.max_per_pipe_ib[bus_id], 198 dpu_cstate->new_perf.max_per_pipe_ib);
218 dpu_cstate->new_perf.max_per_pipe_ib[bus_id]);
219 199
220 DPU_DEBUG("crtc=%d bus_id=%d bw=%llu\n", 200 DPU_DEBUG("crtc=%d bw=%llu\n", tmp_crtc->base.id,
221 tmp_crtc->base.id, bus_id, 201 dpu_cstate->new_perf.bw_ctl);
222 dpu_cstate->new_perf.bw_ctl[bus_id]);
223 } 202 }
224 } 203 }
225 return ret; 204 return ret;
@@ -239,7 +218,6 @@ void dpu_core_perf_crtc_release_bw(struct drm_crtc *crtc)
239 struct dpu_crtc *dpu_crtc; 218 struct dpu_crtc *dpu_crtc;
240 struct dpu_crtc_state *dpu_cstate; 219 struct dpu_crtc_state *dpu_cstate;
241 struct dpu_kms *kms; 220 struct dpu_kms *kms;
242 int i;
243 221
244 if (!crtc) { 222 if (!crtc) {
245 DPU_ERROR("invalid crtc\n"); 223 DPU_ERROR("invalid crtc\n");
@@ -275,10 +253,8 @@ void dpu_core_perf_crtc_release_bw(struct drm_crtc *crtc)
275 if (kms->perf.enable_bw_release) { 253 if (kms->perf.enable_bw_release) {
276 trace_dpu_cmd_release_bw(crtc->base.id); 254 trace_dpu_cmd_release_bw(crtc->base.id);
277 DPU_DEBUG("Release BW crtc=%d\n", crtc->base.id); 255 DPU_DEBUG("Release BW crtc=%d\n", crtc->base.id);
278 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 256 dpu_crtc->cur_perf.bw_ctl = 0;
279 dpu_crtc->cur_perf.bw_ctl[i] = 0; 257 _dpu_core_perf_crtc_update_bus(kms, crtc);
280 _dpu_core_perf_crtc_update_bus(kms, crtc, i);
281 }
282 } 258 }
283} 259}
284 260
@@ -321,11 +297,10 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,
321 int params_changed, bool stop_req) 297 int params_changed, bool stop_req)
322{ 298{
323 struct dpu_core_perf_params *new, *old; 299 struct dpu_core_perf_params *new, *old;
324 int update_bus = 0, update_clk = 0; 300 bool update_bus = false, update_clk = false;
325 u64 clk_rate = 0; 301 u64 clk_rate = 0;
326 struct dpu_crtc *dpu_crtc; 302 struct dpu_crtc *dpu_crtc;
327 struct dpu_crtc_state *dpu_cstate; 303 struct dpu_crtc_state *dpu_cstate;
328 int i;
329 struct msm_drm_private *priv; 304 struct msm_drm_private *priv;
330 struct dpu_kms *kms; 305 struct dpu_kms *kms;
331 int ret; 306 int ret;
@@ -352,62 +327,49 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,
352 new = &dpu_cstate->new_perf; 327 new = &dpu_cstate->new_perf;
353 328
354 if (crtc->enabled && !stop_req) { 329 if (crtc->enabled && !stop_req) {
355 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 330 /*
356 /* 331 * cases for bus bandwidth update.
357 * cases for bus bandwidth update. 332 * 1. new bandwidth vote - "ab or ib vote" is higher
358 * 1. new bandwidth vote - "ab or ib vote" is higher 333 * than current vote for update request.
359 * than current vote for update request. 334 * 2. new bandwidth vote - "ab or ib vote" is lower
360 * 2. new bandwidth vote - "ab or ib vote" is lower 335 * than current vote at end of commit or stop.
361 * than current vote at end of commit or stop. 336 */
362 */ 337 if ((params_changed && ((new->bw_ctl > old->bw_ctl) ||
363 if ((params_changed && ((new->bw_ctl[i] > 338 (new->max_per_pipe_ib > old->max_per_pipe_ib))) ||
364 old->bw_ctl[i]) || 339 (!params_changed && ((new->bw_ctl < old->bw_ctl) ||
365 (new->max_per_pipe_ib[i] > 340 (new->max_per_pipe_ib < old->max_per_pipe_ib)))) {
366 old->max_per_pipe_ib[i]))) || 341 DPU_DEBUG("crtc=%d p=%d new_bw=%llu,old_bw=%llu\n",
367 (!params_changed && ((new->bw_ctl[i] < 342 crtc->base.id, params_changed,
368 old->bw_ctl[i]) || 343 new->bw_ctl, old->bw_ctl);
369 (new->max_per_pipe_ib[i] < 344 old->bw_ctl = new->bw_ctl;
370 old->max_per_pipe_ib[i])))) { 345 old->max_per_pipe_ib = new->max_per_pipe_ib;
371 DPU_DEBUG( 346 update_bus = true;
372 "crtc=%d p=%d new_bw=%llu,old_bw=%llu\n",
373 crtc->base.id, params_changed,
374 new->bw_ctl[i], old->bw_ctl[i]);
375 old->bw_ctl[i] = new->bw_ctl[i];
376 old->max_per_pipe_ib[i] =
377 new->max_per_pipe_ib[i];
378 update_bus |= BIT(i);
379 }
380 } 347 }
381 348
382 if ((params_changed && 349 if ((params_changed &&
383 (new->core_clk_rate > old->core_clk_rate)) || 350 (new->core_clk_rate > old->core_clk_rate)) ||
384 (!params_changed && 351 (!params_changed &&
385 (new->core_clk_rate < old->core_clk_rate))) { 352 (new->core_clk_rate < old->core_clk_rate))) {
386 old->core_clk_rate = new->core_clk_rate; 353 old->core_clk_rate = new->core_clk_rate;
387 update_clk = 1; 354 update_clk = true;
388 } 355 }
389 } else { 356 } else {
390 DPU_DEBUG("crtc=%d disable\n", crtc->base.id); 357 DPU_DEBUG("crtc=%d disable\n", crtc->base.id);
391 memset(old, 0, sizeof(*old)); 358 memset(old, 0, sizeof(*old));
392 memset(new, 0, sizeof(*new)); 359 memset(new, 0, sizeof(*new));
393 update_bus = ~0; 360 update_bus = true;
394 update_clk = 1; 361 update_clk = true;
395 } 362 }
396 trace_dpu_perf_crtc_update(crtc->base.id, 363
397 new->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_MNOC], 364 trace_dpu_perf_crtc_update(crtc->base.id, new->bw_ctl,
398 new->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_LLCC], 365 new->core_clk_rate, stop_req, update_bus, update_clk);
399 new->bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_EBI], 366
400 new->core_clk_rate, stop_req, 367 if (update_bus) {
401 update_bus, update_clk); 368 ret = _dpu_core_perf_crtc_update_bus(kms, crtc);
402 369 if (ret) {
403 for (i = 0; i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 370 DPU_ERROR("crtc-%d: failed to update bus bw vote\n",
404 if (update_bus & BIT(i)) { 371 crtc->base.id);
405 ret = _dpu_core_perf_crtc_update_bus(kms, crtc, i); 372 return ret;
406 if (ret) {
407 DPU_ERROR("crtc-%d: failed to update bw vote for bus-%d\n",
408 crtc->base.id, i);
409 return ret;
410 }
411 } 373 }
412 } 374 }
413 375
@@ -498,8 +460,6 @@ int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent)
498 struct dentry *entry; 460 struct dentry *entry;
499 461
500 entry = debugfs_create_dir("core_perf", parent); 462 entry = debugfs_create_dir("core_perf", parent);
501 if (IS_ERR_OR_NULL(entry))
502 return -EINVAL;
503 463
504 debugfs_create_u64("max_core_clk_rate", 0600, entry, 464 debugfs_create_u64("max_core_clk_rate", 0600, entry,
505 &perf->max_core_clk_rate); 465 &perf->max_core_clk_rate);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h
index 6f0f1710023b..cf4b9b5964c6 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h
@@ -34,8 +34,8 @@ enum dpu_core_perf_data_bus_id {
34 * @core_clk_rate: core clock rate request 34 * @core_clk_rate: core clock rate request
35 */ 35 */
36struct dpu_core_perf_params { 36struct dpu_core_perf_params {
37 u64 max_per_pipe_ib[DPU_CORE_PERF_DATA_BUS_ID_MAX]; 37 u64 max_per_pipe_ib;
38 u64 bw_ctl[DPU_CORE_PERF_DATA_BUS_ID_MAX]; 38 u64 bw_ctl;
39 u64 core_clk_rate; 39 u64 core_clk_rate;
40}; 40};
41 41
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 3772f745589d..40ea6286eac1 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1233,19 +1233,14 @@ static int dpu_crtc_debugfs_state_show(struct seq_file *s, void *v)
1233{ 1233{
1234 struct drm_crtc *crtc = (struct drm_crtc *) s->private; 1234 struct drm_crtc *crtc = (struct drm_crtc *) s->private;
1235 struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc); 1235 struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
1236 int i;
1237 1236
1238 seq_printf(s, "client type: %d\n", dpu_crtc_get_client_type(crtc)); 1237 seq_printf(s, "client type: %d\n", dpu_crtc_get_client_type(crtc));
1239 seq_printf(s, "intf_mode: %d\n", dpu_crtc_get_intf_mode(crtc)); 1238 seq_printf(s, "intf_mode: %d\n", dpu_crtc_get_intf_mode(crtc));
1240 seq_printf(s, "core_clk_rate: %llu\n", 1239 seq_printf(s, "core_clk_rate: %llu\n",
1241 dpu_crtc->cur_perf.core_clk_rate); 1240 dpu_crtc->cur_perf.core_clk_rate);
1242 for (i = DPU_CORE_PERF_DATA_BUS_ID_MNOC; 1241 seq_printf(s, "bw_ctl: %llu\n", dpu_crtc->cur_perf.bw_ctl);
1243 i < DPU_CORE_PERF_DATA_BUS_ID_MAX; i++) { 1242 seq_printf(s, "max_per_pipe_ib: %llu\n",
1244 seq_printf(s, "bw_ctl[%d]: %llu\n", i, 1243 dpu_crtc->cur_perf.max_per_pipe_ib);
1245 dpu_crtc->cur_perf.bw_ctl[i]);
1246 seq_printf(s, "max_per_pipe_ib[%d]: %llu\n", i,
1247 dpu_crtc->cur_perf.max_per_pipe_ib[i]);
1248 }
1249 1244
1250 return 0; 1245 return 0;
1251} 1246}
@@ -1264,10 +1259,7 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
1264 1259
1265 dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name, 1260 dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name,
1266 crtc->dev->primary->debugfs_root); 1261 crtc->dev->primary->debugfs_root);
1267 if (!dpu_crtc->debugfs_root)
1268 return -ENOMEM;
1269 1262
1270 /* don't error check these */
1271 debugfs_create_file("status", 0400, 1263 debugfs_create_file("status", 0400,
1272 dpu_crtc->debugfs_root, 1264 dpu_crtc->debugfs_root,
1273 dpu_crtc, &debugfs_status_fops); 1265 dpu_crtc, &debugfs_status_fops);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 82bf16d61a45..1cf4e306fccf 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -622,9 +622,6 @@ static int dpu_encoder_virt_atomic_check(
622 } 622 }
623 } 623 }
624 624
625 if (!ret)
626 drm_mode_set_crtcinfo(adj_mode, 0);
627
628 trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags, 625 trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags,
629 adj_mode->private_flags); 626 adj_mode->private_flags);
630 627
@@ -1985,8 +1982,6 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
1985 /* create overall sub-directory for the encoder */ 1982 /* create overall sub-directory for the encoder */
1986 dpu_enc->debugfs_root = debugfs_create_dir(name, 1983 dpu_enc->debugfs_root = debugfs_create_dir(name,
1987 drm_enc->dev->primary->debugfs_root); 1984 drm_enc->dev->primary->debugfs_root);
1988 if (!dpu_enc->debugfs_root)
1989 return -ENOMEM;
1990 1985
1991 /* don't error check these */ 1986 /* don't error check these */
1992 debugfs_create_file("status", 0600, 1987 debugfs_create_file("status", 0600,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index 2307c431a894..24ab6249083a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -471,90 +471,6 @@ static const struct dpu_format dpu_format_map[] = {
471}; 471};
472 472
473/* 473/*
474 * A5x tile formats tables:
475 * These tables hold the A5x tile formats supported.
476 */
477static const struct dpu_format dpu_format_map_tile[] = {
478 INTERLEAVED_RGB_FMT_TILED(BGR565,
479 0, COLOR_5BIT, COLOR_6BIT, COLOR_5BIT,
480 C2_R_Cr, C0_G_Y, C1_B_Cb, 0, 3,
481 false, 2, 0,
482 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
483
484 INTERLEAVED_RGB_FMT_TILED(ARGB8888,
485 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
486 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4,
487 true, 4, 0,
488 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
489
490 INTERLEAVED_RGB_FMT_TILED(ABGR8888,
491 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
492 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4,
493 true, 4, 0,
494 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
495
496 INTERLEAVED_RGB_FMT_TILED(XBGR8888,
497 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
498 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4,
499 false, 4, 0,
500 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
501
502 INTERLEAVED_RGB_FMT_TILED(RGBA8888,
503 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
504 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4,
505 true, 4, 0,
506 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
507
508 INTERLEAVED_RGB_FMT_TILED(BGRA8888,
509 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
510 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4,
511 true, 4, 0,
512 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
513
514 INTERLEAVED_RGB_FMT_TILED(BGRX8888,
515 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
516 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4,
517 false, 4, 0,
518 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
519
520 INTERLEAVED_RGB_FMT_TILED(XRGB8888,
521 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
522 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4,
523 false, 4, 0,
524 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
525
526 INTERLEAVED_RGB_FMT_TILED(RGBX8888,
527 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
528 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4,
529 false, 4, 0,
530 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
531
532 INTERLEAVED_RGB_FMT_TILED(ABGR2101010,
533 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
534 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4,
535 true, 4, DPU_FORMAT_FLAG_DX,
536 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
537
538 INTERLEAVED_RGB_FMT_TILED(XBGR2101010,
539 COLOR_8BIT, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
540 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4,
541 true, 4, DPU_FORMAT_FLAG_DX,
542 DPU_FETCH_UBWC, 1, DPU_TILE_HEIGHT_TILED),
543
544 PSEUDO_YUV_FMT_TILED(NV12,
545 0, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
546 C1_B_Cb, C2_R_Cr,
547 DPU_CHROMA_420, DPU_FORMAT_FLAG_YUV,
548 DPU_FETCH_UBWC, 2, DPU_TILE_HEIGHT_NV12),
549
550 PSEUDO_YUV_FMT_TILED(NV21,
551 0, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
552 C2_R_Cr, C1_B_Cb,
553 DPU_CHROMA_420, DPU_FORMAT_FLAG_YUV,
554 DPU_FETCH_UBWC, 2, DPU_TILE_HEIGHT_NV12),
555};
556
557/*
558 * UBWC formats table: 474 * UBWC formats table:
559 * This table holds the UBWC formats supported. 475 * This table holds the UBWC formats supported.
560 * If a compression ratio needs to be used for this or any other format, 476 * If a compression ratio needs to be used for this or any other format,
@@ -599,32 +515,6 @@ static const struct dpu_format dpu_format_map_ubwc[] = {
599 DPU_FETCH_UBWC, 4, DPU_TILE_HEIGHT_NV12), 515 DPU_FETCH_UBWC, 4, DPU_TILE_HEIGHT_NV12),
600}; 516};
601 517
602static const struct dpu_format dpu_format_map_p010[] = {
603 PSEUDO_YUV_FMT_LOOSE(NV12,
604 0, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
605 C1_B_Cb, C2_R_Cr,
606 DPU_CHROMA_420, (DPU_FORMAT_FLAG_YUV | DPU_FORMAT_FLAG_DX),
607 DPU_FETCH_LINEAR, 2),
608};
609
610static const struct dpu_format dpu_format_map_p010_ubwc[] = {
611 PSEUDO_YUV_FMT_LOOSE_TILED(NV12,
612 0, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
613 C1_B_Cb, C2_R_Cr,
614 DPU_CHROMA_420, (DPU_FORMAT_FLAG_YUV | DPU_FORMAT_FLAG_DX |
615 DPU_FORMAT_FLAG_COMPRESSED),
616 DPU_FETCH_UBWC, 4, DPU_TILE_HEIGHT_NV12),
617};
618
619static const struct dpu_format dpu_format_map_tp10_ubwc[] = {
620 PSEUDO_YUV_FMT_TILED(NV12,
621 0, COLOR_8BIT, COLOR_8BIT, COLOR_8BIT,
622 C1_B_Cb, C2_R_Cr,
623 DPU_CHROMA_420, (DPU_FORMAT_FLAG_YUV | DPU_FORMAT_FLAG_DX |
624 DPU_FORMAT_FLAG_COMPRESSED),
625 DPU_FETCH_UBWC, 4, DPU_TILE_HEIGHT_NV12),
626};
627
628/* _dpu_get_v_h_subsample_rate - Get subsample rates for all formats we support 518/* _dpu_get_v_h_subsample_rate - Get subsample rates for all formats we support
629 * Note: Not using the drm_format_*_subsampling since we have formats 519 * Note: Not using the drm_format_*_subsampling since we have formats
630 */ 520 */
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
index 95cfd106e1a7..71b6987bff1e 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
@@ -106,9 +106,9 @@ int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable)
106 rc = -EPERM; 106 rc = -EPERM;
107 } 107 }
108 108
109 if (rc) { 109 if (rc && i) {
110 msm_dss_enable_clk(&clk_arry[i], 110 msm_dss_enable_clk(&clk_arry[i - 1],
111 i, false); 111 i - 1, false);
112 break; 112 break;
113 } 113 }
114 } 114 }
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 885bf88afa3e..435b846f9f52 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -56,7 +56,7 @@ static const char * const iommu_ports[] = {
56#define DPU_DEBUGFS_HWMASKNAME "hw_log_mask" 56#define DPU_DEBUGFS_HWMASKNAME "hw_log_mask"
57 57
58static int dpu_kms_hw_init(struct msm_kms *kms); 58static int dpu_kms_hw_init(struct msm_kms *kms);
59static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms); 59static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
60 60
61static unsigned long dpu_iomap_size(struct platform_device *pdev, 61static unsigned long dpu_iomap_size(struct platform_device *pdev,
62 const char *name) 62 const char *name)
@@ -142,8 +142,6 @@ static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
142 struct dentry *parent) 142 struct dentry *parent)
143{ 143{
144 struct dentry *entry = debugfs_create_dir("danger", parent); 144 struct dentry *entry = debugfs_create_dir("danger", parent);
145 if (IS_ERR_OR_NULL(entry))
146 return;
147 145
148 debugfs_create_file("danger_status", 0600, entry, 146 debugfs_create_file("danger_status", 0600, entry,
149 dpu_kms, &dpu_debugfs_danger_stats_fops); 147 dpu_kms, &dpu_debugfs_danger_stats_fops);
@@ -218,32 +216,29 @@ void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
218 } 216 }
219} 217}
220 218
221void *dpu_debugfs_create_regset32(const char *name, umode_t mode, 219void dpu_debugfs_create_regset32(const char *name, umode_t mode,
222 void *parent, struct dpu_debugfs_regset32 *regset) 220 void *parent, struct dpu_debugfs_regset32 *regset)
223{ 221{
224 if (!name || !regset || !regset->dpu_kms || !regset->blk_len) 222 if (!name || !regset || !regset->dpu_kms || !regset->blk_len)
225 return NULL; 223 return;
226 224
227 /* make sure offset is a multiple of 4 */ 225 /* make sure offset is a multiple of 4 */
228 regset->offset = round_down(regset->offset, 4); 226 regset->offset = round_down(regset->offset, 4);
229 227
230 return debugfs_create_file(name, mode, parent, 228 debugfs_create_file(name, mode, parent, regset, &dpu_fops_regset32);
231 regset, &dpu_fops_regset32);
232} 229}
233 230
234static int _dpu_debugfs_init(struct dpu_kms *dpu_kms) 231static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
235{ 232{
233 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
236 void *p = dpu_hw_util_get_log_mask_ptr(); 234 void *p = dpu_hw_util_get_log_mask_ptr();
237 struct dentry *entry; 235 struct dentry *entry;
238 236
239 if (!p) 237 if (!p)
240 return -EINVAL; 238 return -EINVAL;
241 239
242 entry = debugfs_create_dir("debug", dpu_kms->dev->primary->debugfs_root); 240 entry = debugfs_create_dir("debug", minor->debugfs_root);
243 if (IS_ERR_OR_NULL(entry))
244 return -ENODEV;
245 241
246 /* allow root to be NULL */
247 debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p); 242 debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p);
248 243
249 dpu_debugfs_danger_init(dpu_kms, entry); 244 dpu_debugfs_danger_init(dpu_kms, entry);
@@ -578,13 +573,6 @@ fail:
578 return ret; 573 return ret;
579} 574}
580 575
581#ifdef CONFIG_DEBUG_FS
582static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
583{
584 return _dpu_debugfs_init(to_dpu_kms(kms));
585}
586#endif
587
588static long dpu_kms_round_pixclk(struct msm_kms *kms, unsigned long rate, 576static long dpu_kms_round_pixclk(struct msm_kms *kms, unsigned long rate,
589 struct drm_encoder *encoder) 577 struct drm_encoder *encoder)
590{ 578{
@@ -725,17 +713,20 @@ static const struct msm_kms_funcs kms_funcs = {
725#endif 713#endif
726}; 714};
727 715
728static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms) 716static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
729{ 717{
730 struct msm_mmu *mmu; 718 struct msm_mmu *mmu;
731 719
720 if (!dpu_kms->base.aspace)
721 return;
722
732 mmu = dpu_kms->base.aspace->mmu; 723 mmu = dpu_kms->base.aspace->mmu;
733 724
734 mmu->funcs->detach(mmu, (const char **)iommu_ports, 725 mmu->funcs->detach(mmu, (const char **)iommu_ports,
735 ARRAY_SIZE(iommu_ports)); 726 ARRAY_SIZE(iommu_ports));
736 msm_gem_address_space_put(dpu_kms->base.aspace); 727 msm_gem_address_space_put(dpu_kms->base.aspace);
737 728
738 return 0; 729 dpu_kms->base.aspace = NULL;
739} 730}
740 731
741static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms) 732static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
@@ -754,25 +745,20 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
754 aspace = msm_gem_address_space_create(dpu_kms->dev->dev, 745 aspace = msm_gem_address_space_create(dpu_kms->dev->dev,
755 domain, "dpu1"); 746 domain, "dpu1");
756 if (IS_ERR(aspace)) { 747 if (IS_ERR(aspace)) {
757 ret = PTR_ERR(aspace); 748 iommu_domain_free(domain);
758 goto fail; 749 return PTR_ERR(aspace);
759 } 750 }
760 751
761 dpu_kms->base.aspace = aspace;
762
763 ret = aspace->mmu->funcs->attach(aspace->mmu, iommu_ports, 752 ret = aspace->mmu->funcs->attach(aspace->mmu, iommu_ports,
764 ARRAY_SIZE(iommu_ports)); 753 ARRAY_SIZE(iommu_ports));
765 if (ret) { 754 if (ret) {
766 DPU_ERROR("failed to attach iommu %d\n", ret); 755 DPU_ERROR("failed to attach iommu %d\n", ret);
767 msm_gem_address_space_put(aspace); 756 msm_gem_address_space_put(aspace);
768 goto fail; 757 return ret;
769 } 758 }
770 759
760 dpu_kms->base.aspace = aspace;
771 return 0; 761 return 0;
772fail:
773 _dpu_kms_mmu_destroy(dpu_kms);
774
775 return ret;
776} 762}
777 763
778static struct dss_clk *_dpu_kms_get_clk(struct dpu_kms *dpu_kms, 764static struct dss_clk *_dpu_kms_get_clk(struct dpu_kms *dpu_kms,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
index 31e9ef96ca5d..e9f998344838 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
@@ -197,12 +197,8 @@ void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
197 * @mode: File mode within debugfs 197 * @mode: File mode within debugfs
198 * @parent: Parent directory entry within debugfs, can be NULL 198 * @parent: Parent directory entry within debugfs, can be NULL
199 * @regset: Pointer to persistent register block definition 199 * @regset: Pointer to persistent register block definition
200 *
201 * Return: dentry pointer for newly created file, use either debugfs_remove()
202 * or debugfs_remove_recursive() (on a parent directory) to remove the
203 * file
204 */ 200 */
205void *dpu_debugfs_create_regset32(const char *name, umode_t mode, 201void dpu_debugfs_create_regset32(const char *name, umode_t mode,
206 void *parent, struct dpu_debugfs_regset32 *regset); 202 void *parent, struct dpu_debugfs_regset32 *regset);
207 203
208/** 204/**
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
index 7316b4ab1b85..986915bbbc02 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
@@ -4,11 +4,15 @@
4 */ 4 */
5 5
6#include "dpu_kms.h" 6#include "dpu_kms.h"
7#include <linux/interconnect.h>
7 8
8#define to_dpu_mdss(x) container_of(x, struct dpu_mdss, base) 9#define to_dpu_mdss(x) container_of(x, struct dpu_mdss, base)
9 10
10#define HW_INTR_STATUS 0x0010 11#define HW_INTR_STATUS 0x0010
11 12
13/* Max BW defined in KBps */
14#define MAX_BW 6800000
15
12struct dpu_irq_controller { 16struct dpu_irq_controller {
13 unsigned long enabled_mask; 17 unsigned long enabled_mask;
14 struct irq_domain *domain; 18 struct irq_domain *domain;
@@ -21,8 +25,40 @@ struct dpu_mdss {
21 u32 hwversion; 25 u32 hwversion;
22 struct dss_module_power mp; 26 struct dss_module_power mp;
23 struct dpu_irq_controller irq_controller; 27 struct dpu_irq_controller irq_controller;
28 struct icc_path *path[2];
29 u32 num_paths;
24}; 30};
25 31
32static int dpu_mdss_parse_data_bus_icc_path(struct drm_device *dev,
33 struct dpu_mdss *dpu_mdss)
34{
35 struct icc_path *path0 = of_icc_get(dev->dev, "mdp0-mem");
36 struct icc_path *path1 = of_icc_get(dev->dev, "mdp1-mem");
37
38 if (IS_ERR_OR_NULL(path0))
39 return PTR_ERR_OR_ZERO(path0);
40
41 dpu_mdss->path[0] = path0;
42 dpu_mdss->num_paths = 1;
43
44 if (!IS_ERR_OR_NULL(path1)) {
45 dpu_mdss->path[1] = path1;
46 dpu_mdss->num_paths++;
47 }
48
49 return 0;
50}
51
52static void dpu_mdss_icc_request_bw(struct msm_mdss *mdss)
53{
54 struct dpu_mdss *dpu_mdss = to_dpu_mdss(mdss);
55 int i;
56 u64 avg_bw = dpu_mdss->num_paths ? MAX_BW / dpu_mdss->num_paths : 0;
57
58 for (i = 0; i < dpu_mdss->num_paths; i++)
59 icc_set_bw(dpu_mdss->path[i], avg_bw, kBps_to_icc(MAX_BW));
60}
61
26static void dpu_mdss_irq(struct irq_desc *desc) 62static void dpu_mdss_irq(struct irq_desc *desc)
27{ 63{
28 struct dpu_mdss *dpu_mdss = irq_desc_get_handler_data(desc); 64 struct dpu_mdss *dpu_mdss = irq_desc_get_handler_data(desc);
@@ -136,6 +172,8 @@ static int dpu_mdss_enable(struct msm_mdss *mdss)
136 struct dss_module_power *mp = &dpu_mdss->mp; 172 struct dss_module_power *mp = &dpu_mdss->mp;
137 int ret; 173 int ret;
138 174
175 dpu_mdss_icc_request_bw(mdss);
176
139 ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, true); 177 ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, true);
140 if (ret) 178 if (ret)
141 DPU_ERROR("clock enable failed, ret:%d\n", ret); 179 DPU_ERROR("clock enable failed, ret:%d\n", ret);
@@ -147,12 +185,15 @@ static int dpu_mdss_disable(struct msm_mdss *mdss)
147{ 185{
148 struct dpu_mdss *dpu_mdss = to_dpu_mdss(mdss); 186 struct dpu_mdss *dpu_mdss = to_dpu_mdss(mdss);
149 struct dss_module_power *mp = &dpu_mdss->mp; 187 struct dss_module_power *mp = &dpu_mdss->mp;
150 int ret; 188 int ret, i;
151 189
152 ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, false); 190 ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, false);
153 if (ret) 191 if (ret)
154 DPU_ERROR("clock disable failed, ret:%d\n", ret); 192 DPU_ERROR("clock disable failed, ret:%d\n", ret);
155 193
194 for (i = 0; i < dpu_mdss->num_paths; i++)
195 icc_set_bw(dpu_mdss->path[i], 0, 0);
196
156 return ret; 197 return ret;
157} 198}
158 199
@@ -163,6 +204,7 @@ static void dpu_mdss_destroy(struct drm_device *dev)
163 struct dpu_mdss *dpu_mdss = to_dpu_mdss(priv->mdss); 204 struct dpu_mdss *dpu_mdss = to_dpu_mdss(priv->mdss);
164 struct dss_module_power *mp = &dpu_mdss->mp; 205 struct dss_module_power *mp = &dpu_mdss->mp;
165 int irq; 206 int irq;
207 int i;
166 208
167 pm_runtime_suspend(dev->dev); 209 pm_runtime_suspend(dev->dev);
168 pm_runtime_disable(dev->dev); 210 pm_runtime_disable(dev->dev);
@@ -172,6 +214,9 @@ static void dpu_mdss_destroy(struct drm_device *dev)
172 msm_dss_put_clk(mp->clk_config, mp->num_clk); 214 msm_dss_put_clk(mp->clk_config, mp->num_clk);
173 devm_kfree(&pdev->dev, mp->clk_config); 215 devm_kfree(&pdev->dev, mp->clk_config);
174 216
217 for (i = 0; i < dpu_mdss->num_paths; i++)
218 icc_put(dpu_mdss->path[i]);
219
175 if (dpu_mdss->mmio) 220 if (dpu_mdss->mmio)
176 devm_iounmap(&pdev->dev, dpu_mdss->mmio); 221 devm_iounmap(&pdev->dev, dpu_mdss->mmio);
177 dpu_mdss->mmio = NULL; 222 dpu_mdss->mmio = NULL;
@@ -211,6 +256,10 @@ int dpu_mdss_init(struct drm_device *dev)
211 } 256 }
212 dpu_mdss->mmio_len = resource_size(res); 257 dpu_mdss->mmio_len = resource_size(res);
213 258
259 ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss);
260 if (ret)
261 return ret;
262
214 mp = &dpu_mdss->mp; 263 mp = &dpu_mdss->mp;
215 ret = msm_dss_parse_clock(pdev, mp); 264 ret = msm_dss_parse_clock(pdev, mp);
216 if (ret) { 265 if (ret) {
@@ -232,14 +281,16 @@ int dpu_mdss_init(struct drm_device *dev)
232 irq_set_chained_handler_and_data(irq, dpu_mdss_irq, 281 irq_set_chained_handler_and_data(irq, dpu_mdss_irq,
233 dpu_mdss); 282 dpu_mdss);
234 283
284 priv->mdss = &dpu_mdss->base;
285
235 pm_runtime_enable(dev->dev); 286 pm_runtime_enable(dev->dev);
236 287
288 dpu_mdss_icc_request_bw(priv->mdss);
289
237 pm_runtime_get_sync(dev->dev); 290 pm_runtime_get_sync(dev->dev);
238 dpu_mdss->hwversion = readl_relaxed(dpu_mdss->mmio); 291 dpu_mdss->hwversion = readl_relaxed(dpu_mdss->mmio);
239 pm_runtime_put_sync(dev->dev); 292 pm_runtime_put_sync(dev->dev);
240 293
241 priv->mdss = &dpu_mdss->base;
242
243 return ret; 294 return ret;
244 295
245irq_error: 296irq_error:
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index d831cedb55ec..1858b40b18d8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -21,6 +21,7 @@
21#include <linux/debugfs.h> 21#include <linux/debugfs.h>
22#include <linux/dma-buf.h> 22#include <linux/dma-buf.h>
23 23
24#include <drm/drm_damage_helper.h>
24#include <drm/drm_atomic_uapi.h> 25#include <drm/drm_atomic_uapi.h>
25 26
26#include "msm_drv.h" 27#include "msm_drv.h"
@@ -1324,9 +1325,6 @@ static int _dpu_plane_init_debugfs(struct drm_plane *plane)
1324 debugfs_create_dir(pdpu->pipe_name, 1325 debugfs_create_dir(pdpu->pipe_name,
1325 plane->dev->primary->debugfs_root); 1326 plane->dev->primary->debugfs_root);
1326 1327
1327 if (!pdpu->debugfs_root)
1328 return -ENOMEM;
1329
1330 /* don't error check these */ 1328 /* don't error check these */
1331 debugfs_create_x32("features", 0600, 1329 debugfs_create_x32("features", 0600,
1332 pdpu->debugfs_root, &pdpu->features); 1330 pdpu->debugfs_root, &pdpu->features);
@@ -1535,6 +1533,8 @@ struct drm_plane *dpu_plane_init(struct drm_device *dev,
1535 if (ret) 1533 if (ret)
1536 DPU_ERROR("failed to install zpos property, rc = %d\n", ret); 1534 DPU_ERROR("failed to install zpos property, rc = %d\n", ret);
1537 1535
1536 drm_plane_enable_fb_damage_clips(plane);
1537
1538 /* success! finalize initialization */ 1538 /* success! finalize initialization */
1539 drm_plane_helper_add(plane, &dpu_plane_helper_funcs); 1539 drm_plane_helper_add(plane, &dpu_plane_helper_funcs);
1540 1540
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_trace.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_trace.h
index 7dac604b268d..765484437d11 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_trace.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_trace.h
@@ -138,16 +138,12 @@ TRACE_EVENT(dpu_trace_counter,
138) 138)
139 139
140TRACE_EVENT(dpu_perf_crtc_update, 140TRACE_EVENT(dpu_perf_crtc_update,
141 TP_PROTO(u32 crtc, u64 bw_ctl_mnoc, u64 bw_ctl_llcc, 141 TP_PROTO(u32 crtc, u64 bw_ctl, u32 core_clk_rate,
142 u64 bw_ctl_ebi, u32 core_clk_rate, 142 bool stop_req, bool update_bus, bool update_clk),
143 bool stop_req, u32 update_bus, u32 update_clk), 143 TP_ARGS(crtc, bw_ctl, core_clk_rate, stop_req, update_bus, update_clk),
144 TP_ARGS(crtc, bw_ctl_mnoc, bw_ctl_llcc, bw_ctl_ebi, core_clk_rate,
145 stop_req, update_bus, update_clk),
146 TP_STRUCT__entry( 144 TP_STRUCT__entry(
147 __field(u32, crtc) 145 __field(u32, crtc)
148 __field(u64, bw_ctl_mnoc) 146 __field(u64, bw_ctl)
149 __field(u64, bw_ctl_llcc)
150 __field(u64, bw_ctl_ebi)
151 __field(u32, core_clk_rate) 147 __field(u32, core_clk_rate)
152 __field(bool, stop_req) 148 __field(bool, stop_req)
153 __field(u32, update_bus) 149 __field(u32, update_bus)
@@ -155,20 +151,16 @@ TRACE_EVENT(dpu_perf_crtc_update,
155 ), 151 ),
156 TP_fast_assign( 152 TP_fast_assign(
157 __entry->crtc = crtc; 153 __entry->crtc = crtc;
158 __entry->bw_ctl_mnoc = bw_ctl_mnoc; 154 __entry->bw_ctl = bw_ctl;
159 __entry->bw_ctl_llcc = bw_ctl_llcc;
160 __entry->bw_ctl_ebi = bw_ctl_ebi;
161 __entry->core_clk_rate = core_clk_rate; 155 __entry->core_clk_rate = core_clk_rate;
162 __entry->stop_req = stop_req; 156 __entry->stop_req = stop_req;
163 __entry->update_bus = update_bus; 157 __entry->update_bus = update_bus;
164 __entry->update_clk = update_clk; 158 __entry->update_clk = update_clk;
165 ), 159 ),
166 TP_printk( 160 TP_printk(
167 "crtc=%d bw_mnoc=%llu bw_llcc=%llu bw_ebi=%llu clk_rate=%u stop_req=%d u_bus=%d u_clk=%d", 161 "crtc=%d bw_ctl=%llu clk_rate=%u stop_req=%d u_bus=%d u_clk=%d",
168 __entry->crtc, 162 __entry->crtc,
169 __entry->bw_ctl_mnoc, 163 __entry->bw_ctl,
170 __entry->bw_ctl_llcc,
171 __entry->bw_ctl_ebi,
172 __entry->core_clk_rate, 164 __entry->core_clk_rate,
173 __entry->stop_req, 165 __entry->stop_req,
174 __entry->update_bus, 166 __entry->update_bus,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c
index 3c9236bb291c..8bc3aea7cd86 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c
@@ -310,8 +310,6 @@ void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
310 int i, j; 310 int i, j;
311 311
312 entry = debugfs_create_dir("vbif", debugfs_root); 312 entry = debugfs_create_dir("vbif", debugfs_root);
313 if (IS_ERR_OR_NULL(entry))
314 return;
315 313
316 for (i = 0; i < dpu_kms->catalog->vbif_count; i++) { 314 for (i = 0; i < dpu_kms->catalog->vbif_count; i++) {
317 struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i]; 315 struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i];
@@ -319,8 +317,6 @@ void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
319 snprintf(vbif_name, sizeof(vbif_name), "%d", vbif->id); 317 snprintf(vbif_name, sizeof(vbif_name), "%d", vbif->id);
320 318
321 debugfs_vbif = debugfs_create_dir(vbif_name, entry); 319 debugfs_vbif = debugfs_create_dir(vbif_name, entry);
322 if (IS_ERR_OR_NULL(debugfs_vbif))
323 continue;
324 320
325 debugfs_create_u32("features", 0600, debugfs_vbif, 321 debugfs_create_u32("features", 0600, debugfs_vbif,
326 (u32 *)&vbif->features); 322 (u32 *)&vbif->features);
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
index 005066f7154d..2d46d1126283 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
@@ -15,6 +15,7 @@
15 * this program. If not, see <http://www.gnu.org/licenses/>. 15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18#include <drm/drm_damage_helper.h>
18#include "mdp4_kms.h" 19#include "mdp4_kms.h"
19 20
20#define DOWN_SCALE_MAX 8 21#define DOWN_SCALE_MAX 8
@@ -391,6 +392,8 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
391 392
392 mdp4_plane_install_properties(plane, &plane->base); 393 mdp4_plane_install_properties(plane, &plane->base);
393 394
395 drm_plane_enable_fb_damage_clips(plane);
396
394 return plane; 397 return plane;
395 398
396fail: 399fail:
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
index f86351b16e0f..dd1daf0e305a 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
@@ -713,7 +713,7 @@ fail:
713 if (cfg_handler) 713 if (cfg_handler)
714 mdp5_cfg_destroy(cfg_handler); 714 mdp5_cfg_destroy(cfg_handler);
715 715
716 return NULL; 716 return ERR_PTR(ret);
717} 717}
718 718
719static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev) 719static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index 97179bec8902..1c55401956c4 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -16,6 +16,7 @@
16 * this program. If not, see <http://www.gnu.org/licenses/>. 16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19#include <linux/interconnect.h>
19#include <linux/of_irq.h> 20#include <linux/of_irq.h>
20 21
21#include "msm_drv.h" 22#include "msm_drv.h"
@@ -1048,9 +1049,46 @@ static const struct component_ops mdp5_ops = {
1048 .unbind = mdp5_unbind, 1049 .unbind = mdp5_unbind,
1049}; 1050};
1050 1051
1052static int mdp5_setup_interconnect(struct platform_device *pdev)
1053{
1054 struct icc_path *path0 = of_icc_get(&pdev->dev, "mdp0-mem");
1055 struct icc_path *path1 = of_icc_get(&pdev->dev, "mdp1-mem");
1056 struct icc_path *path_rot = of_icc_get(&pdev->dev, "rotator-mem");
1057
1058 if (IS_ERR(path0))
1059 return PTR_ERR(path0);
1060
1061 if (!path0) {
1062 /* no interconnect support is not necessarily a fatal
1063 * condition, the platform may simply not have an
1064 * interconnect driver yet. But warn about it in case
1065 * bootloader didn't setup bus clocks high enough for
1066 * scanout.
1067 */
1068 dev_warn(&pdev->dev, "No interconnect support may cause display underflows!\n");
1069 return 0;
1070 }
1071
1072 icc_set_bw(path0, 0, MBps_to_icc(6400));
1073
1074 if (!IS_ERR_OR_NULL(path1))
1075 icc_set_bw(path1, 0, MBps_to_icc(6400));
1076 if (!IS_ERR_OR_NULL(path_rot))
1077 icc_set_bw(path_rot, 0, MBps_to_icc(6400));
1078
1079 return 0;
1080}
1081
1051static int mdp5_dev_probe(struct platform_device *pdev) 1082static int mdp5_dev_probe(struct platform_device *pdev)
1052{ 1083{
1084 int ret;
1085
1053 DBG(""); 1086 DBG("");
1087
1088 ret = mdp5_setup_interconnect(pdev);
1089 if (ret)
1090 return ret;
1091
1054 return component_add(&pdev->dev, &mdp5_ops); 1092 return component_add(&pdev->dev, &mdp5_ops);
1055} 1093}
1056 1094
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
index 1105c2433f14..91609bde033a 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
@@ -16,6 +16,7 @@
16 * this program. If not, see <http://www.gnu.org/licenses/>. 16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19#include <drm/drm_damage_helper.h>
19#include <drm/drm_print.h> 20#include <drm/drm_print.h>
20#include "mdp5_kms.h" 21#include "mdp5_kms.h"
21 22
@@ -1099,6 +1100,8 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,
1099 1100
1100 mdp5_plane_install_properties(plane, &plane->base); 1101 mdp5_plane_install_properties(plane, &plane->base);
1101 1102
1103 drm_plane_enable_fb_damage_clips(plane);
1104
1102 return plane; 1105 return plane;
1103 1106
1104fail: 1107fail:
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index ada942498b4e..55ea4bc2ee9c 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -242,6 +242,8 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
242 goto fail; 242 goto fail;
243 } 243 }
244 244
245 msm_dsi_manager_setup_encoder(msm_dsi->id);
246
245 priv->bridges[priv->num_bridges++] = msm_dsi->bridge; 247 priv->bridges[priv->num_bridges++] = msm_dsi->bridge;
246 priv->connectors[priv->num_connectors++] = msm_dsi->connector; 248 priv->connectors[priv->num_connectors++] = msm_dsi->connector;
247 249
diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 20a5d3cb0cab..0da8a4e428ad 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -71,7 +71,6 @@ struct msm_dsi {
71 */ 71 */
72 struct drm_panel *panel; 72 struct drm_panel *panel;
73 struct drm_bridge *external_bridge; 73 struct drm_bridge *external_bridge;
74 unsigned long device_flags;
75 74
76 struct device *phy_dev; 75 struct device *phy_dev;
77 bool phy_enabled; 76 bool phy_enabled;
@@ -89,7 +88,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id);
89struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id); 88struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
90int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); 89int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
91bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len); 90bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
92void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags); 91void msm_dsi_manager_setup_encoder(int id);
93int msm_dsi_manager_register(struct msm_dsi *msm_dsi); 92int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
94void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); 93void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
95bool msm_dsi_manager_validate_current_config(u8 id); 94bool msm_dsi_manager_validate_current_config(u8 id);
@@ -161,8 +160,8 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host,
161int msm_dsi_host_power_off(struct mipi_dsi_host *host); 160int msm_dsi_host_power_off(struct mipi_dsi_host *host);
162int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, 161int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
163 const struct drm_display_mode *mode); 162 const struct drm_display_mode *mode);
164struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, 163struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
165 unsigned long *panel_flags); 164unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
166struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host); 165struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
167int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); 166int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
168void msm_dsi_host_unregister(struct mipi_dsi_host *host); 167void msm_dsi_host_unregister(struct mipi_dsi_host *host);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 9ddf16380289..b7b7c1a9164a 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -110,6 +110,25 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
110 .num_dsi = 2, 110 .num_dsi = 2,
111}; 111};
112 112
113static const char * const dsi_msm8998_bus_clk_names[] = {
114 "iface", "bus", "core",
115};
116
117static const struct msm_dsi_config msm8998_dsi_cfg = {
118 .io_offset = DSI_6G_REG_SHIFT,
119 .reg_cfg = {
120 .num = 2,
121 .regs = {
122 {"vdd", 367000, 16 }, /* 0.9 V */
123 {"vdda", 62800, 2 }, /* 1.2 V */
124 },
125 },
126 .bus_clk_names = dsi_msm8998_bus_clk_names,
127 .num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
128 .io_start = { 0xc994000, 0xc996000 },
129 .num_dsi = 2,
130};
131
113static const char * const dsi_sdm845_bus_clk_names[] = { 132static const char * const dsi_sdm845_bus_clk_names[] = {
114 "iface", "bus", 133 "iface", "bus",
115}; 134};
@@ -178,6 +197,8 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
178 &msm8916_dsi_cfg, &msm_dsi_6g_host_ops}, 197 &msm8916_dsi_cfg, &msm_dsi_6g_host_ops},
179 {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_4_1, 198 {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_4_1,
180 &msm8996_dsi_cfg, &msm_dsi_6g_host_ops}, 199 &msm8996_dsi_cfg, &msm_dsi_6g_host_ops},
200 {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_0,
201 &msm8998_dsi_cfg, &msm_dsi_6g_v2_host_ops},
181 {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_1, 202 {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_1,
182 &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops}, 203 &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
183}; 204};
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index a6a3d2bad263..e2b7a7dfbe49 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -17,6 +17,7 @@
17#define MSM_DSI_6G_VER_MINOR_V1_3 0x10030000 17#define MSM_DSI_6G_VER_MINOR_V1_3 0x10030000
18#define MSM_DSI_6G_VER_MINOR_V1_3_1 0x10030001 18#define MSM_DSI_6G_VER_MINOR_V1_3_1 0x10030001
19#define MSM_DSI_6G_VER_MINOR_V1_4_1 0x10040001 19#define MSM_DSI_6G_VER_MINOR_V1_4_1 0x10040001
20#define MSM_DSI_6G_VER_MINOR_V2_2_0 0x20000000
20#define MSM_DSI_6G_VER_MINOR_V2_2_1 0x20020001 21#define MSM_DSI_6G_VER_MINOR_V2_2_1 0x20020001
21 22
22#define MSM_DSI_V2_VER_MINOR_8064 0x0 23#define MSM_DSI_V2_VER_MINOR_8064 0x0
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index dbf490176c2c..aa35d18ab43c 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1041,7 +1041,7 @@ static void dsi_wait4video_done(struct msm_dsi_host *msm_host)
1041 ret = wait_for_completion_timeout(&msm_host->video_comp, 1041 ret = wait_for_completion_timeout(&msm_host->video_comp,
1042 msecs_to_jiffies(70)); 1042 msecs_to_jiffies(70));
1043 1043
1044 if (ret <= 0) 1044 if (ret == 0)
1045 DRM_DEV_ERROR(dev, "wait for video done timed out\n"); 1045 DRM_DEV_ERROR(dev, "wait for video done timed out\n");
1046 1046
1047 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0); 1047 dsi_intr_ctrl(msm_host, DSI_IRQ_MASK_VIDEO_DONE, 0);
@@ -1590,8 +1590,6 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
1590 msm_host->format = dsi->format; 1590 msm_host->format = dsi->format;
1591 msm_host->mode_flags = dsi->mode_flags; 1591 msm_host->mode_flags = dsi->mode_flags;
1592 1592
1593 msm_dsi_manager_attach_dsi_device(msm_host->id, dsi->mode_flags);
1594
1595 /* Some gpios defined in panel DT need to be controlled by host */ 1593 /* Some gpios defined in panel DT need to be controlled by host */
1596 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); 1594 ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
1597 if (ret) 1595 if (ret)
@@ -2434,17 +2432,14 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
2434 return 0; 2432 return 0;
2435} 2433}
2436 2434
2437struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, 2435struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host)
2438 unsigned long *panel_flags)
2439{ 2436{
2440 struct msm_dsi_host *msm_host = to_msm_dsi_host(host); 2437 return of_drm_find_panel(to_msm_dsi_host(host)->device_node);
2441 struct drm_panel *panel; 2438}
2442
2443 panel = of_drm_find_panel(msm_host->device_node);
2444 if (panel_flags)
2445 *panel_flags = msm_host->mode_flags;
2446 2439
2447 return panel; 2440unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host)
2441{
2442 return to_msm_dsi_host(host)->mode_flags;
2448} 2443}
2449 2444
2450struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host) 2445struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index ec6cb0f7f206..271aa7bbca92 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -225,64 +225,80 @@ static int dsi_mgr_bridge_get_id(struct drm_bridge *bridge)
225 return dsi_bridge->id; 225 return dsi_bridge->id;
226} 226}
227 227
228static enum drm_connector_status dsi_mgr_connector_detect( 228static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
229 struct drm_connector *connector, bool force) 229{
230 unsigned long host_flags = msm_dsi_host_get_mode_flags(msm_dsi->host);
231 return !(host_flags & MIPI_DSI_MODE_VIDEO);
232}
233
234void msm_dsi_manager_setup_encoder(int id)
230{ 235{
231 int id = dsi_mgr_connector_get_id(connector);
232 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); 236 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
233 struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id); 237 struct msm_drm_private *priv = msm_dsi->dev->dev_private;
234 struct msm_drm_private *priv = connector->dev->dev_private;
235 struct msm_kms *kms = priv->kms; 238 struct msm_kms *kms = priv->kms;
239 struct drm_encoder *encoder = msm_dsi_get_encoder(msm_dsi);
236 240
237 DBG("id=%d", id); 241 if (encoder && kms->funcs->set_encoder_mode)
238 if (!msm_dsi->panel) { 242 kms->funcs->set_encoder_mode(kms, encoder,
239 msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host, 243 dsi_mgr_is_cmd_mode(msm_dsi));
240 &msm_dsi->device_flags); 244}
241
242 /* There is only 1 panel in the global panel list
243 * for dual DSI mode. Therefore slave dsi should get
244 * the drm_panel instance from master dsi, and
245 * keep using the panel flags got from the current DSI link.
246 */
247 if (!msm_dsi->panel && IS_DUAL_DSI() &&
248 !IS_MASTER_DSI_LINK(id) && other_dsi)
249 msm_dsi->panel = msm_dsi_host_get_panel(
250 other_dsi->host, NULL);
251 245
246static int msm_dsi_manager_panel_init(struct drm_connector *conn, u8 id)
247{
248 struct msm_drm_private *priv = conn->dev->dev_private;
249 struct msm_kms *kms = priv->kms;
250 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
251 struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
252 struct msm_dsi *master_dsi, *slave_dsi;
253 struct drm_panel *panel;
252 254
253 if (msm_dsi->panel && kms->funcs->set_encoder_mode) { 255 if (IS_DUAL_DSI() && !IS_MASTER_DSI_LINK(id)) {
254 bool cmd_mode = !(msm_dsi->device_flags & 256 master_dsi = other_dsi;
255 MIPI_DSI_MODE_VIDEO); 257 slave_dsi = msm_dsi;
256 struct drm_encoder *encoder = 258 } else {
257 msm_dsi_get_encoder(msm_dsi); 259 master_dsi = msm_dsi;
260 slave_dsi = other_dsi;
261 }
258 262
259 kms->funcs->set_encoder_mode(kms, encoder, cmd_mode); 263 /*
260 } 264 * There is only 1 panel in the global panel list for dual DSI mode.
265 * Therefore slave dsi should get the drm_panel instance from master
266 * dsi.
267 */
268 panel = msm_dsi_host_get_panel(master_dsi->host);
269 if (IS_ERR(panel)) {
270 DRM_ERROR("Could not find panel for %u (%ld)\n", msm_dsi->id,
271 PTR_ERR(panel));
272 return PTR_ERR(panel);
273 }
261 274
262 if (msm_dsi->panel && IS_DUAL_DSI()) 275 if (!panel || !IS_DUAL_DSI())
263 drm_object_attach_property(&connector->base, 276 goto out;
264 connector->dev->mode_config.tile_property, 0);
265 277
266 /* Set split display info to kms once dual DSI panel is 278 drm_object_attach_property(&conn->base,
267 * connected to both hosts. 279 conn->dev->mode_config.tile_property, 0);
268 */ 280
269 if (msm_dsi->panel && IS_DUAL_DSI() && 281 /*
270 other_dsi && other_dsi->panel) { 282 * Set split display info to kms once dual DSI panel is connected to
271 bool cmd_mode = !(msm_dsi->device_flags & 283 * both hosts.
272 MIPI_DSI_MODE_VIDEO); 284 */
273 struct drm_encoder *encoder = msm_dsi_get_encoder( 285 if (other_dsi && other_dsi->panel && kms->funcs->set_split_display) {
274 dsi_mgr_get_dsi(DSI_ENCODER_MASTER)); 286 kms->funcs->set_split_display(kms, master_dsi->encoder,
275 struct drm_encoder *slave_enc = msm_dsi_get_encoder( 287 slave_dsi->encoder,
276 dsi_mgr_get_dsi(DSI_ENCODER_SLAVE)); 288 dsi_mgr_is_cmd_mode(msm_dsi));
277
278 if (kms->funcs->set_split_display)
279 kms->funcs->set_split_display(kms, encoder,
280 slave_enc, cmd_mode);
281 else
282 pr_err("mdp does not support dual DSI\n");
283 }
284 } 289 }
285 290
291out:
292 msm_dsi->panel = panel;
293 return 0;
294}
295
296static enum drm_connector_status dsi_mgr_connector_detect(
297 struct drm_connector *connector, bool force)
298{
299 int id = dsi_mgr_connector_get_id(connector);
300 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
301
286 return msm_dsi->panel ? connector_status_connected : 302 return msm_dsi->panel ? connector_status_connected :
287 connector_status_disconnected; 303 connector_status_disconnected;
288} 304}
@@ -595,7 +611,17 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
595 611
596 drm_connector_attach_encoder(connector, msm_dsi->encoder); 612 drm_connector_attach_encoder(connector, msm_dsi->encoder);
597 613
614 ret = msm_dsi_manager_panel_init(connector, id);
615 if (ret) {
616 DRM_DEV_ERROR(msm_dsi->dev->dev, "init panel failed %d\n", ret);
617 goto fail;
618 }
619
598 return connector; 620 return connector;
621
622fail:
623 connector->funcs->destroy(msm_dsi->connector);
624 return ERR_PTR(ret);
599} 625}
600 626
601bool msm_dsi_manager_validate_current_config(u8 id) 627bool msm_dsi_manager_validate_current_config(u8 id)
@@ -751,35 +777,6 @@ bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len)
751 return true; 777 return true;
752} 778}
753 779
754void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags)
755{
756 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
757 struct drm_device *dev = msm_dsi->dev;
758 struct msm_drm_private *priv;
759 struct msm_kms *kms;
760 struct drm_encoder *encoder;
761 bool cmd_mode;
762
763 /*
764 * drm_device pointer is assigned to msm_dsi only in the modeset_init
765 * path. If mipi_dsi_attach() happens in DSI driver's probe path
766 * (generally the case when we're connected to a drm_panel of the type
767 * mipi_dsi_device), this would be NULL. In such cases, try to set the
768 * encoder mode in the DSI connector's detect() op.
769 */
770 if (!dev)
771 return;
772
773 priv = dev->dev_private;
774 kms = priv->kms;
775 encoder = msm_dsi_get_encoder(msm_dsi);
776 cmd_mode = !(device_flags &
777 MIPI_DSI_MODE_VIDEO);
778
779 if (encoder && kms->funcs->set_encoder_mode)
780 kms->funcs->set_encoder_mode(kms, encoder, cmd_mode);
781}
782
783int msm_dsi_manager_register(struct msm_dsi *msm_dsi) 780int msm_dsi_manager_register(struct msm_dsi *msm_dsi)
784{ 781{
785 struct msm_dsi_manager *msm_dsim = &msm_dsim_glb; 782 struct msm_dsi_manager *msm_dsim = &msm_dsim_glb;
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index bc6f64b202f3..4097eca1b3ef 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -499,6 +499,8 @@ static const struct of_device_id dsi_phy_dt_match[] = {
499#ifdef CONFIG_DRM_MSM_DSI_10NM_PHY 499#ifdef CONFIG_DRM_MSM_DSI_10NM_PHY
500 { .compatible = "qcom,dsi-phy-10nm", 500 { .compatible = "qcom,dsi-phy-10nm",
501 .data = &dsi_phy_10nm_cfgs }, 501 .data = &dsi_phy_10nm_cfgs },
502 { .compatible = "qcom,dsi-phy-10nm-8998",
503 .data = &dsi_phy_10nm_8998_cfgs },
502#endif 504#endif
503 {} 505 {}
504}; 506};
@@ -608,10 +610,12 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
608 goto fail; 610 goto fail;
609 611
610 phy->pll = msm_dsi_pll_init(pdev, phy->cfg->type, phy->id); 612 phy->pll = msm_dsi_pll_init(pdev, phy->cfg->type, phy->id);
611 if (IS_ERR_OR_NULL(phy->pll)) 613 if (IS_ERR_OR_NULL(phy->pll)) {
612 DRM_DEV_INFO(dev, 614 DRM_DEV_INFO(dev,
613 "%s: pll init failed: %ld, need separate pll clk driver\n", 615 "%s: pll init failed: %ld, need separate pll clk driver\n",
614 __func__, PTR_ERR(phy->pll)); 616 __func__, PTR_ERR(phy->pll));
617 phy->pll = NULL;
618 }
615 619
616 dsi_phy_disable_resource(phy); 620 dsi_phy_disable_resource(phy);
617 621
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
index 86322c88b98e..c4069ce6afe6 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
@@ -13,6 +13,9 @@
13#define dsi_phy_read(offset) msm_readl((offset)) 13#define dsi_phy_read(offset) msm_readl((offset))
14#define dsi_phy_write(offset, data) msm_writel((data), (offset)) 14#define dsi_phy_write(offset, data) msm_writel((data), (offset))
15 15
16/* v3.0.0 10nm implementation that requires the old timings settings */
17#define V3_0_0_10NM_OLD_TIMINGS_QUIRK BIT(0)
18
16struct msm_dsi_phy_ops { 19struct msm_dsi_phy_ops {
17 int (*init) (struct msm_dsi_phy *phy); 20 int (*init) (struct msm_dsi_phy *phy);
18 int (*enable)(struct msm_dsi_phy *phy, int src_pll_id, 21 int (*enable)(struct msm_dsi_phy *phy, int src_pll_id,
@@ -33,6 +36,7 @@ struct msm_dsi_phy_cfg {
33 bool src_pll_truthtable[DSI_MAX][DSI_MAX]; 36 bool src_pll_truthtable[DSI_MAX][DSI_MAX];
34 const resource_size_t io_start[DSI_MAX]; 37 const resource_size_t io_start[DSI_MAX];
35 const int num_dsi_phy; 38 const int num_dsi_phy;
39 const int quirks;
36}; 40};
37 41
38extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs; 42extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
@@ -41,6 +45,7 @@ extern const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs;
41extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs; 45extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs;
42extern const struct msm_dsi_phy_cfg dsi_phy_14nm_cfgs; 46extern const struct msm_dsi_phy_cfg dsi_phy_14nm_cfgs;
43extern const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs; 47extern const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs;
48extern const struct msm_dsi_phy_cfg dsi_phy_10nm_8998_cfgs;
44 49
45struct msm_dsi_dphy_timing { 50struct msm_dsi_dphy_timing {
46 u32 clk_pre; 51 u32 clk_pre;
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
index 44959e79ce28..47403d4f2d28 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
@@ -42,6 +42,9 @@ static void dsi_phy_hw_v3_0_lane_settings(struct msm_dsi_phy *phy)
42 u8 tx_dctrl[] = { 0x00, 0x00, 0x00, 0x04, 0x01 }; 42 u8 tx_dctrl[] = { 0x00, 0x00, 0x00, 0x04, 0x01 };
43 void __iomem *lane_base = phy->lane_base; 43 void __iomem *lane_base = phy->lane_base;
44 44
45 if (phy->cfg->quirks & V3_0_0_10NM_OLD_TIMINGS_QUIRK)
46 tx_dctrl[3] = 0x02;
47
45 /* Strength ctrl settings */ 48 /* Strength ctrl settings */
46 for (i = 0; i < 5; i++) { 49 for (i = 0; i < 5; i++) {
47 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_LPTX_STR_CTRL(i), 50 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_LPTX_STR_CTRL(i),
@@ -74,9 +77,11 @@ static void dsi_phy_hw_v3_0_lane_settings(struct msm_dsi_phy *phy)
74 tx_dctrl[i]); 77 tx_dctrl[i]);
75 } 78 }
76 79
77 /* Toggle BIT 0 to release freeze I/0 */ 80 if (!(phy->cfg->quirks & V3_0_0_10NM_OLD_TIMINGS_QUIRK)) {
78 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_TX_DCTRL(3), 0x05); 81 /* Toggle BIT 0 to release freeze I/0 */
79 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_TX_DCTRL(3), 0x04); 82 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_TX_DCTRL(3), 0x05);
83 dsi_phy_write(lane_base + REG_DSI_10nm_PHY_LN_TX_DCTRL(3), 0x04);
84 }
80} 85}
81 86
82static int dsi_10nm_phy_enable(struct msm_dsi_phy *phy, int src_pll_id, 87static int dsi_10nm_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
@@ -221,3 +226,22 @@ const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs = {
221 .io_start = { 0xae94400, 0xae96400 }, 226 .io_start = { 0xae94400, 0xae96400 },
222 .num_dsi_phy = 2, 227 .num_dsi_phy = 2,
223}; 228};
229
230const struct msm_dsi_phy_cfg dsi_phy_10nm_8998_cfgs = {
231 .type = MSM_DSI_PHY_10NM,
232 .src_pll_truthtable = { {false, false}, {true, false} },
233 .reg_cfg = {
234 .num = 1,
235 .regs = {
236 {"vdds", 36000, 32},
237 },
238 },
239 .ops = {
240 .enable = dsi_10nm_phy_enable,
241 .disable = dsi_10nm_phy_disable,
242 .init = dsi_10nm_phy_init,
243 },
244 .io_start = { 0xc994400, 0xc996400 },
245 .num_dsi_phy = 2,
246 .quirks = V3_0_0_10NM_OLD_TIMINGS_QUIRK,
247};
diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
index aabab6311043..8f6100db90ed 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
@@ -104,8 +104,13 @@ struct dsi_pll_10nm {
104 struct dsi_pll_regs reg_setup; 104 struct dsi_pll_regs reg_setup;
105 105
106 /* private clocks: */ 106 /* private clocks: */
107 struct clk_hw *hws[NUM_DSI_CLOCKS_MAX]; 107 struct clk_hw *out_div_clk_hw;
108 u32 num_hws; 108 struct clk_hw *bit_clk_hw;
109 struct clk_hw *byte_clk_hw;
110 struct clk_hw *by_2_bit_clk_hw;
111 struct clk_hw *post_out_div_clk_hw;
112 struct clk_hw *pclk_mux_hw;
113 struct clk_hw *out_dsiclk_hw;
109 114
110 /* clock-provider: */ 115 /* clock-provider: */
111 struct clk_hw_onecell_data *hw_data; 116 struct clk_hw_onecell_data *hw_data;
@@ -617,8 +622,19 @@ static int dsi_pll_10nm_get_provider(struct msm_dsi_pll *pll,
617static void dsi_pll_10nm_destroy(struct msm_dsi_pll *pll) 622static void dsi_pll_10nm_destroy(struct msm_dsi_pll *pll)
618{ 623{
619 struct dsi_pll_10nm *pll_10nm = to_pll_10nm(pll); 624 struct dsi_pll_10nm *pll_10nm = to_pll_10nm(pll);
625 struct device *dev = &pll_10nm->pdev->dev;
620 626
621 DBG("DSI PLL%d", pll_10nm->id); 627 DBG("DSI PLL%d", pll_10nm->id);
628 of_clk_del_provider(dev->of_node);
629
630 clk_hw_unregister_divider(pll_10nm->out_dsiclk_hw);
631 clk_hw_unregister_mux(pll_10nm->pclk_mux_hw);
632 clk_hw_unregister_fixed_factor(pll_10nm->post_out_div_clk_hw);
633 clk_hw_unregister_fixed_factor(pll_10nm->by_2_bit_clk_hw);
634 clk_hw_unregister_fixed_factor(pll_10nm->byte_clk_hw);
635 clk_hw_unregister_divider(pll_10nm->bit_clk_hw);
636 clk_hw_unregister_divider(pll_10nm->out_div_clk_hw);
637 clk_hw_unregister(&pll_10nm->base.clk_hw);
622} 638}
623 639
624/* 640/*
@@ -639,10 +655,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
639 .ops = &clk_ops_dsi_pll_10nm_vco, 655 .ops = &clk_ops_dsi_pll_10nm_vco,
640 }; 656 };
641 struct device *dev = &pll_10nm->pdev->dev; 657 struct device *dev = &pll_10nm->pdev->dev;
642 struct clk_hw **hws = pll_10nm->hws;
643 struct clk_hw_onecell_data *hw_data; 658 struct clk_hw_onecell_data *hw_data;
644 struct clk_hw *hw; 659 struct clk_hw *hw;
645 int num = 0;
646 int ret; 660 int ret;
647 661
648 DBG("DSI%d", pll_10nm->id); 662 DBG("DSI%d", pll_10nm->id);
@@ -660,8 +674,6 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
660 if (ret) 674 if (ret)
661 return ret; 675 return ret;
662 676
663 hws[num++] = &pll_10nm->base.clk_hw;
664
665 snprintf(clk_name, 32, "dsi%d_pll_out_div_clk", pll_10nm->id); 677 snprintf(clk_name, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
666 snprintf(parent, 32, "dsi%dvco_clk", pll_10nm->id); 678 snprintf(parent, 32, "dsi%dvco_clk", pll_10nm->id);
667 679
@@ -670,10 +682,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
670 pll_10nm->mmio + 682 pll_10nm->mmio +
671 REG_DSI_10nm_PHY_PLL_PLL_OUTDIV_RATE, 683 REG_DSI_10nm_PHY_PLL_PLL_OUTDIV_RATE,
672 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL); 684 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
673 if (IS_ERR(hw)) 685 if (IS_ERR(hw)) {
674 return PTR_ERR(hw); 686 ret = PTR_ERR(hw);
687 goto err_base_clk_hw;
688 }
675 689
676 hws[num++] = hw; 690 pll_10nm->out_div_clk_hw = hw;
677 691
678 snprintf(clk_name, 32, "dsi%d_pll_bit_clk", pll_10nm->id); 692 snprintf(clk_name, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
679 snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id); 693 snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
@@ -685,10 +699,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
685 REG_DSI_10nm_PHY_CMN_CLK_CFG0, 699 REG_DSI_10nm_PHY_CMN_CLK_CFG0,
686 0, 4, CLK_DIVIDER_ONE_BASED, 700 0, 4, CLK_DIVIDER_ONE_BASED,
687 &pll_10nm->postdiv_lock); 701 &pll_10nm->postdiv_lock);
688 if (IS_ERR(hw)) 702 if (IS_ERR(hw)) {
689 return PTR_ERR(hw); 703 ret = PTR_ERR(hw);
704 goto err_out_div_clk_hw;
705 }
690 706
691 hws[num++] = hw; 707 pll_10nm->bit_clk_hw = hw;
692 708
693 snprintf(clk_name, 32, "dsi%d_phy_pll_out_byteclk", pll_10nm->id); 709 snprintf(clk_name, 32, "dsi%d_phy_pll_out_byteclk", pll_10nm->id);
694 snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id); 710 snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
@@ -696,10 +712,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
696 /* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */ 712 /* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
697 hw = clk_hw_register_fixed_factor(dev, clk_name, parent, 713 hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
698 CLK_SET_RATE_PARENT, 1, 8); 714 CLK_SET_RATE_PARENT, 1, 8);
699 if (IS_ERR(hw)) 715 if (IS_ERR(hw)) {
700 return PTR_ERR(hw); 716 ret = PTR_ERR(hw);
717 goto err_bit_clk_hw;
718 }
701 719
702 hws[num++] = hw; 720 pll_10nm->byte_clk_hw = hw;
703 hw_data->hws[DSI_BYTE_PLL_CLK] = hw; 721 hw_data->hws[DSI_BYTE_PLL_CLK] = hw;
704 722
705 snprintf(clk_name, 32, "dsi%d_pll_by_2_bit_clk", pll_10nm->id); 723 snprintf(clk_name, 32, "dsi%d_pll_by_2_bit_clk", pll_10nm->id);
@@ -707,20 +725,24 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
707 725
708 hw = clk_hw_register_fixed_factor(dev, clk_name, parent, 726 hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
709 0, 1, 2); 727 0, 1, 2);
710 if (IS_ERR(hw)) 728 if (IS_ERR(hw)) {
711 return PTR_ERR(hw); 729 ret = PTR_ERR(hw);
730 goto err_byte_clk_hw;
731 }
712 732
713 hws[num++] = hw; 733 pll_10nm->by_2_bit_clk_hw = hw;
714 734
715 snprintf(clk_name, 32, "dsi%d_pll_post_out_div_clk", pll_10nm->id); 735 snprintf(clk_name, 32, "dsi%d_pll_post_out_div_clk", pll_10nm->id);
716 snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id); 736 snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
717 737
718 hw = clk_hw_register_fixed_factor(dev, clk_name, parent, 738 hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
719 0, 1, 4); 739 0, 1, 4);
720 if (IS_ERR(hw)) 740 if (IS_ERR(hw)) {
721 return PTR_ERR(hw); 741 ret = PTR_ERR(hw);
742 goto err_by_2_bit_clk_hw;
743 }
722 744
723 hws[num++] = hw; 745 pll_10nm->post_out_div_clk_hw = hw;
724 746
725 snprintf(clk_name, 32, "dsi%d_pclk_mux", pll_10nm->id); 747 snprintf(clk_name, 32, "dsi%d_pclk_mux", pll_10nm->id);
726 snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id); 748 snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
@@ -734,10 +756,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
734 }, 4, 0, pll_10nm->phy_cmn_mmio + 756 }, 4, 0, pll_10nm->phy_cmn_mmio +
735 REG_DSI_10nm_PHY_CMN_CLK_CFG1, 757 REG_DSI_10nm_PHY_CMN_CLK_CFG1,
736 0, 2, 0, NULL); 758 0, 2, 0, NULL);
737 if (IS_ERR(hw)) 759 if (IS_ERR(hw)) {
738 return PTR_ERR(hw); 760 ret = PTR_ERR(hw);
761 goto err_post_out_div_clk_hw;
762 }
739 763
740 hws[num++] = hw; 764 pll_10nm->pclk_mux_hw = hw;
741 765
742 snprintf(clk_name, 32, "dsi%d_phy_pll_out_dsiclk", pll_10nm->id); 766 snprintf(clk_name, 32, "dsi%d_phy_pll_out_dsiclk", pll_10nm->id);
743 snprintf(parent, 32, "dsi%d_pclk_mux", pll_10nm->id); 767 snprintf(parent, 32, "dsi%d_pclk_mux", pll_10nm->id);
@@ -748,14 +772,14 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
748 REG_DSI_10nm_PHY_CMN_CLK_CFG0, 772 REG_DSI_10nm_PHY_CMN_CLK_CFG0,
749 4, 4, CLK_DIVIDER_ONE_BASED, 773 4, 4, CLK_DIVIDER_ONE_BASED,
750 &pll_10nm->postdiv_lock); 774 &pll_10nm->postdiv_lock);
751 if (IS_ERR(hw)) 775 if (IS_ERR(hw)) {
752 return PTR_ERR(hw); 776 ret = PTR_ERR(hw);
777 goto err_pclk_mux_hw;
778 }
753 779
754 hws[num++] = hw; 780 pll_10nm->out_dsiclk_hw = hw;
755 hw_data->hws[DSI_PIXEL_PLL_CLK] = hw; 781 hw_data->hws[DSI_PIXEL_PLL_CLK] = hw;
756 782
757 pll_10nm->num_hws = num;
758
759 hw_data->num = NUM_PROVIDED_CLKS; 783 hw_data->num = NUM_PROVIDED_CLKS;
760 pll_10nm->hw_data = hw_data; 784 pll_10nm->hw_data = hw_data;
761 785
@@ -763,10 +787,29 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
763 pll_10nm->hw_data); 787 pll_10nm->hw_data);
764 if (ret) { 788 if (ret) {
765 DRM_DEV_ERROR(dev, "failed to register clk provider: %d\n", ret); 789 DRM_DEV_ERROR(dev, "failed to register clk provider: %d\n", ret);
766 return ret; 790 goto err_dsiclk_hw;
767 } 791 }
768 792
769 return 0; 793 return 0;
794
795err_dsiclk_hw:
796 clk_hw_unregister_divider(pll_10nm->out_dsiclk_hw);
797err_pclk_mux_hw:
798 clk_hw_unregister_mux(pll_10nm->pclk_mux_hw);
799err_post_out_div_clk_hw:
800 clk_hw_unregister_fixed_factor(pll_10nm->post_out_div_clk_hw);
801err_by_2_bit_clk_hw:
802 clk_hw_unregister_fixed_factor(pll_10nm->by_2_bit_clk_hw);
803err_byte_clk_hw:
804 clk_hw_unregister_fixed_factor(pll_10nm->byte_clk_hw);
805err_bit_clk_hw:
806 clk_hw_unregister_divider(pll_10nm->bit_clk_hw);
807err_out_div_clk_hw:
808 clk_hw_unregister_divider(pll_10nm->out_div_clk_hw);
809err_base_clk_hw:
810 clk_hw_unregister(&pll_10nm->base.clk_hw);
811
812 return ret;
770} 813}
771 814
772struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id) 815struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id)
@@ -775,9 +818,6 @@ struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id)
775 struct msm_dsi_pll *pll; 818 struct msm_dsi_pll *pll;
776 int ret; 819 int ret;
777 820
778 if (!pdev)
779 return ERR_PTR(-ENODEV);
780
781 pll_10nm = devm_kzalloc(&pdev->dev, sizeof(*pll_10nm), GFP_KERNEL); 821 pll_10nm = devm_kzalloc(&pdev->dev, sizeof(*pll_10nm), GFP_KERNEL);
782 if (!pll_10nm) 822 if (!pll_10nm)
783 return ERR_PTR(-ENOMEM); 823 return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 31deb87abfc6..229d49740677 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -259,13 +259,24 @@ static int msm_drm_uninit(struct device *dev)
259 struct msm_mdss *mdss = priv->mdss; 259 struct msm_mdss *mdss = priv->mdss;
260 int i; 260 int i;
261 261
262 /*
263 * Shutdown the hw if we're far enough along where things might be on.
264 * If we run this too early, we'll end up panicking in any variety of
265 * places. Since we don't register the drm device until late in
266 * msm_drm_init, drm_dev->registered is used as an indicator that the
267 * shutdown will be successful.
268 */
269 if (ddev->registered) {
270 drm_dev_unregister(ddev);
271 drm_atomic_helper_shutdown(ddev);
272 }
273
262 /* We must cancel and cleanup any pending vblank enable/disable 274 /* We must cancel and cleanup any pending vblank enable/disable
263 * work before drm_irq_uninstall() to avoid work re-enabling an 275 * work before drm_irq_uninstall() to avoid work re-enabling an
264 * irq after uninstall has disabled it. 276 * irq after uninstall has disabled it.
265 */ 277 */
266 278
267 flush_workqueue(priv->wq); 279 flush_workqueue(priv->wq);
268 destroy_workqueue(priv->wq);
269 280
270 /* clean up event worker threads */ 281 /* clean up event worker threads */
271 for (i = 0; i < priv->num_crtcs; i++) { 282 for (i = 0; i < priv->num_crtcs; i++) {
@@ -279,8 +290,6 @@ static int msm_drm_uninit(struct device *dev)
279 290
280 drm_kms_helper_poll_fini(ddev); 291 drm_kms_helper_poll_fini(ddev);
281 292
282 drm_dev_unregister(ddev);
283
284 msm_perf_debugfs_cleanup(priv); 293 msm_perf_debugfs_cleanup(priv);
285 msm_rd_debugfs_cleanup(priv); 294 msm_rd_debugfs_cleanup(priv);
286 295
@@ -288,7 +297,7 @@ static int msm_drm_uninit(struct device *dev)
288 if (fbdev && priv->fbdev) 297 if (fbdev && priv->fbdev)
289 msm_fbdev_free(ddev); 298 msm_fbdev_free(ddev);
290#endif 299#endif
291 drm_atomic_helper_shutdown(ddev); 300
292 drm_mode_config_cleanup(ddev); 301 drm_mode_config_cleanup(ddev);
293 302
294 pm_runtime_get_sync(dev); 303 pm_runtime_get_sync(dev);
@@ -313,6 +322,7 @@ static int msm_drm_uninit(struct device *dev)
313 ddev->dev_private = NULL; 322 ddev->dev_private = NULL;
314 drm_dev_put(ddev); 323 drm_dev_put(ddev);
315 324
325 destroy_workqueue(priv->wq);
316 kfree(priv); 326 kfree(priv);
317 327
318 return 0; 328 return 0;
@@ -611,6 +621,7 @@ static void load_gpu(struct drm_device *dev)
611 621
612static int context_init(struct drm_device *dev, struct drm_file *file) 622static int context_init(struct drm_device *dev, struct drm_file *file)
613{ 623{
624 struct msm_drm_private *priv = dev->dev_private;
614 struct msm_file_private *ctx; 625 struct msm_file_private *ctx;
615 626
616 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 627 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -619,6 +630,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
619 630
620 msm_submitqueue_init(dev, ctx); 631 msm_submitqueue_init(dev, ctx);
621 632
633 ctx->aspace = priv->gpu->aspace;
622 file->driver_priv = ctx; 634 file->driver_priv = ctx;
623 635
624 return 0; 636 return 0;
@@ -1317,16 +1329,24 @@ static int msm_pdev_probe(struct platform_device *pdev)
1317 1329
1318 ret = add_gpu_components(&pdev->dev, &match); 1330 ret = add_gpu_components(&pdev->dev, &match);
1319 if (ret) 1331 if (ret)
1320 return ret; 1332 goto fail;
1321 1333
1322 /* on all devices that I am aware of, iommu's which can map 1334 /* on all devices that I am aware of, iommu's which can map
1323 * any address the cpu can see are used: 1335 * any address the cpu can see are used:
1324 */ 1336 */
1325 ret = dma_set_mask_and_coherent(&pdev->dev, ~0); 1337 ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
1326 if (ret) 1338 if (ret)
1327 return ret; 1339 goto fail;
1340
1341 ret = component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);
1342 if (ret)
1343 goto fail;
1328 1344
1329 return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match); 1345 return 0;
1346
1347fail:
1348 of_platform_depopulate(&pdev->dev);
1349 return ret;
1330} 1350}
1331 1351
1332static int msm_pdev_remove(struct platform_device *pdev) 1352static int msm_pdev_remove(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index e20e6b429804..d9aa7bad454d 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -68,6 +68,7 @@ struct msm_file_private {
68 rwlock_t queuelock; 68 rwlock_t queuelock;
69 struct list_head submitqueues; 69 struct list_head submitqueues;
70 int queueid; 70 int queueid;
71 struct msm_gem_address_space *aspace;
71}; 72};
72 73
73enum msm_mdp_plane_property { 74enum msm_mdp_plane_property {
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 68fa2c8f61e6..a816ceb58716 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <drm/drm_crtc.h> 18#include <drm/drm_crtc.h>
19#include <drm/drm_damage_helper.h>
19#include <drm/drm_gem_framebuffer_helper.h> 20#include <drm/drm_gem_framebuffer_helper.h>
20#include <drm/drm_probe_helper.h> 21#include <drm/drm_probe_helper.h>
21 22
@@ -35,6 +36,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
35static const struct drm_framebuffer_funcs msm_framebuffer_funcs = { 36static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
36 .create_handle = drm_gem_fb_create_handle, 37 .create_handle = drm_gem_fb_create_handle,
37 .destroy = drm_gem_fb_destroy, 38 .destroy = drm_gem_fb_destroy,
39 .dirty = drm_atomic_helper_dirtyfb,
38}; 40};
39 41
40#ifdef CONFIG_DEBUG_FS 42#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 35f55dd25994..d31d9f927887 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -352,8 +352,10 @@ put_iova(struct drm_gem_object *obj)
352 WARN_ON(!mutex_is_locked(&msm_obj->lock)); 352 WARN_ON(!mutex_is_locked(&msm_obj->lock));
353 353
354 list_for_each_entry_safe(vma, tmp, &msm_obj->vmas, list) { 354 list_for_each_entry_safe(vma, tmp, &msm_obj->vmas, list) {
355 msm_gem_purge_vma(vma->aspace, vma); 355 if (vma->aspace) {
356 msm_gem_close_vma(vma->aspace, vma); 356 msm_gem_purge_vma(vma->aspace, vma);
357 msm_gem_close_vma(vma->aspace, vma);
358 }
357 del_vma(vma); 359 del_vma(vma);
358 } 360 }
359} 361}
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index 812d1b1369a5..36aeb58c132b 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -141,6 +141,7 @@ void msm_gem_free_work(struct work_struct *work);
141struct msm_gem_submit { 141struct msm_gem_submit {
142 struct drm_device *dev; 142 struct drm_device *dev;
143 struct msm_gpu *gpu; 143 struct msm_gpu *gpu;
144 struct msm_gem_address_space *aspace;
144 struct list_head node; /* node in ring submit list */ 145 struct list_head node; /* node in ring submit list */
145 struct list_head bo_list; 146 struct list_head bo_list;
146 struct ww_acquire_ctx ticket; 147 struct ww_acquire_ctx ticket;
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 1b681306aca3..d3801bfa4407 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -32,8 +32,9 @@
32#define BO_PINNED 0x2000 32#define BO_PINNED 0x2000
33 33
34static struct msm_gem_submit *submit_create(struct drm_device *dev, 34static struct msm_gem_submit *submit_create(struct drm_device *dev,
35 struct msm_gpu *gpu, struct msm_gpu_submitqueue *queue, 35 struct msm_gpu *gpu, struct msm_gem_address_space *aspace,
36 uint32_t nr_bos, uint32_t nr_cmds) 36 struct msm_gpu_submitqueue *queue, uint32_t nr_bos,
37 uint32_t nr_cmds)
37{ 38{
38 struct msm_gem_submit *submit; 39 struct msm_gem_submit *submit;
39 uint64_t sz = sizeof(*submit) + ((u64)nr_bos * sizeof(submit->bos[0])) + 40 uint64_t sz = sizeof(*submit) + ((u64)nr_bos * sizeof(submit->bos[0])) +
@@ -47,6 +48,7 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
47 return NULL; 48 return NULL;
48 49
49 submit->dev = dev; 50 submit->dev = dev;
51 submit->aspace = aspace;
50 submit->gpu = gpu; 52 submit->gpu = gpu;
51 submit->fence = NULL; 53 submit->fence = NULL;
52 submit->cmd = (void *)&submit->bos[nr_bos]; 54 submit->cmd = (void *)&submit->bos[nr_bos];
@@ -160,7 +162,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit,
160 struct msm_gem_object *msm_obj = submit->bos[i].obj; 162 struct msm_gem_object *msm_obj = submit->bos[i].obj;
161 163
162 if (submit->bos[i].flags & BO_PINNED) 164 if (submit->bos[i].flags & BO_PINNED)
163 msm_gem_unpin_iova(&msm_obj->base, submit->gpu->aspace); 165 msm_gem_unpin_iova(&msm_obj->base, submit->aspace);
164 166
165 if (submit->bos[i].flags & BO_LOCKED) 167 if (submit->bos[i].flags & BO_LOCKED)
166 ww_mutex_unlock(&msm_obj->base.resv->lock); 168 ww_mutex_unlock(&msm_obj->base.resv->lock);
@@ -264,7 +266,7 @@ static int submit_pin_objects(struct msm_gem_submit *submit)
264 266
265 /* if locking succeeded, pin bo: */ 267 /* if locking succeeded, pin bo: */
266 ret = msm_gem_get_and_pin_iova(&msm_obj->base, 268 ret = msm_gem_get_and_pin_iova(&msm_obj->base,
267 submit->gpu->aspace, &iova); 269 submit->aspace, &iova);
268 270
269 if (ret) 271 if (ret)
270 break; 272 break;
@@ -477,7 +479,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
477 } 479 }
478 } 480 }
479 481
480 submit = submit_create(dev, gpu, queue, args->nr_bos, args->nr_cmds); 482 submit = submit_create(dev, gpu, ctx->aspace, queue, args->nr_bos,
483 args->nr_cmds);
481 if (!submit) { 484 if (!submit) {
482 ret = -ENOMEM; 485 ret = -ENOMEM;
483 goto out_unlock; 486 goto out_unlock;
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index bf4ee2766431..0a4c77fb3d94 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -684,7 +684,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
684 struct msm_gem_object *msm_obj = submit->bos[i].obj; 684 struct msm_gem_object *msm_obj = submit->bos[i].obj;
685 /* move to inactive: */ 685 /* move to inactive: */
686 msm_gem_move_to_inactive(&msm_obj->base); 686 msm_gem_move_to_inactive(&msm_obj->base);
687 msm_gem_unpin_iova(&msm_obj->base, gpu->aspace); 687 msm_gem_unpin_iova(&msm_obj->base, submit->aspace);
688 drm_gem_object_put(&msm_obj->base); 688 drm_gem_object_put(&msm_obj->base);
689 } 689 }
690 690
@@ -768,8 +768,7 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
768 768
769 /* submit takes a reference to the bo and iova until retired: */ 769 /* submit takes a reference to the bo and iova until retired: */
770 drm_gem_object_get(&msm_obj->base); 770 drm_gem_object_get(&msm_obj->base);
771 msm_gem_get_and_pin_iova(&msm_obj->base, 771 msm_gem_get_and_pin_iova(&msm_obj->base, submit->aspace, &iova);
772 submit->gpu->aspace, &iova);
773 772
774 if (submit->bos[i].flags & MSM_SUBMIT_BO_WRITE) 773 if (submit->bos[i].flags & MSM_SUBMIT_BO_WRITE)
775 msm_gem_move_to_active(&msm_obj->base, gpu, true, submit->fence); 774 msm_gem_move_to_active(&msm_obj->base, gpu, true, submit->fence);
diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index 12bb54cefd46..19263290b9b7 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -30,7 +30,7 @@ static int msm_fault_handler(struct iommu_domain *domain, struct device *dev,
30 struct msm_iommu *iommu = arg; 30 struct msm_iommu *iommu = arg;
31 if (iommu->base.handler) 31 if (iommu->base.handler)
32 return iommu->base.handler(iommu->base.arg, iova, flags); 32 return iommu->base.handler(iommu->base.arg, iova, flags);
33 pr_warn_ratelimited("*** fault: iova=%08lx, flags=%d\n", iova, flags); 33 pr_warn_ratelimited("*** fault: iova=%16lx, flags=%d\n", iova, flags);
34 return 0; 34 return 0;
35} 35}
36 36
diff --git a/drivers/gpu/drm/msm/msm_perf.c b/drivers/gpu/drm/msm/msm_perf.c
index 5ab21bd2decb..95948cfe7a12 100644
--- a/drivers/gpu/drm/msm/msm_perf.c
+++ b/drivers/gpu/drm/msm/msm_perf.c
@@ -205,7 +205,6 @@ int msm_perf_debugfs_init(struct drm_minor *minor)
205{ 205{
206 struct msm_drm_private *priv = minor->dev->dev_private; 206 struct msm_drm_private *priv = minor->dev->dev_private;
207 struct msm_perf_state *perf; 207 struct msm_perf_state *perf;
208 struct dentry *ent;
209 208
210 /* only create on first minor: */ 209 /* only create on first minor: */
211 if (priv->perf) 210 if (priv->perf)
@@ -220,19 +219,9 @@ int msm_perf_debugfs_init(struct drm_minor *minor)
220 mutex_init(&perf->read_lock); 219 mutex_init(&perf->read_lock);
221 priv->perf = perf; 220 priv->perf = perf;
222 221
223 ent = debugfs_create_file("perf", S_IFREG | S_IRUGO, 222 debugfs_create_file("perf", S_IFREG | S_IRUGO, minor->debugfs_root,
224 minor->debugfs_root, perf, &perf_debugfs_fops); 223 perf, &perf_debugfs_fops);
225 if (!ent) {
226 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/perf\n",
227 minor->debugfs_root);
228 goto fail;
229 }
230
231 return 0; 224 return 0;
232
233fail:
234 msm_perf_debugfs_cleanup(priv);
235 return -1;
236} 225}
237 226
238void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) 227void msm_perf_debugfs_cleanup(struct msm_drm_private *priv)
diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
index d21172933d92..480d810037ce 100644
--- a/drivers/gpu/drm/msm/msm_rd.c
+++ b/drivers/gpu/drm/msm/msm_rd.c
@@ -244,8 +244,6 @@ static void rd_cleanup(struct msm_rd_state *rd)
244static struct msm_rd_state *rd_init(struct drm_minor *minor, const char *name) 244static struct msm_rd_state *rd_init(struct drm_minor *minor, const char *name)
245{ 245{
246 struct msm_rd_state *rd; 246 struct msm_rd_state *rd;
247 struct dentry *ent;
248 int ret = 0;
249 247
250 rd = kzalloc(sizeof(*rd), GFP_KERNEL); 248 rd = kzalloc(sizeof(*rd), GFP_KERNEL);
251 if (!rd) 249 if (!rd)
@@ -258,20 +256,10 @@ static struct msm_rd_state *rd_init(struct drm_minor *minor, const char *name)
258 256
259 init_waitqueue_head(&rd->fifo_event); 257 init_waitqueue_head(&rd->fifo_event);
260 258
261 ent = debugfs_create_file(name, S_IFREG | S_IRUGO, 259 debugfs_create_file(name, S_IFREG | S_IRUGO, minor->debugfs_root, rd,
262 minor->debugfs_root, rd, &rd_debugfs_fops); 260 &rd_debugfs_fops);
263 if (!ent) {
264 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/%s\n",
265 minor->debugfs_root, name);
266 ret = -ENOMEM;
267 goto fail;
268 }
269 261
270 return rd; 262 return rd;
271
272fail:
273 rd_cleanup(rd);
274 return ERR_PTR(ret);
275} 263}
276 264
277int msm_rd_debugfs_init(struct drm_minor *minor) 265int msm_rd_debugfs_init(struct drm_minor *minor)