Skip to content

Commit 049ec1b

Browse files
committed
Merge tag 'drm-fixes-for-v4.7-rc2' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "A bunch of ARM drivers got into the fixes vibe this time around, so this contains a bunch of fixes for imx, atmel hlcdc, arm hdlcd (only so many combos of hlcd), mediatek and omap drm. Other than that there is one mgag200 fix and a few core drm regression fixes" * tag 'drm-fixes-for-v4.7-rc2' of git://people.freedesktop.org/~airlied/linux: (34 commits) drm/omap: fix unused variable warning. drm: hdlcd: Add information about the underlying framebuffers in debugfs drm: hdlcd: Cleanup the atomic plane operations drm/hdlcd: Fix up crtc_state->event handling drm: hdlcd: Revamp runtime power management drm/mediatek: mtk_dsi: Remove spurious drm_connector_unregister drm/mediatek: mtk_dpi: remove invalid error message drm: atmel-hlcdc: fix a NULL check drm: atmel-hlcdc: fix atmel_hlcdc_crtc_reset() implementation drm/mgag200: Black screen fix for G200e rev 4 drm: Wrap direct calls to driver->gem_free_object from CMA drm: fix fb refcount issue with atomic modesetting drm: make drm_atomic_set_mode_prop_for_crtc() more reliable drm/sti: remove extra mode fixup drm: add missing drm_mode_set_crtcinfo call drm/omap: include gpio/consumer.h where needed drm/omap: include linux/seq_file.h where needed Revert "drm/omap: no need to select OMAP2_DSS" drm/omap: Remove regulator API abuse OMAPDSS: HDMI5: Change DDC timings ...
2 parents f2c6b9e + ab3ab68 commit 049ec1b

Some content is hidden

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

46 files changed

+227
-228
lines changed

Documentation/devicetree/bindings/display/imx/ldb.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Required properties:
6262
display-timings are used instead.
6363

6464
Optional properties (required if display-timings are used):
65+
- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
6566
- display-timings : A node that describes the display timings as defined in
6667
Documentation/devicetree/bindings/display/display-timing.txt.
6768
- fsl,data-mapping : should be "spwg" or "jeida"

drivers/gpu/drm/arm/hdlcd_crtc.c

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@
3333
*
3434
*/
3535

36+
static void hdlcd_crtc_cleanup(struct drm_crtc *crtc)
37+
{
38+
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
39+
40+
/* stop the controller on cleanup */
41+
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0);
42+
drm_crtc_cleanup(crtc);
43+
}
44+
3645
static const struct drm_crtc_funcs hdlcd_crtc_funcs = {
37-
.destroy = drm_crtc_cleanup,
46+
.destroy = hdlcd_crtc_cleanup,
3847
.set_config = drm_atomic_helper_set_config,
3948
.page_flip = drm_atomic_helper_page_flip,
4049
.reset = drm_atomic_helper_crtc_reset,
@@ -97,7 +106,7 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc)
97106
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
98107
struct drm_display_mode *m = &crtc->state->adjusted_mode;
99108
struct videomode vm;
100-
unsigned int polarities, line_length, err;
109+
unsigned int polarities, err;
101110

102111
vm.vfront_porch = m->crtc_vsync_start - m->crtc_vdisplay;
103112
vm.vback_porch = m->crtc_vtotal - m->crtc_vsync_end;
@@ -113,23 +122,18 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc)
113122
if (m->flags & DRM_MODE_FLAG_PVSYNC)
114123
polarities |= HDLCD_POLARITY_VSYNC;
115124

116-
line_length = crtc->primary->state->fb->pitches[0];
117-
118125
/* Allow max number of outstanding requests and largest burst size */
119126
hdlcd_write(hdlcd, HDLCD_REG_BUS_OPTIONS,
120127
HDLCD_BUS_MAX_OUTSTAND | HDLCD_BUS_BURST_16);
121128

122-
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, line_length);
123-
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, line_length);
124-
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, m->crtc_vdisplay - 1);
125129
hdlcd_write(hdlcd, HDLCD_REG_V_DATA, m->crtc_vdisplay - 1);
126130
hdlcd_write(hdlcd, HDLCD_REG_V_BACK_PORCH, vm.vback_porch - 1);
127131
hdlcd_write(hdlcd, HDLCD_REG_V_FRONT_PORCH, vm.vfront_porch - 1);
128132
hdlcd_write(hdlcd, HDLCD_REG_V_SYNC, vm.vsync_len - 1);
133+
hdlcd_write(hdlcd, HDLCD_REG_H_DATA, m->crtc_hdisplay - 1);
129134
hdlcd_write(hdlcd, HDLCD_REG_H_BACK_PORCH, vm.hback_porch - 1);
130135
hdlcd_write(hdlcd, HDLCD_REG_H_FRONT_PORCH, vm.hfront_porch - 1);
131136
hdlcd_write(hdlcd, HDLCD_REG_H_SYNC, vm.hsync_len - 1);
132-
hdlcd_write(hdlcd, HDLCD_REG_H_DATA, m->crtc_hdisplay - 1);
133137
hdlcd_write(hdlcd, HDLCD_REG_POLARITIES, polarities);
134138

