Skip to content

Commit cfcfb65

Browse files
committed
Merge tag 'drm-msm-next-2017-08-22' of git://people.freedesktop.org/~robclark/linux into drm-next
Updates for 4.14.. I have some further patches from Jordan to add multiple priority levels and pre-emption, but those will probably be for 4.15 to give me time for the mesa parts. * tag 'drm-msm-next-2017-08-22' of git://people.freedesktop.org/~robclark/linux: drm/msm/mdp5: mark runtime_pm functions as __maybe_unused drm/msm: remove unused variable drm/msm/mdp5: make helper function static drm/msm: make msm_framebuffer_init() static drm/msm: add helper to allocate stolen fb drm/msm: don't track fbdev's gem object separately drm/msm: add modeset module param drm/msm/mdp5: add tracking for clk enable-count drm/msm: remove unused define drm/msm: Add a helper function for in-kernel buffer allocations drm/msm: Attach the GPU MMU when it is created drm/msm: Add A5XX hardware fault detection drm/msm: Remove uneeded platform dev members drm/msm/mdp5: Set up runtime PM for MDSS drm/msm/mdp5: Write to SMP registers even if allocations don't change drm/msm/mdp5: Don't use mode_set helper funcs for encoders and CRTCs drm/msm/dsi: Implement RPM suspend/resume callbacks drm/msm/dsi: Set up runtime PM for DSI drm/msm/hdmi: Set up runtime PM for HDMI drm/msm/mdp5: Use runtime PM get/put API instead of toggling clocks
2 parents 7c0059d + d1f08d8 commit cfcfb65

31 files changed

Lines changed: 574 additions & 273 deletions

‎drivers/gpu/drm/msm/adreno/a3xx_gpu.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,6 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
486486
adreno_gpu = &a3xx_gpu->base;
487487
gpu = &adreno_gpu->base;
488488

489-
a3xx_gpu->pdev = pdev;
490-
491489
gpu->perfcntrs = perfcntrs;
492490
gpu->num_perfcntrs = ARRAY_SIZE(perfcntrs);
493491

