Skip to content

Commit af8352f

Browse files
committed
Merge tag 'drm-msm-next-2021-04-11' of https://gitlab.freedesktop.org/drm/msm into drm-next
msm-next from Rob: * Big DSI phy/pll cleanup. Includes some clk patches, acked by maintainer * Initial support for sc7280 * compatibles fixes for sm8150/sm8250 * cleanups for all dpu gens to use same bandwidth scaling paths (\o/) * various shrinker path lock contention optimizations * unpin/swap support for GEM objects (disabled by default, enable with msm.enable_eviction=1 .. due to various combinations of iommu drivers with older gens I want to get more testing on hw I don't have in front of me before enabling by default) * The usual assortment of misc fixes and cleanups Signed-off-by: Daniel Vetter <[email protected]> From: Rob Clark <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/CAF6AEGvL=4aw15qoY8fbKG9FCgnx8Y-dCtf7xiFwTQSHopwSQg@mail.gmail.com
2 parents 213cc92 + a29c8c0 commit af8352f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+5287
-5024
lines changed

drivers/clk/clk-mux.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/clk-provider.h>
11+
#include <linux/device.h>
1112
#include <linux/module.h>
1213
#include <linux/slab.h>
1314
#include <linux/io.h>
@@ -206,6 +207,40 @@ struct clk_hw *__clk_hw_register_mux(struct device *dev, struct device_node *np,
206207
}
207208
EXPORT_SYMBOL_GPL(__clk_hw_register_mux);
208209

210+
static void devm_clk_hw_release_mux(struct device *dev, void *res)
211+
{
212+
clk_hw_unregister_mux(*(struct clk_hw **)res);
213+
}
214+
215+
struct clk_hw *__devm_clk_hw_register_mux(struct device *dev, struct device_node *np,
216+
const char *name, u8 num_parents,
217+
const char * const *parent_names,
218+
const struct clk_hw **parent_hws,
219+
const struct clk_parent_data *parent_data,
220+
unsigned long flags, void __iomem *reg, u8 shift, u32 mask,
221+
u8 clk_mux_flags, u32 *table, spinlock_t *lock)
222+
{
223+
struct clk_hw **ptr, *hw;
224+
225+
ptr = devres_alloc(devm_clk_hw_release_mux, sizeof(*ptr), GFP_KERNEL);
226+
if (!ptr)
227+
return ERR_PTR(-ENOMEM);
228+
229+
hw = __clk_hw_register_mux(dev, np, name, num_parents, parent_names, parent_hws,
230+
parent_data, flags, reg, shift, mask,
231+
clk_mux_flags, table, lock);
232+
233+
if (!IS_ERR(hw)) {
234+
*ptr = hw;
235+
devres_add(dev, ptr);
236+
} else {
237+
devres_free(ptr);
238+
}
239+
240+
return hw;
241+
}
242+
EXPORT_SYMBOL_GPL(__devm_clk_hw_register_mux);
243+
209244
struct clk *clk_register_mux_table(struct device *dev, const char *name,
210245
const char * const *parent_names, u8 num_parents,
211246
unsigned long flags, void __iomem *reg, u8 shift, u32 mask,

drivers/gpu/drm/msm/Kconfig

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ config DRM_MSM
2020
select SND_SOC_HDMI_CODEC if SND_SOC
2121
select SYNC_FILE
2222
select PM_OPP
23+
select NVMEM
2324
help
2425
DRM/KMS driver for MSM/snapdragon.
2526

@@ -76,14 +77,6 @@ config DRM_MSM_DSI
7677
Choose this option if you have a need for MIPI DSI connector
7778
support.
7879

79-
config DRM_MSM_DSI_PLL
80-
bool "Enable DSI PLL driver in MSM DRM"
81-
depends on DRM_MSM_DSI && COMMON_CLK
82-
default y
83-
help
84-
Choose this option to enable DSI PLL driver which provides DSI
85-
source clocks under common clock framework.
86-
8780
config DRM_MSM_DSI_28NM_PHY
8881
bool "Enable DSI 28nm PHY driver in MSM DRM"
8982
depends on DRM_MSM_DSI

drivers/gpu/drm/msm/Makefile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,4 @@ msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
136136
msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
137137
msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
138138

139-
ifeq ($(CONFIG_DRM_MSM_DSI_PLL),y)
140-
msm-y += dsi/pll/dsi_pll.o
141-
msm-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/pll/dsi_pll_28nm.o
142-
msm-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/pll/dsi_pll_28nm_8960.o
143-
msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/pll/dsi_pll_14nm.o
144-
msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/pll/dsi_pll_10nm.o
145-
msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/pll/dsi_pll_7nm.o
146-
endif
147-
148139
obj-$(CONFIG_DRM_MSM) += msm.o

drivers/gpu/drm/msm/adreno/a6xx_gmu.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int a6xx_gmu_hfi_start(struct a6xx_gmu *gmu)
246246
}
247247

248248
struct a6xx_gmu_oob_bits {
249-
int set, ack, set_new, ack_new;
249+
int set, ack, set_new, ack_new, clear, clear_new;
250250
const char *name;
251251
};
252252

@@ -260,6 +260,8 @@ static const struct a6xx_gmu_oob_bits a6xx_gmu_oob_bits[] = {
260260
.ack = 24,
261261
.set_new = 30,
262262
.ack_new = 31,
263+
.clear = 24,
264+
.clear_new = 31,
263265
},
264266

265267
[GMU_OOB_PERFCOUNTER_SET] = {
@@ -268,18 +270,22 @@ static const struct a6xx_gmu_oob_bits a6xx_gmu_oob_bits[] = {
268270
.ack = 25,
269271
.set_new = 28,
270272
.ack_new = 30,
273+
.clear = 25,
274+
.clear_new = 29,
271275
},
272276

273277
[GMU_OOB_BOOT_SLUMBER] = {
274278
.name = "BOOT_SLUMBER",
275279
.set = 22,
276280
.ack = 30,
281+
.clear = 30,
277282
},
278283

279284
[GMU_OOB_DCVS_SET] = {
280285
.name = "GPU_DCVS",
281286
.set = 23,
282287
.ack = 31,
288+
.clear = 31,
283289
},
284290
};
285291

@@ -335,9 +341,9 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)
335341
return;
336342

