aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-12-03 14:38:52 -0500
committerDave Airlie <airlied@redhat.com>2017-12-03 14:42:49 -0500
commit2c1c55cb75a9c72f9726fabb8c3607947711a8df (patch)
treefa835b954149545970eaa256107876d9a24bbf28
parentae64f9bd1d3621b5e60d7363bc20afb46aede215 (diff)
parent2f51be0945b9e0b9baafe47289c802be6d4c7980 (diff)
Merge tag 'drm-misc-next-2017-11-30' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
Cross-subsystem Changes: - device tree doc for the Mitsubishi AA070MC01 and Tianma TM070RVHG71 panels (Lukasz Majewski) and for a 2nd endpoint on stm32 (Philippe Cornu) Core Changes: The most important changes are: - Add drm_driver .last_close and .output_poll_changed helpers to reduce fbdev emulation footprint in drivers (Noralf) - Fix plane clipping in core and for vmwgfx (Ville) Then we have a bunch of of improvement for print and debug such as the addition of a framebuffer debugfs file. ELD connector, HDMI and improvements. And a bunch of misc improvements, clean ups and style changes and doc updates [airlied: drop eld bits from amdgpu_dm] Driver Changes: - sii8620: filter unsupported modes and add DVI mode support (Maciej Purski) - rockchip: analogix_dp: Remove unnecessary init code (Jeffy Chen) - virtio, cirrus: add fb create_handle support to enable screenshots(Lepton Wu) - virtio: replace reference/unreference with get/put (Aastha Gupta) - vc4, gma500: Convert timers to use timer_setup() (Kees Cook) - vc4: Reject HDMI modes with too high of clocks (Eric) - vc4: Add support for more pixel formats (Dave Stevenson) - stm: dsi: Rename driver name to "stm32-display-dsi" (Philippe Cornu) - stm: ltdc: add a 2nd endpoint (Philippe Cornu) - via: use monotonic time for VIA_WAIT_IRQ (Arnd Bergmann) * tag 'drm-misc-next-2017-11-30' of git://anongit.freedesktop.org/drm/drm-misc: (96 commits) drm/bridge: tc358767: add copyright lines MAINTAINERS: change maintainer for Rockchip drm drivers drm/vblank: Fix vblank timestamp debugs drm/via: use monotonic time for VIA_WAIT_IRQ dma-buf: Fix ifnullfree.cocci warnings drm/printer: Add drm_vprintf() drm/edid: Allow HDMI infoframe without VIC or S3D video/hdmi: Allow "empty" HDMI infoframes dma-buf/fence: Fix lock inversion within dma-fence-array drm/sti: Handle return value of platform_get_irq_byname drm/vc4: Add support for NV21 and NV61. drm/vc4: Use .pixel_order instead of custom .flip_cbcr drm/vc4: Add support for DRM_FORMAT_RGB888 and DRM_FORMAT_BGR888 drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c drm: Check crtc_state->enable rather than crtc->enabled in drm_plane_helper_check_state() drm/vmwgfx: Try to fix plane clipping drm/vmwgfx: Use drm_plane_helper_check_state() drm/vmwgfx: Remove bogus crtc coords vs fb size check gpu: gma500: remove unneeded DRIVER_LICENSE #define drm: don't link DP aux i2c adapter to the hardware device node ...
-rw-r--r--Documentation/devicetree/bindings/display/panel/mitsubishi,aa070mc01.txt7
-rw-r--r--Documentation/devicetree/bindings/display/panel/tianma,tm070rvhg71.txt29
-rw-r--r--Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt1
-rw-r--r--Documentation/devicetree/bindings/display/st,stm32-ltdc.txt6
-rw-r--r--Documentation/gpu/todo.rst4
-rw-r--r--MAINTAINERS4
-rw-r--r--drivers/base/Kconfig1
-rw-r--r--drivers/dma-buf/dma-buf.c9
-rw-r--r--drivers/dma-buf/dma-fence-array.c14
-rw-r--r--drivers/dma-buf/reservation.c58
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c1
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c2
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c7
-rw-r--r--drivers/gpu/drm/arc/arcpgu_drv.c2
-rw-r--r--drivers/gpu/drm/arm/hdlcd_crtc.c8
-rw-r--r--drivers/gpu/drm/arm/hdlcd_drv.c2
-rw-r--r--drivers/gpu/drm/arm/malidp_planes.c3
-rw-r--r--drivers/gpu/drm/bridge/analogix-anx78xx.c2
-rw-r--r--drivers/gpu/drm/bridge/sil-sii8620.c53
-rw-r--r--drivers/gpu/drm/bridge/synopsys/dw-hdmi.c6
-rw-r--r--drivers/gpu/drm/bridge/tc358767.c2
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_main.c9
-rw-r--r--drivers/gpu/drm/drm_atomic.c25
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c112
-rw-r--r--drivers/gpu/drm/drm_debugfs.c8
-rw-r--r--drivers/gpu/drm/drm_dp_helper.c1
-rw-r--r--drivers/gpu/drm/drm_drv.c47
-rw-r--r--drivers/gpu/drm/drm_edid.c104
-rw-r--r--drivers/gpu/drm/drm_fb_cma_helper.c37
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c69
-rw-r--r--drivers/gpu/drm/drm_framebuffer.c87
-rw-r--r--drivers/gpu/drm/drm_gem.c21
-rw-r--r--drivers/gpu/drm/drm_gem_cma_helper.c53
-rw-r--r--drivers/gpu/drm/drm_internal.h7
-rw-r--r--drivers/gpu/drm/drm_mm.c2
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c111
-rw-r--r--drivers/gpu/drm/drm_print.c54
-rw-r--r--drivers/gpu/drm/drm_simple_kms_helper.c9
-rw-r--r--drivers/gpu/drm/drm_syncobj.c11
-rw-r--r--drivers/gpu/drm/drm_vblank.c12
-rw-r--r--drivers/gpu/drm/drm_vma_manager.c15
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c3
-rw-r--r--drivers/gpu/drm/gma500/mmu.c2
-rw-r--r--drivers/gpu/drm/gma500/psb_drv.c2
-rw-r--r--drivers/gpu/drm/gma500/psb_drv.h1
-rw-r--r--drivers/gpu/drm/i2c/tda998x_drv.c1
-rw-r--r--drivers/gpu/drm/i915/intel_display.c20
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c1
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c14
-rw-r--r--drivers/gpu/drm/i915/intel_modes.c1
-rw-r--r--drivers/gpu/drm/imx/ipuv3-plane.c8
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_plane.c8
-rw-r--r--drivers/gpu/drm/mediatek/mtk_hdmi.c4
-rw-r--r--drivers/gpu/drm/meson/meson_plane.c8
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c10
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c26
-rw-r--r--drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c2
-rw-r--r--drivers/gpu/drm/panel/panel-simple.c62
-rw-r--r--drivers/gpu/drm/qxl/qxl_ttm.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_mst.c1
-rw-r--r--drivers/gpu/drm/rockchip/analogix_dp-rockchip.c28
-rw-r--r--drivers/gpu/drm/rockchip/cdn-dp-core.c4
-rw-r--r--drivers/gpu/drm/rockchip/inno_hdmi.c1
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_vop.c6
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_vop_reg.c30
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_vop_reg.h6
-rw-r--r--drivers/gpu/drm/selftests/test-drm_mm.c5
-rw-r--r--drivers/gpu/drm/sti/Kconfig1
-rw-r--r--drivers/gpu/drm/sti/sti_hdmi.c10
-rw-r--r--drivers/gpu/drm/sti/sti_vtg.c38
-rw-r--r--drivers/gpu/drm/stm/dw_mipi_dsi-stm.c6
-rw-r--r--drivers/gpu/drm/stm/ltdc.c66
-rw-r--r--drivers/gpu/drm/tegra/dc.c4
-rw-r--r--drivers/gpu/drm/tegra/output.c1
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_drv.c2
-rw-r--r--drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c4
-rw-r--r--drivers/gpu/drm/tinydrm/mipi-dbi.c8
-rw-r--r--drivers/gpu/drm/vc4/vc4_hdmi.c16
-rw-r--r--drivers/gpu/drm/vc4/vc4_plane.c38
-rw-r--r--drivers/gpu/drm/via/via_drv.h4
-rw-r--r--drivers/gpu/drm/via/via_irq.c27
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_display.c12
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_ioctl.c2
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_kms.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c40
-rw-r--r--drivers/gpu/drm/zte/zx_hdmi.c1
-rw-r--r--drivers/gpu/drm/zte/zx_plane.c15
-rw-r--r--drivers/video/hdmi.c51
-rw-r--r--include/drm/drmP.h197
-rw-r--r--include/drm/drm_atomic_helper.h7
-rw-r--r--include/drm/drm_connector.h14
-rw-r--r--include/drm/drm_device.h9
-rw-r--r--include/drm/drm_dp_helper.h1
-rw-r--r--include/drm/drm_drv.h22
-rw-r--r--include/drm/drm_edid.h2
-rw-r--r--include/drm/drm_encoder.h6
-rw-r--r--include/drm/drm_fb_cma_helper.h6
-rw-r--r--include/drm/drm_fb_helper.h11
-rw-r--r--include/drm/drm_framebuffer.h2
-rw-r--r--include/drm/drm_gem_cma_helper.h16
-rw-r--r--include/drm/drm_mm.h2
-rw-r--r--include/drm/drm_mode_config.h2
-rw-r--r--include/drm/drm_modeset_helper_vtables.h3
-rw-r--r--include/drm/drm_plane.h14
-rw-r--r--include/drm/drm_plane_helper.h5
-rw-r--r--include/drm/drm_print.h219
-rw-r--r--include/drm/drm_syncobj.h2
-rw-r--r--include/drm/drm_vma_manager.h2
-rw-r--r--include/drm/tinydrm/tinydrm.h1
-rw-r--r--include/linux/dma-fence-array.h3
-rw-r--r--include/linux/dma-fence.h2
-rw-r--r--include/linux/reservation.h23
113 files changed, 1325 insertions, 873 deletions
diff --git a/Documentation/devicetree/bindings/display/panel/mitsubishi,aa070mc01.txt b/Documentation/devicetree/bindings/display/panel/mitsubishi,aa070mc01.txt
new file mode 100644
index 000000000000..7d8f6eeef6d9
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/mitsubishi,aa070mc01.txt
@@ -0,0 +1,7 @@
1Mitsubishi "AA070MC01 7.0" WVGA TFT LCD panel
2
3Required properties:
4- compatible: should be "mitsubishi,aa070mc01-ca1"
5
6This binding is compatible with the simple-panel binding, which is specified
7in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/display/panel/tianma,tm070rvhg71.txt b/Documentation/devicetree/bindings/display/panel/tianma,tm070rvhg71.txt
new file mode 100644
index 000000000000..b25261e63a6d
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/tianma,tm070rvhg71.txt
@@ -0,0 +1,29 @@
1Tianma Micro-electronics TM070RVHG71 7.0" WXGA TFT LCD panel
2
3Required properties:
4- compatible: should be "tianma,tm070rvhg71"
5- power-supply: single regulator to provide the supply voltage
6- backlight: phandle of the backlight device attached to the panel
7
8Required nodes:
9- port: LVDS port mapping to connect this display
10
11This panel needs single power supply voltage. Its backlight is conntrolled
12via PWM signal.
13
14Example:
15--------
16
17Example device-tree definition when connected to iMX6Q based board
18
19 panel: panel-lvds0 {
20 compatible = "tianma,tm070rvhg71";
21 backlight = <&backlight_lvds>;
22 power-supply = <&reg_lvds>;
23
24 port {
25 panel_in_lvds0: endpoint {
26 remote-endpoint = <&lvds0_out>;
27 };
28 };
29 };
diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
index 5d835d9c1ba8..eeda3597011e 100644
--- a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
+++ b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
@@ -7,6 +7,7 @@ buffer to an external LCD interface.
7Required properties: 7Required properties:
8- compatible: value should be one of the following 8- compatible: value should be one of the following
9 "rockchip,rk3036-vop"; 9 "rockchip,rk3036-vop";
10 "rockchip,rk3126-vop";
10 "rockchip,rk3288-vop"; 11 "rockchip,rk3288-vop";
11 "rockchip,rk3368-vop"; 12 "rockchip,rk3368-vop";
12 "rockchip,rk3366-vop"; 13 "rockchip,rk3366-vop";
diff --git a/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
index 74b5ac7b26d6..029252253ad4 100644
--- a/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
+++ b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
@@ -10,7 +10,11 @@
10 - "lcd" for the clock feeding the output pixel clock & IP clock. 10 - "lcd" for the clock feeding the output pixel clock & IP clock.
11 - resets: reset to be used by the device (defined by use of RCC macro). 11 - resets: reset to be used by the device (defined by use of RCC macro).
12 Required nodes: 12 Required nodes:
13 - Video port for RGB output. 13 - Video port for DPI RGB output: ltdc has one video port with up to 2
14 endpoints:
15 - for external dpi rgb panel or bridge, using gpios.
16 - for internal dpi input of the MIPI DSI host controller.
17 Note: These 2 endpoints cannot be activated simultaneously.
14 18
15* STMicroelectronics STM32 DSI controller specific extensions to Synopsys 19* STMicroelectronics STM32 DSI controller specific extensions to Synopsys
16 DesignWare MIPI DSI host controller 20 DesignWare MIPI DSI host controller
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 36625aa66c27..01eaa40dafc9 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -179,6 +179,10 @@ don't do this, drivers used dev_info/warn/err to make this differentiation. We
179now have DRM_DEV_* variants of the drm print macros, so we can start to convert 179now have DRM_DEV_* variants of the drm print macros, so we can start to convert
180those drivers back to using drm-formwatted specific log messages. 180those drivers back to using drm-formwatted specific log messages.
181 181
182Before you start this conversion please contact the relevant maintainers to make
183sure your work will be merged - not everyone agrees that the DRM dmesg macros
184are better.
185
182Contact: Sean Paul, Maintainer of the driver you plan to convert 186Contact: Sean Paul, Maintainer of the driver you plan to convert
183 187
184Core refactorings 188Core refactorings
diff --git a/MAINTAINERS b/MAINTAINERS
index d4fdcb12616c..d7eedb15be85 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4587,6 +4587,7 @@ F: include/linux/vga*
4587DRM DRIVERS AND MISC GPU PATCHES 4587DRM DRIVERS AND MISC GPU PATCHES
4588M: Daniel Vetter <daniel.vetter@intel.com> 4588M: Daniel Vetter <daniel.vetter@intel.com>
4589M: Jani Nikula <jani.nikula@linux.intel.com> 4589M: Jani Nikula <jani.nikula@linux.intel.com>
4590M: Gustavo Padovan <gustavo@padovan.org>
4590M: Sean Paul <seanpaul@chromium.org> 4591M: Sean Paul <seanpaul@chromium.org>
4591W: https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-misc.html 4592W: https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-misc.html
4592S: Maintained 4593S: Maintained
@@ -4715,7 +4716,8 @@ F: Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
4715F: Documentation/devicetree/bindings/display/renesas,du.txt 4716F: Documentation/devicetree/bindings/display/renesas,du.txt
4716 4717
4717DRM DRIVERS FOR ROCKCHIP 4718DRM DRIVERS FOR ROCKCHIP
4718M: Mark Yao <mark.yao@rock-chips.com> 4719M: Sandy Huang <hjc@rock-chips.com>
4720M: Heiko Stübner <heiko@sntech.de>
4719L: dri-devel@lists.freedesktop.org 4721L: dri-devel@lists.freedesktop.org
4720S: Maintained 4722S: Maintained
4721F: drivers/gpu/drm/rockchip/ 4723F: drivers/gpu/drm/rockchip/
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 2f6614c9a229..2c3cab066871 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -245,6 +245,7 @@ config DMA_SHARED_BUFFER
245 bool 245 bool
246 default n 246 default n
247 select ANON_INODES 247 select ANON_INODES
248 select IRQ_WORK
248 help 249 help
249 This option enables the framework for buffer-sharing between 250 This option enables the framework for buffer-sharing between
250 multiple drivers. A buffer is associated with a file using driver 251 multiple drivers. A buffer is associated with a file using driver
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index bc1cb284111c..058805b6d164 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -351,13 +351,13 @@ static inline int is_dma_buf_file(struct file *file)
351 * 351 *
352 * 2. Userspace passes this file-descriptors to all drivers it wants this buffer 352 * 2. Userspace passes this file-descriptors to all drivers it wants this buffer
353 * to share with: First the filedescriptor is converted to a &dma_buf using 353 * to share with: First the filedescriptor is converted to a &dma_buf using
354 * dma_buf_get(). The the buffer is attached to the device using 354 * dma_buf_get(). Then the buffer is attached to the device using
355 * dma_buf_attach(). 355 * dma_buf_attach().
356 * 356 *
357 * Up to this stage the exporter is still free to migrate or reallocate the 357 * Up to this stage the exporter is still free to migrate or reallocate the
358 * backing storage. 358 * backing storage.
359 * 359 *
360 * 3. Once the buffer is attached to all devices userspace can inniate DMA 360 * 3. Once the buffer is attached to all devices userspace can initiate DMA
361 * access to the shared buffer. In the kernel this is done by calling 361 * access to the shared buffer. In the kernel this is done by calling
362 * dma_buf_map_attachment() and dma_buf_unmap_attachment(). 362 * dma_buf_map_attachment() and dma_buf_unmap_attachment().
363 * 363 *
@@ -617,7 +617,7 @@ EXPORT_SYMBOL_GPL(dma_buf_detach);
617 * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR 617 * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR
618 * on error. May return -EINTR if it is interrupted by a signal. 618 * on error. May return -EINTR if it is interrupted by a signal.
619 * 619 *
620 * A mapping must be unmapped again using dma_buf_map_attachment(). Note that 620 * A mapping must be unmapped by using dma_buf_unmap_attachment(). Note that
621 * the underlying backing storage is pinned for as long as a mapping exists, 621 * the underlying backing storage is pinned for as long as a mapping exists,
622 * therefore users/importers should not hold onto a mapping for undue amounts of 622 * therefore users/importers should not hold onto a mapping for undue amounts of
623 * time. 623 * time.
@@ -1179,8 +1179,7 @@ static int dma_buf_init_debugfs(void)
1179 1179
1180static void dma_buf_uninit_debugfs(void) 1180static void dma_buf_uninit_debugfs(void)
1181{ 1181{
1182 if (dma_buf_debugfs_dir) 1182 debugfs_remove_recursive(dma_buf_debugfs_dir);
1183 debugfs_remove_recursive(dma_buf_debugfs_dir);
1184} 1183}
1185#else 1184#else
1186static inline int dma_buf_init_debugfs(void) 1185static inline int dma_buf_init_debugfs(void)
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 0350829ba62e..dd1edfb27b61 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -31,6 +31,14 @@ static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence)
31 return "unbound"; 31 return "unbound";
32} 32}
33 33
34static void irq_dma_fence_array_work(struct irq_work *wrk)
35{
36 struct dma_fence_array *array = container_of(wrk, typeof(*array), work);
37
38 dma_fence_signal(&array->base);
39 dma_fence_put(&array->base);
40}
41
34static void dma_fence_array_cb_func(struct dma_fence *f, 42static void dma_fence_array_cb_func(struct dma_fence *f,
35 struct dma_fence_cb *cb) 43 struct dma_fence_cb *cb)
36{ 44{
@@ -39,8 +47,9 @@ static void dma_fence_array_cb_func(struct dma_fence *f,
39 struct dma_fence_array *array = array_cb->array; 47 struct dma_fence_array *array = array_cb->array;
40 48
41 if (atomic_dec_and_test(&array->num_pending)) 49 if (atomic_dec_and_test(&array->num_pending))
42 dma_fence_signal(&array->base); 50 irq_work_queue(&array->work);
43 dma_fence_put(&array->base); 51 else
52 dma_fence_put(&array->base);
44} 53}
45 54
46static bool dma_fence_array_enable_signaling(struct dma_fence *fence) 55static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
@@ -136,6 +145,7 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
136 spin_lock_init(&array->lock); 145 spin_lock_init(&array->lock);
137 dma_fence_init(&array->base, &dma_fence_array_ops, &array->lock, 146 dma_fence_init(&array->base, &dma_fence_array_ops, &array->lock,
138 context, seqno); 147 context, seqno);
148 init_irq_work(&array->work, irq_dma_fence_array_work);
139 149
140 array->num_fences = num_fences; 150 array->num_fences = num_fences;
141 atomic_set(&array->num_pending, signal_on_any ? 1 : num_fences); 151 atomic_set(&array->num_pending, signal_on_any ? 1 : num_fences);
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index b44d9d7db347..b759a569b7b8 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -104,7 +104,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
104 struct reservation_object_list *fobj, 104 struct reservation_object_list *fobj,
105 struct dma_fence *fence) 105 struct dma_fence *fence)
106{ 106{
107 u32 i; 107 struct dma_fence *signaled = NULL;
108 u32 i, signaled_idx;
108 109
109 dma_fence_get(fence); 110 dma_fence_get(fence);
110 111
@@ -126,17 +127,28 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
126 dma_fence_put(old_fence); 127 dma_fence_put(old_fence);
127 return; 128 return;
128 } 129 }
130
131 if (!signaled && dma_fence_is_signaled(old_fence)) {
132 signaled = old_fence;
133 signaled_idx = i;
134 }
129 } 135 }
130 136
131 /* 137 /*
132 * memory barrier is added by write_seqcount_begin, 138 * memory barrier is added by write_seqcount_begin,
133 * fobj->shared_count is protected by this lock too 139 * fobj->shared_count is protected by this lock too
134 */ 140 */
135 RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); 141 if (signaled) {
136 fobj->shared_count++; 142 RCU_INIT_POINTER(fobj->shared[signaled_idx], fence);
143 } else {
144 RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence);
145 fobj->shared_count++;
146 }
137 147
138 write_seqcount_end(&obj->seq); 148 write_seqcount_end(&obj->seq);
139 preempt_enable(); 149 preempt_enable();
150
151 dma_fence_put(signaled);
140} 152}
141 153
142static void 154static void
@@ -145,8 +157,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
145 struct reservation_object_list *fobj, 157 struct reservation_object_list *fobj,
146 struct dma_fence *fence) 158 struct dma_fence *fence)
147{ 159{
148 unsigned i; 160 unsigned i, j, k;
149 struct dma_fence *old_fence = NULL;
150 161
151 dma_fence_get(fence); 162 dma_fence_get(fence);
152 163
@@ -162,24 +173,21 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
162 * references from the old struct are carried over to 173 * references from the old struct are carried over to
163 * the new. 174 * the new.
164 */ 175 */
165 fobj->shared_count = old->shared_count; 176 for (i = 0, j = 0, k = fobj->shared_max; i < old->shared_count; ++i) {
166
167 for (i = 0; i < old->shared_count; ++i) {
168 struct dma_fence *check; 177 struct dma_fence *check;
169 178
170 check = rcu_dereference_protected(old->shared[i], 179 check = rcu_dereference_protected(old->shared[i],
171 reservation_object_held(obj)); 180 reservation_object_held(obj));
172 181
173 if (!old_fence && check->context == fence->context) { 182 if (check->context == fence->context ||
174 old_fence = check; 183 dma_fence_is_signaled(check))
175 RCU_INIT_POINTER(fobj->shared[i], fence); 184 RCU_INIT_POINTER(fobj->shared[--k], check);
176 } else 185 else
177 RCU_INIT_POINTER(fobj->shared[i], check); 186 RCU_INIT_POINTER(fobj->shared[j++], check);
178 }
179 if (!old_fence) {
180 RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence);
181 fobj->shared_count++;
182 } 187 }
188 fobj->shared_count = j;
189 RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence);
190 fobj->shared_count++;
183 191
184done: 192done:
185 preempt_disable(); 193 preempt_disable();
@@ -192,10 +200,18 @@ done:
192 write_seqcount_end(&obj->seq); 200 write_seqcount_end(&obj->seq);
193 preempt_enable(); 201 preempt_enable();
194 202
195 if (old) 203 if (!old)
196 kfree_rcu(old, rcu); 204 return;
197 205
198 dma_fence_put(old_fence); 206 /* Drop the references to the signaled fences */
207 for (i = k; i < fobj->shared_max; ++i) {
208 struct dma_fence *f;
209
210 f = rcu_dereference_protected(fobj->shared[i],
211 reservation_object_held(obj));
212 dma_fence_put(f);
213 }
214 kfree_rcu(old, rcu);
199} 215}
200 216
201/** 217/**
@@ -318,7 +334,7 @@ retry:
318 continue; 334 continue;
319 } 335 }
320 336
321 dst_list->shared[dst_list->shared_count++] = fence; 337 rcu_assign_pointer(dst_list->shared[dst_list->shared_count++], fence);
322 } 338 }
323 } else { 339 } else {
324 dst_list = NULL; 340 dst_list = NULL;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index df9cbc78e168..8ca3783f2deb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -358,7 +358,6 @@ static int amdgpu_connector_ddc_get_modes(struct drm_connector *connector)
358 if (amdgpu_connector->edid) { 358 if (amdgpu_connector->edid) {
359 drm_mode_connector_update_edid_property(connector, amdgpu_connector->edid); 359 drm_mode_connector_update_edid_property(connector, amdgpu_connector->edid);
360 ret = drm_add_edid_modes(connector, amdgpu_connector->edid); 360 ret = drm_add_edid_modes(connector, amdgpu_connector->edid);
361 drm_edid_to_eld(connector, amdgpu_connector->edid);
362 return ret; 361 return ret;
363 } 362 }
364 drm_mode_connector_update_edid_property(connector, NULL); 363 drm_mode_connector_update_edid_property(connector, NULL);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index f71fe6d2ddda..c324c3b76fac 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3333,8 +3333,6 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
3333 amdgpu_dm_connector->num_modes = 3333 amdgpu_dm_connector->num_modes =
3334 drm_add_edid_modes(connector, edid); 3334 drm_add_edid_modes(connector, edid);
3335 3335
3336 drm_edid_to_eld(connector, edid);
3337
3338 amdgpu_dm_get_native_mode(connector); 3336 amdgpu_dm_get_native_mode(connector);
3339 } else { 3337 } else {
3340 amdgpu_dm_connector->num_modes = 0; 3338 amdgpu_dm_connector->num_modes = 0;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index f8efb98b1fa7..707928b88448 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -177,12 +177,7 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = {
177static int dm_connector_update_modes(struct drm_connector *connector, 177static int dm_connector_update_modes(struct drm_connector *connector,
178 struct edid *edid) 178 struct edid *edid)
179{ 179{
180 int ret; 180 return drm_add_edid_modes(connector, edid);
181
182 ret = drm_add_edid_modes(connector, edid);
183 drm_edid_to_eld(connector, edid);
184
185 return ret;
186} 181}
187 182
188static int dm_dp_mst_get_modes(struct drm_connector *connector) 183static int dm_dp_mst_get_modes(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 074fd4ea7ece..f067de4e1e82 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -155,7 +155,6 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
155 155
156static struct drm_info_list arcpgu_debugfs_list[] = { 156static struct drm_info_list arcpgu_debugfs_list[] = {
157 { "clocks", arcpgu_show_pxlclock, 0 }, 157 { "clocks", arcpgu_show_pxlclock, 0 },
158 { "fb", drm_fb_cma_debugfs_show, 0 },
159}; 158};
160 159
161static int arcpgu_debugfs_init(struct drm_minor *minor) 160static int arcpgu_debugfs_init(struct drm_minor *minor)
@@ -180,6 +179,7 @@ static struct drm_driver arcpgu_drm_driver = {
180 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 179 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
181 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 180 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
182 .gem_free_object_unlocked = drm_gem_cma_free_object, 181 .gem_free_object_unlocked = drm_gem_cma_free_object,
182 .gem_print_info = drm_gem_cma_print_info,
183 .gem_vm_ops = &drm_gem_cma_vm_ops, 183 .gem_vm_ops = &drm_gem_cma_vm_ops,
184 .gem_prime_export = drm_gem_prime_export, 184 .gem_prime_export = drm_gem_prime_export,
185 .gem_prime_import = drm_gem_prime_import, 185 .gem_prime_import = drm_gem_prime_import,
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 5a5427bbd70e..630721f429f7 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -252,10 +252,10 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
252 clip.x2 = crtc_state->adjusted_mode.hdisplay; 252 clip.x2 = crtc_state->adjusted_mode.hdisplay;
253 clip.y2 = crtc_state->adjusted_mode.vdisplay; 253 clip.y2 = crtc_state->adjusted_mode.vdisplay;
254 254
255 return drm_plane_helper_check_state(state, &clip, 255 return drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
256 DRM_PLANE_HELPER_NO_SCALING, 256 DRM_PLANE_HELPER_NO_SCALING,
257 DRM_PLANE_HELPER_NO_SCALING, 257 DRM_PLANE_HELPER_NO_SCALING,
258 false, true); 258 false, true);
259} 259}
260 260
261static void hdlcd_plane_atomic_update(struct drm_plane *plane, 261static void hdlcd_plane_atomic_update(struct drm_plane *plane,
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 0afb53b1f4e9..feaa8bc3d7b7 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -231,7 +231,6 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg)
231static struct drm_info_list hdlcd_debugfs_list[] = { 231static struct drm_info_list hdlcd_debugfs_list[] = {
232 { "interrupt_count", hdlcd_show_underrun_count, 0 }, 232 { "interrupt_count", hdlcd_show_underrun_count, 0 },
233 { "clocks", hdlcd_show_pxlclock, 0 }, 233 { "clocks", hdlcd_show_pxlclock, 0 },
234 { "fb", drm_fb_cma_debugfs_show, 0 },
235}; 234};
236 235
237static int hdlcd_debugfs_init(struct drm_minor *minor) 236static int hdlcd_debugfs_init(struct drm_minor *minor)
@@ -253,6 +252,7 @@ static struct drm_driver hdlcd_driver = {
253 .irq_postinstall = hdlcd_irq_postinstall, 252 .irq_postinstall = hdlcd_irq_postinstall,
254 .irq_uninstall = hdlcd_irq_uninstall, 253 .irq_uninstall = hdlcd_irq_uninstall,
255 .gem_free_object_unlocked = drm_gem_cma_free_object, 254 .gem_free_object_unlocked = drm_gem_cma_free_object,
255 .gem_print_info = drm_gem_cma_print_info,
256 .gem_vm_ops = &drm_gem_cma_vm_ops, 256 .gem_vm_ops = &drm_gem_cma_vm_ops,
257 .dumb_create = drm_gem_cma_dumb_create, 257 .dumb_create = drm_gem_cma_dumb_create,
258 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 258 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index e7419797bbd1..33c5ef96ced0 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -150,7 +150,8 @@ static int malidp_se_check_scaling(struct malidp_plane *mp,
150 150
151 clip.x2 = crtc_state->adjusted_mode.hdisplay; 151 clip.x2 = crtc_state->adjusted_mode.hdisplay;
152 clip.y2 = crtc_state->adjusted_mode.vdisplay; 152 clip.y2 = crtc_state->adjusted_mode.vdisplay;
153 ret = drm_plane_helper_check_state(state, &clip, 0, INT_MAX, true, true); 153 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
154 0, INT_MAX, true, true);
154 if (ret) 155 if (ret)
155 return ret; 156 return ret;
156 157
diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix-anx78xx.c
index 9385eb0b1ee4..ed12a7ddd64a 100644
--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
@@ -977,8 +977,6 @@ static int anx78xx_get_modes(struct drm_connector *connector)
977 } 977 }
978 978
979 num_modes = drm_add_edid_modes(connector, anx78xx->edid); 979 num_modes = drm_add_edid_modes(connector, anx78xx->edid);
980 /* Store the ELD */
981 drm_edid_to_eld(connector, anx78xx->edid);
982 980
983unlock: 981unlock:
984 mutex_unlock(&anx78xx->lock); 982 mutex_unlock(&anx78xx->lock);
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
index b7eb704d0a8a..86789f8918a4 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -1169,8 +1169,18 @@ static void sii8620_set_infoframes(struct sii8620 *ctx)
1169 sii8620_write_buf(ctx, REG_TPI_INFO_B0, buf, ret); 1169 sii8620_write_buf(ctx, REG_TPI_INFO_B0, buf, ret);
1170} 1170}
1171 1171
1172static void sii8620_start_hdmi(struct sii8620 *ctx) 1172static void sii8620_start_video(struct sii8620 *ctx)
1173{ 1173{
1174 if (!sii8620_is_mhl3(ctx))
1175 sii8620_stop_video(ctx);
1176
1177 if (ctx->sink_type == SINK_DVI && !sii8620_is_mhl3(ctx)) {
1178 sii8620_write(ctx, REG_RX_HDMI_CTRL2,
1179 VAL_RX_HDMI_CTRL2_DEFVAL);
1180 sii8620_write(ctx, REG_TPI_SC, 0);
1181 return;
1182 }
1183
1174 sii8620_write_seq_static(ctx, 1184 sii8620_write_seq_static(ctx,
1175 REG_RX_HDMI_CTRL2, VAL_RX_HDMI_CTRL2_DEFVAL 1185 REG_RX_HDMI_CTRL2, VAL_RX_HDMI_CTRL2_DEFVAL
1176 | BIT_RX_HDMI_CTRL2_USE_AV_MUTE, 1186 | BIT_RX_HDMI_CTRL2_USE_AV_MUTE,
@@ -1229,21 +1239,6 @@ static void sii8620_start_hdmi(struct sii8620 *ctx)
1229 sii8620_set_infoframes(ctx); 1239 sii8620_set_infoframes(ctx);
1230} 1240}
1231 1241
1232static void sii8620_start_video(struct sii8620 *ctx)
1233{
1234 if (!sii8620_is_mhl3(ctx))
1235 sii8620_stop_video(ctx);
1236
1237 switch (ctx->sink_type) {
1238 case SINK_HDMI:
1239 sii8620_start_hdmi(ctx);
1240 break;
1241 case SINK_DVI:
1242 default:
1243 break;
1244 }
1245}
1246
1247static void sii8620_disable_hpd(struct sii8620 *ctx) 1242static void sii8620_disable_hpd(struct sii8620 *ctx)
1248{ 1243{
1249 sii8620_setbits(ctx, REG_EDID_CTRL, BIT_EDID_CTRL_EDID_PRIME_VALID, 0); 1244 sii8620_setbits(ctx, REG_EDID_CTRL, BIT_EDID_CTRL_EDID_PRIME_VALID, 0);
@@ -1945,8 +1940,13 @@ static void sii8620_irq_scdt(struct sii8620 *ctx)
1945 if (stat & BIT_INTR_SCDT_CHANGE) { 1940 if (stat & BIT_INTR_SCDT_CHANGE) {
1946 u8 cstat = sii8620_readb(ctx, REG_TMDS_CSTAT_P3); 1941 u8 cstat = sii8620_readb(ctx, REG_TMDS_CSTAT_P3);
1947 1942
1948 if (cstat & BIT_TMDS_CSTAT_P3_SCDT) 1943 if (cstat & BIT_TMDS_CSTAT_P3_SCDT) {
1949 sii8620_scdt_high(ctx); 1944 if (ctx->sink_type == SINK_HDMI)
1945 /* enable infoframe interrupt */
1946 sii8620_scdt_high(ctx);
1947 else
1948 sii8620_start_video(ctx);
1949 }
1950 } 1950 }
1951 1951
1952 sii8620_write(ctx, REG_INTR5, stat); 1952 sii8620_write(ctx, REG_INTR5, stat);
@@ -2191,6 +2191,19 @@ static void sii8620_detach(struct drm_bridge *bridge)
2191 rc_unregister_device(ctx->rc_dev); 2191 rc_unregister_device(ctx->rc_dev);
2192} 2192}
2193 2193
2194static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge,
2195 const struct drm_display_mode *mode)
2196{
2197 struct sii8620 *ctx = bridge_to_sii8620(bridge);
2198 bool can_pack = ctx->devcap[MHL_DCAP_VID_LINK_MODE] &
2199 MHL_DCAP_VID_LINK_PPIXEL;
2200 unsigned int max_pclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK :
2201 MHL1_MAX_LCLK;
2202 max_pclk /= can_pack ? 2 : 3;
2203
2204 return (mode->clock > max_pclk) ? MODE_CLOCK_HIGH : MODE_OK;
2205}
2206
2194static bool sii8620_mode_fixup(struct drm_bridge *bridge, 2207static bool sii8620_mode_fixup(struct drm_bridge *bridge,
2195 const struct drm_display_mode *mode, 2208 const struct drm_display_mode *mode,
2196 struct drm_display_mode *adjusted_mode) 2209 struct drm_display_mode *adjusted_mode)
@@ -2220,8 +2233,9 @@ end:
2220 union hdmi_infoframe frm; 2233 union hdmi_infoframe frm;
2221 u8 mhl_vic[] = { 0, 95, 94, 93, 98 }; 2234 u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
2222 2235
2236 /* FIXME: We need the connector here */
2223 drm_hdmi_vendor_infoframe_from_display_mode( 2237 drm_hdmi_vendor_infoframe_from_display_mode(
2224 &frm.vendor.hdmi, adjusted_mode); 2238 &frm.vendor.hdmi, NULL, adjusted_mode);
2225 vic = frm.vendor.hdmi.vic; 2239 vic = frm.vendor.hdmi.vic;
2226 if (vic >= ARRAY_SIZE(mhl_vic)) 2240 if (vic >= ARRAY_SIZE(mhl_vic))
2227 vic = 0; 2241 vic = 0;
@@ -2238,6 +2252,7 @@ static const struct drm_bridge_funcs sii8620_bridge_funcs = {
2238 .attach = sii8620_attach, 2252 .attach = sii8620_attach,
2239 .detach = sii8620_detach, 2253 .detach = sii8620_detach,
2240 .mode_fixup = sii8620_mode_fixup, 2254 .mode_fixup = sii8620_mode_fixup,
2255 .mode_valid = sii8620_mode_valid,
2241}; 2256};
2242 2257
2243static int sii8620_probe(struct i2c_client *client, 2258static int sii8620_probe(struct i2c_client *client,
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index b72259bf6e2f..a38db40ce990 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1438,7 +1438,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
1438 u8 buffer[10]; 1438 u8 buffer[10];
1439 ssize_t err; 1439 ssize_t err;
1440 1440
1441 err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode); 1441 err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
1442 &hdmi->connector,
1443 mode);
1442 if (err < 0) 1444 if (err < 0)
1443 /* 1445 /*
1444 * Going into that statement does not means vendor infoframe 1446 * Going into that statement does not means vendor infoframe
@@ -1911,8 +1913,6 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
1911 drm_mode_connector_update_edid_property(connector, edid); 1913 drm_mode_connector_update_edid_property(connector, edid);
1912 cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid); 1914 cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid);
1913 ret = drm_add_edid_modes(connector, edid); 1915 ret = drm_add_edid_modes(connector, edid);
1914 /* Store the ELD */
1915 drm_edid_to_eld(connector, edid);
1916 kfree(edid); 1916 kfree(edid);
1917 } else { 1917 } else {
1918 dev_dbg(hdmi->dev, "failed to get edid\n"); 1918 dev_dbg(hdmi->dev, "failed to get edid\n");
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 8636e7eeb731..08ab7d6aea65 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -6,6 +6,8 @@
6 * 6 *
7 * Copyright (C) 2016 Pengutronix, Philipp Zabel <p.zabel@pengutronix.de> 7 * Copyright (C) 2016 Pengutronix, Philipp Zabel <p.zabel@pengutronix.de>
8 * 8 *
9 * Copyright (C) 2016 Zodiac Inflight Innovations
10 *
9 * Initially based on: drivers/gpu/drm/i2c/tda998x_drv.c 11 * Initially based on: drivers/gpu/drm/i2c/tda998x_drv.c
10 * 12 *
11 * Copyright (C) 2012 Texas Instruments 13 * Copyright (C) 2012 Texas Instruments
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index b5f528543956..26df1e8cd490 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -13,6 +13,14 @@
13 13
14#include "cirrus_drv.h" 14#include "cirrus_drv.h"
15 15
16static int cirrus_create_handle(struct drm_framebuffer *fb,
17 struct drm_file* file_priv,
18 unsigned int* handle)
19{
20 struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
21
22 return drm_gem_handle_create(file_priv, cirrus_fb->obj, handle);
23}
16 24
17static void cirrus_user_framebuffer_destroy(struct drm_framebuffer *fb) 25static void cirrus_user_framebuffer_destroy(struct drm_framebuffer *fb)
18{ 26{
@@ -24,6 +32,7 @@ static void cirrus_user_framebuffer_destroy(struct drm_framebuffer *fb)
24} 32}
25 33
26static const struct drm_framebuffer_funcs cirrus_fb_funcs = { 34static const struct drm_framebuffer_funcs cirrus_fb_funcs = {
35 .create_handle = cirrus_create_handle,
27 .destroy = cirrus_user_framebuffer_destroy, 36 .destroy = cirrus_user_framebuffer_destroy,
28}; 37};
29 38
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c2da5585e201..37445d50816a 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -33,6 +33,7 @@
33#include <linux/sync_file.h> 33#include <linux/sync_file.h>
34 34
35#include "drm_crtc_internal.h" 35#include "drm_crtc_internal.h"
36#include "drm_internal.h"
36 37
37void __drm_crtc_commit_free(struct kref *kref) 38void __drm_crtc_commit_free(struct kref *kref)
38{ 39{
@@ -907,11 +908,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
907 state->src_h > fb_height || 908 state->src_h > fb_height ||
908 state->src_y > fb_height - state->src_h) { 909 state->src_y > fb_height - state->src_h) {
909 DRM_DEBUG_ATOMIC("Invalid source coordinates " 910 DRM_DEBUG_ATOMIC("Invalid source coordinates "
910 "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n", 911 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
911 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10, 912 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
912 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10, 913 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
913 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10, 914 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
914 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10); 915 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
916 state->fb->width, state->fb->height);
915 return -ENOSPC; 917 return -ENOSPC;
916 } 918 }
917 919
@@ -934,21 +936,8 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
934 drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name); 936 drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name);
935 drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); 937 drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
936 drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0); 938 drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
937 if (state->fb) { 939 if (state->fb)
938 struct drm_framebuffer *fb = state->fb; 940 drm_framebuffer_print_info(p, 2, state->fb);
939 int i, n = fb->format->num_planes;
940 struct drm_format_name_buf format_name;
941
942 drm_printf(p, "\t\tformat=%s\n",
943 drm_get_format_name(fb->format->format, &format_name));
944 drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
945 drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
946 drm_printf(p, "\t\tlayers:\n");
947 for (i = 0; i < n; i++) {
948 drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]);
949 drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]);
950 }
951 }
952 drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest)); 941 drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
953 drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src)); 942 drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
954 drm_printf(p, "\trotation=%x\n", state->rotation); 943 drm_printf(p, "\trotation=%x\n", state->rotation);
@@ -1808,7 +1797,7 @@ int drm_atomic_debugfs_init(struct drm_minor *minor)
1808#endif 1797#endif
1809 1798
1810/* 1799/*
1811 * The big monstor ioctl 1800 * The big monster ioctl
1812 */ 1801 */
1813 1802
1814static struct drm_pending_vblank_event *create_vblank_event( 1803static struct drm_pending_vblank_event *create_vblank_event(
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index b16f1d69a0bb..ab4032167094 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -696,6 +696,100 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
696EXPORT_SYMBOL(drm_atomic_helper_check_modeset); 696EXPORT_SYMBOL(drm_atomic_helper_check_modeset);
697 697
698/** 698/**
699 * drm_atomic_helper_check_plane_state() - Check plane state for validity
700 * @plane_state: plane state to check
701 * @crtc_state: crtc state to check
702 * @clip: integer clipping coordinates
703 * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
704 * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
705 * @can_position: is it legal to position the plane such that it
706 * doesn't cover the entire crtc? This will generally
707 * only be false for primary planes.
708 * @can_update_disabled: can the plane be updated while the crtc
709 * is disabled?
710 *
711 * Checks that a desired plane update is valid, and updates various
712 * bits of derived state (clipped coordinates etc.). Drivers that provide
713 * their own plane handling rather than helper-provided implementations may
714 * still wish to call this function to avoid duplication of error checking
715 * code.
716 *
717 * RETURNS:
718 * Zero if update appears valid, error code on failure
719 */
720int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state,
721 const struct drm_crtc_state *crtc_state,
722 const struct drm_rect *clip,
723 int min_scale,
724 int max_scale,
725 bool can_position,
726 bool can_update_disabled)
727{
728 struct drm_framebuffer *fb = plane_state->fb;
729 struct drm_rect *src = &plane_state->src;
730 struct drm_rect *dst = &plane_state->dst;
731 unsigned int rotation = plane_state->rotation;
732 int hscale, vscale;
733
734 WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc);
735
736 *src = drm_plane_state_src(plane_state);
737 *dst = drm_plane_state_dest(plane_state);
738
739 if (!fb) {
740 plane_state->visible = false;
741 return 0;
742 }
743
744 /* crtc should only be NULL when disabling (i.e., !fb) */
745 if (WARN_ON(!plane_state->crtc)) {
746 plane_state->visible = false;
747 return 0;
748 }
749
750 if (!crtc_state->enable && !can_update_disabled) {
751 DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
752 return -EINVAL;
753 }
754
755 drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
756
757 /* Check scaling */
758 hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
759 vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
760 if (hscale < 0 || vscale < 0) {
761 DRM_DEBUG_KMS("Invalid scaling of plane\n");
762 drm_rect_debug_print("src: ", &plane_state->src, true);
763 drm_rect_debug_print("dst: ", &plane_state->dst, false);
764 return -ERANGE;
765 }
766
767 plane_state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
768
769 drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
770
771 if (!plane_state->visible)
772 /*
773 * Plane isn't visible; some drivers can handle this
774 * so we just return success here. Drivers that can't
775 * (including those that use the primary plane helper's
776 * update function) will return an error from their
777 * update_plane handler.
778 */
779 return 0;
780
781 if (!can_position && !drm_rect_equals(dst, clip)) {
782 DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
783 drm_rect_debug_print("dst: ", dst, false);
784 drm_rect_debug_print("clip: ", clip, false);
785 return -EINVAL;
786 }
787
788 return 0;
789}
790EXPORT_SYMBOL(drm_atomic_helper_check_plane_state);
791
792/**
699 * drm_atomic_helper_check_planes - validate state object for planes changes 793 * drm_atomic_helper_check_planes - validate state object for planes changes
700 * @dev: DRM device 794 * @dev: DRM device
701 * @state: the driver state object 795 * @state: the driver state object
@@ -907,6 +1001,12 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
907 * 1001 *
908 * Drivers can use this for building their own atomic commit if they don't have 1002 * Drivers can use this for building their own atomic commit if they don't have
909 * a pure helper-based modeset implementation. 1003 * a pure helper-based modeset implementation.
1004 *
1005 * Since these updates are not synchronized with lockings, only code paths
1006 * called from &drm_mode_config_helper_funcs.atomic_commit_tail can look at the
1007 * legacy state filled out by this helper. Defacto this means this helper and
1008 * the legacy state pointers are only really useful for transitioning an
1009 * existing driver to the atomic world.
910 */ 1010 */
911void 1011void
912drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, 1012drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
@@ -1787,11 +1887,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
1787 !try_wait_for_completion(&old_conn_state->commit->flip_done)) 1887 !try_wait_for_completion(&old_conn_state->commit->flip_done))
1788 return -EBUSY; 1888 return -EBUSY;
1789 1889
1790 /* commit tracked through new_crtc_state->commit, no need to do it explicitly */ 1890 /* Always track connectors explicitly for e.g. link retraining. */
1791 if (new_conn_state->crtc) 1891 commit = crtc_or_fake_commit(state, new_conn_state->crtc ?: old_conn_state->crtc);
1792 continue;
1793
1794 commit = crtc_or_fake_commit(state, old_conn_state->crtc);
1795 if (!commit) 1892 if (!commit)
1796 return -ENOMEM; 1893 return -ENOMEM;
1797 1894
@@ -1805,10 +1902,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
1805 !try_wait_for_completion(&old_plane_state->commit->flip_done)) 1902 !try_wait_for_completion(&old_plane_state->commit->flip_done))
1806 return -EBUSY; 1903 return -EBUSY;
1807 1904
1808 /* 1905 /* Always track planes explicitly for async pageflip support. */
1809 * Unlike connectors, always track planes explicitly for
1810 * async pageflip support.
1811 */
1812 commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc); 1906 commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc);
1813 if (!commit) 1907 if (!commit)
1814 return -ENOMEM; 1908 return -ENOMEM;
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index c1807d5754b2..b2482818fee8 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -158,6 +158,14 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
158 } 158 }
159 } 159 }
160 160
161 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
162 ret = drm_framebuffer_debugfs_init(minor);
163 if (ret) {
164 DRM_ERROR("Failed to create framebuffer debugfs file\n");
165 return ret;
166 }
167 }
168
161 if (dev->driver->debugfs_init) { 169 if (dev->driver->debugfs_init) {
162 ret = dev->driver->debugfs_init(minor); 170 ret = dev->driver->debugfs_init(minor);
163 if (ret) { 171 if (ret) {
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index b3d68964b407..adf79be42c1e 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -1097,7 +1097,6 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
1097 aux->ddc.class = I2C_CLASS_DDC; 1097 aux->ddc.class = I2C_CLASS_DDC;
1098 aux->ddc.owner = THIS_MODULE; 1098 aux->ddc.owner = THIS_MODULE;
1099 aux->ddc.dev.parent = aux->dev; 1099 aux->ddc.dev.parent = aux->dev;
1100 aux->ddc.dev.of_node = aux->dev->of_node;
1101 1100
1102 strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev), 1101 strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
1103 sizeof(aux->ddc.name)); 1102 sizeof(aux->ddc.name));
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a934fd5e7e55..9acc1e157813 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -75,53 +75,6 @@ static bool drm_core_init_complete = false;
75 75
76static struct dentry *drm_debugfs_root; 76static struct dentry *drm_debugfs_root;
77 77
78#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
79
80void drm_dev_printk(const struct device *dev, const char *level,
81 unsigned int category, const char *function_name,
82 const char *prefix, const char *format, ...)
83{
84 struct va_format vaf;
85 va_list args;
86
87 if (category != DRM_UT_NONE && !(drm_debug & category))
88 return;
89
90 va_start(args, format);
91 vaf.fmt = format;
92 vaf.va = &args;
93
94 if (dev)
95 dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix,
96 &vaf);
97 else
98 printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf);
99
100 va_end(args);
101}
102EXPORT_SYMBOL(drm_dev_printk);
103
104void drm_printk(const char *level, unsigned int category,
105 const char *format, ...)
106{
107 struct va_format vaf;
108 va_list args;
109
110 if (category != DRM_UT_NONE && !(drm_debug & category))
111 return;
112
113 va_start(args, format);
114 vaf.fmt = format;
115 vaf.va = &args;
116
117 printk("%s" "[" DRM_NAME ":%ps]%s %pV",
118 level, __builtin_return_address(0),
119 strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
120
121 va_end(args);
122}
123EXPORT_SYMBOL(drm_printk);
124
125/* 78/*
126 * DRM Minors 79 * DRM Minors
127 * A DRM device can provide several char-dev interfaces on the DRM-Major. Each 80 * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5dfe14763871..524eace3d460 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3398,6 +3398,7 @@ static int
3398do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len, 3398do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
3399 const u8 *video_db, u8 video_len) 3399 const u8 *video_db, u8 video_len)
3400{ 3400{
3401 struct drm_display_info *info = &connector->display_info;
3401 int modes = 0, offset = 0, i, multi_present = 0, multi_len; 3402 int modes = 0, offset = 0, i, multi_present = 0, multi_len;
3402 u8 vic_len, hdmi_3d_len = 0; 3403 u8 vic_len, hdmi_3d_len = 0;
3403 u16 mask; 3404 u16 mask;
@@ -3525,6 +3526,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
3525 } 3526 }
3526 3527
3527out: 3528out:
3529 if (modes > 0)
3530 info->has_hdmi_infoframe = true;
3528 return modes; 3531 return modes;
3529} 3532}
3530 3533
@@ -3761,8 +3764,8 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
3761{ 3764{
3762 u8 len = cea_db_payload_len(db); 3765 u8 len = cea_db_payload_len(db);
3763 3766
3764 if (len >= 6) 3767 if (len >= 6 && (db[6] & (1 << 7)))
3765 connector->eld[5] |= (db[6] >> 7) << 1; /* Supports_AI */ 3768 connector->eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_SUPPORTS_AI;
3766 if (len >= 8) { 3769 if (len >= 8) {
3767 connector->latency_present[0] = db[8] >> 7; 3770 connector->latency_present[0] = db[8] >> 7;
3768 connector->latency_present[1] = (db[8] >> 6) & 1; 3771 connector->latency_present[1] = (db[8] >> 6) & 1;
@@ -3834,16 +3837,27 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
3834} 3837}
3835EXPORT_SYMBOL(drm_edid_get_monitor_name); 3838EXPORT_SYMBOL(drm_edid_get_monitor_name);
3836 3839
3837/** 3840static void clear_eld(struct drm_connector *connector)
3841{
3842 memset(connector->eld, 0, sizeof(connector->eld));
3843
3844 connector->latency_present[0] = false;
3845 connector->latency_present[1] = false;
3846 connector->video_latency[0] = 0;
3847 connector->audio_latency[0] = 0;
3848 connector->video_latency[1] = 0;
3849 connector->audio_latency[1] = 0;
3850}
3851
3852/*
3838 * drm_edid_to_eld - build ELD from EDID 3853 * drm_edid_to_eld - build ELD from EDID
3839 * @connector: connector corresponding to the HDMI/DP sink 3854 * @connector: connector corresponding to the HDMI/DP sink
3840 * @edid: EDID to parse 3855 * @edid: EDID to parse
3841 * 3856 *
3842 * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The 3857 * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The
3843 * Conn_Type, HDCP and Port_ID ELD fields are left for the graphics driver to 3858 * HDCP and Port_ID ELD fields are left for the graphics driver to fill in.
3844 * fill in.
3845 */ 3859 */
3846void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) 3860static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3847{ 3861{
3848 uint8_t *eld = connector->eld; 3862 uint8_t *eld = connector->eld;
3849 u8 *cea; 3863 u8 *cea;
@@ -3852,14 +3866,7 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3852 int mnl; 3866 int mnl;
3853 int dbl; 3867 int dbl;
3854 3868
3855 memset(eld, 0, sizeof(connector->eld)); 3869 clear_eld(connector);
3856
3857 connector->latency_present[0] = false;
3858 connector->latency_present[1] = false;
3859 connector->video_latency[0] = 0;
3860 connector->audio_latency[0] = 0;
3861 connector->video_latency[1] = 0;
3862 connector->audio_latency[1] = 0;
3863 3870
3864 if (!edid) 3871 if (!edid)
3865 return; 3872 return;
@@ -3870,17 +3877,18 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3870 return; 3877 return;
3871 } 3878 }
3872 3879
3873 mnl = get_monitor_name(edid, eld + 20); 3880 mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]);
3881 DRM_DEBUG_KMS("ELD monitor %s\n", &eld[DRM_ELD_MONITOR_NAME_STRING]);
3874 3882
3875 eld[4] = (cea[1] << 5) | mnl; 3883 eld[DRM_ELD_CEA_EDID_VER_MNL] = cea[1] << DRM_ELD_CEA_EDID_VER_SHIFT;
3876 DRM_DEBUG_KMS("ELD monitor %s\n", eld + 20); 3884 eld[DRM_ELD_CEA_EDID_VER_MNL] |= mnl;
3877 3885
3878 eld[0] = 2 << 3; /* ELD version: 2 */ 3886 eld[DRM_ELD_VER] = DRM_ELD_VER_CEA861D;
3879 3887
3880 eld[16] = edid->mfg_id[0]; 3888 eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0];
3881 eld[17] = edid->mfg_id[1]; 3889 eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1];
3882 eld[18] = edid->prod_code[0]; 3890 eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0];
3883 eld[19] = edid->prod_code[1]; 3891 eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1];
3884 3892
3885 if (cea_revision(cea) >= 3) { 3893 if (cea_revision(cea) >= 3) {
3886 int i, start, end; 3894 int i, start, end;
@@ -3901,14 +3909,14 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3901 /* Audio Data Block, contains SADs */ 3909 /* Audio Data Block, contains SADs */
3902 sad_count = min(dbl / 3, 15 - total_sad_count); 3910 sad_count = min(dbl / 3, 15 - total_sad_count);
3903 if (sad_count >= 1) 3911 if (sad_count >= 1)
3904 memcpy(eld + 20 + mnl + total_sad_count * 3, 3912 memcpy(&eld[DRM_ELD_CEA_SAD(mnl, total_sad_count)],
3905 &db[1], sad_count * 3); 3913 &db[1], sad_count * 3);
3906 total_sad_count += sad_count; 3914 total_sad_count += sad_count;
3907 break; 3915 break;
3908 case SPEAKER_BLOCK: 3916 case SPEAKER_BLOCK:
3909 /* Speaker Allocation Data Block */ 3917 /* Speaker Allocation Data Block */
3910 if (dbl >= 1) 3918 if (dbl >= 1)
3911 eld[7] = db[1]; 3919 eld[DRM_ELD_SPEAKER] = db[1];
3912 break; 3920 break;
3913 case VENDOR_BLOCK: 3921 case VENDOR_BLOCK:
3914 /* HDMI Vendor-Specific Data Block */ 3922 /* HDMI Vendor-Specific Data Block */
@@ -3920,7 +3928,13 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3920 } 3928 }
3921 } 3929 }
3922 } 3930 }
3923 eld[5] |= total_sad_count << 4; 3931 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= total_sad_count << DRM_ELD_SAD_COUNT_SHIFT;
3932
3933 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
3934 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
3935 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_DP;
3936 else
3937 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_HDMI;
3924 3938
3925 eld[DRM_ELD_BASELINE_ELD_LEN] = 3939 eld[DRM_ELD_BASELINE_ELD_LEN] =
3926 DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4); 3940 DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4);
@@ -3928,7 +3942,6 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
3928 DRM_DEBUG_KMS("ELD size %d, SAD count %d\n", 3942 DRM_DEBUG_KMS("ELD size %d, SAD count %d\n",
3929 drm_eld_size(eld), total_sad_count); 3943 drm_eld_size(eld), total_sad_count);
3930} 3944}
3931EXPORT_SYMBOL(drm_edid_to_eld);
3932 3945
3933/** 3946/**
3934 * drm_edid_to_sad - extracts SADs from EDID 3947 * drm_edid_to_sad - extracts SADs from EDID
@@ -4238,6 +4251,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
4238 struct drm_display_info *display = &connector->display_info; 4251 struct drm_display_info *display = &connector->display_info;
4239 struct drm_hdmi_info *hdmi = &display->hdmi; 4252 struct drm_hdmi_info *hdmi = &display->hdmi;
4240 4253
4254 display->has_hdmi_infoframe = true;
4255
4241 if (hf_vsdb[6] & 0x80) { 4256 if (hf_vsdb[6] & 0x80) {
4242 hdmi->scdc.supported = true; 4257 hdmi->scdc.supported = true;
4243 if (hf_vsdb[6] & 0x40) 4258 if (hf_vsdb[6] & 0x40)
@@ -4411,6 +4426,7 @@ static void drm_add_display_info(struct drm_connector *connector,
4411 info->cea_rev = 0; 4426 info->cea_rev = 0;
4412 info->max_tmds_clock = 0; 4427 info->max_tmds_clock = 0;
4413 info->dvi_dual = false; 4428 info->dvi_dual = false;
4429 info->has_hdmi_infoframe = false;
4414 4430
4415 info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP); 4431 info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
4416 4432
@@ -4608,8 +4624,8 @@ static int add_displayid_detailed_modes(struct drm_connector *connector,
4608 * @edid: EDID data 4624 * @edid: EDID data
4609 * 4625 *
4610 * Add the specified modes to the connector's mode list. Also fills out the 4626 * Add the specified modes to the connector's mode list. Also fills out the
4611 * &drm_display_info structure in @connector with any information which can be 4627 * &drm_display_info structure and ELD in @connector with any information which
4612 * derived from the edid. 4628 * can be derived from the edid.
4613 * 4629 *
4614 * Return: The number of modes added or 0 if we couldn't find any. 4630 * Return: The number of modes added or 0 if we couldn't find any.
4615 */ 4631 */
@@ -4619,9 +4635,11 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
4619 u32 quirks; 4635 u32 quirks;
4620 4636
4621 if (edid == NULL) { 4637 if (edid == NULL) {
4638 clear_eld(connector);
4622 return 0; 4639 return 0;
4623 } 4640 }
4624 if (!drm_edid_is_valid(edid)) { 4641 if (!drm_edid_is_valid(edid)) {
4642 clear_eld(connector);
4625 dev_warn(connector->dev->dev, "%s: EDID invalid.\n", 4643 dev_warn(connector->dev->dev, "%s: EDID invalid.\n",
4626 connector->name); 4644 connector->name);
4627 return 0; 4645 return 0;
@@ -4629,6 +4647,8 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
4629 4647
4630 quirks = edid_get_quirks(edid); 4648 quirks = edid_get_quirks(edid);
4631 4649
4650 drm_edid_to_eld(connector, edid);
4651
4632 /* 4652 /*
4633 * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. 4653 * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks.
4634 * To avoid multiple parsing of same block, lets parse that map 4654 * To avoid multiple parsing of same block, lets parse that map
@@ -4904,6 +4924,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
4904 * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with 4924 * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
4905 * data from a DRM display mode 4925 * data from a DRM display mode
4906 * @frame: HDMI vendor infoframe 4926 * @frame: HDMI vendor infoframe
4927 * @connector: the connector
4907 * @mode: DRM display mode 4928 * @mode: DRM display mode
4908 * 4929 *
4909 * Note that there's is a need to send HDMI vendor infoframes only when using a 4930 * Note that there's is a need to send HDMI vendor infoframes only when using a
@@ -4914,8 +4935,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
4914 */ 4935 */
4915int 4936int
4916drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, 4937drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
4938 struct drm_connector *connector,
4917 const struct drm_display_mode *mode) 4939 const struct drm_display_mode *mode)
4918{ 4940{
4941 /*
4942 * FIXME: sil-sii8620 doesn't have a connector around when
4943 * we need one, so we have to be prepared for a NULL connector.
4944 */
4945 bool has_hdmi_infoframe = connector ?
4946 connector->display_info.has_hdmi_infoframe : false;
4919 int err; 4947 int err;
4920 u32 s3d_flags; 4948 u32 s3d_flags;
4921 u8 vic; 4949 u8 vic;
@@ -4923,11 +4951,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
4923 if (!frame || !mode) 4951 if (!frame || !mode)
4924 return -EINVAL; 4952 return -EINVAL;
4925 4953
4954 if (!has_hdmi_infoframe)
4955 return -EINVAL;
4956
4926 vic = drm_match_hdmi_mode(mode); 4957 vic = drm_match_hdmi_mode(mode);
4927 s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK; 4958 s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
4928 4959
4929 if (!vic && !s3d_flags) 4960 /*
4930 return -EINVAL; 4961 * Even if it's not absolutely necessary to send the infoframe
4962 * (ie.vic==0 and s3d_struct==0) we will still send it if we
4963 * know that the sink can handle it. This is based on a
4964 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
4965 * have trouble realizing that they shuld switch from 3D to 2D
4966 * mode if the source simply stops sending the infoframe when
4967 * it wants to switch from 3D to 2D.
4968 */
4931 4969
4932 if (vic && s3d_flags) 4970 if (vic && s3d_flags)
4933 return -EINVAL; 4971 return -EINVAL;
@@ -4936,10 +4974,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
4936 if (err < 0) 4974 if (err < 0)
4937 return err; 4975 return err;
4938 4976
4939 if (vic) 4977 frame->vic = vic;
4940 frame->vic = vic; 4978 frame->s3d_struct = s3d_structure_from_display_mode(mode);
4941 else
4942 frame->s3d_struct = s3d_structure_from_display_mode(mode);
4943 4979
4944 return 0; 4980 return 0;
4945} 4981}
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 0e3c14174d08..35b56dfba929 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -130,43 +130,6 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
130} 130}
131EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr); 131EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr);
132 132
133#ifdef CONFIG_DEBUG_FS
134static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
135{
136 int i;
137
138 seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
139 (char *)&fb->format->format);
140
141 for (i = 0; i < fb->format->num_planes; i++) {
142 seq_printf(m, " %d: offset=%d pitch=%d, obj: ",
143 i, fb->offsets[i], fb->pitches[i]);
144 drm_gem_cma_describe(drm_fb_cma_get_gem_obj(fb, i), m);
145 }
146}
147
148/**
149 * drm_fb_cma_debugfs_show() - Helper to list CMA framebuffer objects
150 * in debugfs.
151 * @m: output file
152 * @arg: private data for the callback
153 */
154int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
155{
156 struct drm_info_node *node = (struct drm_info_node *) m->private;
157 struct drm_device *dev = node->minor->dev;
158 struct drm_framebuffer *fb;
159
160 mutex_lock(&dev->mode_config.fb_lock);
161 drm_for_each_fb(fb, dev)
162 drm_fb_cma_describe(fb, m);
163 mutex_unlock(&dev->mode_config.fb_lock);
164
165 return 0;
166}
167EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
168#endif
169
170static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma) 133static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
171{ 134{
172 return dma_mmap_writecombine(info->device, vma, info->screen_base, 135 return dma_mmap_writecombine(info->device, vma, info->screen_base,
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e56166334455..09919e8d67f9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -150,6 +150,9 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
150{ 150{
151 int err; 151 int err;
152 152
153 if (!fb_helper)
154 return 0;
155
153 mutex_lock(&fb_helper->lock); 156 mutex_lock(&fb_helper->lock);
154 err = __drm_fb_helper_add_one_connector(fb_helper, connector); 157 err = __drm_fb_helper_add_one_connector(fb_helper, connector);
155 mutex_unlock(&fb_helper->lock); 158 mutex_unlock(&fb_helper->lock);
@@ -161,7 +164,7 @@ EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
161/** 164/**
162 * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev 165 * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev
163 * emulation helper 166 * emulation helper
164 * @fb_helper: fbdev initialized with drm_fb_helper_init 167 * @fb_helper: fbdev initialized with drm_fb_helper_init, can be NULL
165 * 168 *
166 * This functions adds all the available connectors for use with the given 169 * This functions adds all the available connectors for use with the given
167 * fb_helper. This is a separate step to allow drivers to freely assign 170 * fb_helper. This is a separate step to allow drivers to freely assign
@@ -179,7 +182,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
179 struct drm_connector_list_iter conn_iter; 182 struct drm_connector_list_iter conn_iter;
180 int i, ret = 0; 183 int i, ret = 0;
181 184
182 if (!drm_fbdev_emulation) 185 if (!drm_fbdev_emulation || !fb_helper)
183 return 0; 186 return 0;
184 187
185 mutex_lock(&fb_helper->lock); 188 mutex_lock(&fb_helper->lock);
@@ -245,6 +248,9 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
245{ 248{
246 int err; 249 int err;
247 250
251 if (!fb_helper)
252 return 0;
253
248 mutex_lock(&fb_helper->lock); 254 mutex_lock(&fb_helper->lock);
249 err = __drm_fb_helper_remove_one_connector(fb_helper, connector); 255 err = __drm_fb_helper_remove_one_connector(fb_helper, connector);
250 mutex_unlock(&fb_helper->lock); 256 mutex_unlock(&fb_helper->lock);
@@ -484,7 +490,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
484 490
485/** 491/**
486 * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration 492 * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration
487 * @fb_helper: fbcon to restore 493 * @fb_helper: driver-allocated fbdev helper, can be NULL
488 * 494 *
489 * This should be called from driver's drm &drm_driver.lastclose callback 495 * This should be called from driver's drm &drm_driver.lastclose callback
490 * when implementing an fbcon on top of kms using this helper. This ensures that 496 * when implementing an fbcon on top of kms using this helper. This ensures that
@@ -498,7 +504,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
498 bool do_delayed; 504 bool do_delayed;
499 int ret; 505 int ret;
500 506
501 if (!drm_fbdev_emulation) 507 if (!drm_fbdev_emulation || !fb_helper)
502 return -ENODEV; 508 return -ENODEV;
503 509
504 if (READ_ONCE(fb_helper->deferred_setup)) 510 if (READ_ONCE(fb_helper->deferred_setup))
@@ -793,8 +799,10 @@ int drm_fb_helper_init(struct drm_device *dev,
793 struct drm_mode_config *config = &dev->mode_config; 799 struct drm_mode_config *config = &dev->mode_config;
794 int i; 800 int i;
795 801
796 if (!drm_fbdev_emulation) 802 if (!drm_fbdev_emulation) {
803 dev->fb_helper = fb_helper;
797 return 0; 804 return 0;
805 }
798 806
799 if (!max_conn_count) 807 if (!max_conn_count)
800 return -EINVAL; 808 return -EINVAL;
@@ -829,6 +837,8 @@ int drm_fb_helper_init(struct drm_device *dev,
829 i++; 837 i++;
830 } 838 }
831 839
840 dev->fb_helper = fb_helper;
841
832 return 0; 842 return 0;
833out_free: 843out_free:
834 drm_fb_helper_crtc_free(fb_helper); 844 drm_fb_helper_crtc_free(fb_helper);
@@ -883,7 +893,7 @@ EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
883 893
884/** 894/**
885 * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device 895 * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
886 * @fb_helper: driver-allocated fbdev helper 896 * @fb_helper: driver-allocated fbdev helper, can be NULL
887 * 897 *
888 * A wrapper around unregister_framebuffer, to release the fb_info 898 * A wrapper around unregister_framebuffer, to release the fb_info
889 * framebuffer device. This must be called before releasing all resources for 899 * framebuffer device. This must be called before releasing all resources for
@@ -898,7 +908,7 @@ EXPORT_SYMBOL(drm_fb_helper_unregister_fbi);
898 908
899/** 909/**
900 * drm_fb_helper_fini - finialize a &struct drm_fb_helper 910 * drm_fb_helper_fini - finialize a &struct drm_fb_helper
901 * @fb_helper: driver-allocated fbdev helper 911 * @fb_helper: driver-allocated fbdev helper, can be NULL
902 * 912 *
903 * This cleans up all remaining resources associated with @fb_helper. Must be 913 * This cleans up all remaining resources associated with @fb_helper. Must be
904 * called after drm_fb_helper_unlink_fbi() was called. 914 * called after drm_fb_helper_unlink_fbi() was called.
@@ -907,7 +917,12 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
907{ 917{
908 struct fb_info *info; 918 struct fb_info *info;
909 919
910 if (!drm_fbdev_emulation || !fb_helper) 920 if (!fb_helper)
921 return;
922
923 fb_helper->dev->fb_helper = NULL;
924
925 if (!drm_fbdev_emulation)
911 return; 926 return;
912 927
913 cancel_work_sync(&fb_helper->resume_work); 928 cancel_work_sync(&fb_helper->resume_work);
@@ -937,7 +952,7 @@ EXPORT_SYMBOL(drm_fb_helper_fini);
937 952
938/** 953/**
939 * drm_fb_helper_unlink_fbi - wrapper around unlink_framebuffer 954 * drm_fb_helper_unlink_fbi - wrapper around unlink_framebuffer
940 * @fb_helper: driver-allocated fbdev helper 955 * @fb_helper: driver-allocated fbdev helper, can be NULL
941 * 956 *
942 * A wrapper around unlink_framebuffer implemented by fbdev core 957 * A wrapper around unlink_framebuffer implemented by fbdev core
943 */ 958 */
@@ -1138,7 +1153,7 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
1138 1153
1139/** 1154/**
1140 * drm_fb_helper_set_suspend - wrapper around fb_set_suspend 1155 * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
1141 * @fb_helper: driver-allocated fbdev helper 1156 * @fb_helper: driver-allocated fbdev helper, can be NULL
1142 * @suspend: whether to suspend or resume 1157 * @suspend: whether to suspend or resume
1143 * 1158 *
1144 * A wrapper around fb_set_suspend implemented by fbdev core. 1159 * A wrapper around fb_set_suspend implemented by fbdev core.
@@ -1155,7 +1170,7 @@ EXPORT_SYMBOL(drm_fb_helper_set_suspend);
1155/** 1170/**
1156 * drm_fb_helper_set_suspend_unlocked - wrapper around fb_set_suspend that also 1171 * drm_fb_helper_set_suspend_unlocked - wrapper around fb_set_suspend that also
1157 * takes the console lock 1172 * takes the console lock
1158 * @fb_helper: driver-allocated fbdev helper 1173 * @fb_helper: driver-allocated fbdev helper, can be NULL
1159 * @suspend: whether to suspend or resume 1174 * @suspend: whether to suspend or resume
1160 * 1175 *
1161 * A wrapper around fb_set_suspend() that takes the console lock. If the lock 1176 * A wrapper around fb_set_suspend() that takes the console lock. If the lock
@@ -2576,7 +2591,7 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);
2576/** 2591/**
2577 * drm_fb_helper_hotplug_event - respond to a hotplug notification by 2592 * drm_fb_helper_hotplug_event - respond to a hotplug notification by
2578 * probing all the outputs attached to the fb 2593 * probing all the outputs attached to the fb
2579 * @fb_helper: the drm_fb_helper 2594 * @fb_helper: driver-allocated fbdev helper, can be NULL
2580 * 2595 *
2581 * Scan the connectors attached to the fb_helper and try to put together a 2596 * Scan the connectors attached to the fb_helper and try to put together a
2582 * setup after notification of a change in output configuration. 2597 * setup after notification of a change in output configuration.
@@ -2598,7 +2613,7 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
2598{ 2613{
2599 int err = 0; 2614 int err = 0;
2600 2615
2601 if (!drm_fbdev_emulation) 2616 if (!drm_fbdev_emulation || !fb_helper)
2602 return 0; 2617 return 0;
2603 2618
2604 mutex_lock(&fb_helper->lock); 2619 mutex_lock(&fb_helper->lock);
@@ -2626,6 +2641,34 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
2626} 2641}
2627EXPORT_SYMBOL(drm_fb_helper_hotplug_event); 2642EXPORT_SYMBOL(drm_fb_helper_hotplug_event);
2628 2643
2644/**
2645 * drm_fb_helper_lastclose - DRM driver lastclose helper for fbdev emulation
2646 * @dev: DRM device
2647 *
2648 * This function can be used as the &drm_driver->lastclose callback for drivers
2649 * that only need to call drm_fb_helper_restore_fbdev_mode_unlocked().
2650 */
2651void drm_fb_helper_lastclose(struct drm_device *dev)
2652{
2653 drm_fb_helper_restore_fbdev_mode_unlocked(dev->fb_helper);
2654}
2655EXPORT_SYMBOL(drm_fb_helper_lastclose);
2656
2657/**
2658 * drm_fb_helper_output_poll_changed - DRM mode config \.output_poll_changed
2659 * helper for fbdev emulation
2660 * @dev: DRM device
2661 *
2662 * This function can be used as the
2663 * &drm_mode_config_funcs.output_poll_changed callback for drivers that only
2664 * need to call drm_fb_helper_hotplug_event().
2665 */
2666void drm_fb_helper_output_poll_changed(struct drm_device *dev)
2667{
2668 drm_fb_helper_hotplug_event(dev->fb_helper);
2669}
2670EXPORT_SYMBOL(drm_fb_helper_output_poll_changed);
2671
2629/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT) 2672/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
2630 * but the module doesn't depend on any fb console symbols. At least 2673 * but the module doesn't depend on any fb console symbols. At least
2631 * attempt to load fbcon to avoid leaving the system without a usable console. 2674 * attempt to load fbcon to avoid leaving the system without a usable console.
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 279c1035c12d..d63d4c2ac4c8 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -25,7 +25,9 @@
25#include <drm/drm_auth.h> 25#include <drm/drm_auth.h>
26#include <drm/drm_framebuffer.h> 26#include <drm/drm_framebuffer.h>
27#include <drm/drm_atomic.h> 27#include <drm/drm_atomic.h>
28#include <drm/drm_print.h>
28 29
30#include "drm_internal.h"
29#include "drm_crtc_internal.h" 31#include "drm_crtc_internal.h"
30 32
31/** 33/**
@@ -78,11 +80,12 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
78 src_h > fb_height || 80 src_h > fb_height ||
79 src_y > fb_height - src_h) { 81 src_y > fb_height - src_h) {
80 DRM_DEBUG_KMS("Invalid source coordinates " 82 DRM_DEBUG_KMS("Invalid source coordinates "
81 "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n", 83 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
82 src_w >> 16, ((src_w & 0xffff) * 15625) >> 10, 84 src_w >> 16, ((src_w & 0xffff) * 15625) >> 10,
83 src_h >> 16, ((src_h & 0xffff) * 15625) >> 10, 85 src_h >> 16, ((src_h & 0xffff) * 15625) >> 10,
84 src_x >> 16, ((src_x & 0xffff) * 15625) >> 10, 86 src_x >> 16, ((src_x & 0xffff) * 15625) >> 10,
85 src_y >> 16, ((src_y & 0xffff) * 15625) >> 10); 87 src_y >> 16, ((src_y & 0xffff) * 15625) >> 10,
88 fb->width, fb->height);
86 return -ENOSPC; 89 return -ENOSPC;
87 } 90 }
88 91
@@ -766,14 +769,18 @@ static int atomic_remove_fb(struct drm_framebuffer *fb)
766 struct drm_plane *plane; 769 struct drm_plane *plane;
767 struct drm_connector *conn; 770 struct drm_connector *conn;
768 struct drm_connector_state *conn_state; 771 struct drm_connector_state *conn_state;
769 int i, ret = 0; 772 int i, ret;
770 unsigned plane_mask; 773 unsigned plane_mask;
774 bool disable_crtcs = false;
771 775
772 state = drm_atomic_state_alloc(dev); 776retry_disable:
773 if (!state)
774 return -ENOMEM;
775
776 drm_modeset_acquire_init(&ctx, 0); 777 drm_modeset_acquire_init(&ctx, 0);
778
779 state = drm_atomic_state_alloc(dev);
780 if (!state) {
781 ret = -ENOMEM;
782 goto out;
783 }
777 state->acquire_ctx = &ctx; 784 state->acquire_ctx = &ctx;
778 785
779retry: 786retry:
@@ -794,7 +801,7 @@ retry:
794 goto unlock; 801 goto unlock;
795 } 802 }
796 803
797 if (plane_state->crtc->primary == plane) { 804 if (disable_crtcs && plane_state->crtc->primary == plane) {
798 struct drm_crtc_state *crtc_state; 805 struct drm_crtc_state *crtc_state;
799 806
800 crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc); 807 crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
@@ -819,6 +826,7 @@ retry:
819 plane->old_fb = plane->fb; 826 plane->old_fb = plane->fb;
820 } 827 }
821 828
829 /* This list is only filled when disable_crtcs is set. */
822 for_each_new_connector_in_state(state, conn, conn_state, i) { 830 for_each_new_connector_in_state(state, conn, conn_state, i) {
823 ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); 831 ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
824 832
@@ -841,9 +849,15 @@ unlock:
841 849
842 drm_atomic_state_put(state); 850 drm_atomic_state_put(state);
843 851
852out:
844 drm_modeset_drop_locks(&ctx); 853 drm_modeset_drop_locks(&ctx);
845 drm_modeset_acquire_fini(&ctx); 854 drm_modeset_acquire_fini(&ctx);
846 855
856 if (ret == -EINVAL && !disable_crtcs) {
857 disable_crtcs = true;
858 goto retry_disable;
859 }
860
847 return ret; 861 return ret;
848} 862}
849 863
@@ -957,3 +971,60 @@ int drm_framebuffer_plane_height(int height,
957 return fb_plane_height(height, fb->format, plane); 971 return fb_plane_height(height, fb->format, plane);
958} 972}
959EXPORT_SYMBOL(drm_framebuffer_plane_height); 973EXPORT_SYMBOL(drm_framebuffer_plane_height);
974
975void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
976 const struct drm_framebuffer *fb)
977{
978 struct drm_format_name_buf format_name;
979 unsigned int i;
980
981 drm_printf_indent(p, indent, "refcount=%u\n",
982 drm_framebuffer_read_refcount(fb));
983 drm_printf_indent(p, indent, "format=%s\n",
984 drm_get_format_name(fb->format->format, &format_name));
985 drm_printf_indent(p, indent, "modifier=0x%llx\n", fb->modifier);
986 drm_printf_indent(p, indent, "size=%ux%u\n", fb->width, fb->height);
987 drm_printf_indent(p, indent, "layers:\n");
988
989 for (i = 0; i < fb->format->num_planes; i++) {
990 drm_printf_indent(p, indent + 1, "size[%u]=%dx%d\n", i,
991 drm_framebuffer_plane_width(fb->width, fb, i),
992 drm_framebuffer_plane_height(fb->height, fb, i));
993 drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]);
994 drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]);
995 drm_printf_indent(p, indent + 1, "obj[%u]:%s\n", i,
996 fb->obj[i] ? "" : "(null)");
997 if (fb->obj[i])
998 drm_gem_print_info(p, indent + 2, fb->obj[i]);
999 }
1000}
1001
1002#ifdef CONFIG_DEBUG_FS
1003static int drm_framebuffer_info(struct seq_file *m, void *data)
1004{
1005 struct drm_info_node *node = m->private;
1006 struct drm_device *dev = node->minor->dev;
1007 struct drm_printer p = drm_seq_file_printer(m);
1008 struct drm_framebuffer *fb;
1009
1010 mutex_lock(&dev->mode_config.fb_lock);
1011 drm_for_each_fb(fb, dev) {
1012 drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
1013 drm_framebuffer_print_info(&p, 1, fb);
1014 }
1015 mutex_unlock(&dev->mode_config.fb_lock);
1016
1017 return 0;
1018}
1019
1020static const struct drm_info_list drm_framebuffer_debugfs_list[] = {
1021 { "framebuffer", drm_framebuffer_info, 0 },
1022};
1023
1024int drm_framebuffer_debugfs_init(struct drm_minor *minor)
1025{
1026 return drm_debugfs_create_files(drm_framebuffer_debugfs_list,
1027 ARRAY_SIZE(drm_framebuffer_debugfs_list),
1028 minor->debugfs_root, minor);
1029}
1030#endif
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 55d6182555c7..01f8d9481211 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -40,6 +40,7 @@
40#include <drm/drmP.h> 40#include <drm/drmP.h>
41#include <drm/drm_vma_manager.h> 41#include <drm/drm_vma_manager.h>
42#include <drm/drm_gem.h> 42#include <drm/drm_gem.h>
43#include <drm/drm_print.h>
43#include "drm_internal.h" 44#include "drm_internal.h"
44 45
45/** @file drm_gem.c 46/** @file drm_gem.c
@@ -348,7 +349,7 @@ EXPORT_SYMBOL_GPL(drm_gem_dumb_map_offset);
348 * @file: drm file-private structure to remove the dumb handle from 349 * @file: drm file-private structure to remove the dumb handle from
349 * @dev: corresponding drm_device 350 * @dev: corresponding drm_device
350 * @handle: the dumb handle to remove 351 * @handle: the dumb handle to remove
351 * 352 *
352 * This implements the &drm_driver.dumb_destroy kms driver callback for drivers 353 * This implements the &drm_driver.dumb_destroy kms driver callback for drivers
353 * which use gem to manage their backing storage. 354 * which use gem to manage their backing storage.
354 */ 355 */
@@ -365,7 +366,7 @@ EXPORT_SYMBOL(drm_gem_dumb_destroy);
365 * @file_priv: drm file-private structure to register the handle for 366 * @file_priv: drm file-private structure to register the handle for
366 * @obj: object to register 367 * @obj: object to register
367 * @handlep: pointer to return the created handle to the caller 368 * @handlep: pointer to return the created handle to the caller
368 * 369 *
369 * This expects the &drm_device.object_name_lock to be held already and will 370 * This expects the &drm_device.object_name_lock to be held already and will
370 * drop it before returning. Used to avoid races in establishing new handles 371 * drop it before returning. Used to avoid races in establishing new handles
371 * when importing an object from either an flink name or a dma-buf. 372 * when importing an object from either an flink name or a dma-buf.
@@ -1040,3 +1041,19 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
1040 return ret; 1041 return ret;
1041} 1042}
1042EXPORT_SYMBOL(drm_gem_mmap); 1043EXPORT_SYMBOL(drm_gem_mmap);
1044
1045void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
1046 const struct drm_gem_object *obj)
1047{
1048 drm_printf_indent(p, indent, "name=%d\n", obj->name);
1049 drm_printf_indent(p, indent, "refcount=%u\n",
1050 kref_read(&obj->refcount));
1051 drm_printf_indent(p, indent, "start=%08lx\n",
1052 drm_vma_node_start(&obj->vma_node));
1053 drm_printf_indent(p, indent, "size=%zu\n", obj->size);
1054 drm_printf_indent(p, indent, "imported=%s\n",
1055 obj->import_attach ? "yes" : "no");
1056
1057 if (obj->dev->driver->gem_print_info)
1058 obj->dev->driver->gem_print_info(p, indent, obj);
1059}
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index 020e7668dfab..80a5115c3846 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -397,31 +397,24 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
397EXPORT_SYMBOL_GPL(drm_gem_cma_get_unmapped_area); 397EXPORT_SYMBOL_GPL(drm_gem_cma_get_unmapped_area);
398#endif 398#endif
399 399
400#ifdef CONFIG_DEBUG_FS
401/** 400/**
402 * drm_gem_cma_describe - describe a CMA GEM object for debugfs 401 * drm_gem_cma_print_info() - Print &drm_gem_cma_object info for debugfs
403 * @cma_obj: CMA GEM object 402 * @p: DRM printer
404 * @m: debugfs file handle 403 * @indent: Tab indentation level
404 * @obj: GEM object
405 * 405 *
406 * This function can be used to dump a human-readable representation of the 406 * This function can be used as the &drm_driver->gem_print_info callback.
407 * CMA GEM object into a synthetic file. 407 * It prints paddr and vaddr for use in e.g. debugfs output.
408 */ 408 */
409void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj, 409void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
410 struct seq_file *m) 410 const struct drm_gem_object *obj)
411{ 411{
412 struct drm_gem_object *obj = &cma_obj->base; 412 const struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
413 uint64_t off;
414
415 off = drm_vma_node_start(&obj->vma_node);
416
417 seq_printf(m, "%2d (%2d) %08llx %pad %p %zu",
418 obj->name, kref_read(&obj->refcount),
419 off, &cma_obj->paddr, cma_obj->vaddr, obj->size);
420 413
421 seq_printf(m, "\n"); 414 drm_printf_indent(p, indent, "paddr=%pad\n", &cma_obj->paddr);
415 drm_printf_indent(p, indent, "vaddr=%p\n", cma_obj->vaddr);
422} 416}
423EXPORT_SYMBOL_GPL(drm_gem_cma_describe); 417EXPORT_SYMBOL(drm_gem_cma_print_info);
424#endif
425 418
426/** 419/**
427 * drm_gem_cma_prime_get_sg_table - provide a scatter/gather table of pinned 420 * drm_gem_cma_prime_get_sg_table - provide a scatter/gather table of pinned
@@ -482,8 +475,26 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
482{ 475{
483 struct drm_gem_cma_object *cma_obj; 476 struct drm_gem_cma_object *cma_obj;
484 477
485 if (sgt->nents != 1) 478 if (sgt->nents != 1) {
486 return ERR_PTR(-EINVAL); 479 /* check if the entries in the sg_table are contiguous */
480 dma_addr_t next_addr = sg_dma_address(sgt->sgl);
481 struct scatterlist *s;
482 unsigned int i;
483
484 for_each_sg(sgt->sgl, s, sgt->nents, i) {
485 /*
486 * sg_dma_address(s) is only valid for entries
487 * that have sg_dma_len(s) != 0
488 */
489 if (!sg_dma_len(s))
490 continue;
491
492 if (sg_dma_address(s) != next_addr)
493 return ERR_PTR(-EINVAL);
494
495 next_addr = sg_dma_address(s) + sg_dma_len(s);
496 }
497 }
487 498
488 /* Create a CMA GEM buffer. */ 499 /* Create a CMA GEM buffer. */
489 cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size); 500 cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size);
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index c9d5a6cd4d41..b72242e93ea4 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -111,6 +111,8 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
111 struct drm_file *file_priv); 111 struct drm_file *file_priv);
112void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); 112void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
113void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); 113void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
114void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
115 const struct drm_gem_object *obj);
114 116
115/* drm_debugfs.c drm_debugfs_crc.c */ 117/* drm_debugfs.c drm_debugfs_crc.c */
116#if defined(CONFIG_DEBUG_FS) 118#if defined(CONFIG_DEBUG_FS)
@@ -178,3 +180,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
178 struct drm_file *file_private); 180 struct drm_file *file_private);
179int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, 181int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
180 struct drm_file *file_private); 182 struct drm_file *file_private);
183
184/* drm_framebuffer.c */
185void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
186 const struct drm_framebuffer *fb);
187int drm_framebuffer_debugfs_init(struct drm_minor *minor);
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 61a1c8ea74bc..eb86bc3f753b 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -92,7 +92,7 @@
92 * some basic allocator dumpers for debugging. 92 * some basic allocator dumpers for debugging.
93 * 93 *
94 * Note that this range allocator is not thread-safe, drivers need to protect 94 * Note that this range allocator is not thread-safe, drivers need to protect
95 * modifications with their on locking. The idea behind this is that for a full 95 * modifications with their own locking. The idea behind this is that for a full
96 * memory manager additional data needs to be protected anyway, hence internal 96 * memory manager additional data needs to be protected anyway, hence internal
97 * locking would be fully redundant. 97 * locking would be fully redundant.
98 */ 98 */
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 759ed93f4ba8..f1be8cd4e387 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -100,97 +100,6 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
100} 100}
101 101
102/** 102/**
103 * drm_plane_helper_check_state() - Check plane state for validity
104 * @state: plane state to check
105 * @clip: integer clipping coordinates
106 * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
107 * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
108 * @can_position: is it legal to position the plane such that it
109 * doesn't cover the entire crtc? This will generally
110 * only be false for primary planes.
111 * @can_update_disabled: can the plane be updated while the crtc
112 * is disabled?
113 *
114 * Checks that a desired plane update is valid, and updates various
115 * bits of derived state (clipped coordinates etc.). Drivers that provide
116 * their own plane handling rather than helper-provided implementations may
117 * still wish to call this function to avoid duplication of error checking
118 * code.
119 *
120 * RETURNS:
121 * Zero if update appears valid, error code on failure
122 */
123int drm_plane_helper_check_state(struct drm_plane_state *state,
124 const struct drm_rect *clip,
125 int min_scale,
126 int max_scale,
127 bool can_position,
128 bool can_update_disabled)
129{
130 struct drm_crtc *crtc = state->crtc;
131 struct drm_framebuffer *fb = state->fb;
132 struct drm_rect *src = &state->src;
133 struct drm_rect *dst = &state->dst;
134 unsigned int rotation = state->rotation;
135 int hscale, vscale;
136
137 *src = drm_plane_state_src(state);
138 *dst = drm_plane_state_dest(state);
139
140 if (!fb) {
141 state->visible = false;
142 return 0;
143 }
144
145 /* crtc should only be NULL when disabling (i.e., !fb) */
146 if (WARN_ON(!crtc)) {
147 state->visible = false;
148 return 0;
149 }
150
151 if (!crtc->enabled && !can_update_disabled) {
152 DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
153 return -EINVAL;
154 }
155
156 drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
157
158 /* Check scaling */
159 hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
160 vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
161 if (hscale < 0 || vscale < 0) {
162 DRM_DEBUG_KMS("Invalid scaling of plane\n");
163 drm_rect_debug_print("src: ", &state->src, true);
164 drm_rect_debug_print("dst: ", &state->dst, false);
165 return -ERANGE;
166 }
167
168 state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
169
170 drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
171
172 if (!state->visible)
173 /*
174 * Plane isn't visible; some drivers can handle this
175 * so we just return success here. Drivers that can't
176 * (including those that use the primary plane helper's
177 * update function) will return an error from their
178 * update_plane handler.
179 */
180 return 0;
181
182 if (!can_position && !drm_rect_equals(dst, clip)) {
183 DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
184 drm_rect_debug_print("dst: ", dst, false);
185 drm_rect_debug_print("clip: ", clip, false);
186 return -EINVAL;
187 }
188
189 return 0;
190}
191EXPORT_SYMBOL(drm_plane_helper_check_state);
192
193/**
194 * drm_plane_helper_check_update() - Check plane update for validity 103 * drm_plane_helper_check_update() - Check plane update for validity
195 * @plane: plane object to update 104 * @plane: plane object to update
196 * @crtc: owning CRTC of owning plane 105 * @crtc: owning CRTC of owning plane
@@ -230,7 +139,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
230 bool can_update_disabled, 139 bool can_update_disabled,
231 bool *visible) 140 bool *visible)
232{ 141{
233 struct drm_plane_state state = { 142 struct drm_plane_state plane_state = {
234 .plane = plane, 143 .plane = plane,
235 .crtc = crtc, 144 .crtc = crtc,
236 .fb = fb, 145 .fb = fb,
@@ -245,18 +154,22 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
245 .rotation = rotation, 154 .rotation = rotation,
246 .visible = *visible, 155 .visible = *visible,
247 }; 156 };
157 struct drm_crtc_state crtc_state = {
158 .crtc = crtc,
159 .enable = crtc->enabled,
160 };
248 int ret; 161 int ret;
249 162
250 ret = drm_plane_helper_check_state(&state, clip, 163 ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state,
251 min_scale, max_scale, 164 clip, min_scale, max_scale,
252 can_position, 165 can_position,
253 can_update_disabled); 166 can_update_disabled);
254 if (ret) 167 if (ret)
255 return ret; 168 return ret;
256 169
257 *src = state.src; 170 *src = plane_state.src;
258 *dst = state.dst; 171 *dst = plane_state.dst;
259 *visible = state.visible; 172 *visible = plane_state.visible;
260 173
261 return 0; 174 return 0;
262} 175}
diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 74c466aca622..781518fd88e3 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -23,6 +23,8 @@
23 * Rob Clark <robdclark@gmail.com> 23 * Rob Clark <robdclark@gmail.com>
24 */ 24 */
25 25
26#define DEBUG /* for pr_debug() */
27
26#include <stdarg.h> 28#include <stdarg.h>
27#include <linux/seq_file.h> 29#include <linux/seq_file.h>
28#include <drm/drmP.h> 30#include <drm/drmP.h>
@@ -53,13 +55,57 @@ EXPORT_SYMBOL(__drm_printfn_debug);
53 */ 55 */
54void drm_printf(struct drm_printer *p, const char *f, ...) 56void drm_printf(struct drm_printer *p, const char *f, ...)
55{ 57{
56 struct va_format vaf;
57 va_list args; 58 va_list args;
58 59
59 va_start(args, f); 60 va_start(args, f);
60 vaf.fmt = f; 61 drm_vprintf(p, f, &args);
61 vaf.va = &args;
62 p->printfn(p, &vaf);
63 va_end(args); 62 va_end(args);
64} 63}
65EXPORT_SYMBOL(drm_printf); 64EXPORT_SYMBOL(drm_printf);
65
66#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
67
68void drm_dev_printk(const struct device *dev, const char *level,
69 unsigned int category, const char *function_name,
70 const char *prefix, const char *format, ...)
71{
72 struct va_format vaf;
73 va_list args;
74
75 if (category != DRM_UT_NONE && !(drm_debug & category))
76 return;
77
78 va_start(args, format);
79 vaf.fmt = format;
80 vaf.va = &args;
81
82 if (dev)
83 dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix,
84 &vaf);
85 else
86 printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf);
87
88 va_end(args);
89}
90EXPORT_SYMBOL(drm_dev_printk);
91
92void drm_printk(const char *level, unsigned int category,
93 const char *format, ...)
94{
95 struct va_format vaf;
96 va_list args;
97
98 if (category != DRM_UT_NONE && !(drm_debug & category))
99 return;
100
101 va_start(args, format);
102 vaf.fmt = format;
103 vaf.va = &args;
104
105 printk("%s" "[" DRM_NAME ":%ps]%s %pV",
106 level, __builtin_return_address(0),
107 strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
108
109 va_end(args);
110}
111EXPORT_SYMBOL(drm_printk);
diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
index dc9fd109de14..9f3b1c94802b 100644
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -103,10 +103,11 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
103 clip.x2 = crtc_state->adjusted_mode.hdisplay; 103 clip.x2 = crtc_state->adjusted_mode.hdisplay;
104 clip.y2 = crtc_state->adjusted_mode.vdisplay; 104 clip.y2 = crtc_state->adjusted_mode.vdisplay;
105 105
106 ret = drm_plane_helper_check_state(plane_state, &clip, 106 ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state,
107 DRM_PLANE_HELPER_NO_SCALING, 107 &clip,
108 DRM_PLANE_HELPER_NO_SCALING, 108 DRM_PLANE_HELPER_NO_SCALING,
109 false, true); 109 DRM_PLANE_HELPER_NO_SCALING,
110 false, true);
110 if (ret) 111 if (ret)
111 return ret; 112 return ret;
112 113
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index f776fc1cc543..9b733c510cbf 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -106,7 +106,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
106 * callback when a fence has already been set. 106 * callback when a fence has already been set.
107 */ 107 */
108 if (syncobj->fence) { 108 if (syncobj->fence) {
109 *fence = dma_fence_get(syncobj->fence); 109 *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
110 lockdep_is_held(&syncobj->lock)));
110 ret = 1; 111 ret = 1;
111 } else { 112 } else {
112 *fence = NULL; 113 *fence = NULL;
@@ -168,8 +169,9 @@ void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
168 169
169 spin_lock(&syncobj->lock); 170 spin_lock(&syncobj->lock);
170 171
171 old_fence = syncobj->fence; 172 old_fence = rcu_dereference_protected(syncobj->fence,
172 syncobj->fence = fence; 173 lockdep_is_held(&syncobj->lock));
174 rcu_assign_pointer(syncobj->fence, fence);
173 175
174 if (fence != old_fence) { 176 if (fence != old_fence) {
175 list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) { 177 list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
@@ -659,7 +661,8 @@ static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
659 container_of(cb, struct syncobj_wait_entry, syncobj_cb); 661 container_of(cb, struct syncobj_wait_entry, syncobj_cb);
660 662
661 /* This happens inside the syncobj lock */ 663 /* This happens inside the syncobj lock */
662 wait->fence = dma_fence_get(syncobj->fence); 664 wait->fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
665 lockdep_is_held(&syncobj->lock)));
663 wake_up_process(wait->task); 666 wake_up_process(wait->task);
664} 667}
665 668
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 3717b3df34a4..32d9bcf5be7f 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -663,14 +663,16 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
663 delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), 663 delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos),
664 mode->crtc_clock); 664 mode->crtc_clock);
665 665
666 /* save this only for debugging purposes */
667 ts_etime = ktime_to_timespec64(etime);
668 ts_vblank_time = ktime_to_timespec64(*vblank_time);
669 /* Subtract time delta from raw timestamp to get final 666 /* Subtract time delta from raw timestamp to get final
670 * vblank_time timestamp for end of vblank. 667 * vblank_time timestamp for end of vblank.
671 */ 668 */
672 etime = ktime_sub_ns(etime, delta_ns); 669 *vblank_time = ktime_sub_ns(etime, delta_ns);
673 *vblank_time = etime; 670
671 if ((drm_debug & DRM_UT_VBL) == 0)
672 return true;
673
674 ts_etime = ktime_to_timespec64(etime);
675 ts_vblank_time = ktime_to_timespec64(*vblank_time);
674 676
675 DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %lld.%06ld -> %lld.%06ld [e %d us, %d rep]\n", 677 DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %lld.%06ld -> %lld.%06ld [e %d us, %d rep]\n",
676 pipe, hpos, vpos, 678 pipe, hpos, vpos,
diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index 28f1226576f8..23c749c05b5a 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -203,21 +203,16 @@ EXPORT_SYMBOL(drm_vma_offset_lookup_locked);
203int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, 203int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
204 struct drm_vma_offset_node *node, unsigned long pages) 204 struct drm_vma_offset_node *node, unsigned long pages)
205{ 205{
206 int ret; 206 int ret = 0;
207 207
208 write_lock(&mgr->vm_lock); 208 write_lock(&mgr->vm_lock);
209 209
210 if (drm_mm_node_allocated(&node->vm_node)) { 210 if (!drm_mm_node_allocated(&node->vm_node))
211 ret = 0; 211 ret = drm_mm_insert_node(&mgr->vm_addr_space_mm,
212 goto out_unlock; 212 &node->vm_node, pages);
213 }
214 213
215 ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
216 if (ret)
217 goto out_unlock;
218
219out_unlock:
220 write_unlock(&mgr->vm_lock); 214 write_unlock(&mgr->vm_lock);
215
221 return ret; 216 return ret;
222} 217}
223EXPORT_SYMBOL(drm_vma_offset_add); 218EXPORT_SYMBOL(drm_vma_offset_add);
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 82d1b7e2febe..a4b75a46f946 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -829,7 +829,8 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
829 DRM_INFO("%s: invalid AVI infoframe (%d)\n", __func__, ret); 829 DRM_INFO("%s: invalid AVI infoframe (%d)\n", __func__, ret);
830 } 830 }
831 831
832 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi, m); 832 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
833 &hdata->connector, m);
833 if (!ret) 834 if (!ret)
834 ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf, 835 ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
835 sizeof(buf)); 836 sizeof(buf));
diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
index 0eaf11c19939..ccb161c73a59 100644
--- a/drivers/gpu/drm/gma500/mmu.c
+++ b/drivers/gpu/drm/gma500/mmu.c
@@ -395,7 +395,7 @@ static void psb_mmu_pt_unmap_unlock(struct psb_mmu_pt *pt)
395 psb_mmu_clflush(pd->driver, (void *)&v[pt->index]); 395 psb_mmu_clflush(pd->driver, (void *)&v[pt->index]);
396 atomic_set(&pd->driver->needs_tlbflush, 1); 396 atomic_set(&pd->driver->needs_tlbflush, 1);
397 } 397 }
398 kunmap_atomic(pt->v); 398 kunmap_atomic(v);
399 spin_unlock(&pd->driver->lock); 399 spin_unlock(&pd->driver->lock);
400 psb_mmu_free_pt(pt); 400 psb_mmu_free_pt(pt);
401 return; 401 return;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 37a3be71acd9..8f5cc1f471cd 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -527,4 +527,4 @@ module_exit(psb_exit);
527 527
528MODULE_AUTHOR(DRIVER_AUTHOR); 528MODULE_AUTHOR(DRIVER_AUTHOR);
529MODULE_DESCRIPTION(DRIVER_DESC); 529MODULE_DESCRIPTION(DRIVER_DESC);
530MODULE_LICENSE(DRIVER_LICENSE); 530MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index 821497dbd3fc..4918efc57b7a 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -36,7 +36,6 @@
36#include "mmu.h" 36#include "mmu.h"
37 37
38#define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others" 38#define DRIVER_AUTHOR "Alan Cox <alan@linux.intel.com> and others"
39#define DRIVER_LICENSE "GPL"
40 39
41#define DRIVER_NAME "gma500" 40#define DRIVER_NAME "gma500"
42#define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650" 41#define DRIVER_DESC "DRM driver for the Intel GMA500, GMA600, GMA3600, GMA3650"
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index 127815253a84..cd3f0873bbdd 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1100,7 +1100,6 @@ static int tda998x_connector_get_modes(struct drm_connector *connector)
1100 1100
1101 drm_mode_connector_update_edid_property(connector, edid); 1101 drm_mode_connector_update_edid_property(connector, edid);
1102 n = drm_add_edid_modes(connector, edid); 1102 n = drm_add_edid_modes(connector, edid);
1103 drm_edid_to_eld(connector, edid);
1104 1103
1105 kfree(edid); 1104 kfree(edid);
1106 1105
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 878acc432a4b..e0fffd883b54 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9314,11 +9314,12 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state,
9314 u32 offset; 9314 u32 offset;
9315 int ret; 9315 int ret;
9316 9316
9317 ret = drm_plane_helper_check_state(&plane_state->base, 9317 ret = drm_atomic_helper_check_plane_state(&plane_state->base,
9318 &plane_state->clip, 9318 &crtc_state->base,
9319 DRM_PLANE_HELPER_NO_SCALING, 9319 &plane_state->clip,
9320 DRM_PLANE_HELPER_NO_SCALING, 9320 DRM_PLANE_HELPER_NO_SCALING,
9321 true, true); 9321 DRM_PLANE_HELPER_NO_SCALING,
9322 true, true);
9322 if (ret) 9323 if (ret)
9323 return ret; 9324 return ret;
9324 9325
@@ -12794,10 +12795,11 @@ intel_check_primary_plane(struct intel_plane *plane,
12794 can_position = true; 12795 can_position = true;
12795 } 12796 }
12796 12797
12797 ret = drm_plane_helper_check_state(&state->base, 12798 ret = drm_atomic_helper_check_plane_state(&state->base,
12798 &state->clip, 12799 &crtc_state->base,
12799 min_scale, max_scale, 12800 &state->clip,
12800 can_position, true); 12801 min_scale, max_scale,
12802 can_position, true);
12801 if (ret) 12803 if (ret)
12802 return ret; 12804 return ret;
12803 12805
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 158438bb0389..65260fb35d2a 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -5868,7 +5868,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
5868 if (drm_add_edid_modes(connector, edid)) { 5868 if (drm_add_edid_modes(connector, edid)) {
5869 drm_mode_connector_update_edid_property(connector, 5869 drm_mode_connector_update_edid_property(connector,
5870 edid); 5870 edid);
5871 drm_edid_to_eld(connector, edid);
5872 } else { 5871 } else {
5873 kfree(edid); 5872 kfree(edid);
5874 edid = ERR_PTR(-EINVAL); 5873 edid = ERR_PTR(-EINVAL);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 4dea833f9d1b..e039702c1907 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -513,12 +513,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
513 513
514static void 514static void
515intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder, 515intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
516 const struct intel_crtc_state *crtc_state) 516 const struct intel_crtc_state *crtc_state,
517 const struct drm_connector_state *conn_state)
517{ 518{
518 union hdmi_infoframe frame; 519 union hdmi_infoframe frame;
519 int ret; 520 int ret;
520 521
521 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, 522 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
523 conn_state->connector,
522 &crtc_state->base.adjusted_mode); 524 &crtc_state->base.adjusted_mode);
523 if (ret < 0) 525 if (ret < 0)
524 return; 526 return;
@@ -585,7 +587,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
585 587
586 intel_hdmi_set_avi_infoframe(encoder, crtc_state); 588 intel_hdmi_set_avi_infoframe(encoder, crtc_state);
587 intel_hdmi_set_spd_infoframe(encoder, crtc_state); 589 intel_hdmi_set_spd_infoframe(encoder, crtc_state);
588 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); 590 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
589} 591}
590 592
591static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state) 593static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
@@ -726,7 +728,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
726 728
727 intel_hdmi_set_avi_infoframe(encoder, crtc_state); 729 intel_hdmi_set_avi_infoframe(encoder, crtc_state);
728 intel_hdmi_set_spd_infoframe(encoder, crtc_state); 730 intel_hdmi_set_spd_infoframe(encoder, crtc_state);
729 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); 731 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
730} 732}
731 733
732static void cpt_set_infoframes(struct drm_encoder *encoder, 734static void cpt_set_infoframes(struct drm_encoder *encoder,
@@ -769,7 +771,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
769 771
770 intel_hdmi_set_avi_infoframe(encoder, crtc_state); 772 intel_hdmi_set_avi_infoframe(encoder, crtc_state);
771 intel_hdmi_set_spd_infoframe(encoder, crtc_state); 773 intel_hdmi_set_spd_infoframe(encoder, crtc_state);
772 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); 774 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
773} 775}
774 776
775static void vlv_set_infoframes(struct drm_encoder *encoder, 777static void vlv_set_infoframes(struct drm_encoder *encoder,
@@ -822,7 +824,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
822 824
823 intel_hdmi_set_avi_infoframe(encoder, crtc_state); 825 intel_hdmi_set_avi_infoframe(encoder, crtc_state);
824 intel_hdmi_set_spd_infoframe(encoder, crtc_state); 826 intel_hdmi_set_spd_infoframe(encoder, crtc_state);
825 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); 827 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
826} 828}
827 829
828static void hsw_set_infoframes(struct drm_encoder *encoder, 830static void hsw_set_infoframes(struct drm_encoder *encoder,
@@ -855,7 +857,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
855 857
856 intel_hdmi_set_avi_infoframe(encoder, crtc_state); 858 intel_hdmi_set_avi_infoframe(encoder, crtc_state);
857 intel_hdmi_set_spd_infoframe(encoder, crtc_state); 859 intel_hdmi_set_spd_infoframe(encoder, crtc_state);
858 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state); 860 intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
859} 861}
860 862
861void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable) 863void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index 28a778b785ac..4e43f873c889 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -57,7 +57,6 @@ int intel_connector_update_modes(struct drm_connector *connector,
57 57
58 drm_mode_connector_update_edid_property(connector, edid); 58 drm_mode_connector_update_edid_property(connector, edid);
59 ret = drm_add_edid_modes(connector, edid); 59 ret = drm_add_edid_modes(connector, edid);
60 drm_edid_to_eld(connector, edid);
61 60
62 intel_connector_update_eld_conn_type(connector); 61 intel_connector_update_eld_conn_type(connector);
63 62
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index 247c60e6bed2..5a67daedcf4d 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -342,10 +342,10 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
342 clip.y1 = 0; 342 clip.y1 = 0;
343 clip.x2 = crtc_state->adjusted_mode.hdisplay; 343 clip.x2 = crtc_state->adjusted_mode.hdisplay;
344 clip.y2 = crtc_state->adjusted_mode.vdisplay; 344 clip.y2 = crtc_state->adjusted_mode.vdisplay;
345 ret = drm_plane_helper_check_state(state, &clip, 345 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
346 DRM_PLANE_HELPER_NO_SCALING, 346 DRM_PLANE_HELPER_NO_SCALING,
347 DRM_PLANE_HELPER_NO_SCALING, 347 DRM_PLANE_HELPER_NO_SCALING,
348 can_position, true); 348 can_position, true);
349 if (ret) 349 if (ret)
350 return ret; 350 return ret;
351 351
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 6f121891430f..5ef898b93d8d 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -111,10 +111,10 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
111 clip.x2 = crtc_state->mode.hdisplay; 111 clip.x2 = crtc_state->mode.hdisplay;
112 clip.y2 = crtc_state->mode.vdisplay; 112 clip.y2 = crtc_state->mode.vdisplay;
113 113
114 return drm_plane_helper_check_state(state, &clip, 114 return drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
115 DRM_PLANE_HELPER_NO_SCALING, 115 DRM_PLANE_HELPER_NO_SCALING,
116 DRM_PLANE_HELPER_NO_SCALING, 116 DRM_PLANE_HELPER_NO_SCALING,
117 true, true); 117 true, true);
118} 118}
119 119
120static void mtk_plane_atomic_update(struct drm_plane *plane, 120static void mtk_plane_atomic_update(struct drm_plane *plane,
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 3ff502771ba2..59a11026dceb 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
1054 u8 buffer[10]; 1054 u8 buffer[10];
1055 ssize_t err; 1055 ssize_t err;
1056 1056
1057 err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode); 1057 err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
1058 &hdmi->conn, mode);
1058 if (err) { 1059 if (err) {
1059 dev_err(hdmi->dev, 1060 dev_err(hdmi->dev,
1060 "Failed to get vendor infoframe from mode: %zd\n", err); 1061 "Failed to get vendor infoframe from mode: %zd\n", err);
@@ -1222,7 +1223,6 @@ static int mtk_hdmi_conn_get_modes(struct drm_connector *conn)
1222 drm_mode_connector_update_edid_property(conn, edid); 1223 drm_mode_connector_update_edid_property(conn, edid);
1223 1224
1224 ret = drm_add_edid_modes(conn, edid); 1225 ret = drm_add_edid_modes(conn, edid);
1225 drm_edid_to_eld(conn, edid);
1226 kfree(edid); 1226 kfree(edid);
1227 return ret; 1227 return ret;
1228} 1228}
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 17e96fa47868..d0a6ac8390f3 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -61,10 +61,10 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
61 clip.x2 = crtc_state->mode.hdisplay; 61 clip.x2 = crtc_state->mode.hdisplay;
62 clip.y2 = crtc_state->mode.vdisplay; 62 clip.y2 = crtc_state->mode.vdisplay;
63 63
64 return drm_plane_helper_check_state(state, &clip, 64 return drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
65 DRM_PLANE_HELPER_NO_SCALING, 65 DRM_PLANE_HELPER_NO_SCALING,
66 DRM_PLANE_HELPER_NO_SCALING, 66 DRM_PLANE_HELPER_NO_SCALING,
67 true, true); 67 true, true);
68} 68}
69 69
70/* Takes a fixed 16.16 number and converts it to integer. */ 70/* Takes a fixed 16.16 number and converts it to integer. */
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index be50445f9901..ee41423baeb7 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -327,8 +327,9 @@ static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state,
327 min_scale = FRAC_16_16(1, 8); 327 min_scale = FRAC_16_16(1, 8);
328 max_scale = FRAC_16_16(8, 1); 328 max_scale = FRAC_16_16(8, 1);
329 329
330 ret = drm_plane_helper_check_state(state, &clip, min_scale, 330 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
331 max_scale, true, true); 331 min_scale, max_scale,
332 true, true);
332 if (ret) 333 if (ret)
333 return ret; 334 return ret;
334 335
@@ -505,8 +506,9 @@ static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
505 min_scale = FRAC_16_16(1, 8); 506 min_scale = FRAC_16_16(1, 8);
506 max_scale = FRAC_16_16(8, 1); 507 max_scale = FRAC_16_16(8, 1);
507 508
508 ret = drm_plane_helper_check_state(state, &clip, min_scale, 509 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
509 max_scale, true, true); 510 min_scale, max_scale,
511 true, true);
510 if (ret) 512 if (ret)
511 return ret; 513 return ret;
512 514
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 584466ef688f..65336948e807 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1143,10 +1143,11 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
1143{ 1143{
1144 int ret; 1144 int ret;
1145 1145
1146 ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip, 1146 ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
1147 DRM_PLANE_HELPER_NO_SCALING, 1147 &asyw->clip,
1148 DRM_PLANE_HELPER_NO_SCALING, 1148 DRM_PLANE_HELPER_NO_SCALING,
1149 true, true); 1149 DRM_PLANE_HELPER_NO_SCALING,
1150 true, true);
1150 asyh->curs.visible = asyw->state.visible; 1151 asyh->curs.visible = asyw->state.visible;
1151 if (ret || !asyh->curs.visible) 1152 if (ret || !asyh->curs.visible)
1152 return ret; 1153 return ret;
@@ -1432,10 +1433,11 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
1432 if (!fb->format->depth) 1433 if (!fb->format->depth)
1433 return -EINVAL; 1434 return -EINVAL;
1434 1435
1435 ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip, 1436 ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
1436 DRM_PLANE_HELPER_NO_SCALING, 1437 &asyw->clip,
1437 DRM_PLANE_HELPER_NO_SCALING, 1438 DRM_PLANE_HELPER_NO_SCALING,
1438 false, true); 1439 DRM_PLANE_HELPER_NO_SCALING,
1440 false, true);
1439 if (ret) 1441 if (ret)
1440 return ret; 1442 return ret;
1441 1443
@@ -2688,7 +2690,6 @@ nv50_audio_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
2688 if (!drm_detect_monitor_audio(nv_connector->edid)) 2690 if (!drm_detect_monitor_audio(nv_connector->edid))
2689 return; 2691 return;
2690 2692
2691 drm_edid_to_eld(&nv_connector->base, nv_connector->edid);
2692 memcpy(args.data, nv_connector->base.eld, sizeof(args.data)); 2693 memcpy(args.data, nv_connector->base.eld, sizeof(args.data));
2693 2694
2694 nvif_mthd(disp->disp, 0, &args, 2695 nvif_mthd(disp->disp, 0, &args,
@@ -2755,7 +2756,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
2755 = hdmi_infoframe_pack(&avi_frame, args.infoframes, 17); 2756 = hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
2756 } 2757 }
2757 2758
2758 ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode); 2759 ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
2760 &nv_connector->base, mode);
2759 if (!ret) { 2761 if (!ret) {
2760 /* We have a Vendor InfoFrame, populate it to the display */ 2762 /* We have a Vendor InfoFrame, populate it to the display */
2761 args.pwr.vendor_infoframe_length 2763 args.pwr.vendor_infoframe_length
@@ -3064,10 +3066,8 @@ nv50_mstc_get_modes(struct drm_connector *connector)
3064 3066
3065 mstc->edid = drm_dp_mst_get_edid(&mstc->connector, mstc->port->mgr, mstc->port); 3067 mstc->edid = drm_dp_mst_get_edid(&mstc->connector, mstc->port->mgr, mstc->port);
3066 drm_mode_connector_update_edid_property(&mstc->connector, mstc->edid); 3068 drm_mode_connector_update_edid_property(&mstc->connector, mstc->edid);
3067 if (mstc->edid) { 3069 if (mstc->edid)
3068 ret = drm_add_edid_modes(&mstc->connector, mstc->edid); 3070 ret = drm_add_edid_modes(&mstc->connector, mstc->edid);
3069 drm_edid_to_eld(&mstc->connector, mstc->edid);
3070 }
3071 3071
3072 if (!mstc->connector.display_info.bpc) 3072 if (!mstc->connector.display_info.bpc)
3073 mstc->connector.display_info.bpc = 8; 3073 mstc->connector.display_info.bpc = 8;
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 890fd6ff397c..d964d454e4ae 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -221,7 +221,7 @@ static struct rpi_touchscreen *panel_to_ts(struct drm_panel *panel)
221 return container_of(panel, struct rpi_touchscreen, base); 221 return container_of(panel, struct rpi_touchscreen, base);
222} 222}
223 223
224static u8 rpi_touchscreen_i2c_read(struct rpi_touchscreen *ts, u8 reg) 224static int rpi_touchscreen_i2c_read(struct rpi_touchscreen *ts, u8 reg)
225{ 225{
226 return i2c_smbus_read_byte_data(ts->i2c, reg); 226 return i2c_smbus_read_byte_data(ts->i2c, reg);
227} 227}
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index b7c4709f7b34..5591984a392b 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1356,6 +1356,38 @@ static const struct panel_desc lg_lp129qe = {
1356 }, 1356 },
1357}; 1357};
1358 1358
1359static const struct drm_display_mode mitsubishi_aa070mc01_mode = {
1360 .clock = 30400,
1361 .hdisplay = 800,
1362 .hsync_start = 800 + 0,
1363 .hsync_end = 800 + 1,
1364 .htotal = 800 + 0 + 1 + 160,
1365 .vdisplay = 480,
1366 .vsync_start = 480 + 0,
1367 .vsync_end = 480 + 48 + 1,
1368 .vtotal = 480 + 48 + 1 + 0,
1369 .vrefresh = 60,
1370 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
1371};
1372
1373static const struct panel_desc mitsubishi_aa070mc01 = {
1374 .modes = &mitsubishi_aa070mc01_mode,
1375 .num_modes = 1,
1376 .bpc = 8,
1377 .size = {
1378 .width = 152,
1379 .height = 91,
1380 },
1381
1382 .delay = {
1383 .enable = 200,
1384 .unprepare = 200,
1385 .disable = 400,
1386 },
1387 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1388 .bus_flags = DRM_BUS_FLAG_DE_HIGH,
1389};
1390
1359static const struct display_timing nec_nl12880bc20_05_timing = { 1391static const struct display_timing nec_nl12880bc20_05_timing = {
1360 .pixelclock = { 67000000, 71000000, 75000000 }, 1392 .pixelclock = { 67000000, 71000000, 75000000 },
1361 .hactive = { 1280, 1280, 1280 }, 1393 .hactive = { 1280, 1280, 1280 },
@@ -1837,6 +1869,30 @@ static const struct panel_desc tianma_tm070jdhg30 = {
1837 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, 1869 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1838}; 1870};
1839 1871
1872static const struct display_timing tianma_tm070rvhg71_timing = {
1873 .pixelclock = { 27700000, 29200000, 39600000 },
1874 .hactive = { 800, 800, 800 },
1875 .hfront_porch = { 12, 40, 212 },
1876 .hback_porch = { 88, 88, 88 },
1877 .hsync_len = { 1, 1, 40 },
1878 .vactive = { 480, 480, 480 },
1879 .vfront_porch = { 1, 13, 88 },
1880 .vback_porch = { 32, 32, 32 },
1881 .vsync_len = { 1, 1, 3 },
1882 .flags = DISPLAY_FLAGS_DE_HIGH,
1883};
1884
1885static const struct panel_desc tianma_tm070rvhg71 = {
1886 .timings = &tianma_tm070rvhg71_timing,
1887 .num_timings = 1,
1888 .bpc = 8,
1889 .size = {
1890 .width = 154,
1891 .height = 86,
1892 },
1893 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1894};
1895
1840static const struct drm_display_mode toshiba_lt089ac29000_mode = { 1896static const struct drm_display_mode toshiba_lt089ac29000_mode = {
1841 .clock = 79500, 1897 .clock = 79500,
1842 .hdisplay = 1280, 1898 .hdisplay = 1280,
@@ -2086,6 +2142,9 @@ static const struct of_device_id platform_of_match[] = {
2086 .compatible = "lg,lp129qe", 2142 .compatible = "lg,lp129qe",
2087 .data = &lg_lp129qe, 2143 .data = &lg_lp129qe,
2088 }, { 2144 }, {
2145 .compatible = "mitsubishi,aa070mc01-ca1",
2146 .data = &mitsubishi_aa070mc01,
2147 }, {
2089 .compatible = "nec,nl12880bc20-05", 2148 .compatible = "nec,nl12880bc20-05",
2090 .data = &nec_nl12880bc20_05, 2149 .data = &nec_nl12880bc20_05,
2091 }, { 2150 }, {
@@ -2143,6 +2202,9 @@ static const struct of_device_id platform_of_match[] = {
2143 .compatible = "tianma,tm070jdhg30", 2202 .compatible = "tianma,tm070jdhg30",
2144 .data = &tianma_tm070jdhg30, 2203 .data = &tianma_tm070jdhg30,
2145 }, { 2204 }, {
2205 .compatible = "tianma,tm070rvhg71",
2206 .data = &tianma_tm070rvhg71,
2207 }, {
2146 .compatible = "toshiba,lt089ac29000", 2208 .compatible = "toshiba,lt089ac29000",
2147 .data = &toshiba_lt089ac29000, 2209 .data = &toshiba_lt089ac29000,
2148 }, { 2210 }, {
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index ab4823875311..586ecd6e0e45 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -123,11 +123,8 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
123 struct qxl_device *qdev; 123 struct qxl_device *qdev;
124 int r; 124 int r;
125 125
126 if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) { 126 if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
127 pr_info("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
128 __func__, vma->vm_pgoff);
129 return -EINVAL; 127 return -EINVAL;
130 }
131 128
132 file_priv = filp->private_data; 129 file_priv = filp->private_data;
133 qdev = file_priv->minor->dev->dev_private; 130 qdev = file_priv->minor->dev->dev_private;
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 59dcefb2df3b..5012f5e47a1e 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -392,7 +392,6 @@ static int radeon_ddc_get_modes(struct drm_connector *connector)
392 if (radeon_connector->edid) { 392 if (radeon_connector->edid) {
393 drm_mode_connector_update_edid_property(connector, radeon_connector->edid); 393 drm_mode_connector_update_edid_property(connector, radeon_connector->edid);
394 ret = drm_add_edid_modes(connector, radeon_connector->edid); 394 ret = drm_add_edid_modes(connector, radeon_connector->edid);
395 drm_edid_to_eld(connector, radeon_connector->edid);
396 return ret; 395 return ret;
397 } 396 }
398 drm_mode_connector_update_edid_property(connector, NULL); 397 drm_mode_connector_update_edid_property(connector, NULL);
diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 2917ea1b667e..183b4b482138 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -197,7 +197,6 @@ static int radeon_dp_mst_get_ddc_modes(struct drm_connector *connector)
197 if (radeon_connector->edid) { 197 if (radeon_connector->edid) {
198 drm_mode_connector_update_edid_property(&radeon_connector->base, radeon_connector->edid); 198 drm_mode_connector_update_edid_property(&radeon_connector->base, radeon_connector->edid);
199 ret = drm_add_edid_modes(&radeon_connector->base, radeon_connector->edid); 199 ret = drm_add_edid_modes(&radeon_connector->base, radeon_connector->edid);
200 drm_edid_to_eld(&radeon_connector->base, radeon_connector->edid);
201 return ret; 200 return ret;
202 } 201 }
203 drm_mode_connector_update_edid_property(&radeon_connector->base, NULL); 202 drm_mode_connector_update_edid_property(&radeon_connector->base, NULL);
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 93b7102dd008..1262120a3834 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -267,11 +267,10 @@ static struct drm_encoder_funcs rockchip_dp_encoder_funcs = {
267 .destroy = rockchip_dp_drm_encoder_destroy, 267 .destroy = rockchip_dp_drm_encoder_destroy,
268}; 268};
269 269
270static int rockchip_dp_init(struct rockchip_dp_device *dp) 270static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
271{ 271{
272 struct device *dev = dp->dev; 272 struct device *dev = dp->dev;
273 struct device_node *np = dev->of_node; 273 struct device_node *np = dev->of_node;
274 int ret;
275 274
276 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); 275 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
277 if (IS_ERR(dp->grf)) { 276 if (IS_ERR(dp->grf)) {
@@ -301,19 +300,6 @@ static int rockchip_dp_init(struct rockchip_dp_device *dp)
301 return PTR_ERR(dp->rst); 300 return PTR_ERR(dp->rst);
302 } 301 }
303 302
304 ret = clk_prepare_enable(dp->pclk);
305 if (ret < 0) {
306 DRM_DEV_ERROR(dp->dev, "failed to enable pclk %d\n", ret);
307 return ret;
308 }
309
310 ret = rockchip_dp_pre_init(dp);
311 if (ret < 0) {
312 DRM_DEV_ERROR(dp->dev, "failed to pre init %d\n", ret);
313 clk_disable_unprepare(dp->pclk);
314 return ret;
315 }
316
317 return 0; 303 return 0;
318} 304}
319 305
@@ -359,10 +345,6 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
359 if (!dp_data) 345 if (!dp_data)
360 return -ENODEV; 346 return -ENODEV;
361 347
362 ret = rockchip_dp_init(dp);
363 if (ret < 0)
364 return ret;
365
366 dp->data = dp_data; 348 dp->data = dp_data;
367 dp->drm_dev = drm_dev; 349 dp->drm_dev = drm_dev;
368 350
@@ -396,7 +378,6 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
396 rockchip_drm_psr_unregister(&dp->encoder); 378 rockchip_drm_psr_unregister(&dp->encoder);
397 379
398 analogix_dp_unbind(dev, master, data); 380 analogix_dp_unbind(dev, master, data);
399 clk_disable_unprepare(dp->pclk);
400} 381}
401 382
402static const struct component_ops rockchip_dp_component_ops = { 383static const struct component_ops rockchip_dp_component_ops = {
@@ -412,7 +393,7 @@ static int rockchip_dp_probe(struct platform_device *pdev)
412 int ret; 393 int ret;
413 394
414 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); 395 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
415 if (ret) 396 if (ret < 0)
416 return ret; 397 return ret;
417 398
418 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL); 399 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
@@ -420,9 +401,12 @@ static int rockchip_dp_probe(struct platform_device *pdev)
420 return -ENOMEM; 401 return -ENOMEM;
421 402
422 dp->dev = dev; 403 dp->dev = dev;
423
424 dp->plat_data.panel = panel; 404 dp->plat_data.panel = panel;
425 405
406 ret = rockchip_dp_of_probe(dp);
407 if (ret < 0)
408 return ret;
409
426 /* 410 /*
427 * We just use the drvdata until driver run into component 411 * We just use the drvdata until driver run into component
428 * add function, and then we would set drvdata to null, so 412 * add function, and then we would set drvdata to null, so
diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 275844d0d0ec..ec999d9f15f6 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -276,11 +276,9 @@ static int cdn_dp_connector_get_modes(struct drm_connector *connector)
276 276
277 dp->sink_has_audio = drm_detect_monitor_audio(edid); 277 dp->sink_has_audio = drm_detect_monitor_audio(edid);
278 ret = drm_add_edid_modes(connector, edid); 278 ret = drm_add_edid_modes(connector, edid);
279 if (ret) { 279 if (ret)
280 drm_mode_connector_update_edid_property(connector, 280 drm_mode_connector_update_edid_property(connector,
281 edid); 281 edid);
282 drm_edid_to_eld(connector, edid);
283 }
284 } 282 }
285 mutex_unlock(&dp->lock); 283 mutex_unlock(&dp->lock);
286 284
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index ee584d87111f..fab30927a889 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
282 int rc; 282 int rc;
283 283
284 rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, 284 rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
285 &hdmi->connector,
285 mode); 286 mode);
286 287
287 return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI, 288 return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 19128b4dea54..ba7505292b78 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -659,9 +659,9 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
659 clip.x2 = crtc_state->adjusted_mode.hdisplay; 659 clip.x2 = crtc_state->adjusted_mode.hdisplay;
660 clip.y2 = crtc_state->adjusted_mode.vdisplay; 660 clip.y2 = crtc_state->adjusted_mode.vdisplay;
661 661
662 ret = drm_plane_helper_check_state(state, &clip, 662 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
663 min_scale, max_scale, 663 min_scale, max_scale,
664 true, true); 664 true, true);
665 if (ret) 665 if (ret)
666 return ret; 666 return ret;
667 667
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index 4a39049e901a..2e4eea3459fe 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -149,6 +149,34 @@ static const struct vop_data rk3036_vop = {
149 .win_size = ARRAY_SIZE(rk3036_vop_win_data), 149 .win_size = ARRAY_SIZE(rk3036_vop_win_data),
150}; 150};
151 151
152static const struct vop_win_phy rk3126_win1_data = {
153 .data_formats = formats_win_lite,
154 .nformats = ARRAY_SIZE(formats_win_lite),
155 .enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 1),
156 .format = VOP_REG(RK3036_SYS_CTRL, 0x7, 6),
157 .rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 19),
158 .dsp_info = VOP_REG(RK3126_WIN1_DSP_INFO, 0x0fff0fff, 0),
159 .dsp_st = VOP_REG(RK3126_WIN1_DSP_ST, 0x1fff1fff, 0),
160 .yrgb_mst = VOP_REG(RK3126_WIN1_MST, 0xffffffff, 0),
161 .yrgb_vir = VOP_REG(RK3036_WIN1_VIR, 0xffff, 0),
162};
163
164static const struct vop_win_data rk3126_vop_win_data[] = {
165 { .base = 0x00, .phy = &rk3036_win0_data,
166 .type = DRM_PLANE_TYPE_PRIMARY },
167 { .base = 0x00, .phy = &rk3126_win1_data,
168 .type = DRM_PLANE_TYPE_CURSOR },
169};
170
171static const struct vop_data rk3126_vop = {
172 .intr = &rk3036_intr,
173 .common = &rk3036_common,
174 .modeset = &rk3036_modeset,
175 .output = &rk3036_output,
176 .win = rk3126_vop_win_data,
177 .win_size = ARRAY_SIZE(rk3126_vop_win_data),
178};
179
152static const struct vop_scl_extension rk3288_win_full_scl_ext = { 180static const struct vop_scl_extension rk3288_win_full_scl_ext = {
153 .cbcr_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 31), 181 .cbcr_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 31),
154 .cbcr_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 30), 182 .cbcr_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 30),
@@ -510,6 +538,8 @@ static const struct vop_data rk3328_vop = {
510static const struct of_device_id vop_driver_dt_match[] = { 538static const struct of_device_id vop_driver_dt_match[] = {
511 { .compatible = "rockchip,rk3036-vop", 539 { .compatible = "rockchip,rk3036-vop",
512 .data = &rk3036_vop }, 540 .data = &rk3036_vop },
541 { .compatible = "rockchip,rk3126-vop",
542 .data = &rk3126_vop },
513 { .compatible = "rockchip,rk3288-vop", 543 { .compatible = "rockchip,rk3288-vop",
514 .data = &rk3288_vop }, 544 .data = &rk3288_vop },
515 { .compatible = "rockchip,rk3368-vop", 545 { .compatible = "rockchip,rk3368-vop",
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.h b/drivers/gpu/drm/rockchip/rockchip_vop_reg.h
index 4a4799ff65de..f81b510ea99c 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.h
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.h
@@ -878,4 +878,10 @@
878#define RK3036_HWC_LUT_ADDR 0x800 878#define RK3036_HWC_LUT_ADDR 0x800
879/* rk3036 register definition end */ 879/* rk3036 register definition end */
880 880
881/* rk3126 register definition */
882#define RK3126_WIN1_MST 0x4c
883#define RK3126_WIN1_DSP_INFO 0x50
884#define RK3126_WIN1_DSP_ST 0x54
885/* rk3126 register definition end */
886
881#endif /* _ROCKCHIP_VOP_REG_H */ 887#endif /* _ROCKCHIP_VOP_REG_H */
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 86eb4c185a28..7cc935d7b7aa 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -682,6 +682,8 @@ static int __igt_insert(unsigned int count, u64 size, bool replace)
682 drm_mm_for_each_node_safe(node, next, &mm) 682 drm_mm_for_each_node_safe(node, next, &mm)
683 drm_mm_remove_node(node); 683 drm_mm_remove_node(node);
684 DRM_MM_BUG_ON(!drm_mm_clean(&mm)); 684 DRM_MM_BUG_ON(!drm_mm_clean(&mm));
685
686 cond_resched();
685 } 687 }
686 688
687 ret = 0; 689 ret = 0;
@@ -944,6 +946,8 @@ static int __igt_insert_range(unsigned int count, u64 size, u64 start, u64 end)
944 drm_mm_for_each_node_safe(node, next, &mm) 946 drm_mm_for_each_node_safe(node, next, &mm)
945 drm_mm_remove_node(node); 947 drm_mm_remove_node(node);
946 DRM_MM_BUG_ON(!drm_mm_clean(&mm)); 948 DRM_MM_BUG_ON(!drm_mm_clean(&mm));
949
950 cond_resched();
947 } 951 }
948 952
949 ret = 0; 953 ret = 0;
@@ -1068,6 +1072,7 @@ static int igt_align(void *ignored)
1068 drm_mm_for_each_node_safe(node, next, &mm) 1072 drm_mm_for_each_node_safe(node, next, &mm)
1069 drm_mm_remove_node(node); 1073 drm_mm_remove_node(node);
1070 DRM_MM_BUG_ON(!drm_mm_clean(&mm)); 1074 DRM_MM_BUG_ON(!drm_mm_clean(&mm));
1075
1071 cond_resched(); 1076 cond_resched();
1072 } 1077 }
1073 1078
diff --git a/drivers/gpu/drm/sti/Kconfig b/drivers/gpu/drm/sti/Kconfig
index acd72865feac..cca4b3c9aeb5 100644
--- a/drivers/gpu/drm/sti/Kconfig
+++ b/drivers/gpu/drm/sti/Kconfig
@@ -8,5 +8,6 @@ config DRM_STI
8 select DRM_PANEL 8 select DRM_PANEL
9 select FW_LOADER 9 select FW_LOADER
10 select SND_SOC_HDMI_CODEC if SND_SOC 10 select SND_SOC_HDMI_CODEC if SND_SOC
11 select OF
11 help 12 help
12 Choose this option to enable DRM on STM stiH4xx chipset 13 Choose this option to enable DRM on STM stiH4xx chipset
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 30f02d2fdd03..4ea1cc1c032e 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
515 515
516 DRM_DEBUG_DRIVER("\n"); 516 DRM_DEBUG_DRIVER("\n");
517 517
518 ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode); 518 ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
519 hdmi->drm_connector,
520 mode);
519 if (ret < 0) { 521 if (ret < 0) {
520 /* 522 /*
521 * Going into that statement does not means vendor infoframe 523 * Going into that statement does not means vendor infoframe
@@ -976,7 +978,6 @@ static int sti_hdmi_connector_get_modes(struct drm_connector *connector)
976 978
977 count = drm_add_edid_modes(connector, edid); 979 count = drm_add_edid_modes(connector, edid);
978 drm_mode_connector_update_edid_property(connector, edid); 980 drm_mode_connector_update_edid_property(connector, edid);
979 drm_edid_to_eld(connector, edid);
980 981
981 kfree(edid); 982 kfree(edid);
982 return count; 983 return count;
@@ -1414,6 +1415,11 @@ static int sti_hdmi_probe(struct platform_device *pdev)
1414 init_waitqueue_head(&hdmi->wait_event); 1415 init_waitqueue_head(&hdmi->wait_event);
1415 1416
1416 hdmi->irq = platform_get_irq_byname(pdev, "irq"); 1417 hdmi->irq = platform_get_irq_byname(pdev, "irq");
1418 if (hdmi->irq < 0) {
1419 DRM_ERROR("Cannot get HDMI irq\n");
1420 ret = hdmi->irq;
1421 goto release_adapter;
1422 }
1417 1423
1418 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, 1424 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq,
1419 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); 1425 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi);
diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
index 2dcba1d3a122..3aa2fa6f2228 100644
--- a/drivers/gpu/drm/sti/sti_vtg.c
+++ b/drivers/gpu/drm/sti/sti_vtg.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/notifier.h> 11#include <linux/notifier.h>
12#include <linux/of_platform.h>
12#include <linux/platform_device.h> 13#include <linux/platform_device.h>
13 14
14#include <drm/drmP.h> 15#include <drm/drmP.h>
@@ -72,8 +73,6 @@
72#define AWG_DELAY_ED (-8) 73#define AWG_DELAY_ED (-8)
73#define AWG_DELAY_SD (-7) 74#define AWG_DELAY_SD (-7)
74 75
75static LIST_HEAD(vtg_lookup);
76
77/* 76/*
78 * STI VTG register offset structure 77 * STI VTG register offset structure
79 * 78 *
@@ -123,42 +122,31 @@ struct sti_vtg_sync_params {
123/** 122/**
124 * STI VTG structure 123 * STI VTG structure
125 * 124 *
126 * @dev: pointer to device driver
127 * @np: device node
128 * @regs: register mapping 125 * @regs: register mapping
129 * @sync_params: synchronisation parameters used to generate timings 126 * @sync_params: synchronisation parameters used to generate timings
130 * @irq: VTG irq 127 * @irq: VTG irq
131 * @irq_status: store the IRQ status value 128 * @irq_status: store the IRQ status value
132 * @notifier_list: notifier callback 129 * @notifier_list: notifier callback
133 * @crtc: the CRTC for vblank event 130 * @crtc: the CRTC for vblank event
134 * @link: List node to link the structure in lookup list
135 */ 131 */
136struct sti_vtg { 132struct sti_vtg {
137 struct device *dev;
138 struct device_node *np;
139 void __iomem *regs; 133 void __iomem *regs;
140 struct sti_vtg_sync_params sync_params[VTG_MAX_SYNC_OUTPUT]; 134 struct sti_vtg_sync_params sync_params[VTG_MAX_SYNC_OUTPUT];
141 int irq; 135 int irq;
142 u32 irq_status; 136 u32 irq_status;
143 struct raw_notifier_head notifier_list; 137 struct raw_notifier_head notifier_list;
144 struct drm_crtc *crtc; 138 struct drm_crtc *crtc;
145 struct list_head link;
146}; 139};
147 140
148static void vtg_register(struct sti_vtg *vtg)
149{
150 list_add_tail(&vtg->link, &vtg_lookup);
151}
152
153struct sti_vtg *of_vtg_find(struct device_node *np) 141struct sti_vtg *of_vtg_find(struct device_node *np)
154{ 142{
155 struct sti_vtg *vtg; 143 struct platform_device *pdev;
156 144
157 list_for_each_entry(vtg, &vtg_lookup, link) { 145 pdev = of_find_device_by_node(np);
158 if (vtg->np == np) 146 if (!pdev)
159 return vtg; 147 return NULL;
160 } 148
161 return NULL; 149 return (struct sti_vtg *)platform_get_drvdata(pdev);
162} 150}
163 151
164static void vtg_reset(struct sti_vtg *vtg) 152static void vtg_reset(struct sti_vtg *vtg)
@@ -397,9 +385,6 @@ static int vtg_probe(struct platform_device *pdev)
397 if (!vtg) 385 if (!vtg)
398 return -ENOMEM; 386 return -ENOMEM;
399 387
400 vtg->dev = dev;
401 vtg->np = pdev->dev.of_node;
402
403 /* Get Memory ressources */ 388 /* Get Memory ressources */
404 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 389 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
405 if (!res) { 390 if (!res) {
@@ -428,16 +413,10 @@ static int vtg_probe(struct platform_device *pdev)
428 return ret; 413 return ret;
429 } 414 }
430 415
431 vtg_register(vtg);
432 platform_set_drvdata(pdev, vtg); 416 platform_set_drvdata(pdev, vtg);
433 417
434 DRM_INFO("%s %s\n", __func__, dev_name(vtg->dev)); 418 DRM_INFO("%s %s\n", __func__, dev_name(dev));
435
436 return 0;
437}
438 419
439static int vtg_remove(struct platform_device *pdev)
440{
441 return 0; 420 return 0;
442} 421}
443 422
@@ -454,7 +433,6 @@ struct platform_driver sti_vtg_driver = {
454 .of_match_table = vtg_of_match, 433 .of_match_table = vtg_of_match,
455 }, 434 },
456 .probe = vtg_probe, 435 .probe = vtg_probe,
457 .remove = vtg_remove,
458}; 436};
459 437
460MODULE_AUTHOR("Benjamin Gaignard <benjamin.gaignard@st.com>"); 438MODULE_AUTHOR("Benjamin Gaignard <benjamin.gaignard@st.com>");
diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
index e5b6310240fe..3e8b9ed7e8b3 100644
--- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
+++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
@@ -129,7 +129,7 @@ static int dsi_pll_get_params(int clkin_khz, int clkout_khz,
129 int fvco_min, fvco_max, delta, best_delta; /* all in khz */ 129 int fvco_min, fvco_max, delta, best_delta; /* all in khz */
130 130
131 /* Early checks preventing division by 0 & odd results */ 131 /* Early checks preventing division by 0 & odd results */
132 if ((clkin_khz <= 0) || (clkout_khz <= 0)) 132 if (clkin_khz <= 0 || clkout_khz <= 0)
133 return -EINVAL; 133 return -EINVAL;
134 134
135 fvco_min = LANE_MIN_KBPS * 2 * ODF_MAX; 135 fvco_min = LANE_MIN_KBPS * 2 * ODF_MAX;
@@ -155,7 +155,7 @@ static int dsi_pll_get_params(int clkin_khz, int clkout_khz,
155 for (o = ODF_MIN; o <= ODF_MAX; o *= 2) { 155 for (o = ODF_MIN; o <= ODF_MAX; o *= 2) {
156 n = DIV_ROUND_CLOSEST(i * o * clkout_khz, clkin_khz); 156 n = DIV_ROUND_CLOSEST(i * o * clkout_khz, clkin_khz);
157 /* Check ndiv according to vco range */ 157 /* Check ndiv according to vco range */
158 if ((n < n_min) || (n > n_max)) 158 if (n < n_min || n > n_max)
159 continue; 159 continue;
160 /* Check if new delta is better & saves parameters */ 160 /* Check if new delta is better & saves parameters */
161 delta = dsi_pll_get_clkout_khz(clkin_khz, i, n, o) - 161 delta = dsi_pll_get_clkout_khz(clkin_khz, i, n, o) -
@@ -342,7 +342,7 @@ static struct platform_driver dw_mipi_dsi_stm_driver = {
342 .remove = dw_mipi_dsi_stm_remove, 342 .remove = dw_mipi_dsi_stm_remove,
343 .driver = { 343 .driver = {
344 .of_match_table = dw_mipi_dsi_stm_dt_ids, 344 .of_match_table = dw_mipi_dsi_stm_dt_ids,
345 .name = "dw_mipi_dsi-stm", 345 .name = "stm32-display-dsi",
346 }, 346 },
347}; 347};
348 348
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 735c9081202a..35e884239f60 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -33,6 +33,8 @@
33 33
34#define MAX_IRQ 4 34#define MAX_IRQ 4
35 35
36#define MAX_ENDPOINTS 2
37
36#define HWVER_10200 0x010200 38#define HWVER_10200 0x010200
37#define HWVER_10300 0x010300 39#define HWVER_10300 0x010300
38#define HWVER_20101 0x020101 40#define HWVER_20101 0x020101
@@ -556,7 +558,7 @@ static int ltdc_plane_atomic_check(struct drm_plane *plane,
556 src_h = state->src_h >> 16; 558 src_h = state->src_h >> 16;
557 559
558 /* Reject scaling */ 560 /* Reject scaling */
559 if ((src_w != state->crtc_w) || (src_h != state->crtc_h)) { 561 if (src_w != state->crtc_w || src_h != state->crtc_h) {
560 DRM_ERROR("Scaling is not supported"); 562 DRM_ERROR("Scaling is not supported");
561 return -EINVAL; 563 return -EINVAL;
562 } 564 }
@@ -856,18 +858,33 @@ int ltdc_load(struct drm_device *ddev)
856 struct ltdc_device *ldev = ddev->dev_private; 858 struct ltdc_device *ldev = ddev->dev_private;
857 struct device *dev = ddev->dev; 859 struct device *dev = ddev->dev;
858 struct device_node *np = dev->of_node; 860 struct device_node *np = dev->of_node;
859 struct drm_bridge *bridge; 861 struct drm_bridge *bridge[MAX_ENDPOINTS] = {NULL};
860 struct drm_panel *panel; 862 struct drm_panel *panel[MAX_ENDPOINTS] = {NULL};
861 struct drm_crtc *crtc; 863 struct drm_crtc *crtc;
862 struct reset_control *rstc; 864 struct reset_control *rstc;
863 struct resource *res; 865 struct resource *res;
864 int irq, ret, i; 866 int irq, ret, i, endpoint_not_ready = -ENODEV;
865 867
866 DRM_DEBUG_DRIVER("\n"); 868 DRM_DEBUG_DRIVER("\n");
867 869
868 ret = drm_of_find_panel_or_bridge(np, 0, 0, &panel, &bridge); 870 /* Get endpoints if any */
869 if (ret) 871 for (i = 0; i < MAX_ENDPOINTS; i++) {
870 return ret; 872 ret = drm_of_find_panel_or_bridge(np, 0, i, &panel[i],
873 &bridge[i]);
874
875 /*
876 * If at least one endpoint is ready, continue probing,
877 * else if at least one endpoint is -EPROBE_DEFER and
878 * there is no previous ready endpoints, defer probing.
879 */
880 if (!ret)
881 endpoint_not_ready = 0;
882 else if (ret == -EPROBE_DEFER && endpoint_not_ready)
883 endpoint_not_ready = -EPROBE_DEFER;
884 }
885
886 if (endpoint_not_ready)
887 return endpoint_not_ready;
871 888
872 rstc = devm_reset_control_get_exclusive(dev, NULL); 889 rstc = devm_reset_control_get_exclusive(dev, NULL);
873 890
@@ -928,19 +945,25 @@ int ltdc_load(struct drm_device *ddev)
928 945
929 DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version); 946 DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version);
930 947
931 if (panel) { 948 /* Add endpoints panels or bridges if any */
932 bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI); 949 for (i = 0; i < MAX_ENDPOINTS; i++) {
933 if (IS_ERR(bridge)) { 950 if (panel[i]) {
934 DRM_ERROR("Failed to create panel-bridge\n"); 951 bridge[i] = drm_panel_bridge_add(panel[i],
935 ret = PTR_ERR(bridge); 952 DRM_MODE_CONNECTOR_DPI);
936 goto err; 953 if (IS_ERR(bridge[i])) {
954 DRM_ERROR("panel-bridge endpoint %d\n", i);
955 ret = PTR_ERR(bridge[i]);
956 goto err;
957 }
937 } 958 }
938 }
939 959
940 ret = ltdc_encoder_init(ddev, bridge); 960 if (bridge[i]) {
941 if (ret) { 961 ret = ltdc_encoder_init(ddev, bridge[i]);
942 DRM_ERROR("Failed to init encoder\n"); 962 if (ret) {
943 goto err; 963 DRM_ERROR("init encoder endpoint %d\n", i);
964 goto err;
965 }
966 }
944 } 967 }
945 968
946 crtc = devm_kzalloc(dev, sizeof(*crtc), GFP_KERNEL); 969 crtc = devm_kzalloc(dev, sizeof(*crtc), GFP_KERNEL);
@@ -968,7 +991,8 @@ int ltdc_load(struct drm_device *ddev)
968 return 0; 991 return 0;
969 992
970err: 993err:
971 drm_panel_bridge_remove(bridge); 994 for (i = 0; i < MAX_ENDPOINTS; i++)
995 drm_panel_bridge_remove(bridge[i]);
972 996
973 clk_disable_unprepare(ldev->pixel_clk); 997 clk_disable_unprepare(ldev->pixel_clk);
974 998
@@ -978,10 +1002,12 @@ err:
978void ltdc_unload(struct drm_device *ddev) 1002void ltdc_unload(struct drm_device *ddev)
979{ 1003{
980 struct ltdc_device *ldev = ddev->dev_private; 1004 struct ltdc_device *ldev = ddev->dev_private;
1005 int i;
981 1006
982 DRM_DEBUG_DRIVER("\n"); 1007 DRM_DEBUG_DRIVER("\n");
983 1008
984 drm_of_panel_bridge_remove(ddev->dev->of_node, 0, 0); 1009 for (i = 0; i < MAX_ENDPOINTS; i++)
1010 drm_of_panel_bridge_remove(ddev->dev->of_node, 0, i);
985 1011
986 clk_disable_unprepare(ldev->pixel_clk); 1012 clk_disable_unprepare(ldev->pixel_clk);
987} 1013}
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 24a5ef4f5bb8..fc70351b9017 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -491,8 +491,8 @@ static int tegra_plane_state_add(struct tegra_plane *plane,
491 clip.y2 = crtc_state->mode.vdisplay; 491 clip.y2 = crtc_state->mode.vdisplay;
492 492
493 /* Check plane state for visibility and calculate clipping bounds */ 493 /* Check plane state for visibility and calculate clipping bounds */
494 err = drm_plane_helper_check_state(state, &clip, 0, INT_MAX, 494 err = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
495 true, true); 495 0, INT_MAX, true, true);
496 if (err < 0) 496 if (err < 0)
497 return err; 497 return err;
498 498
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 1cfbacea8113..24f8a3b712b4 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -39,7 +39,6 @@ int tegra_output_connector_get_modes(struct drm_connector *connector)
39 39
40 if (edid) { 40 if (edid) {
41 err = drm_add_edid_modes(connector, edid); 41 err = drm_add_edid_modes(connector, edid);
42 drm_edid_to_eld(connector, edid);
43 kfree(edid); 42 kfree(edid);
44 } 43 }
45 44
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 72ce063aa0d8..bc4feb3a84b9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -507,7 +507,6 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
507static struct drm_info_list tilcdc_debugfs_list[] = { 507static struct drm_info_list tilcdc_debugfs_list[] = {
508 { "regs", tilcdc_regs_show, 0 }, 508 { "regs", tilcdc_regs_show, 0 },
509 { "mm", tilcdc_mm_show, 0 }, 509 { "mm", tilcdc_mm_show, 0 },
510 { "fb", drm_fb_cma_debugfs_show, 0 },
511}; 510};
512 511
513static int tilcdc_debugfs_init(struct drm_minor *minor) 512static int tilcdc_debugfs_init(struct drm_minor *minor)
@@ -541,6 +540,7 @@ static struct drm_driver tilcdc_driver = {
541 .lastclose = tilcdc_lastclose, 540 .lastclose = tilcdc_lastclose,
542 .irq_handler = tilcdc_irq, 541 .irq_handler = tilcdc_irq,
543 .gem_free_object_unlocked = drm_gem_cma_free_object, 542 .gem_free_object_unlocked = drm_gem_cma_free_object,
543 .gem_print_info = drm_gem_cma_print_info,
544 .gem_vm_ops = &drm_gem_cma_vm_ops, 544 .gem_vm_ops = &drm_gem_cma_vm_ops,
545 .dumb_create = drm_gem_cma_dumb_create, 545 .dumb_create = drm_gem_cma_dumb_create,
546 546
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index bd6cce093a85..bf96072d1b97 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -414,11 +414,9 @@ tinydrm_dbg_spi_print(struct spi_device *spi, struct spi_transfer *tr,
414void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m) 414void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m)
415{ 415{
416 struct spi_transfer *tmp; 416 struct spi_transfer *tmp;
417 struct list_head *pos;
418 int i = 0; 417 int i = 0;
419 418
420 list_for_each(pos, &m->transfers) { 419 list_for_each_entry(tmp, &m->transfers, transfer_list) {
421 tmp = list_entry(pos, struct spi_transfer, transfer_list);
422 420
423 if (tmp->tx_buf) 421 if (tmp->tx_buf)
424 tinydrm_dbg_spi_print(spi, tmp, tmp->tx_buf, i, true); 422 tinydrm_dbg_spi_print(spi, tmp, tmp->tx_buf, i, true);
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index d43e992ab432..347f9b226f26 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -961,10 +961,6 @@ static const struct file_operations mipi_dbi_debugfs_command_fops = {
961 .write = mipi_dbi_debugfs_command_write, 961 .write = mipi_dbi_debugfs_command_write,
962}; 962};
963 963
964static const struct drm_info_list mipi_dbi_debugfs_list[] = {
965 { "fb", drm_fb_cma_debugfs_show, 0 },
966};
967
968/** 964/**
969 * mipi_dbi_debugfs_init - Create debugfs entries 965 * mipi_dbi_debugfs_init - Create debugfs entries
970 * @minor: DRM minor 966 * @minor: DRM minor
@@ -987,9 +983,7 @@ int mipi_dbi_debugfs_init(struct drm_minor *minor)
987 debugfs_create_file("command", mode, minor->debugfs_root, mipi, 983 debugfs_create_file("command", mode, minor->debugfs_root, mipi,
988 &mipi_dbi_debugfs_command_fops); 984 &mipi_dbi_debugfs_command_fops);
989 985
990 return drm_debugfs_create_files(mipi_dbi_debugfs_list, 986 return 0;
991 ARRAY_SIZE(mipi_dbi_debugfs_list),
992 minor->debugfs_root, minor);
993} 987}
994EXPORT_SYMBOL(mipi_dbi_debugfs_init); 988EXPORT_SYMBOL(mipi_dbi_debugfs_init);
995 989
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 0b2088264039..984501e3f0b0 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -287,7 +287,6 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector)
287 287
288 drm_mode_connector_update_edid_property(connector, edid); 288 drm_mode_connector_update_edid_property(connector, edid);
289 ret = drm_add_edid_modes(connector, edid); 289 ret = drm_add_edid_modes(connector, edid);
290 drm_edid_to_eld(connector, edid);
291 kfree(edid); 290 kfree(edid);
292 291
293 return ret; 292 return ret;
@@ -695,7 +694,22 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
695 } 694 }
696} 695}
697 696
697static enum drm_mode_status
698vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc,
699 const struct drm_display_mode *mode)
700{
701 /* HSM clock must be 108% of the pixel clock. Additionally,
702 * the AXI clock needs to be at least 25% of pixel clock, but
703 * HSM ends up being the limiting factor.
704 */
705 if (mode->clock > HSM_CLOCK_FREQ / (1000 * 108 / 100))
706 return MODE_CLOCK_HIGH;
707
708 return MODE_OK;
709}
710
698static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = { 711static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = {
712 .mode_valid = vc4_hdmi_encoder_mode_valid,
699 .disable = vc4_hdmi_encoder_disable, 713 .disable = vc4_hdmi_encoder_disable,
700 .enable = vc4_hdmi_encoder_enable, 714 .enable = vc4_hdmi_encoder_enable,
701}; 715};
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 423a23ed8fc2..515f97997624 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -86,7 +86,6 @@ static const struct hvs_format {
86 u32 hvs; /* HVS_FORMAT_* */ 86 u32 hvs; /* HVS_FORMAT_* */
87 u32 pixel_order; 87 u32 pixel_order;
88 bool has_alpha; 88 bool has_alpha;
89 bool flip_cbcr;
90} hvs_formats[] = { 89} hvs_formats[] = {
91 { 90 {
92 .drm = DRM_FORMAT_XRGB8888, .hvs = HVS_PIXEL_FORMAT_RGBA8888, 91 .drm = DRM_FORMAT_XRGB8888, .hvs = HVS_PIXEL_FORMAT_RGBA8888,
@@ -121,30 +120,52 @@ static const struct hvs_format {
121 .pixel_order = HVS_PIXEL_ORDER_ABGR, .has_alpha = false, 120 .pixel_order = HVS_PIXEL_ORDER_ABGR, .has_alpha = false,
122 }, 121 },
123 { 122 {
123 .drm = DRM_FORMAT_RGB888, .hvs = HVS_PIXEL_FORMAT_RGB888,
124 .pixel_order = HVS_PIXEL_ORDER_XRGB, .has_alpha = false,
125 },
126 {
127 .drm = DRM_FORMAT_BGR888, .hvs = HVS_PIXEL_FORMAT_RGB888,
128 .pixel_order = HVS_PIXEL_ORDER_XBGR, .has_alpha = false,
129 },
130 {
124 .drm = DRM_FORMAT_YUV422, 131 .drm = DRM_FORMAT_YUV422,
125 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE, 132 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
133 .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
126 }, 134 },
127 { 135 {
128 .drm = DRM_FORMAT_YVU422, 136 .drm = DRM_FORMAT_YVU422,
129 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE, 137 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
130 .flip_cbcr = true, 138 .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
131 }, 139 },
132 { 140 {
133 .drm = DRM_FORMAT_YUV420, 141 .drm = DRM_FORMAT_YUV420,
134 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE, 142 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
143 .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
135 }, 144 },
136 { 145 {
137 .drm = DRM_FORMAT_YVU420, 146 .drm = DRM_FORMAT_YVU420,
138 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE, 147 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
139 .flip_cbcr = true, 148 .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
140 }, 149 },
141 { 150 {
142 .drm = DRM_FORMAT_NV12, 151 .drm = DRM_FORMAT_NV12,
143 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_2PLANE, 152 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_2PLANE,
153 .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
154 },
155 {
156 .drm = DRM_FORMAT_NV21,
157 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_2PLANE,
158 .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
144 }, 159 },
145 { 160 {
146 .drm = DRM_FORMAT_NV16, 161 .drm = DRM_FORMAT_NV16,
147 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE, 162 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE,
163 .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
164 },
165 {
166 .drm = DRM_FORMAT_NV61,
167 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE,
168 .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
148 }, 169 },
149}; 170};
150 171
@@ -617,15 +638,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
617 * The pointers may be any byte address. 638 * The pointers may be any byte address.
618 */ 639 */
619 vc4_state->ptr0_offset = vc4_state->dlist_count; 640 vc4_state->ptr0_offset = vc4_state->dlist_count;
620 if (!format->flip_cbcr) { 641 for (i = 0; i < num_planes; i++)
621 for (i = 0; i < num_planes; i++) 642 vc4_dlist_write(vc4_state, vc4_state->offsets[i]);
622 vc4_dlist_write(vc4_state, vc4_state->offsets[i]);
623 } else {
624 WARN_ON_ONCE(num_planes != 3);
625 vc4_dlist_write(vc4_state, vc4_state->offsets[0]);
626 vc4_dlist_write(vc4_state, vc4_state->offsets[2]);
627 vc4_dlist_write(vc4_state, vc4_state->offsets[1]);
628 }
629 643
630 /* Pointer Context Word 0/1/2: Written by the HVS */ 644 /* Pointer Context Word 0/1/2: Written by the HVS */
631 for (i = 0; i < num_planes; i++) 645 for (i = 0; i < num_planes; i++)
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 9873942ca8f4..6d1ae834484c 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -74,9 +74,9 @@ typedef struct drm_via_private {
74 volatile uint32_t *last_pause_ptr; 74 volatile uint32_t *last_pause_ptr;
75 volatile uint32_t *hw_addr_ptr; 75 volatile uint32_t *hw_addr_ptr;
76 drm_via_ring_buffer_t ring; 76 drm_via_ring_buffer_t ring;
77 struct timeval last_vblank; 77 ktime_t last_vblank;
78 int last_vblank_valid; 78 int last_vblank_valid;
79 unsigned usec_per_vblank; 79 ktime_t nsec_per_vblank;
80 atomic_t vbl_received; 80 atomic_t vbl_received;
81 drm_via_state_t hc_state; 81 drm_via_state_t hc_state;
82 char pci_buf[VIA_PCI_BUF_SIZE]; 82 char pci_buf[VIA_PCI_BUF_SIZE];
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index ea8172c747a2..c96830ccc0ec 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -88,13 +88,6 @@ static int via_num_unichrome = ARRAY_SIZE(via_unichrome_irqs);
88static int via_irqmap_unichrome[] = {-1, -1, -1, 0, -1, 1}; 88static int via_irqmap_unichrome[] = {-1, -1, -1, 0, -1, 1};
89 89
90 90
91static unsigned time_diff(struct timeval *now, struct timeval *then)
92{
93 return (now->tv_usec >= then->tv_usec) ?
94 now->tv_usec - then->tv_usec :
95 1000000 - (then->tv_usec - now->tv_usec);
96}
97
98u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe) 91u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
99{ 92{
100 drm_via_private_t *dev_priv = dev->dev_private; 93 drm_via_private_t *dev_priv = dev->dev_private;
@@ -111,7 +104,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
111 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 104 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
112 u32 status; 105 u32 status;
113 int handled = 0; 106 int handled = 0;
114 struct timeval cur_vblank; 107 ktime_t cur_vblank;
115 drm_via_irq_t *cur_irq = dev_priv->via_irqs; 108 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
116 int i; 109 int i;
117 110
@@ -119,18 +112,18 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
119 if (status & VIA_IRQ_VBLANK_PENDING) { 112 if (status & VIA_IRQ_VBLANK_PENDING) {
120 atomic_inc(&dev_priv->vbl_received); 113 atomic_inc(&dev_priv->vbl_received);
121 if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) { 114 if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
122 do_gettimeofday(&cur_vblank); 115 cur_vblank = ktime_get();
123 if (dev_priv->last_vblank_valid) { 116 if (dev_priv->last_vblank_valid) {
124 dev_priv->usec_per_vblank = 117 dev_priv->nsec_per_vblank =
125 time_diff(&cur_vblank, 118 ktime_sub(cur_vblank,
126 &dev_priv->last_vblank) >> 4; 119 dev_priv->last_vblank) >> 4;
127 } 120 }
128 dev_priv->last_vblank = cur_vblank; 121 dev_priv->last_vblank = cur_vblank;
129 dev_priv->last_vblank_valid = 1; 122 dev_priv->last_vblank_valid = 1;
130 } 123 }
131 if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) { 124 if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
132 DRM_DEBUG("US per vblank is: %u\n", 125 DRM_DEBUG("nsec per vblank is: %llu\n",
133 dev_priv->usec_per_vblank); 126 ktime_to_ns(dev_priv->nsec_per_vblank));
134 } 127 }
135 drm_handle_vblank(dev, 0); 128 drm_handle_vblank(dev, 0);
136 handled = 1; 129 handled = 1;
@@ -350,7 +343,7 @@ void via_driver_irq_uninstall(struct drm_device *dev)
350int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) 343int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
351{ 344{
352 drm_via_irqwait_t *irqwait = data; 345 drm_via_irqwait_t *irqwait = data;
353 struct timeval now; 346 struct timespec64 now;
354 int ret = 0; 347 int ret = 0;
355 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 348 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
356 drm_via_irq_t *cur_irq = dev_priv->via_irqs; 349 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
@@ -384,9 +377,9 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
384 377
385 ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence, 378 ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence,
386 &irqwait->request.sequence); 379 &irqwait->request.sequence);
387 do_gettimeofday(&now); 380 ktime_get_ts64(&now);
388 irqwait->reply.tval_sec = now.tv_sec; 381 irqwait->reply.tval_sec = now.tv_sec;
389 irqwait->reply.tval_usec = now.tv_usec; 382 irqwait->reply.tval_usec = now.tv_nsec / NSEC_PER_USEC;
390 383
391 return ret; 384 return ret;
392} 385}
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 41b0930f7968..19114a3c5ee4 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -71,7 +71,19 @@ virtio_gpu_framebuffer_surface_dirty(struct drm_framebuffer *fb,
71 return virtio_gpu_surface_dirty(virtio_gpu_fb, clips, num_clips); 71 return virtio_gpu_surface_dirty(virtio_gpu_fb, clips, num_clips);
72} 72}
73 73
74static int
75virtio_gpu_framebuffer_create_handle(struct drm_framebuffer *fb,
76 struct drm_file *file_priv,
77 unsigned int *handle)
78{
79 struct virtio_gpu_framebuffer *virtio_gpu_fb =
80 to_virtio_gpu_framebuffer(fb);
81
82 return drm_gem_handle_create(file_priv, virtio_gpu_fb->obj, handle);
83}
84
74static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = { 85static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = {
86 .create_handle = virtio_gpu_framebuffer_create_handle,
75 .destroy = virtio_gpu_user_framebuffer_destroy, 87 .destroy = virtio_gpu_user_framebuffer_destroy,
76 .dirty = virtio_gpu_framebuffer_surface_dirty, 88 .dirty = virtio_gpu_framebuffer_surface_dirty,
77}; 89};
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 0528edb4a2bf..461f81aa1bbe 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -261,7 +261,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
261 ret = virtio_gpu_object_attach(vgdev, qobj, res_id, NULL); 261 ret = virtio_gpu_object_attach(vgdev, qobj, res_id, NULL);
262 } else { 262 } else {
263 /* use a gem reference since unref list undoes them */ 263 /* use a gem reference since unref list undoes them */
264 drm_gem_object_reference(&qobj->gem_base); 264 drm_gem_object_get(&qobj->gem_base);
265 mainbuf.bo = &qobj->tbo; 265 mainbuf.bo = &qobj->tbo;
266 list_add(&mainbuf.head, &validate_list); 266 list_add(&mainbuf.head, &validate_list);
267 267
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 6400506a06b0..65060c08522d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -272,20 +272,18 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
272 struct virtio_gpu_device *vgdev = dev->dev_private; 272 struct virtio_gpu_device *vgdev = dev->dev_private;
273 struct virtio_gpu_fpriv *vfpriv; 273 struct virtio_gpu_fpriv *vfpriv;
274 uint32_t id; 274 uint32_t id;
275 char dbgname[64], tmpname[TASK_COMM_LEN]; 275 char dbgname[TASK_COMM_LEN];
276 276
277 /* can't create contexts without 3d renderer */ 277 /* can't create contexts without 3d renderer */
278 if (!vgdev->has_virgl_3d) 278 if (!vgdev->has_virgl_3d)
279 return 0; 279 return 0;
280 280
281 get_task_comm(tmpname, current);
282 snprintf(dbgname, sizeof(dbgname), "%s", tmpname);
283 dbgname[63] = 0;
284 /* allocate a virt GPU context for this opener */ 281 /* allocate a virt GPU context for this opener */
285 vfpriv = kzalloc(sizeof(*vfpriv), GFP_KERNEL); 282 vfpriv = kzalloc(sizeof(*vfpriv), GFP_KERNEL);
286 if (!vfpriv) 283 if (!vfpriv)
287 return -ENOMEM; 284 return -ENOMEM;
288 285
286 get_task_comm(dbgname, current);
289 virtio_gpu_context_create(vgdev, strlen(dbgname), dbgname, &id); 287 virtio_gpu_context_create(vgdev, strlen(dbgname), dbgname, &id);
290 288
291 vfpriv->ctx_id = id; 289 vfpriv->ctx_id = id;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 0545740b3724..a2a93d7e2a04 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -441,31 +441,23 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
441int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, 441int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
442 struct drm_plane_state *state) 442 struct drm_plane_state *state)
443{ 443{
444 struct drm_crtc_state *crtc_state = NULL;
444 struct drm_framebuffer *new_fb = state->fb; 445 struct drm_framebuffer *new_fb = state->fb;
445 bool visible; 446 struct drm_rect clip = {};
446
447 struct drm_rect src = {
448 .x1 = state->src_x,
449 .y1 = state->src_y,
450 .x2 = state->src_x + state->src_w,
451 .y2 = state->src_y + state->src_h,
452 };
453 struct drm_rect dest = {
454 .x1 = state->crtc_x,
455 .y1 = state->crtc_y,
456 .x2 = state->crtc_x + state->crtc_w,
457 .y2 = state->crtc_y + state->crtc_h,
458 };
459 struct drm_rect clip = dest;
460 int ret; 447 int ret;
461 448
462 ret = drm_plane_helper_check_update(plane, state->crtc, new_fb, 449 if (state->crtc)
463 &src, &dest, &clip, 450 crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc);
464 DRM_MODE_ROTATE_0, 451
465 DRM_PLANE_HELPER_NO_SCALING, 452 if (crtc_state && crtc_state->enable) {
466 DRM_PLANE_HELPER_NO_SCALING, 453 clip.x2 = crtc_state->adjusted_mode.hdisplay;
467 false, true, &visible); 454 clip.y2 = crtc_state->adjusted_mode.vdisplay;
455 }
468 456
457 ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
458 DRM_PLANE_HELPER_NO_SCALING,
459 DRM_PLANE_HELPER_NO_SCALING,
460 false, true);
469 461
470 if (!ret && new_fb) { 462 if (!ret && new_fb) {
471 struct drm_crtc *crtc = state->crtc; 463 struct drm_crtc *crtc = state->crtc;
@@ -476,12 +468,6 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
476 468
477 vcs = vmw_connector_state_to_vcs(du->connector.state); 469 vcs = vmw_connector_state_to_vcs(du->connector.state);
478 470
479 if ((dest.x2 > new_fb->width ||
480 dest.y2 > new_fb->height)) {
481 DRM_ERROR("CRTC area outside of framebuffer\n");
482 return -EINVAL;
483 }
484
485 /* Only one active implicit framebuffer at a time. */ 471 /* Only one active implicit framebuffer at a time. */
486 mutex_lock(&dev_priv->global_kms_state_mutex); 472 mutex_lock(&dev_priv->global_kms_state_mutex);
487 if (vcs->is_implicit && dev_priv->implicit_fb && 473 if (vcs->is_implicit && dev_priv->implicit_fb &&
diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
index b8abb1b496ff..13ea90f7a185 100644
--- a/drivers/gpu/drm/zte/zx_hdmi.c
+++ b/drivers/gpu/drm/zte/zx_hdmi.c
@@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
108 int ret; 108 int ret;
109 109
110 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, 110 ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
111 &hdmi->connector,
111 mode); 112 mode);
112 if (ret) { 113 if (ret) {
113 DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n", 114 DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 18e763493264..68fd2e2dc78a 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -80,9 +80,9 @@ static int zx_vl_plane_atomic_check(struct drm_plane *plane,
80 clip.x2 = crtc_state->adjusted_mode.hdisplay; 80 clip.x2 = crtc_state->adjusted_mode.hdisplay;
81 clip.y2 = crtc_state->adjusted_mode.vdisplay; 81 clip.y2 = crtc_state->adjusted_mode.vdisplay;
82 82
83 return drm_plane_helper_check_state(plane_state, &clip, 83 return drm_atomic_helper_check_plane_state(plane_state, crtc_state,
84 min_scale, max_scale, 84 &clip, min_scale, max_scale,
85 true, true); 85 true, true);
86} 86}
87 87
88static int zx_vl_get_fmt(uint32_t format) 88static int zx_vl_get_fmt(uint32_t format)
@@ -315,10 +315,11 @@ static int zx_gl_plane_atomic_check(struct drm_plane *plane,
315 clip.x2 = crtc_state->adjusted_mode.hdisplay; 315 clip.x2 = crtc_state->adjusted_mode.hdisplay;
316 clip.y2 = crtc_state->adjusted_mode.vdisplay; 316 clip.y2 = crtc_state->adjusted_mode.vdisplay;
317 317
318 return drm_plane_helper_check_state(plane_state, &clip, 318 return drm_atomic_helper_check_plane_state(plane_state, crtc_state,
319 DRM_PLANE_HELPER_NO_SCALING, 319 &clip,
320 DRM_PLANE_HELPER_NO_SCALING, 320 DRM_PLANE_HELPER_NO_SCALING,
321 false, true); 321 DRM_PLANE_HELPER_NO_SCALING,
322 false, true);
322} 323}
323 324
324static int zx_gl_get_fmt(uint32_t format) 325static int zx_gl_get_fmt(uint32_t format)
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 1cf907ecded4..111a0ab6280a 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
321} 321}
322EXPORT_SYMBOL(hdmi_vendor_infoframe_init); 322EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
323 323
324static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
325{
326 /* for side by side (half) we also need to provide 3D_Ext_Data */
327 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
328 return 6;
329 else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
330 return 5;
331 else
332 return 4;
333}
334
324/** 335/**
325 * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer 336 * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
326 * @frame: HDMI infoframe 337 * @frame: HDMI infoframe
@@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
341 u8 *ptr = buffer; 352 u8 *ptr = buffer;
342 size_t length; 353 size_t length;
343 354
344 /* empty info frame */
345 if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
346 return -EINVAL;
347
348 /* only one of those can be supplied */ 355 /* only one of those can be supplied */
349 if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) 356 if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
350 return -EINVAL; 357 return -EINVAL;
351 358
352 /* for side by side (half) we also need to provide 3D_Ext_Data */ 359 frame->length = hdmi_vendor_infoframe_length(frame);
353 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
354 frame->length = 6;
355 else
356 frame->length = 5;
357 360
358 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; 361 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
359 362
@@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
372 ptr[5] = 0x0c; 375 ptr[5] = 0x0c;
373 ptr[6] = 0x00; 376 ptr[6] = 0x00;
374 377
375 if (frame->vic) { 378 if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
376 ptr[7] = 0x1 << 5; /* video format */
377 ptr[8] = frame->vic;
378 } else {
379 ptr[7] = 0x2 << 5; /* video format */ 379 ptr[7] = 0x2 << 5; /* video format */
380 ptr[8] = (frame->s3d_struct & 0xf) << 4; 380 ptr[8] = (frame->s3d_struct & 0xf) << 4;
381 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) 381 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
382 ptr[9] = (frame->s3d_ext_data & 0xf) << 4; 382 ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
383 } else if (frame->vic) {
384 ptr[7] = 0x1 << 5; /* video format */
385 ptr[8] = frame->vic;
386 } else {
387 ptr[7] = 0x0 << 5; /* video format */
383 } 388 }
384 389
385 hdmi_infoframe_set_checksum(buffer, length); 390 hdmi_infoframe_set_checksum(buffer, length);
@@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
1165 1170
1166 if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR || 1171 if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
1167 ptr[1] != 1 || 1172 ptr[1] != 1 ||
1168 (ptr[2] != 5 && ptr[2] != 6)) 1173 (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
1169 return -EINVAL; 1174 return -EINVAL;
1170 1175
1171 length = ptr[2]; 1176 length = ptr[2];
@@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
1193 1198
1194 hvf->length = length; 1199 hvf->length = length;
1195 1200
1196 if (hdmi_video_format == 0x1) { 1201 if (hdmi_video_format == 0x2) {
1197 hvf->vic = ptr[4]; 1202 if (length != 5 && length != 6)
1198 } else if (hdmi_video_format == 0x2) { 1203 return -EINVAL;
1199 hvf->s3d_struct = ptr[4] >> 4; 1204 hvf->s3d_struct = ptr[4] >> 4;
1200 if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) { 1205 if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
1201 if (length == 6) 1206 if (length != 6)
1202 hvf->s3d_ext_data = ptr[5] >> 4;
1203 else
1204 return -EINVAL; 1207 return -EINVAL;
1208 hvf->s3d_ext_data = ptr[5] >> 4;
1205 } 1209 }
1210 } else if (hdmi_video_format == 0x1) {
1211 if (length != 5)
1212 return -EINVAL;
1213 hvf->vic = ptr[4];
1214 } else {
1215 if (length != 4)
1216 return -EINVAL;
1206 } 1217 }
1207 1218
1208 return 0; 1219 return 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 59be1232d005..c6666cd09347 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -75,6 +75,7 @@
75#include <drm/drm_sarea.h> 75#include <drm/drm_sarea.h>
76#include <drm/drm_drv.h> 76#include <drm/drm_drv.h>
77#include <drm/drm_prime.h> 77#include <drm/drm_prime.h>
78#include <drm/drm_print.h>
78#include <drm/drm_pci.h> 79#include <drm/drm_pci.h>
79#include <drm/drm_file.h> 80#include <drm/drm_file.h>
80#include <drm/drm_debugfs.h> 81#include <drm/drm_debugfs.h>
@@ -94,212 +95,16 @@ struct dma_buf_attachment;
94struct pci_dev; 95struct pci_dev;
95struct pci_controller; 96struct pci_controller;
96 97
97/*
98 * The following categories are defined:
99 *
100 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
101 * This is the category used by the DRM_DEBUG() macro.
102 *
103 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
104 * This is the category used by the DRM_DEBUG_DRIVER() macro.
105 *
106 * KMS: used in the modesetting code.
107 * This is the category used by the DRM_DEBUG_KMS() macro.
108 *
109 * PRIME: used in the prime code.
110 * This is the category used by the DRM_DEBUG_PRIME() macro.
111 *
112 * ATOMIC: used in the atomic code.
113 * This is the category used by the DRM_DEBUG_ATOMIC() macro.
114 *
115 * VBL: used for verbose debug message in the vblank code
116 * This is the category used by the DRM_DEBUG_VBL() macro.
117 *
118 * Enabling verbose debug messages is done through the drm.debug parameter,
119 * each category being enabled by a bit.
120 *
121 * drm.debug=0x1 will enable CORE messages
122 * drm.debug=0x2 will enable DRIVER messages
123 * drm.debug=0x3 will enable CORE and DRIVER messages
124 * ...
125 * drm.debug=0x3f will enable all messages
126 *
127 * An interesting feature is that it's possible to enable verbose logging at
128 * run-time by echoing the debug value in its sysfs node:
129 * # echo 0xf > /sys/module/drm/parameters/debug
130 */
131#define DRM_UT_NONE 0x00
132#define DRM_UT_CORE 0x01
133#define DRM_UT_DRIVER 0x02
134#define DRM_UT_KMS 0x04
135#define DRM_UT_PRIME 0x08
136#define DRM_UT_ATOMIC 0x10
137#define DRM_UT_VBL 0x20
138#define DRM_UT_STATE 0x40
139#define DRM_UT_LEASE 0x80
140
141/***********************************************************************/ 98/***********************************************************************/
142/** \name DRM template customization defaults */ 99/** \name DRM template customization defaults */
143/*@{*/ 100/*@{*/
144 101
145/***********************************************************************/ 102/***********************************************************************/
146/** \name Macros to make printk easier */
147/*@{*/
148
149#define _DRM_PRINTK(once, level, fmt, ...) \
150 do { \
151 printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
152 ##__VA_ARGS__); \
153 } while (0)
154
155#define DRM_INFO(fmt, ...) \
156 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
157#define DRM_NOTE(fmt, ...) \
158 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
159#define DRM_WARN(fmt, ...) \
160 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
161
162#define DRM_INFO_ONCE(fmt, ...) \
163 _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
164#define DRM_NOTE_ONCE(fmt, ...) \
165 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
166#define DRM_WARN_ONCE(fmt, ...) \
167 _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
168
169/**
170 * Error output.
171 *
172 * \param fmt printf() like format string.
173 * \param arg arguments
174 */
175#define DRM_DEV_ERROR(dev, fmt, ...) \
176 drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
177 fmt, ##__VA_ARGS__)
178#define DRM_ERROR(fmt, ...) \
179 drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__)
180
181/**
182 * Rate limited error output. Like DRM_ERROR() but won't flood the log.
183 *
184 * \param fmt printf() like format string.
185 * \param arg arguments
186 */
187#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \
188({ \
189 static DEFINE_RATELIMIT_STATE(_rs, \
190 DEFAULT_RATELIMIT_INTERVAL, \
191 DEFAULT_RATELIMIT_BURST); \
192 \
193 if (__ratelimit(&_rs)) \
194 DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \
195})
196#define DRM_ERROR_RATELIMITED(fmt, ...) \
197 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
198
199#define DRM_DEV_INFO(dev, fmt, ...) \
200 drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \
201 ##__VA_ARGS__)
202
203#define DRM_DEV_INFO_ONCE(dev, fmt, ...) \
204({ \
205 static bool __print_once __read_mostly; \
206 if (!__print_once) { \
207 __print_once = true; \
208 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \
209 } \
210})
211
212/**
213 * Debug output.
214 *
215 * \param fmt printf() like format string.
216 * \param arg arguments
217 */
218#define DRM_DEV_DEBUG(dev, fmt, args...) \
219 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
220 ##args)
221#define DRM_DEBUG(fmt, ...) \
222 drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
223
224#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \
225 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \
226 fmt, ##args)
227#define DRM_DEBUG_DRIVER(fmt, ...) \
228 drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
229
230#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \
231 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \
232 ##args)
233#define DRM_DEBUG_KMS(fmt, ...) \
234 drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
235
236#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
237 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
238 fmt, ##args)
239#define DRM_DEBUG_PRIME(fmt, ...) \
240 drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
241
242#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \
243 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \
244 fmt, ##args)
245#define DRM_DEBUG_ATOMIC(fmt, ...) \
246 drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
247
248#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \
249 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \
250 ##args)
251#define DRM_DEBUG_VBL(fmt, ...) \
252 drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
253
254#define DRM_DEBUG_LEASE(fmt, ...) \
255 drm_printk(KERN_DEBUG, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
256
257#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \
258({ \
259 static DEFINE_RATELIMIT_STATE(_rs, \
260 DEFAULT_RATELIMIT_INTERVAL, \
261 DEFAULT_RATELIMIT_BURST); \
262 if (__ratelimit(&_rs)) \
263 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \
264 __func__, "", fmt, ##args); \
265})
266
267/**
268 * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
269 *
270 * \param fmt printf() like format string.
271 * \param arg arguments
272 */
273#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \
274 DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
275#define DRM_DEBUG_RATELIMITED(fmt, args...) \
276 DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
277#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \
278 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
279#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
280 DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
281#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \
282 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
283#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
284 DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
285#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \
286 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
287#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
288 DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
289
290/* Format strings and argument splitters to simplify printing
291 * various "complex" objects
292 */
293
294/*@}*/
295
296/***********************************************************************/
297/** \name Internal types and structures */ 103/** \name Internal types and structures */
298/*@{*/ 104/*@{*/
299 105
300#define DRM_IF_VERSION(maj, min) (maj << 16 | min) 106#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
301 107
302
303/** 108/**
304 * drm_drv_uses_atomic_modeset - check if the driver implements 109 * drm_drv_uses_atomic_modeset - check if the driver implements
305 * atomic_commit() 110 * atomic_commit()
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index d2b56cc657e9..4842ee9485ce 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -38,6 +38,13 @@ struct drm_private_state;
38 38
39int drm_atomic_helper_check_modeset(struct drm_device *dev, 39int drm_atomic_helper_check_modeset(struct drm_device *dev,
40 struct drm_atomic_state *state); 40 struct drm_atomic_state *state);
41int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state,
42 const struct drm_crtc_state *crtc_state,
43 const struct drm_rect *clip,
44 int min_scale,
45 int max_scale,
46 bool can_position,
47 bool can_update_disabled);
41int drm_atomic_helper_check_planes(struct drm_device *dev, 48int drm_atomic_helper_check_planes(struct drm_device *dev,
42 struct drm_atomic_state *state); 49 struct drm_atomic_state *state);
43int drm_atomic_helper_check(struct drm_device *dev, 50int drm_atomic_helper_check(struct drm_device *dev,
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index df9807a3caae..66d6c99d15e5 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -270,6 +270,11 @@ struct drm_display_info {
270 bool dvi_dual; 270 bool dvi_dual;
271 271
272 /** 272 /**
273 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
274 */
275 bool has_hdmi_infoframe;
276
277 /**
273 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even 278 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
274 * more stuff redundant with @bus_formats. 279 * more stuff redundant with @bus_formats.
275 */ 280 */
@@ -704,7 +709,6 @@ struct drm_cmdline_mode {
704 * @force: a DRM_FORCE_<foo> state for forced mode sets 709 * @force: a DRM_FORCE_<foo> state for forced mode sets
705 * @override_edid: has the EDID been overwritten through debugfs for testing? 710 * @override_edid: has the EDID been overwritten through debugfs for testing?
706 * @encoder_ids: valid encoders for this connector 711 * @encoder_ids: valid encoders for this connector
707 * @encoder: encoder driving this connector, if any
708 * @eld: EDID-like data, if present 712 * @eld: EDID-like data, if present
709 * @latency_present: AV delay info from ELD, if found 713 * @latency_present: AV delay info from ELD, if found
710 * @video_latency: video latency info from ELD, if found 714 * @video_latency: video latency info from ELD, if found
@@ -874,7 +878,13 @@ struct drm_connector {
874 878
875#define DRM_CONNECTOR_MAX_ENCODER 3 879#define DRM_CONNECTOR_MAX_ENCODER 3
876 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 880 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
877 struct drm_encoder *encoder; /* currently active encoder */ 881 /**
882 * @encoder: Currently bound encoder driving this connector, if any.
883 * Only really meaningful for non-atomic drivers. Atomic drivers should
884 * instead look at &drm_connector_state.best_encoder, and in case they
885 * need the CRTC driving this output, &drm_connector_state.crtc.
886 */
887 struct drm_encoder *encoder;
878 888
879#define MAX_ELD_BYTES 128 889#define MAX_ELD_BYTES 128
880 /* EDID bits */ 890 /* EDID bits */
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index e21af87a2f3c..7c4fa32f3fc6 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -17,6 +17,7 @@ struct drm_vblank_crtc;
17struct drm_sg_mem; 17struct drm_sg_mem;
18struct drm_local_map; 18struct drm_local_map;
19struct drm_vma_offset_manager; 19struct drm_vma_offset_manager;
20struct drm_fb_helper;
20 21
21struct inode; 22struct inode;
22 23
@@ -185,6 +186,14 @@ struct drm_device {
185 struct drm_vma_offset_manager *vma_offset_manager; 186 struct drm_vma_offset_manager *vma_offset_manager;
186 /*@} */ 187 /*@} */
187 int switch_power_state; 188 int switch_power_state;
189
190 /**
191 * @fb_helper:
192 *
193 * Pointer to the fbdev emulation structure.
194 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
195 */
196 struct drm_fb_helper *fb_helper;
188}; 197};
189 198
190#endif 199#endif
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 2623a1255481..da58a428c8d7 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -635,6 +635,7 @@
635# define DP_SET_POWER_D0 0x1 635# define DP_SET_POWER_D0 0x1
636# define DP_SET_POWER_D3 0x2 636# define DP_SET_POWER_D3 0x2
637# define DP_SET_POWER_MASK 0x3 637# define DP_SET_POWER_MASK 0x3
638# define DP_SET_POWER_D3_AUX_ON 0x5
638 639
639#define DP_EDP_DPCD_REV 0x700 /* eDP 1.2 */ 640#define DP_EDP_DPCD_REV 0x700 /* eDP 1.2 */
640# define DP_EDP_11 0x00 641# define DP_EDP_11 0x00
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 412e83a4d3db..d32b688eb346 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -39,6 +39,7 @@ struct drm_minor;
39struct dma_buf_attachment; 39struct dma_buf_attachment;
40struct drm_display_mode; 40struct drm_display_mode;
41struct drm_mode_create_dumb; 41struct drm_mode_create_dumb;
42struct drm_printer;
42 43
43/* driver capabilities and requirements mask */ 44/* driver capabilities and requirements mask */
44#define DRIVER_USE_AGP 0x1 45#define DRIVER_USE_AGP 0x1
@@ -429,6 +430,20 @@ struct drm_driver {
429 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); 430 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
430 431
431 /** 432 /**
433 * @gem_print_info:
434 *
435 * If driver subclasses struct &drm_gem_object, it can implement this
436 * optional hook for printing additional driver specific info.
437 *
438 * drm_printf_indent() should be used in the callback passing it the
439 * indent argument.
440 *
441 * This callback is called from drm_gem_print_info().
442 */
443 void (*gem_print_info)(struct drm_printer *p, unsigned int indent,
444 const struct drm_gem_object *obj);
445
446 /**
432 * @gem_create_object: constructor for gem objects 447 * @gem_create_object: constructor for gem objects
433 * 448 *
434 * Hook for allocating the GEM object struct, for use by core 449 * Hook for allocating the GEM object struct, for use by core
@@ -592,13 +607,6 @@ struct drm_driver {
592 int dev_priv_size; 607 int dev_priv_size;
593}; 608};
594 609
595__printf(6, 7)
596void drm_dev_printk(const struct device *dev, const char *level,
597 unsigned int category, const char *function_name,
598 const char *prefix, const char *format, ...);
599__printf(3, 4)
600void drm_printk(const char *level, unsigned int category,
601 const char *format, ...);
602extern unsigned int drm_debug; 610extern unsigned int drm_debug;
603 611
604int drm_dev_init(struct drm_device *dev, 612int drm_dev_init(struct drm_device *dev,
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 2ec41d032e56..b25d12ef120a 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -333,7 +333,6 @@ struct drm_encoder;
333struct drm_connector; 333struct drm_connector;
334struct drm_display_mode; 334struct drm_display_mode;
335 335
336void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid);
337int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); 336int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads);
338int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb); 337int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb);
339int drm_av_sync_delay(struct drm_connector *connector, 338int drm_av_sync_delay(struct drm_connector *connector,
@@ -357,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
357 bool is_hdmi2_sink); 356 bool is_hdmi2_sink);
358int 357int
359drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, 358drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
359 struct drm_connector *connector,
360 const struct drm_display_mode *mode); 360 const struct drm_display_mode *mode);
361void 361void
362drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame, 362drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
index ee4cfbe63c52..fb299696c7c4 100644
--- a/include/drm/drm_encoder.h
+++ b/include/drm/drm_encoder.h
@@ -88,7 +88,6 @@ struct drm_encoder_funcs {
88 * @head: list management 88 * @head: list management
89 * @base: base KMS object 89 * @base: base KMS object
90 * @name: human readable name, can be overwritten by the driver 90 * @name: human readable name, can be overwritten by the driver
91 * @crtc: currently bound CRTC
92 * @bridge: bridge associated to the encoder 91 * @bridge: bridge associated to the encoder
93 * @funcs: control functions 92 * @funcs: control functions
94 * @helper_private: mid-layer private data 93 * @helper_private: mid-layer private data
@@ -166,6 +165,11 @@ struct drm_encoder {
166 */ 165 */
167 uint32_t possible_clones; 166 uint32_t possible_clones;
168 167
168 /**
169 * @crtc: Currently bound CRTC, only really meaningful for non-atomic
170 * drivers. Atomic drivers should instead check
171 * &drm_connector_state.crtc.
172 */
169 struct drm_crtc *crtc; 173 struct drm_crtc *crtc;
170 struct drm_bridge *bridge; 174 struct drm_bridge *bridge;
171 const struct drm_encoder_funcs *funcs; 175 const struct drm_encoder_funcs *funcs;
diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h
index faf56c53df28..65def43eb231 100644
--- a/include/drm/drm_fb_cma_helper.h
+++ b/include/drm/drm_fb_cma_helper.h
@@ -36,11 +36,5 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
36 struct drm_plane_state *state, 36 struct drm_plane_state *state,
37 unsigned int plane); 37 unsigned int plane);
38 38
39#ifdef CONFIG_DEBUG_FS
40struct seq_file;
41
42int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg);
43#endif
44
45#endif 39#endif
46 40
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 33fe95927742..877e5b395c02 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -310,6 +310,9 @@ drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn);
310int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector); 310int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector);
311int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, 311int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
312 struct drm_connector *connector); 312 struct drm_connector *connector);
313
314void drm_fb_helper_lastclose(struct drm_device *dev);
315void drm_fb_helper_output_poll_changed(struct drm_device *dev);
313#else 316#else
314static inline void drm_fb_helper_prepare(struct drm_device *dev, 317static inline void drm_fb_helper_prepare(struct drm_device *dev,
315 struct drm_fb_helper *helper, 318 struct drm_fb_helper *helper,
@@ -507,6 +510,14 @@ drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
507 return 0; 510 return 0;
508} 511}
509 512
513static inline void drm_fb_helper_lastclose(struct drm_device *dev)
514{
515}
516
517static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev)
518{
519}
520
510#endif 521#endif
511 522
512static inline int 523static inline int
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 4c5ee4ae54df..dccb897951ba 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -264,7 +264,7 @@ static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb)
264 * 264 *
265 * This functions returns the framebuffer's reference count. 265 * This functions returns the framebuffer's reference count.
266 */ 266 */
267static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) 267static inline uint32_t drm_framebuffer_read_refcount(const struct drm_framebuffer *fb)
268{ 268{
269 return kref_read(&fb->base.refcount); 269 return kref_read(&fb->base.refcount);
270} 270}
diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
index 520e3feb502c..19777145cf8e 100644
--- a/include/drm/drm_gem_cma_helper.h
+++ b/include/drm/drm_gem_cma_helper.h
@@ -9,7 +9,9 @@
9 * struct drm_gem_cma_object - GEM object backed by CMA memory allocations 9 * struct drm_gem_cma_object - GEM object backed by CMA memory allocations
10 * @base: base GEM object 10 * @base: base GEM object
11 * @paddr: physical address of the backing memory 11 * @paddr: physical address of the backing memory
12 * @sgt: scatter/gather table for imported PRIME buffers 12 * @sgt: scatter/gather table for imported PRIME buffers. The table can have
13 * more than one entry but they are guaranteed to have contiguous
14 * DMA addresses.
13 * @vaddr: kernel virtual address of the backing memory 15 * @vaddr: kernel virtual address of the backing memory
14 */ 16 */
15struct drm_gem_cma_object { 17struct drm_gem_cma_object {
@@ -21,11 +23,8 @@ struct drm_gem_cma_object {
21 void *vaddr; 23 void *vaddr;
22}; 24};
23 25
24static inline struct drm_gem_cma_object * 26#define to_drm_gem_cma_obj(gem_obj) \
25to_drm_gem_cma_obj(struct drm_gem_object *gem_obj) 27 container_of(gem_obj, struct drm_gem_cma_object, base)
26{
27 return container_of(gem_obj, struct drm_gem_cma_object, base);
28}
29 28
30#ifndef CONFIG_MMU 29#ifndef CONFIG_MMU
31#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \ 30#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
@@ -91,9 +90,8 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
91 unsigned long flags); 90 unsigned long flags);
92#endif 91#endif
93 92
94#ifdef CONFIG_DEBUG_FS 93void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
95void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m); 94 const struct drm_gem_object *obj);
96#endif
97 95
98struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj); 96struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
99struct drm_gem_object * 97struct drm_gem_object *
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 8d10fc97801c..101f566ae43d 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -386,7 +386,7 @@ int drm_mm_insert_node_in_range(struct drm_mm *mm,
386 * @color: opaque tag value to use for this node 386 * @color: opaque tag value to use for this node
387 * @mode: fine-tune the allocation search and placement 387 * @mode: fine-tune the allocation search and placement
388 * 388 *
389 * This is a simplified version of drm_mm_insert_node_in_range_generic() with no 389 * This is a simplified version of drm_mm_insert_node_in_range() with no
390 * range restrictions applied. 390 * range restrictions applied.
391 * 391 *
392 * The preallocated node must be cleared to 0. 392 * The preallocated node must be cleared to 0.
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index b21e827c5c78..5306ebd537b2 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -752,7 +752,7 @@ struct drm_mode_config {
752 bool allow_fb_modifiers; 752 bool allow_fb_modifiers;
753 753
754 /** 754 /**
755 * @modifiers: Plane property to list support modifier/format 755 * @modifiers_property: Plane property to list support modifier/format
756 * combination. 756 * combination.
757 */ 757 */
758 struct drm_property *modifiers_property; 758 struct drm_property *modifiers_property;
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 16646c44b7df..3e76ca805b0f 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -801,9 +801,6 @@ struct drm_connector_helper_funcs {
801 * resolution can call drm_add_modes_noedid(), and mark the preferred 801 * resolution can call drm_add_modes_noedid(), and mark the preferred
802 * one using drm_set_preferred_mode(). 802 * one using drm_set_preferred_mode().
803 * 803 *
804 * Finally drivers that support audio probably want to update the ELD
805 * data, too, using drm_edid_to_eld().
806 *
807 * This function is only called after the @detect hook has indicated 804 * This function is only called after the @detect hook has indicated
808 * that a sink is connected and when the EDID isn't overridden through 805 * that a sink is connected and when the EDID isn't overridden through
809 * sysfs or the kernel commandline. 806 * sysfs or the kernel commandline.
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 571615079230..8185e3468a23 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -474,8 +474,8 @@ enum drm_plane_type {
474 * @format_types: array of formats supported by this plane 474 * @format_types: array of formats supported by this plane
475 * @format_count: number of formats supported 475 * @format_count: number of formats supported
476 * @format_default: driver hasn't supplied supported formats for the plane 476 * @format_default: driver hasn't supplied supported formats for the plane
477 * @crtc: currently bound CRTC 477 * @modifiers: array of modifiers supported by this plane
478 * @fb: currently bound fb 478 * @modifier_count: number of modifiers supported
479 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by 479 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
480 * drm_mode_set_config_internal() to implement correct refcounting. 480 * drm_mode_set_config_internal() to implement correct refcounting.
481 * @funcs: helper functions 481 * @funcs: helper functions
@@ -512,7 +512,17 @@ struct drm_plane {
512 uint64_t *modifiers; 512 uint64_t *modifiers;
513 unsigned int modifier_count; 513 unsigned int modifier_count;
514 514
515 /**
516 * @crtc: Currently bound CRTC, only really meaningful for non-atomic
517 * drivers. Atomic drivers should instead check &drm_plane_state.crtc.
518 */
515 struct drm_crtc *crtc; 519 struct drm_crtc *crtc;
520
521 /**
522 * @fb: Currently bound framebuffer, only really meaningful for
523 * non-atomic drivers. Atomic drivers should instead check
524 * &drm_plane_state.fb.
525 */
516 struct drm_framebuffer *fb; 526 struct drm_framebuffer *fb;
517 527
518 struct drm_framebuffer *old_fb; 528 struct drm_framebuffer *old_fb;
diff --git a/include/drm/drm_plane_helper.h b/include/drm/drm_plane_helper.h
index 7c8a00ceadb7..8aa49c0ecd4d 100644
--- a/include/drm/drm_plane_helper.h
+++ b/include/drm/drm_plane_helper.h
@@ -38,11 +38,6 @@
38 */ 38 */
39#define DRM_PLANE_HELPER_NO_SCALING (1<<16) 39#define DRM_PLANE_HELPER_NO_SCALING (1<<16)
40 40
41int drm_plane_helper_check_state(struct drm_plane_state *state,
42 const struct drm_rect *clip,
43 int min_scale, int max_scale,
44 bool can_position,
45 bool can_update_disabled);
46int drm_plane_helper_check_update(struct drm_plane *plane, 41int drm_plane_helper_check_update(struct drm_plane *plane,
47 struct drm_crtc *crtc, 42 struct drm_crtc *crtc,
48 struct drm_framebuffer *fb, 43 struct drm_framebuffer *fb,
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index ca4d7c6321f2..5f9932e2246e 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -80,6 +80,29 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
80__printf(2, 3) 80__printf(2, 3)
81void drm_printf(struct drm_printer *p, const char *f, ...); 81void drm_printf(struct drm_printer *p, const char *f, ...);
82 82
83/**
84 * drm_vprintf - print to a &drm_printer stream
85 * @p: the &drm_printer
86 * @fmt: format string
87 * @va: the va_list
88 */
89__printf(2, 0)
90static inline void
91drm_vprintf(struct drm_printer *p, const char *fmt, va_list *va)
92{
93 struct va_format vaf = { .fmt = fmt, .va = va };
94
95 p->printfn(p, &vaf);
96}
97
98/**
99 * drm_printf_indent - Print to a &drm_printer stream with indentation
100 * @printer: DRM printer
101 * @indent: Tab indentation level (max 5)
102 * @fmt: Format string
103 */
104#define drm_printf_indent(printer, indent, fmt, ...) \
105 drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__)
83 106
84/** 107/**
85 * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file 108 * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file
@@ -128,4 +151,200 @@ static inline struct drm_printer drm_debug_printer(const char *prefix)
128 }; 151 };
129 return p; 152 return p;
130} 153}
154
155/*
156 * The following categories are defined:
157 *
158 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
159 * This is the category used by the DRM_DEBUG() macro.
160 *
161 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
162 * This is the category used by the DRM_DEBUG_DRIVER() macro.
163 *
164 * KMS: used in the modesetting code.
165 * This is the category used by the DRM_DEBUG_KMS() macro.
166 *
167 * PRIME: used in the prime code.
168 * This is the category used by the DRM_DEBUG_PRIME() macro.
169 *
170 * ATOMIC: used in the atomic code.
171 * This is the category used by the DRM_DEBUG_ATOMIC() macro.
172 *
173 * VBL: used for verbose debug message in the vblank code
174 * This is the category used by the DRM_DEBUG_VBL() macro.
175 *
176 * Enabling verbose debug messages is done through the drm.debug parameter,
177 * each category being enabled by a bit.
178 *
179 * drm.debug=0x1 will enable CORE messages
180 * drm.debug=0x2 will enable DRIVER messages
181 * drm.debug=0x3 will enable CORE and DRIVER messages
182 * ...
183 * drm.debug=0x3f will enable all messages
184 *
185 * An interesting feature is that it's possible to enable verbose logging at
186 * run-time by echoing the debug value in its sysfs node:
187 * # echo 0xf > /sys/module/drm/parameters/debug
188 */
189#define DRM_UT_NONE 0x00
190#define DRM_UT_CORE 0x01
191#define DRM_UT_DRIVER 0x02
192#define DRM_UT_KMS 0x04
193#define DRM_UT_PRIME 0x08
194#define DRM_UT_ATOMIC 0x10
195#define DRM_UT_VBL 0x20
196#define DRM_UT_STATE 0x40
197#define DRM_UT_LEASE 0x80
198
199__printf(6, 7)
200void drm_dev_printk(const struct device *dev, const char *level,
201 unsigned int category, const char *function_name,
202 const char *prefix, const char *format, ...);
203__printf(3, 4)
204void drm_printk(const char *level, unsigned int category,
205 const char *format, ...);
206
207/* Macros to make printk easier */
208
209#define _DRM_PRINTK(once, level, fmt, ...) \
210 do { \
211 printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
212 ##__VA_ARGS__); \
213 } while (0)
214
215#define DRM_INFO(fmt, ...) \
216 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
217#define DRM_NOTE(fmt, ...) \
218 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
219#define DRM_WARN(fmt, ...) \
220 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
221
222#define DRM_INFO_ONCE(fmt, ...) \
223 _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
224#define DRM_NOTE_ONCE(fmt, ...) \
225 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
226#define DRM_WARN_ONCE(fmt, ...) \
227 _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
228
229/**
230 * Error output.
231 *
232 * @dev: device pointer
233 * @fmt: printf() like format string.
234 */
235#define DRM_DEV_ERROR(dev, fmt, ...) \
236 drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
237 fmt, ##__VA_ARGS__)
238#define DRM_ERROR(fmt, ...) \
239 drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__)
240
241/**
242 * Rate limited error output. Like DRM_ERROR() but won't flood the log.
243 *
244 * @dev: device pointer
245 * @fmt: printf() like format string.
246 */
247#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \
248({ \
249 static DEFINE_RATELIMIT_STATE(_rs, \
250 DEFAULT_RATELIMIT_INTERVAL, \
251 DEFAULT_RATELIMIT_BURST); \
252 \
253 if (__ratelimit(&_rs)) \
254 DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \
255})
256#define DRM_ERROR_RATELIMITED(fmt, ...) \
257 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
258
259#define DRM_DEV_INFO(dev, fmt, ...) \
260 drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \
261 ##__VA_ARGS__)
262
263#define DRM_DEV_INFO_ONCE(dev, fmt, ...) \
264({ \
265 static bool __print_once __read_mostly; \
266 if (!__print_once) { \
267 __print_once = true; \
268 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \
269 } \
270})
271
272/**
273 * Debug output.
274 *
275 * @dev: device pointer
276 * @fmt: printf() like format string.
277 */
278#define DRM_DEV_DEBUG(dev, fmt, args...) \
279 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
280 ##args)
281#define DRM_DEBUG(fmt, ...) \
282 drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
283
284#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \
285 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \
286 fmt, ##args)
287#define DRM_DEBUG_DRIVER(fmt, ...) \
288 drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
289
290#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \
291 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \
292 ##args)
293#define DRM_DEBUG_KMS(fmt, ...) \
294 drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
295
296#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
297 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
298 fmt, ##args)
299#define DRM_DEBUG_PRIME(fmt, ...) \
300 drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
301
302#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \
303 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \
304 fmt, ##args)
305#define DRM_DEBUG_ATOMIC(fmt, ...) \
306 drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
307
308#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \
309 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \
310 ##args)
311#define DRM_DEBUG_VBL(fmt, ...) \
312 drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
313
314#define DRM_DEBUG_LEASE(fmt, ...) \
315 drm_printk(KERN_DEBUG, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
316
317#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \
318({ \
319 static DEFINE_RATELIMIT_STATE(_rs, \
320 DEFAULT_RATELIMIT_INTERVAL, \
321 DEFAULT_RATELIMIT_BURST); \
322 if (__ratelimit(&_rs)) \
323 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \
324 __func__, "", fmt, ##args); \
325})
326
327/**
328 * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
329 *
330 * @dev: device pointer
331 * @fmt: printf() like format string.
332 */
333#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \
334 DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
335#define DRM_DEBUG_RATELIMITED(fmt, args...) \
336 DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
337#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \
338 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
339#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
340 DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
341#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \
342 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
343#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
344 DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
345#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \
346 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
347#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
348 DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
349
131#endif /* DRM_PRINT_H_ */ 350#endif /* DRM_PRINT_H_ */
diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h
index 43e2f382d2f0..9e8ba90c6784 100644
--- a/include/drm/drm_syncobj.h
+++ b/include/drm/drm_syncobj.h
@@ -49,7 +49,7 @@ struct drm_syncobj {
49 * This field should not be used directly. Use drm_syncobj_fence_get 49 * This field should not be used directly. Use drm_syncobj_fence_get
50 * and drm_syncobj_replace_fence instead. 50 * and drm_syncobj_replace_fence instead.
51 */ 51 */
52 struct dma_fence *fence; 52 struct dma_fence __rcu *fence;
53 /** 53 /**
54 * @cb_list: 54 * @cb_list:
55 * List of callbacks to call when the fence gets replaced 55 * List of callbacks to call when the fence gets replaced
diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h
index d84d52f6d2b1..8758df94e9a0 100644
--- a/include/drm/drm_vma_manager.h
+++ b/include/drm/drm_vma_manager.h
@@ -152,7 +152,7 @@ static inline void drm_vma_node_reset(struct drm_vma_offset_node *node)
152 * Start address of @node for page-based addressing. 0 if the node does not 152 * Start address of @node for page-based addressing. 0 if the node does not
153 * have an offset allocated. 153 * have an offset allocated.
154 */ 154 */
155static inline unsigned long drm_vma_node_start(struct drm_vma_offset_node *node) 155static inline unsigned long drm_vma_node_start(const struct drm_vma_offset_node *node)
156{ 156{
157 return node->vm_node.start; 157 return node->vm_node.start;
158} 158}
diff --git a/include/drm/tinydrm/tinydrm.h b/include/drm/tinydrm/tinydrm.h
index 4774fe3d4273..423828922e5a 100644
--- a/include/drm/tinydrm/tinydrm.h
+++ b/include/drm/tinydrm/tinydrm.h
@@ -46,6 +46,7 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
46 */ 46 */
47#define TINYDRM_GEM_DRIVER_OPS \ 47#define TINYDRM_GEM_DRIVER_OPS \
48 .gem_free_object = tinydrm_gem_cma_free_object, \ 48 .gem_free_object = tinydrm_gem_cma_free_object, \
49 .gem_print_info = drm_gem_cma_print_info, \
49 .gem_vm_ops = &drm_gem_cma_vm_ops, \ 50 .gem_vm_ops = &drm_gem_cma_vm_ops, \
50 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ 51 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
51 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ 52 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
index 332a5420243c..bc8940ca280d 100644
--- a/include/linux/dma-fence-array.h
+++ b/include/linux/dma-fence-array.h
@@ -21,6 +21,7 @@
21#define __LINUX_DMA_FENCE_ARRAY_H 21#define __LINUX_DMA_FENCE_ARRAY_H
22 22
23#include <linux/dma-fence.h> 23#include <linux/dma-fence.h>
24#include <linux/irq_work.h>
24 25
25/** 26/**
26 * struct dma_fence_array_cb - callback helper for fence array 27 * struct dma_fence_array_cb - callback helper for fence array
@@ -47,6 +48,8 @@ struct dma_fence_array {
47 unsigned num_fences; 48 unsigned num_fences;
48 atomic_t num_pending; 49 atomic_t num_pending;
49 struct dma_fence **fences; 50 struct dma_fence **fences;
51
52 struct irq_work work;
50}; 53};
51 54
52extern const struct dma_fence_ops dma_fence_array_ops; 55extern const struct dma_fence_ops dma_fence_array_ops;
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index efdabbb64e3c..4c008170fe65 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -242,7 +242,7 @@ static inline struct dma_fence *dma_fence_get_rcu(struct dma_fence *fence)
242 * The caller is required to hold the RCU read lock. 242 * The caller is required to hold the RCU read lock.
243 */ 243 */
244static inline struct dma_fence * 244static inline struct dma_fence *
245dma_fence_get_rcu_safe(struct dma_fence * __rcu *fencep) 245dma_fence_get_rcu_safe(struct dma_fence __rcu **fencep)
246{ 246{
247 do { 247 do {
248 struct dma_fence *fence; 248 struct dma_fence *fence;
diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index 21fc84d82d41..02166e815afb 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -167,6 +167,29 @@ reservation_object_lock(struct reservation_object *obj,
167} 167}
168 168
169/** 169/**
170 * reservation_object_lock_interruptible - lock the reservation object
171 * @obj: the reservation object
172 * @ctx: the locking context
173 *
174 * Locks the reservation object interruptible for exclusive access and
175 * modification. Note, that the lock is only against other writers, readers
176 * will run concurrently with a writer under RCU. The seqlock is used to
177 * notify readers if they overlap with a writer.
178 *
179 * As the reservation object may be locked by multiple parties in an
180 * undefined order, a #ww_acquire_ctx is passed to unwind if a cycle
181 * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation
182 * object may be locked by itself by passing NULL as @ctx.
183 */
184static inline int
185reservation_object_lock_interruptible(struct reservation_object *obj,
186 struct ww_acquire_ctx *ctx)
187{
188 return ww_mutex_lock_interruptible(&obj->lock, ctx);
189}
190
191
192/**
170 * reservation_object_trylock - trylock the reservation object 193 * reservation_object_trylock - trylock the reservation object
171 * @obj: the reservation object 194 * @obj: the reservation object
172 * 195 *