‎drivers/gpu/drm/msm/adreno/a3xx_gpu.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
struct a3xx_gpu {
3030
struct adreno_gpu base;
31-
struct platform_device *pdev;
3231

3332
/* if OCMEM is used for GMEM: */
3433
uint32_t ocmem_base;

‎drivers/gpu/drm/msm/adreno/a4xx_gpu.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,6 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
568568
adreno_gpu = &a4xx_gpu->base;
569569
gpu = &adreno_gpu->base;
570570

571-
a4xx_gpu->pdev = pdev;
572-
573571
gpu->perfcntrs = NULL;
574572
gpu->num_perfcntrs = 0;
575573

‎drivers/gpu/drm/msm/adreno/a4xx_gpu.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
struct a4xx_gpu {
2525
struct adreno_gpu base;
26-
struct platform_device *pdev;
2726

2827
/* if OCMEM is used for GMEM: */
2928
uint32_t ocmem_base;

‎drivers/gpu/drm/msm/adreno/a5xx_gpu.c‎

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -284,28 +284,14 @@ static int a5xx_me_init(struct msm_gpu *gpu)
284284
static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu,
285285
const struct firmware *fw, u64 *iova)
286286
{
287-
struct drm_device *drm = gpu->dev;
288287
struct drm_gem_object *bo;
289288
void *ptr;
290289

291-
bo = msm_gem_new_locked(drm, fw->size - 4, MSM_BO_UNCACHED);
292-
if (IS_ERR(bo))
293-
return bo;
290+
ptr = msm_gem_kernel_new_locked(gpu->dev, fw->size - 4,
291+
MSM_BO_UNCACHED | MSM_BO_GPU_READONLY, gpu->aspace, &bo, iova);
294292

295-
ptr = msm_gem_get_vaddr(bo);
296-
if (!ptr) {
297-
drm_gem_object_unreference(bo);
298-
return ERR_PTR(-ENOMEM);
299-
}
300-
301-
if (iova) {
302-
int ret = msm_gem_get_iova(bo, gpu->aspace, iova);
303-
304-
if (ret) {
305-
drm_gem_object_unreference(bo);
306-
return ERR_PTR(ret);
307-
}
308-
}
293+
if (IS_ERR(ptr))
294+
return ERR_CAST(ptr);
309295

310296
memcpy(ptr, &fw->data[4], fw->size - 4);
311297

@@ -372,8 +358,7 @@ static int a5xx_zap_shader_init(struct msm_gpu *gpu)
372358
{
373359
static bool loaded;
374360
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
375-
struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);
376-
struct platform_device *pdev = a5xx_gpu->pdev;
361+
struct platform_device *pdev = gpu->pdev;
377362
int ret;
378363

379364
/*
@@ -410,6 +395,7 @@ static int a5xx_zap_shader_init(struct msm_gpu *gpu)
410395
A5XX_RBBM_INT_0_MASK_RBBM_ETS_MS_TIMEOUT | \
411396
A5XX_RBBM_INT_0_MASK_RBBM_ATB_ASYNC_OVERFLOW | \
412397
A5XX_RBBM_INT_0_MASK_CP_HW_ERROR | \
398+
A5XX_RBBM_INT_0_MASK_MISC_HANG_DETECT | \
413399
A5XX_RBBM_INT_0_MASK_CP_CACHE_FLUSH_TS | \
414400
A5XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS | \
415401
A5XX_RBBM_INT_0_MASK_GPMU_VOLTAGE_DROOP)
@@ -812,6 +798,27 @@ static void a5xx_gpmu_err_irq(struct msm_gpu *gpu)
812798
dev_err_ratelimited(gpu->dev->dev, "GPMU | voltage droop\n");
813799
}
814800

801+
static void a5xx_fault_detect_irq(struct msm_gpu *gpu)
802+
{
803+
struct drm_device *dev = gpu->dev;
804+
struct msm_drm_private *priv = dev->dev_private;
805+
806+
dev_err(dev->dev, "gpu fault fence %x status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n",
807+
gpu->funcs->last_fence(gpu),
808+
gpu_read(gpu, REG_A5XX_RBBM_STATUS),
809+
gpu_read(gpu, REG_A5XX_CP_RB_RPTR),
810+
gpu_read(gpu, REG_A5XX_CP_RB_WPTR),
811+
gpu_read64(gpu, REG_A5XX_CP_IB1_BASE, REG_A5XX_CP_IB1_BASE_HI),
812+
gpu_read(gpu, REG_A5XX_CP_IB1_BUFSZ),
813+
gpu_read64(gpu, REG_A5XX_CP_IB2_BASE, REG_A5XX_CP_IB2_BASE_HI),
814+
gpu_read(gpu, REG_A5XX_CP_IB2_BUFSZ));
815+
816+
/* Turn off the hangcheck timer to keep it from bothering us */
817+
del_timer(&gpu->hangcheck_timer);
818+
819+
queue_work(priv->wq, &gpu->recover_work);
820+
}
821+
815822
#define RBBM_ERROR_MASK \
816823
(A5XX_RBBM_INT_0_MASK_RBBM_AHB_ERROR | \
817824
A5XX_RBBM_INT_0_MASK_RBBM_TRANSFER_TIMEOUT | \
@@ -838,6 +845,9 @@ static irqreturn_t a5xx_irq(struct msm_gpu *gpu)
838845
if (status & A5XX_RBBM_INT_0_MASK_CP_HW_ERROR)
839846
a5xx_cp_err_irq(gpu);
840847

848+
if (status & A5XX_RBBM_INT_0_MASK_MISC_HANG_DETECT)
849+
a5xx_fault_detect_irq(gpu);
850+
841851
if (status & A5XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS)
842852
a5xx_uche_err_irq(gpu);
843853

@@ -1015,7 +1025,6 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
10151025
adreno_gpu = &a5xx_gpu->base;
10161026
gpu = &adreno_gpu->base;
10171027

1018-
a5xx_gpu->pdev = pdev;
10191028
adreno_gpu->registers = a5xx_registers;
10201029
adreno_gpu->reg_offsets = a5xx_register_offsets;
10211030

‎drivers/gpu/drm/msm/adreno/a5xx_gpu.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
struct a5xx_gpu {
2525
struct adreno_gpu base;
26-
struct platform_device *pdev;
2726

2827
struct drm_gem_object *pm4_bo;
2928
uint64_t pm4_iova;

‎drivers/gpu/drm/msm/adreno/a5xx_power.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,10 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu)
294294
*/
295295
bosize = (cmds_size + (cmds_size / TYPE4_MAX_PAYLOAD) + 1) << 2;
296296

297-
a5xx_gpu->gpmu_bo = msm_gem_new_locked(drm, bosize, MSM_BO_UNCACHED);
298-
if (IS_ERR(a5xx_gpu->gpmu_bo))
299-
goto err;
300-
301-
if (msm_gem_get_iova(a5xx_gpu->gpmu_bo, gpu->aspace,
302-
&a5xx_gpu->gpmu_iova))
303-
goto err;
304-
305-
ptr = msm_gem_get_vaddr(a5xx_gpu->gpmu_bo);
306-
if (!ptr)
297+
ptr = msm_gem_kernel_new_locked(drm, bosize,
298+
MSM_BO_UNCACHED | MSM_BO_GPU_READONLY, gpu->aspace,
299+
&a5xx_gpu->gpmu_bo, &a5xx_gpu->gpmu_iova);
300+
if (IS_ERR(ptr))
307301
goto err;
308302

309303
while (cmds_size > 0) {

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

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,6 @@ void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords)
337337
DRM_ERROR("%s: timeout waiting for ringbuffer space\n", gpu->name);
338338
}
339339

340-
static const char *iommu_ports[] = {
341-
"gfx3d_user", "gfx3d_priv",
342-
"gfx3d1_user", "gfx3d1_priv",
343-
};
344-
345340
int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
346341
struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs)
347342
{
@@ -373,15 +368,15 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
373368

374369
adreno_gpu_config.ringsz = RB_SIZE;
375370

371+
pm_runtime_set_autosuspend_delay(&pdev->dev, DRM_MSM_INACTIVE_PERIOD);
372+
pm_runtime_use_autosuspend(&pdev->dev);
373+
pm_runtime_enable(&pdev->dev);
374+
376375
ret = msm_gpu_init(drm, pdev, &adreno_gpu->base, &funcs->base,
377376
adreno_gpu->info->name, &adreno_gpu_config);
378377
if (ret)
379378
return ret;
380379

381-
pm_runtime_set_autosuspend_delay(&pdev->dev, DRM_MSM_INACTIVE_PERIOD);
382-
pm_runtime_use_autosuspend(&pdev->dev);
383-
pm_runtime_enable(&pdev->dev);
384-
385380
ret = request_firmware(&adreno_gpu->pm4, adreno_gpu->info->pm4fw, drm->dev);
386381
if (ret) {
387382
dev_err(drm->dev, "failed to load %s PM4 firmware: %d\n",
@@ -396,37 +391,17 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
396391
return ret;
397392
}
398393

399-
if (gpu->aspace && gpu->aspace->mmu) {
400-
struct msm_mmu *mmu = gpu->aspace->mmu;
401-
ret = mmu->funcs->attach(mmu, iommu_ports,
402-
ARRAY_SIZE(iommu_ports));
403-
if (ret)
404-
return ret;
405-
}
394+
adreno_gpu->memptrs = msm_gem_kernel_new(drm,
395+
sizeof(*adreno_gpu->memptrs), MSM_BO_UNCACHED, gpu->aspace,
396+
&adreno_gpu->memptrs_bo, &adreno_gpu->memptrs_iova);
406397

407-
adreno_gpu->memptrs_bo = msm_gem_new(drm, sizeof(*adreno_gpu->memptrs),
408-
MSM_BO_UNCACHED);
409-
if (IS_ERR(adreno_gpu->memptrs_bo)) {
410-
ret = PTR_ERR(adreno_gpu->memptrs_bo);
411-
adreno_gpu->memptrs_bo = NULL;
412-
dev_err(drm->dev, "could not allocate memptrs: %d\n", ret);
413-
return ret;
414-
}
415-
416-
adreno_gpu->memptrs = msm_gem_get_vaddr(adreno_gpu->memptrs_bo);
417398
if (IS_ERR(adreno_gpu->memptrs)) {
418-
dev_err(drm->dev, "could not vmap memptrs\n");
419-
return -ENOMEM;
420-
}
421-
422-
ret = msm_gem_get_iova(adreno_gpu->memptrs_bo, gpu->aspace,
423-
&adreno_gpu->memptrs_iova);
424-
if (ret) {
425-
dev_err(drm->dev, "could not map memptrs: %d\n", ret);
426-
return ret;
399+
ret = PTR_ERR(adreno_gpu->memptrs);
400+
adreno_gpu->memptrs = NULL;
401+
dev_err(drm->dev, "could not allocate memptrs: %d\n", ret);
427402
}
428403

429-
return 0;
404+
return ret;
430405
}
431406

432407
void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
@@ -446,10 +421,4 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
446421
release_firmware(adreno_gpu->pfp);
447422

448423
msm_gpu_cleanup(gpu);
449-
450-
if (gpu->aspace) {
451-
gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu,
452-
iommu_ports, ARRAY_SIZE(iommu_ports));
453-
msm_gem_address_space_put(gpu->aspace);
454-
}
455424
}

‎drivers/gpu/drm/msm/dsi/dsi.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ static const struct of_device_id dt_match[] = {
161161
{}
162162
};
163163

164+
static const struct dev_pm_ops dsi_pm_ops = {
165+
SET_RUNTIME_PM_OPS(msm_dsi_runtime_suspend, msm_dsi_runtime_resume, NULL)
166+
};
167+
164168
static struct platform_driver dsi_driver = {
165169
.probe = dsi_dev_probe,
166170
.remove = dsi_dev_remove,
167171
.driver = {
168172
.name = "msm_dsi",
169173
.of_match_table = dt_match,
174+
.pm = &dsi_pm_ops,
170175
},
171176
};
172177

‎drivers/gpu/drm/msm/dsi/dsi.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host);
179179
int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
180180
struct drm_device *dev);
181181
int msm_dsi_host_init(struct msm_dsi *msm_dsi);
182+
int msm_dsi_runtime_suspend(struct device *dev);
183+
int msm_dsi_runtime_resume(struct device *dev);
182184

183185
/* dsi phy */
184186
struct msm_dsi_phy;

0 commit comments

Comments
 (0)