337343
if (gmu->legacy)
338-
bit = a6xx_gmu_oob_bits[state].ack;
344+
bit = a6xx_gmu_oob_bits[state].clear;
339345
else
340-
bit = a6xx_gmu_oob_bits[state].ack_new;
346+
bit = a6xx_gmu_oob_bits[state].clear_new;
341347

342348
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, 1 << bit);
343349
}

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
273273
case MSM_PARAM_FAULTS:
274274
*value = gpu->global_faults;
275275
return 0;
276+
case MSM_PARAM_SUSPENDS:
277+
*value = gpu->suspend_count;
278+
return 0;
276279
default:
277280
DBG("%s: invalid param: %u", gpu->name, param);
278281
return -EINVAL;

drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ int dpu_core_irq_idx_lookup(struct dpu_kms *dpu_kms,
5858
if (!dpu_kms->hw_intr || !dpu_kms->hw_intr->ops.irq_idx_lookup)
5959
return -EINVAL;
6060

61-
return dpu_kms->hw_intr->ops.irq_idx_lookup(intr_type,
62-
instance_idx);
61+
return dpu_kms->hw_intr->ops.irq_idx_lookup(dpu_kms->hw_intr,
62+
intr_type, instance_idx);
6363
}
6464

6565
/**

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,
380380
} else {
381381
DPU_DEBUG("crtc=%d disable\n", crtc->base.id);
382382
memset(old, 0, sizeof(*old));
383-
memset(new, 0, sizeof(*new));
384383
update_bus = true;
385384
update_clk = true;
386385
}

drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,83 @@ static void dpu_crtc_destroy(struct drm_crtc *crtc)
6666
kfree(dpu_crtc);
6767
}
6868

69+
static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
70+
{
71+
struct drm_device *dev = crtc->dev;
72+
struct drm_encoder *encoder;
73+
74+
drm_for_each_encoder(encoder, dev)
75+
if (encoder->crtc == crtc)
76+
return encoder;
77+
78+
return NULL;
79+
}
80+
81+
static u32 dpu_crtc_get_vblank_counter(struct drm_crtc *crtc)
82+
{
83+
struct drm_encoder *encoder;
84+
85+
encoder = get_encoder_from_crtc(crtc);
86+
if (!encoder) {
87+
DRM_ERROR("no encoder found for crtc %d\n", crtc->index);
88+
return false;
89+
}
90+
91+
return dpu_encoder_get_frame_count(encoder);
92+
}
93+
94+
static bool dpu_crtc_get_scanout_position(struct drm_crtc *crtc,
95+
bool in_vblank_irq,
96+
int *vpos, int *hpos,
97+
ktime_t *stime, ktime_t *etime,
98+
const struct drm_display_mode *mode)
99+
{
100+
unsigned int pipe = crtc->index;
101+
struct drm_encoder *encoder;
102+
int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
103+
104+
encoder = get_encoder_from_crtc(crtc);
105+
if (!encoder) {
106+
DRM_ERROR("no encoder found for crtc %d\n", pipe);
107+
return false;
108+
}
109+
110+
vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
111+
vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
112+
113+
/*
114+
* the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
115+
* the end of VFP. Translate the porch values relative to the line
116+
* counter positions.
117+
*/
118+
119+
vactive_start = vsw + vbp + 1;
120+
vactive_end = vactive_start + mode->crtc_vdisplay;
121+
122+
/* last scan line before VSYNC */
123+
vfp_end = mode->crtc_vtotal;
124+
125+
if (stime)
126+
*stime = ktime_get();
127+
128+
line = dpu_encoder_get_linecount(encoder);
129+
130+
if (line < vactive_start)
131+
line -= vactive_start;
132+
else if (line > vactive_end)
133+
line = line - vfp_end - vactive_start;
134+
else
135+
line -= vactive_start;
136+
137+
*vpos = line;
138+
*hpos = 0;
139+
140+
if (etime)
141+
*etime = ktime_get();
142+
143+
return true;
144+
}
145+
69146
static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer,
70147
struct dpu_plane_state *pstate, struct dpu_format *format)
71148
{
@@ -130,7 +207,9 @@ static void _dpu_crtc_blend_setup_mixer(struct drm_crtc *crtc,
130207
uint32_t stage_idx, lm_idx;
131208
int zpos_cnt[DPU_STAGE_MAX + 1] = { 0 };
132209
bool bg_alpha_enable = false;
210+
DECLARE_BITMAP(fetch_active, SSPP_MAX);
133211

212+
memset(fetch_active, 0, sizeof(fetch_active));
134213
drm_atomic_crtc_for_each_plane(plane, crtc) {
135214
state = plane->state;
136215
if (!state)
@@ -140,7 +219,7 @@ static void _dpu_crtc_blend_setup_mixer(struct drm_crtc *crtc,
140219
fb = state->fb;
141220

142221
dpu_plane_get_ctl_flush(plane, ctl, &flush_mask);
143-
222+
set_bit(dpu_plane_pipe(plane), fetch_active);
144223
DPU_DEBUG("crtc %d stage:%d - plane %d sspp %d fb %d\n",
145224
crtc->base.id,
146225
pstate->stage,
@@ -180,6 +259,9 @@ static void _dpu_crtc_blend_setup_mixer(struct drm_crtc *crtc,
180259
}
181260
}
182261

262+
if (ctl->ops.set_active_pipes)
263+
ctl->ops.set_active_pipes(ctl, fetch_active);
264+
183265
_dpu_crtc_program_lm_output_roi(crtc);
184266
}
185267

@@ -839,6 +921,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
839921
DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
840922
crtc->base.id, crtc_state->enable,
841923
crtc_state->active);
924+
memset(&cstate->new_perf, 0, sizeof(cstate->new_perf));
842925
goto end;
843926
}
844927

@@ -1247,6 +1330,8 @@ static const struct drm_crtc_funcs dpu_crtc_funcs = {
12471330
.early_unregister = dpu_crtc_early_unregister,
12481331
.enable_vblank = msm_crtc_enable_vblank,
12491332
.disable_vblank = msm_crtc_disable_vblank,
1333+
.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
1334+
.get_vblank_counter = dpu_crtc_get_vblank_counter,
12501335
};
12511336

12521337
static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
@@ -1255,6 +1340,7 @@ static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
12551340
.atomic_check = dpu_crtc_atomic_check,
12561341
.atomic_begin = dpu_crtc_atomic_begin,
12571342
.atomic_flush = dpu_crtc_atomic_flush,
1343+
.get_scanout_position = dpu_crtc_get_scanout_position,
12581344
};
12591345

