Skip to content

Commit 5e0e7a4

Browse files
committed
Merge tag 'drm-misc-fixes-2021-06-24' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
A DMA address check for nouveau, an error code return fix for kmb, fixes to wait for a moving fence after pinning the BO for amdgpu, nouveau and radeon, a crtc and async page flip fix for atmel-hlcdc and a cpu hang fix for vc4. Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20210624190353.wyizoil3wqrrxz5d@gilmour
2 parents efea0c1 + d330099 commit 5e0e7a4

File tree

9 files changed

+91
-24
lines changed

9 files changed

+91
-24
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,21 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach)
214214
{
215215
struct drm_gem_object *obj = attach->dmabuf->priv;
216216
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
217+
int r;
217218

218219
/* pin buffer into GTT */
219-
return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
220+
r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
221+
if (r)
222+
return r;
223+
224+
if (bo->tbo.moving) {
225+
r = dma_fence_wait(bo->tbo.moving, true);
226+
if (r) {
227+
amdgpu_bo_unpin(bo);
228+
return r;
229+
}
230+
}
231+
return 0;
220232
}
221233

222234
/**

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ static void atmel_hlcdc_crtc_atomic_enable(struct drm_crtc *c,
232232

233233
pm_runtime_put_sync(dev->dev);
234234

235-
drm_crtc_vblank_on(c);
236235
}
237236

238237
#define ATMEL_HLCDC_RGB444_OUTPUT BIT(0)
@@ -343,8 +342,17 @@ static int atmel_hlcdc_crtc_atomic_check(struct drm_crtc *c,
343342

344343
static void atmel_hlcdc_crtc_atomic_begin(struct drm_crtc *c,
345344
struct drm_atomic_state *state)
345+
{
346+
drm_crtc_vblank_on(c);
347+
}
348+
349+
static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *c,
350+
struct drm_atomic_state *state)
346351
{
347352
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
353+
unsigned long flags;
354+
355+
spin_lock_irqsave(&c->dev->event_lock, flags);
348356

349357
if (c->state->event) {
350358
c->state->event->pipe = drm_crtc_index(c);
@@ -354,12 +362,7 @@ static void atmel_hlcdc_crtc_atomic_begin(struct drm_crtc *c,
354362
crtc->event = c->state->event;
355363
c->state->event = NULL;
356364
}
357-
}
358-
359-
static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc,
360-
struct drm_atomic_state *state)
361-
{
362-
/* TODO: write common plane control register if available */
365+
spin_unlock_irqrestore(&c->dev->event_lock, flags);
363366
}
364367

365368
static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)
593593
dev->mode_config.max_width = dc->desc->max_width;
594594
dev->mode_config.max_height = dc->desc->max_height;
595595
dev->mode_config.funcs = &mode_config_funcs;
596+
dev->mode_config.async_page_flip = true;
596597

597598
return 0;
598599
}

drivers/gpu/drm/kmb/kmb_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static int kmb_hw_init(struct drm_device *drm, unsigned long flags)
137137
/* Allocate LCD interrupt resources */
138138
irq_lcd = platform_get_irq(pdev, 0);
139139
if (irq_lcd < 0) {
140+
ret = irq_lcd;
140141
drm_err(&kmb->drm, "irq_lcd not found");
141142
goto setup_fail;
142143
}

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
546546
struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
547547
int i, j;
548548

549-
if (!ttm_dma)
549+
if (!ttm_dma || !ttm_dma->dma_address)
550550
return;
551551
if (!ttm_dma->pages) {
552552
NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -582,7 +582,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
582582
struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
583583
int i, j;
584584

585-
if (!ttm_dma)
585+
if (!ttm_dma || !ttm_dma->dma_address)
586586
return;
587587
if (!ttm_dma->pages) {
588588
NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);

drivers/gpu/drm/nouveau/nouveau_prime.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,22 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj)
9393
if (ret)
9494
return -EINVAL;
9595

96-
return 0;
96+
ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
97+
if (ret)
98+
goto error;
99+
100+
if (nvbo->bo.moving)
101+
ret = dma_fence_wait(nvbo->bo.moving, true);
102+
103+
ttm_bo_unreserve(&nvbo->bo);
104+
if (ret)
105+
goto error;
106+
107+
return ret;
108+
109+
error:
110+
nouveau_bo_unpin(nvbo);
111+
return ret;
97112
}
98113

99114
void nouveau_gem_prime_unpin(struct drm_gem_object *obj)

