Skip to content

Commit 52fa904

Browse files
committed
Merge tag 'drm-msm-fixes-2022-01-25' of https://gitlab.freedesktop.org/drm/msm into drm-fixes
A few msm fixes. - parameter checks - put_device balancing - idle/suspend fixes Signed-off-by: Dave Airlie <[email protected]> From: Rob Clark <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/CAF6AEGvAfsgtr==VM4wixAC_hSTuV=eNWXxX=BhZqQrbxHjKgg@mail.gmail.com
2 parents 2fd0e5f + 6aa89ae commit 52fa904

File tree

10 files changed

+70
-11
lines changed

10 files changed

+70
-11
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,8 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)
15601560
for (i = 0; i < gpu->nr_rings; i++)
15611561
a6xx_gpu->shadow[i] = 0;
15621562

1563+
gpu->suspend_count++;
1564+
15631565
return 0;
15641566
}
15651567

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,27 @@ static int adreno_resume(struct device *dev)
608608
return gpu->funcs->pm_resume(gpu);
609609
}
610610

611+
static int active_submits(struct msm_gpu *gpu)
612+
{
613+
int active_submits;
614+
mutex_lock(&gpu->active_lock);
615+
active_submits = gpu->active_submits;
616+
mutex_unlock(&gpu->active_lock);
617+
return active_submits;
618+
}
619+
611620
static int adreno_suspend(struct device *dev)
612621
{
613622
struct msm_gpu *gpu = dev_to_gpu(dev);
623+
int remaining;
624+
625+
remaining = wait_event_timeout(gpu->retire_event,
626+
active_submits(gpu) == 0,
627+
msecs_to_jiffies(1000));
628+
if (remaining == 0) {
629+
dev_err(dev, "Timeout waiting for GPU to suspend\n");
630+
return -EBUSY;
631+
}
614632

615633
return gpu->funcs->pm_suspend(gpu);
616634
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ static void dpu_setup_dspp_pcc(struct dpu_hw_dspp *ctx,
2626
struct dpu_hw_pcc_cfg *cfg)
2727
{
2828

29-
u32 base = ctx->cap->sblk->pcc.base;
29+
u32 base;
3030

31-
if (!ctx || !base) {
31+
if (!ctx) {
32+
DRM_ERROR("invalid ctx %pK\n", ctx);
33+
return;
34+
}
35+
36+
base = ctx->cap->sblk->pcc.base;
37+
38+
if (!base) {
3239
DRM_ERROR("invalid ctx %pK pcc base 0x%x\n", ctx, base);
3340
return;
3441
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
4040

4141
of_node_put(phy_node);
4242

43-
if (!phy_pdev || !msm_dsi->phy) {
43+
if (!phy_pdev) {
44+
DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__);
45+
return -EPROBE_DEFER;
46+
}
47+
if (!msm_dsi->phy) {
48+
put_device(&phy_pdev->dev);
4449
DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__);
4550
return -EPROBE_DEFER;
4651
}

drivers/gpu/drm/msm/dsi/phy/dsi_phy.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,14 @@ int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
808808
struct msm_dsi_phy_clk_request *clk_req,
809809
struct msm_dsi_phy_shared_timings *shared_timings)
810810
{
811-
struct device *dev = &phy->pdev->dev;
811+
struct device *dev;
812812
int ret;
813813

814814
if (!phy || !phy->cfg->ops.enable)
815815
return -EINVAL;
816816

817+
dev = &phy->pdev->dev;
818+
817819
ret = dsi_phy_enable_resource(phy);
818820
if (ret) {
819821
DRM_DEV_ERROR(dev, "%s: resource enable failed, %d\n",

drivers/gpu/drm/msm/hdmi/hdmi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi)
9797

9898
of_node_put(phy_node);
9999

100-
if (!phy_pdev || !hdmi->phy) {
100+
if (!phy_pdev) {
101101
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
102102
return -EPROBE_DEFER;
103103
}
104+
if (!hdmi->phy) {
105+
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
106+
put_device(&phy_pdev->dev);
107+
return -EPROBE_DEFER;
108+
}
104109

105110
hdmi->phy_dev = get_device(&phy_pdev->dev);
106111

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static int msm_init_vram(struct drm_device *dev)
461461
of_node_put(node);
462462
if (ret)
463463
return ret;
464-
size = r.end - r.start;
464+
size = r.end - r.start + 1;
465465
DRM_INFO("using VRAM carveout: %lx@%pa\n", size, &r.start);
466466

467467
/* if we have no IOMMU, then we need to use carveout allocator.
@@ -510,7 +510,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
510510
struct msm_drm_private *priv = dev_get_drvdata(dev);
511511
struct drm_device *ddev;
512512
struct msm_kms *kms;
513-
struct msm_mdss *mdss;
514513
int ret, i;
515514

516515
ddev = drm_dev_alloc(drv, dev);
@@ -521,8 +520,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
521520
ddev->dev_private = priv;
522521
priv->dev = ddev;
523522

524-
mdss = priv->mdss;
525-
526523
priv->wq = alloc_ordered_workqueue("msm", 0);
527524
priv->hangcheck_period = DRM_MSM_HANGCHECK_DEFAULT_PERIOD;
528525

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static void retire_submits(struct msm_gpu *gpu)
703703
}
704704
}
705705
}
706+
707+
wake_up_all(&gpu->retire_event);
706708
}
707709

708710
static void retire_worker(struct kthread_work *work)
@@ -848,6 +850,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
848850
INIT_LIST_HEAD(&gpu->active_list);
849851
mutex_init(&gpu->active_lock);
850852
mutex_init(&gpu->lock);
853+
init_waitqueue_head(&gpu->retire_event);
851854
kthread_init_work(&gpu->retire_work, retire_worker);
852855
kthread_init_work(&gpu->recover_work, recover_worker);
853856
kthread_init_work(&gpu->fault_work, fault_worker);

drivers/gpu/drm/msm/msm_gpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ struct msm_gpu {
230230
/* work for handling GPU recovery: */
231231
struct kthread_work recover_work;
232232

233+
/** retire_event: notified when submits are retired: */
234+
wait_queue_head_t retire_event;
235+
233236
/* work for handling active-list retiring: */
234237
struct kthread_work retire_work;
235238

drivers/gpu/drm/msm/msm_gpu_devfreq.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ void msm_devfreq_init(struct msm_gpu *gpu)
133133
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
134134
}
135135

136+
static void cancel_idle_work(struct msm_gpu_devfreq *df)
137+
{
138+
hrtimer_cancel(&df->idle_work.timer);
139+
kthread_cancel_work_sync(&df->idle_work.work);
140+
}
141+
142+
static void cancel_boost_work(struct msm_gpu_devfreq *df)
143+
{
144+
hrtimer_cancel(&df->boost_work.timer);
145+
kthread_cancel_work_sync(&df->boost_work.work);
146+
}
147+
136148
void msm_devfreq_cleanup(struct msm_gpu *gpu)
137149
{
138150
struct msm_gpu_devfreq *df = &gpu->devfreq;
@@ -152,7 +164,12 @@ void msm_devfreq_resume(struct msm_gpu *gpu)
152164

153165
void msm_devfreq_suspend(struct msm_gpu *gpu)
154166
{
155-
devfreq_suspend_device(gpu->devfreq.devfreq);
167+
struct msm_gpu_devfreq *df = &gpu->devfreq;
168+
169+
devfreq_suspend_device(df->devfreq);
170+
171+
cancel_idle_work(df);
172+
cancel_boost_work(df);
156173
}
157174

158175
static void msm_devfreq_boost_work(struct kthread_work *work)
@@ -196,7 +213,7 @@ void msm_devfreq_active(struct msm_gpu *gpu)
196213
/*
197214
* Cancel any pending transition to idle frequency:
198215
*/
199-
hrtimer_cancel(&df->idle_work.timer);
216+
cancel_idle_work(df);
200217

201218
idle_time = ktime_to_ms(ktime_sub(ktime_get(), df->idle_time));
202219

0 commit comments

Comments
 (0)