12601346
/* initialize crtc */

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,36 @@ int dpu_encoder_helper_unregister_irq(struct dpu_encoder_phys *phys_enc,
426426
return 0;
427427
}
428428

429+
int dpu_encoder_get_frame_count(struct drm_encoder *drm_enc)
430+
{
431+
struct dpu_encoder_virt *dpu_enc;
432+
struct dpu_encoder_phys *phys;
433+
int framecount = 0;
434+
435+
dpu_enc = to_dpu_encoder_virt(drm_enc);
436+
phys = dpu_enc ? dpu_enc->cur_master : NULL;
437+
438+
if (phys && phys->ops.get_frame_count)
439+
framecount = phys->ops.get_frame_count(phys);
440+
441+
return framecount;
442+
}
443+
444+
int dpu_encoder_get_linecount(struct drm_encoder *drm_enc)
445+
{
446+
struct dpu_encoder_virt *dpu_enc;
447+
struct dpu_encoder_phys *phys;
448+
int linecount = 0;
449+
450+
dpu_enc = to_dpu_encoder_virt(drm_enc);
451+
phys = dpu_enc ? dpu_enc->cur_master : NULL;
452+
453+
if (phys && phys->ops.get_line_count)
454+
linecount = phys->ops.get_line_count(phys);
455+
456+
return linecount;
457+
}
458+
429459
void dpu_encoder_get_hw_resources(struct drm_encoder *drm_enc,
430460
struct dpu_encoder_hw_resources *hw_res)
431461
{

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,16 @@ void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc);
156156
*/
157157
void dpu_encoder_set_idle_timeout(struct drm_encoder *drm_enc,
158158
u32 idle_timeout);
159+
/**
160+
* dpu_encoder_get_linecount - get interface line count for the encoder.
161+
* @drm_enc: Pointer to previously created drm encoder structure
162+
*/
163+
int dpu_encoder_get_linecount(struct drm_encoder *drm_enc);
164+
165+
/**
166+
* dpu_encoder_get_frame_count - get interface frame count for the encoder.
167+
* @drm_enc: Pointer to previously created drm encoder structure
168+
*/
169+
int dpu_encoder_get_frame_count(struct drm_encoder *drm_enc);
159170

160171
#endif /* __DPU_ENCODER_H__ */

0 commit comments

Comments
 (0)