drivers/gpu/drm/panel/panel-samsung-ld9040.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ MODULE_DEVICE_TABLE(spi, ld9040_ids);
383383
static struct spi_driver ld9040_driver = {
384384
.probe = ld9040_probe,
385385
.remove = ld9040_remove,
386+
.id_table = ld9040_ids,
386387
.driver = {
387388
.name = "panel-samsung-ld9040",
388389
.of_match_table = ld9040_of_match,

drivers/gpu/drm/radeon/radeon_prime.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,19 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj)
7777

7878
/* pin buffer into GTT */
7979
ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
80-
if (likely(ret == 0))
81-
bo->prime_shared_count++;
82-
80+
if (unlikely(ret))
81+
goto error;
82+
83+
if (bo->tbo.moving) {
84+
ret = dma_fence_wait(bo->tbo.moving, false);
85+
if (unlikely(ret)) {
86+
radeon_bo_unpin(bo);
87+
goto error;
88+
}
89+
}
90+
91+
bo->prime_shared_count++;
92+
error:
8393
radeon_bo_unreserve(bo);
8494
return ret;
8595
}

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
159159
struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
160160
bool connected = false;
161161

162+
WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
163+
162164
if (vc4_hdmi->hpd_gpio) {
163165
if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
164166
vc4_hdmi->hpd_active_low)
@@ -180,10 +182,12 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
180182
}
181183
}
182184

185+
pm_runtime_put(&vc4_hdmi->pdev->dev);
183186
return connector_status_connected;
184187
}
185188

186189
cec_phys_addr_invalidate(vc4_hdmi->cec_adap);
190+
pm_runtime_put(&vc4_hdmi->pdev->dev);
187191
return connector_status_disconnected;
188192
}
189193

@@ -473,7 +477,6 @@ static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder,
473477
HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE);
474478

475479
clk_disable_unprepare(vc4_hdmi->pixel_bvb_clock);
476-
clk_disable_unprepare(vc4_hdmi->hsm_clock);
477480
clk_disable_unprepare(vc4_hdmi->pixel_clock);
478481

479482
ret = pm_runtime_put(&vc4_hdmi->pdev->dev);
@@ -784,13 +787,6 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
784787
return;
785788
}
786789

787-
ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
788-
if (ret) {
789-
DRM_ERROR("Failed to turn on HSM clock: %d\n", ret);
790-
clk_disable_unprepare(vc4_hdmi->pixel_clock);
791-
return;
792-
}
793-
794790
vc4_hdmi_cec_update_clk_div(vc4_hdmi);
795791

796792
/*
@@ -801,15 +797,13 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
801797
(hsm_rate > VC4_HSM_MID_CLOCK ? 150000000 : 75000000));
802798
if (ret) {
803799
DRM_ERROR("Failed to set pixel bvb clock rate: %d\n", ret);
804-
clk_disable_unprepare(vc4_hdmi->hsm_clock);
805800
clk_disable_unprepare(vc4_hdmi->pixel_clock);
806801
return;
807802
}
808803

809804
ret = clk_prepare_enable(vc4_hdmi->pixel_bvb_clock);
810805
if (ret) {
811806
DRM_ERROR("Failed to turn on pixel bvb clock: %d\n", ret);
812-
clk_disable_unprepare(vc4_hdmi->hsm_clock);
813807
clk_disable_unprepare(vc4_hdmi->pixel_clock);
814808
return;
815809
}
@@ -1929,6 +1923,29 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi)
19291923
return 0;
19301924
}
19311925

1926+
#ifdef CONFIG_PM
1927+
static int vc4_hdmi_runtime_suspend(struct device *dev)
1928+
{
1929+
struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
1930+
1931+
clk_disable_unprepare(vc4_hdmi->hsm_clock);
1932+
1933+
return 0;
1934+
}
1935+
1936+
static int vc4_hdmi_runtime_resume(struct device *dev)
1937+
{
1938+
struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
1939+
int ret;
1940+
1941+
ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
1942+
if (ret)
1943+
return ret;
1944+
1945+
return 0;
1946+
}
1947+
#endif
1948+
19321949
static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
19331950
{
19341951
const struct vc4_hdmi_variant *variant = of_device_get_match_data(dev);
@@ -2165,11 +2182,18 @@ static const struct of_device_id vc4_hdmi_dt_match[] = {
21652182
{}
21662183
};
21672184

2185+
static const struct dev_pm_ops vc4_hdmi_pm_ops = {
2186+
SET_RUNTIME_PM_OPS(vc4_hdmi_runtime_suspend,
2187+
vc4_hdmi_runtime_resume,
2188+
NULL)
2189+
};
2190+
21682191
struct platform_driver vc4_hdmi_driver = {
21692192
.probe = vc4_hdmi_dev_probe,
21702193
.remove = vc4_hdmi_dev_remove,
21712194
.driver = {
21722195
.name = "vc4_hdmi",
21732196
.of_match_table = vc4_hdmi_dt_match,
2197+
.pm = &vc4_hdmi_pm_ops,
21742198
},
21752199
};

0 commit comments

Comments
 (0)