135139
err = hdlcd_set_pxl_fmt(crtc);
@@ -144,20 +148,19 @@ static void hdlcd_crtc_enable(struct drm_crtc *crtc)
144148
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
145149

146150
clk_prepare_enable(hdlcd->clk);
151+
hdlcd_crtc_mode_set_nofb(crtc);
147152
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1);
148-
drm_crtc_vblank_on(crtc);
149153
}
150154

151155
static void hdlcd_crtc_disable(struct drm_crtc *crtc)
152156
{
153157
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
154158

155-
if (!crtc->primary->fb)
159+
if (!crtc->state->active)
156160
return;
157161

158-
clk_disable_unprepare(hdlcd->clk);
159162
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0);
160-
drm_crtc_vblank_off(crtc);
163+
clk_disable_unprepare(hdlcd->clk);
161164
}
162165

163166
static int hdlcd_crtc_atomic_check(struct drm_crtc *crtc,
@@ -179,20 +182,17 @@ static int hdlcd_crtc_atomic_check(struct drm_crtc *crtc,
179182
static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc,
180183
struct drm_crtc_state *state)
181184
{
182-
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
183-
unsigned long flags;
184-
185-
if (crtc->state->event) {
186-
struct drm_pending_vblank_event *event = crtc->state->event;
185+
struct drm_pending_vblank_event *event = crtc->state->event;
187186

187+
if (event) {
188188
crtc->state->event = NULL;
189-
event->pipe = drm_crtc_index(crtc);
190-
191-
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
192189

193-
spin_lock_irqsave(&crtc->dev->event_lock, flags);
194-
list_add_tail(&event->base.link, &hdlcd->event_list);
195-
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
190+
spin_lock_irq(&crtc->dev->event_lock);
191+
if (drm_crtc_vblank_get(crtc) == 0)
192+
drm_crtc_arm_vblank_event(crtc, event);
193+
else
194+
drm_crtc_send_vblank_event(crtc, event);
195+
spin_unlock_irq(&crtc->dev->event_lock);
196196
}
197197
}
198198

@@ -225,6 +225,15 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
225225
static int hdlcd_plane_atomic_check(struct drm_plane *plane,
226226
struct drm_plane_state *state)
227227
{
228+
u32 src_w, src_h;
229+
230+
src_w = state->src_w >> 16;
231+
src_h = state->src_h >> 16;
232+
233+
/* we can't do any scaling of the plane source */
234+
if ((src_w != state->crtc_w) || (src_h != state->crtc_h))
235+
return -EINVAL;
236+
228237
return 0;
229238
}
230239

@@ -233,20 +242,31 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
233242
{
234243
struct hdlcd_drm_private *hdlcd;
235244
struct drm_gem_cma_object *gem;
245+
unsigned int depth, bpp;
246+
u32 src_w, src_h, dest_w, dest_h;
236247
dma_addr_t scanout_start;
237248

238-
if (!plane->state->crtc || !plane->state->fb)
249+
if (!plane->state->fb)
239250
return;
240251

241-
hdlcd = crtc_to_hdlcd_priv(plane->state->crtc);
252+
drm_fb_get_bpp_depth(plane->state->fb->pixel_format, &depth, &bpp);
253+
src_w = plane->state->src_w >> 16;
254+
src_h = plane->state->src_h >> 16;
255+
dest_w = plane->state->crtc_w;
256+
dest_h = plane->state->crtc_h;
242257
gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
243-
scanout_start = gem->paddr;
258+
scanout_start = gem->paddr + plane->state->fb->offsets[0] +
259+
plane->state->crtc_y * plane->state->fb->pitches[0] +
260+
plane->state->crtc_x * bpp / 8;
261+
262+
hdlcd = plane->dev->dev_private;
263+
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, plane->state->fb->pitches[0]);
264+
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, plane->state->fb->pitches[0]);
265+
hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, dest_h - 1);
244266
hdlcd_write(hdlcd, HDLCD_REG_FB_BASE, scanout_start);
245267
}
246268

247269
static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = {
248-
.prepare_fb = NULL,
249-
.cleanup_fb = NULL,
250270
.atomic_check = hdlcd_plane_atomic_check,
251271
.atomic_update = hdlcd_plane_atomic_update,
252272
};
@@ -294,16 +314,6 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
294314
return plane;
295315
}
296316

297-
void hdlcd_crtc_suspend(struct drm_crtc *crtc)
298-
{
299-
hdlcd_crtc_disable(crtc);
300-
}
301-
302-
void hdlcd_crtc_resume(struct drm_crtc *crtc)
303-
{
304-
hdlcd_crtc_enable(crtc);
305-
}
306-
307317
int hdlcd_setup_crtc(struct drm_device *drm)
308318
{
309319
struct hdlcd_drm_private *hdlcd = drm->dev_private;

drivers/gpu/drm/arm/hdlcd_drv.c

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ static int hdlcd_load(struct drm_device *drm, unsigned long flags)
4949
atomic_set(&hdlcd->dma_end_count, 0);
5050
#endif
5151

52-
INIT_LIST_HEAD(&hdlcd->event_list);
53-
5452
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5553
hdlcd->mmio = devm_ioremap_resource(drm->dev, res);
5654
if (IS_ERR(hdlcd->mmio)) {
@@ -84,11 +82,7 @@ static int hdlcd_load(struct drm_device *drm, unsigned long flags)
8482
goto setup_fail;
8583
}
8684

87-
pm_runtime_enable(drm->dev);
88-
89-
pm_runtime_get_sync(drm->dev);
9085
ret = drm_irq_install(drm, platform_get_irq(pdev, 0));
91-
pm_runtime_put_sync(drm->dev);
9286
if (ret < 0) {
9387
DRM_ERROR("failed to install IRQ handler\n");
9488
goto irq_fail;
@@ -164,24 +158,9 @@ static irqreturn_t hdlcd_irq(int irq, void *arg)
164158
atomic_inc(&hdlcd->vsync_count);
165159

166160
#endif
167-
if (irq_status & HDLCD_INTERRUPT_VSYNC) {
168-
bool events_sent = false;
169-
unsigned long flags;
170-
struct drm_pending_vblank_event *e, *t;
171-
161+
if (irq_status & HDLCD_INTERRUPT_VSYNC)
172162
drm_crtc_handle_vblank(&hdlcd->crtc);
173163

174-
spin_lock_irqsave(&drm->event_lock, flags);
175-
list_for_each_entry_safe(e, t, &hdlcd->event_list, base.link) {
176-
list_del(&e->base.link);
177-
drm_crtc_send_vblank_event(&hdlcd->crtc, e);
178-
events_sent = true;
179-
}
180-
if (events_sent)
181-
drm_crtc_vblank_put(&hdlcd->crtc);
182-
spin_unlock_irqrestore(&drm->event_lock, flags);
183-
}
184-
185164
/* acknowledge interrupt(s) */
186165
hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, irq_status);
187166

@@ -275,6 +254,7 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg)
275254
static struct drm_info_list hdlcd_debugfs_list[] = {
276255
{ "interrupt_count", hdlcd_show_underrun_count, 0 },
277256
{ "clocks", hdlcd_show_pxlclock, 0 },
257+
{ "fb", drm_fb_cma_debugfs_show, 0 },
278258
};
279259

280260
static int hdlcd_debugfs_init(struct drm_minor *minor)
@@ -357,6 +337,8 @@ static int hdlcd_drm_bind(struct device *dev)
357337
return -ENOMEM;
358338

359339
drm->dev_private = hdlcd;
340+
dev_set_drvdata(dev, drm);
341+
360342
hdlcd_setup_mode_config(drm);
361343
ret = hdlcd_load(drm, 0);
362344
if (ret)
@@ -366,14 +348,18 @@ static int hdlcd_drm_bind(struct device *dev)
366348
if (ret)
367349
goto err_unload;
368350

369-
dev_set_drvdata(dev, drm);
370-
371351
ret = component_bind_all(dev, drm);
372352
if (ret) {
373353
DRM_ERROR("Failed to bind all components\n");
374354
goto err_unregister;
375355
}
376356

357+
ret = pm_runtime_set_active(dev);
358+
if (ret)
359+
goto err_pm_active;
360+
361+
pm_runtime_enable(dev);
362+
377363
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
378364
if (ret < 0) {
379365
DRM_ERROR("failed to initialise vblank\n");
@@ -399,16 +385,16 @@ static int hdlcd_drm_bind(struct device *dev)
399385
drm_mode_config_cleanup(drm);
400386
drm_vblank_cleanup(drm);
401387
err_vblank:
388+
pm_runtime_disable(drm->dev);
389+
err_pm_active:
402390
component_unbind_all(dev, drm);
403391
err_unregister:
404392
drm_dev_unregister(drm);
405393
err_unload:
406-
pm_runtime_get_sync(drm->dev);
407394
drm_irq_uninstall(drm);
408-
pm_runtime_put_sync(drm->dev);
409-
pm_runtime_disable(drm->dev);
410395
of_reserved_mem_device_release(drm->dev);
411396
err_free:
397+
dev_set_drvdata(dev, NULL);
412398
drm_dev_unref(drm);
413399

414400
return ret;
@@ -495,30 +481,34 @@ MODULE_DEVICE_TABLE(of, hdlcd_of_match);
495481
static int __maybe_unused hdlcd_pm_suspend(struct device *dev)
496482
{
497483
struct drm_device *drm = dev_get_drvdata(dev);
498-
struct drm_crtc *crtc;
484+
struct hdlcd_drm_private *hdlcd = drm ? drm->dev_private : NULL;
499485

500-
if (pm_runtime_suspended(dev))
486+
if (!hdlcd)
501487
return 0;
502488

503-
drm_modeset_lock_all(drm);
504-
list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
505-
hdlcd_crtc_suspend(crtc);
506-
drm_modeset_unlock_all(drm);
489+
drm_kms_helper_poll_disable(drm);
490+
491+
hdlcd->state = drm_atomic_helper_suspend(drm);
492+
if (IS_ERR(hdlcd->state)) {
493+
drm_kms_helper_poll_enable(drm);
494+
return PTR_ERR(hdlcd->state);
495+
}
496+
507497
return 0;
508498
}
509499

510500
static int __maybe_unused hdlcd_pm_resume(struct device *dev)
511501
{
512502
struct drm_device *drm = dev_get_drvdata(dev);
513-
struct drm_crtc *crtc;
503+
struct hdlcd_drm_private *hdlcd = drm ? drm->dev_private : NULL;
514504

515-
if (!pm_runtime_suspended(dev))
505+
if (!hdlcd)
516506
return 0;
517507

518-
drm_modeset_lock_all(drm);
519-
list_for_each_entry(crtc, &drm->mode_config.crtc_list, head)
520-
hdlcd_crtc_resume(crtc);
521-
drm_modeset_unlock_all(drm);
508+
drm_atomic_helper_resume(drm, hdlcd->state);
509+
drm_kms_helper_poll_enable(drm);
510+
pm_runtime_set_active(dev);
511+
522512
return 0;
523513
}
524514

drivers/gpu/drm/arm/hdlcd_drv.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ struct hdlcd_drm_private {
99
void __iomem *mmio;
1010
struct clk *clk;
1111
struct drm_fbdev_cma *fbdev;
12-
struct drm_framebuffer *fb;
13-
struct list_head event_list;
1412
struct drm_crtc crtc;
1513
struct drm_plane *plane;
14+
struct drm_atomic_state *state;
1615
#ifdef CONFIG_DEBUG_FS
1716
atomic_t buffer_underrun_count;
1817
atomic_t bus_error_count;
@@ -36,7 +35,5 @@ static inline u32 hdlcd_read(struct hdlcd_drm_private *hdlcd, unsigned int reg)
3635

3736
int hdlcd_setup_crtc(struct drm_device *dev);
3837
void hdlcd_set_scanout(struct hdlcd_drm_private *hdlcd);
39-
void hdlcd_crtc_suspend(struct drm_crtc *crtc);
40-
void hdlcd_crtc_resume(struct drm_crtc *crtc);
4138

4239
#endif /* __HDLCD_DRV_H__ */

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,11 @@ void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc)
391391
{
392392
struct atmel_hlcdc_crtc_state *state;
393393

394-
if (crtc->state && crtc->state->mode_blob)
395-
drm_property_unreference_blob(crtc->state->mode_blob);
396-
397394
if (crtc->state) {
395+
__drm_atomic_helper_crtc_destroy_state(crtc->state);
398396
state = drm_crtc_state_to_atmel_hlcdc_crtc_state(crtc->state);
399397
kfree(state);
398+
crtc->state = NULL;
400399
}
401400

402401
state = kzalloc(sizeof(*state), GFP_KERNEL);
@@ -415,8 +414,9 @@ atmel_hlcdc_crtc_duplicate_state(struct drm_crtc *crtc)
415414
return NULL;
416415

417416
state = kmalloc(sizeof(*state), GFP_KERNEL);
418-
if (state)
419-
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
417+
if (!state)
418+
return NULL;
419+
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
420420

421421
cur = drm_crtc_state_to_atmel_hlcdc_crtc_state(crtc->state);
422422
state->output_mode = cur->output_mode;

drivers/gpu/drm/drm_atomic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
351351
drm_property_unreference_blob(state->mode_blob);
352352
state->mode_blob = NULL;
353353

354+
memset(&state->mode, 0, sizeof(state->mode));
355+
354356
if (blob) {
355357
if (blob->length != sizeof(struct drm_mode_modeinfo) ||
356358
drm_mode_convert_umode(&state->mode,
@@ -363,7 +365,6 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
363365
DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n",
364366
state->mode.name, state);
365367
} else {
366-
memset(&state->mode, 0, sizeof(state->mode));
367368
state->enable = false;
368369
DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n",
369370
state);

0 commit comments

Comments
 (0)