1
0
Fork 0
Commit Graph

39394 Commits (redonkable)

Author SHA1 Message Date
Sandor Yu 9e8cb59e91 MLK-20518: hdp: Fix memory out of bounds access
Fix memory out of bounds access.
Change arry type for functopn avi info frame,
Align the arry type and its length.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
(cherry picked from commit 2fc41a88c9da514ae3f377e7cb73f4df886f038e)
2018-12-05 14:57:58 +08:00
Laurentiu Palcu e820bcc7b9 MA-13638-1: Revert "MLK-20361: drm/panel/raydium: increase vsync_len to 4"
This reverts commit 3c53532c466add234ac3ca2e70cefe80ea308b4f.

This change affects iMX8MM functionality, generating flicker.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-12-03 15:43:42 +02:00
Liu Ying a530794d7e MLK-20508 drm/imx: dpu: plane: Revert a patch related to tile to linear fb switch
The root cause of the on-the-fly switch from tile to linear fb switch issue
is identified, so the full modeset workaround is no more needed.

Patch "MLK-20506 gpu: imx: imx8_dprc: Set CROP_ULC_X/Y to be zero for linear fb"
is the correct fix for this issue.

Revert "MLK-20470 drm/imx: dpu: plane: Do full modeset for tile to linear fb switch"

This reverts commit 9245bbf650fdeb79ebf869d48b6bd1b43c2bcf3b.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 7812bebe9c60a6ce954ce5ad504a6be002835462)
2018-12-03 17:20:07 +08:00
Liu Ying 805e90af5f MLK-20506 gpu: imx: imx8_dprc: Set CROP_ULC_X/Y to be zero for linear fb
Nonzero CROP_ULC_X/Y are only valid for tile framebuffer cropping.
Thus, we should set them to be zero for linear framebuffer, otherwise,
an on-the-fly switch from tile framebuffer(with cropping enabled) to
linear framebuffer would cause hardware malfunction.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 4fc67aed944526545e6ee44d582b013a6327c8d1)
2018-12-03 17:20:06 +08:00
Laurentiu Palcu a49ffcd97c MLK-20361: drm/panel/raydium: increase vsync_len to 4
This is a work-around for the shifted display issue when using DCSS with
the DDR self-refresh disabled.

Also, make sure it works with LCDIF as well.

Increasing VSYNC length gives DCSS more time to fetch the data from RAM
before the next frame kicks in.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
(cherry picked from commit 3c53532c466add234ac3ca2e70cefe80ea308b4f)
2018-11-28 13:47:45 +02:00
Liu Ying bab01e6580 MLK-20486 drm/imx: ldb: Cleanup enc&conn in ->unbind() if necessary
When the master imx-drm-core binding fails, component_bind_all()
in imx-drm-core ->bind() callback will unbind all bound components
first and then call drm_mode_config_cleanup().  Since the encoder
and connector(located in imx_ldb.imx_ldb_channel) are freed after
the ldb ->unbind() callback, drm_mode_config_cleanup() would
accidentally access the freed encoder and connector again.  To fix
this issue, we should cleanup the encoder and connector, i.e.,
remove them from the global encoder and connector lists, in the
->unbind() callback, so that, drm_mode_config_cleanup() won't find
them again in the lists.  However, we have to make sure they exist
before the cleanup in the ->unbind() callback, because imx-drm-core
->unbind() calls drm_mode_config_cleanup() first and then unbinds
all components via component_unbind_all().  Moreover, the connector
isn't created at the first place if a bridge exists, so the check
before the cleanup makes sense for this reason as well.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 6d3fd1316d67ff0e62fae4067b61fd3f2809dfa5)
2018-11-28 19:36:14 +08:00
Liu Ying 4c828b1d06 MLK-16302-2 drm/imx: dpu: crtc: Cleanup crtc in ->unbind() if necessary
When the master imx-drm-core binding fails, component_bind_all()
in imx-drm-core ->bind() callback will unbind all bound components
first and then call drm_mode_config_cleanup().  Since the crtc as
a member(base) of dpu_crtc is freed after the dpu crtc ->unbind()
callback, drm_mode_config_cleanup() would accidentally access the
freed crtc again.  To fix this issue, we should cleanup the crtc,
i.e., remove the crtc from the global crtc list, in the ->unbind()
callback, so that drm_mode_config_cleanup() won't find the crtc
again in the list.  However, we have to make sure the crtc exists
before the cleanup in the ->unbind() callback, because imx-drm-core
->unbind() calls drm_mode_config_cleanup() first and then unbinds
all components via component_unbind_all().

There is a probe deferral caused by the LDB component(later probed
GPIO resource) on some platforms(e.g., i.MX8QXP MEK), which causes
multiple times to try binding and triggers the issue described above.

This patch may fix the issue reported by KASAN:
[    3.217996] BUG: KASAN: use-after-free in drm_mode_config_cleanup+0x220/0x448
[    3.225149] Read of size 8 at addr ffff80000ad719b0 by task swapper/0/1
[    3.231769]
[    3.233279] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.14.78-05529-ge53ea0dba88e-dirty #43
[    3.241642] Hardware name: Freescale i.MX8QXP MEK (DT)
[    3.246793] Call trace:
[    3.249270] [<ffff20000808e7d0>] dump_backtrace+0x0/0x390
[    3.254690] [<ffff20000808eb74>] show_stack+0x14/0x20
[    3.259769] [<ffff20000968a108>] dump_stack+0xf8/0x158
[    3.264932] [<ffff20000830db10>] print_address_description+0x60/0x270
[    3.271396] [<ffff20000830dff0>] kasan_report+0x210/0x2f0
[    3.276818] [<ffff20000830c6f4>] __asan_load8+0x84/0xa8
[    3.282065] [<ffff200008ad4380>] drm_mode_config_cleanup+0x220/0x448
[    3.288447] [<ffff200008afa7b4>] imx_drm_bind+0x2b4/0x358
[    3.293863] [<ffff200008b2024c>] try_to_bring_up_master+0x20c/0x278
[    3.300148] [<ffff200008b20438>] component_add+0x180/0x300
[    3.305653] [<ffff200008b0b530>] dpu_bliteng_probe+0x30/0x48
[    3.311339] [<ffff200008b2e13c>] platform_drv_probe+0x74/0x108
[    3.317198] [<ffff200008b2b3c8>] driver_probe_device+0x3a0/0x4a8
[    3.323226] [<ffff200008b2b5a0>] __driver_attach+0xd0/0xd8
[    3.328735] [<ffff200008b27e78>] bus_for_each_dev+0xc0/0x140
[    3.334419] [<ffff200008b2a618>] driver_attach+0x30/0x40
[    3.339749] [<ffff200008b29d48>] bus_add_driver+0x2a8/0x320
[    3.345344] [<ffff200008b2c54c>] driver_register+0xb4/0x190
[    3.350941] [<ffff200008b2e054>] __platform_driver_register+0x7c/0x88
[    3.357410] [<ffff20000a228118>] dpu_bliteng_driver_init+0x1c/0x24
[    3.363613] [<ffff200008084540>] do_one_initcall+0xe0/0x260
[    3.369211] [<ffff20000a1c10f0>] kernel_init_freeable+0x230/0x2d8
[    3.375330] [<ffff2000096aa4a8>] kernel_init+0x10/0x118
[    3.380574] [<ffff2000080863c8>] ret_from_fork+0x10/0x18
[    3.385894]
[    3.387393] Allocated by task 1:
[    3.390642]  kasan_kmalloc+0xd0/0x180
[    3.394322]  kasan_slab_alloc+0x14/0x20
[    3.398174]  __kmalloc_node_track_caller+0x1ec/0x278
[    3.403157]  devm_kmalloc+0x8c/0x128
[    3.406753]  dpu_crtc_bind+0x38/0xbe0
[    3.410434]  component_bind_all+0x254/0x438
[    3.414638]  imx_drm_bind+0x1b0/0x358
[    3.418314]  try_to_bring_up_master+0x20c/0x278
[    3.422857]  component_add+0x180/0x300
[    3.426622]  dpu_bliteng_probe+0x30/0x48
[    3.430559]  platform_drv_probe+0x74/0x108
[    3.434676]  driver_probe_device+0x3a0/0x4a8
[    3.438966]  __driver_attach+0xd0/0xd8
[    3.442730]  bus_for_each_dev+0xc0/0x140
[    3.446663]  driver_attach+0x30/0x40
[    3.450251]  bus_add_driver+0x2a8/0x320
[    3.454103]  driver_register+0xb4/0x190
[    3.457960]  __platform_driver_register+0x7c/0x88
[    3.462687]  dpu_bliteng_driver_init+0x1c/0x24
[    3.467147]  do_one_initcall+0xe0/0x260
[    3.470997]  kernel_init_freeable+0x230/0x2d8
[    3.475366]  kernel_init+0x10/0x118
[    3.478867]  ret_from_fork+0x10/0x18
[    3.482447]
[    3.483941] Freed by task 1:
[    3.486837]  kasan_slab_free+0x88/0x198
[    3.490691]  kfree+0x70/0x210
[    3.493672]  release_nodes+0x538/0x5c0
[    3.497432]  devres_release_group+0x164/0x200
[    3.501801]  component_unbind.isra.4+0x98/0xb8
[    3.506257]  component_bind_all+0x3c8/0x438
[    3.510456]  imx_drm_bind+0x1b0/0x358
[    3.514131]  try_to_bring_up_master+0x20c/0x278
[    3.518671]  component_add+0x180/0x300
[    3.522434]  dpu_bliteng_probe+0x30/0x48
[    3.526375]  platform_drv_probe+0x74/0x108
[    3.530490]  driver_probe_device+0x3a0/0x4a8
[    3.534781]  __driver_attach+0xd0/0xd8
[    3.538551]  bus_for_each_dev+0xc0/0x140
[    3.542488]  driver_attach+0x30/0x40
[    3.546083]  bus_add_driver+0x2a8/0x320
[    3.549941]  driver_register+0xb4/0x190
[    3.553793]  __platform_driver_register+0x7c/0x88
[    3.558519]  dpu_bliteng_driver_init+0x1c/0x24
[    3.562979]  do_one_initcall+0xe0/0x260
[    3.566827]  kernel_init_freeable+0x230/0x2d8
[    3.571199]  kernel_init+0x10/0x118
[    3.574698]  ret_from_fork+0x10/0x18
[    3.578277]
[    3.579783] The buggy address belongs to the object at ffff80000ad71980
[    3.579783]  which belongs to the cache kmalloc-2048 of size 2048
[    3.592501] The buggy address is located 48 bytes inside of
[    3.592501]  2048-byte region [ffff80000ad71980, ffff80000ad72180)
[    3.604258] The buggy address belongs to the page:
[    3.609072] page:ffff7e00002b5c00 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
[    3.618926] flags: 0xfffc00000008100(slab|head)
[    3.623484] raw: 0fffc00000008100 0000000000000000 0000000000000000 00000001800f000f
[    3.631252] raw: dead000000000100 dead000000000200 ffff800010703400 0000000000000000
[    3.639007] page dumped because: kasan: bad access detected
[    3.644590]
[    3.646086] Memory state around the buggy address:
[    3.650898]  ffff80000ad71880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[    3.658134]  ffff80000ad71900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[    3.665370] >ffff80000ad71980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.672599]                                      ^
[    3.677402]  ffff80000ad71a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.684641]  ffff80000ad71a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 5fc482dbf423fff005214db5ac4ac2dcd5cae028)
2018-11-28 19:36:13 +08:00
Liu Ying aed3e47d01 MLK-16302-1 drm/imx: dpu: plane: Free dpu_plane when bailout from dpu_plane_init
The dpu_plane is allocated with kzalloc() in dpu_plane_init().
In case, dpu_plane_init() fails after that allocation, the bailout path
should free the dpu_plane, otherwise, there will be memory leakage.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 99cb80f855aafbe524519db635c3d03bd4cc8d85)
2018-11-28 19:35:54 +08:00
Fancy Fang a2eb45252d MLK-20337 drm/imx: lcdif: block 'active CRTC with no plane' commit
When an atomic commit contains an active CRTC with no plane,
it may cause two potential issues:

First, this CRTC will fetch its last attached plane data
or has no data can be fetched depending on the plane
driver's atomic_disable() implementation.

Second, this CRTC's 'plane_changed' will be false during
the whole commit tail stage, and this will make vblank
wait to be bypassed which directly causes the later wait
flip done timeout.

So add this commit case check to the LCDIF CRTC's atomic
check to block this kind of commits.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 67ced65259a4dbf040ce4a931325be6ba97e5131)
2018-11-28 10:14:48 +08:00
Liu Ying 2e4a928dd9 MLK-20470 drm/imx: dpu: plane: Do full modeset for tile to linear fb switch
When pixel combiner is used, it turns out that on-the-fly switch from
tile framebuffer to linear framebuffer would cause hardware malfunction
- right half display would be missing and master&slave content shadow
load done event won't come.  Thus, go for a full modeset as a workaround.
Note that we check if the original framebuffer is tile or not for both
primary and overlay planes.  So, this could be over-kill.  The issue was
found when we use 32bit GPU super tile as the original framebuffer on the
primary plane(restart Weston frequently).  However, since we usually
don't do this kind of switch in real graphics, it should be fine.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit 9245bbf650fdeb79ebf869d48b6bd1b43c2bcf3b)
2018-11-27 16:29:41 +08:00
Sandor Yu dfd24b052e MLK-20415: drm: imx: hdp: Adjust HDMI Vswing
The iMX8QM HDMI voltage swing needs to be increased for HDMI compliance.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
(cherry picked from commit 5ba997eef35fc74653c29bb99dbe4d97292dc6e4)
2018-11-20 10:50:36 +08:00
Laurentiu Palcu 0c645d3601 MLK-20216-2: drm/imx/dcss: remove dead code
This fixes Coverity issue since enable is always true.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-15 15:21:51 +02:00
Laurentiu Palcu e03498dcdd MLK-20216-1: drm/imx/dcss: fix suspicious sign extension
This addresses Coverity issues related to "Suspicious sign extension"
when an u16 is promoted to int (32bit signed) and then to u64. If the
resulting int is greater than 0x7fffffff the upper bits of the u64 will
all be 1.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-15 15:21:51 +02:00
Oliver Brown 81c7646749 MLK-20332 drm: imx hdp: Display version information for HDMI/DP firmware
The HDMI/DP firmware verison will now be displayed.
Moved firmware handling to common file for HDMI and DisplayPort.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
2018-11-13 08:56:23 -06:00
Laurentiu Palcu 34e6d1babc MLK-20117 drm/imx/dcss: fix color issue when Adobe_ARGB gamut is used
Adobe ARGB gamut was selected even if the output pipe pixel encoding was
YUV. That produced a pink tint on the screen.

This patch will make sure the Adobe ARGB gamut is selected only when the
output pipe pixel encoding is RGB.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-13 16:11:35 +02:00
Laurentiu Palcu 08ac01ad71 MLK-20304-2 imx/drm/dcss: get the hdmi controller CS from private_flags
DCSS HDR10 output pipe is always 10-bit. All we need to know to better
setup the LUTs and/or CSC matrices is the output colorspace.

This patch will fetch the CS from adjusted_mode's private_flags, as
indicated in the connector's mode_fixup phase.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-13 16:11:35 +02:00
Laurentiu Palcu 31d0619322 MLK-20304-1 drm/imx/hdp: add mode_fixup hook and better handling of DC and CS
The HDMI sink may support different color depths for RGB and/or YUV
colorspaces. Currently, for mscale, 10-bit YUV420 is used only for
2160p@60. For the rest of modes 8-bit RGB is used.

This patch will add a mode_fixup() hook in the hdp_ops struct, allowing
each platform to perform a better handling of the various color depths
and colorspaces.

With the current patch, the RGB output will always be preferred to YUV
colorspaces, given the same color depth, since YUV colorspaces perform
UV subsampling, producing less quality. Also, whenever possible, better
color depth will be preferred (12-bit, 10-bit and, lastly, 8-bit).

The chosen colorspace and color depth will always be based on EDID's
Capability Map Data Block and YUV420 Video Data Block, as well as on
HDMI controller's known clock constraints.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-13 16:11:35 +02:00
Liu Ying 3ec344d6fa MLK-20324 gpu: imx: dpu: tcon: Initialize tmp_m in tcon_cfg_videomode()
The video mode tmp_m, as a local variable in tcon_cfg_videomode(),
is uninitialized and used to store a copy instance from the real
video mode.  tcon_cfg_videomode() would change the timing of it if
side_by_side mode is enabled.  Theoretically, there should be no
problem even if we don't initialize tmp_m.  However, coverity
reports that tmp_m is an uninitialized scalar variable when the copy
is being done(CID 5233067: Uninitialized scalar variable (UNINIT)).
This patch fixes the issue reported by coverity.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-12 17:42:35 +08:00
Liu Ying 95bc1eb150 MLK-20318 gpu: imx: dpu: scaler: Avoid out-of-bounds array read on src_sels[i][j]
The logic in function h/vscaler_pixengcfg_dynamic_src_sel() to avoid
overrunning array src_sel[i][j] is wrong.  The correct one is to check
on the index i which should be less than the array size of h/vs_id_array[].
This patch fixes the potential array overrunning issue, that is,
out-of-bounds array read issue.  The issue is reported by coverity -
CID 1477349 and CID 1477345.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-12 17:42:35 +08:00
Liu Ying d95b6b9740 MLK-20316 gpu: imx: dpu: Avoid out-of-bound array access in dpu_{unit}_init()
The callers of dpu_{unit}_init() might provide an invalid id as
the parameter, it may cause overrunning dpu->{unit}_priv[] and
cf_shdlreqs[] arrays and out-of-bound array access.  Although
the current only caller is dpu_submodules_init() and it always
provides valid ids, it would be good to fix the potential issue.
This patch fixes several issues reported by coverity - CID 1477330,
CID 1477335, CID 1477348, CID 1477346, CID 3298619, CID 1477347,
CID 5233021 and CID 1477321.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-12 10:48:39 +08:00
Liu Ying 92899d70e5 MLK-20307 gpu: imx: dpu: extdst: Fix get_xval()
The function get_xval() returns the C_XVAL and L_XVAL fields of
the CURPIXELCNT and LASTPIXELCNT registers.  They are 16bit and
sit in the low 16bit of the registers.  This patch fixes the way
we mask the register and read the fields out.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-12 09:55:19 +08:00
Liu Ying 9f7f845c12 MLK-20301 gpu: imx: dpu: layerblend: Remove several invalid registers & wrappers
The layerblend units don't contain the CONTROLWORD, CURPIXELCNT,
LASTPIXELCNT and PERFCOUNTER registers, so let's remove them
and their wrappers(no one is calling them), which were introduced
accidentally.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-09 17:14:32 +08:00
Liu Ying ab7892a388 MLK-20287 drm/imx: ldb: Check retval of sc_misc_set_control in ldb_pixel_link_init
The return value of sc_misc_set_control() should be checked in
ldb_pixel_link_init(), instead of being ignored.  This patch
fixes this issue.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-09 09:46:58 +08:00
Dzung Hoang cd7d34cd77 MLK-20263: drm/imx/dcss: fix channel-0 line shift
If an RGB buffer is fed to channel-0, the output will have one line
shifted down, with the last line appearing on top.

Using the 7-tap filter will fix the issue. The 5-tap filter code will be
removed completely.

Signed-off-by: Dzung Hoang <dzung.hoang@nxp.com>
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-08 15:12:28 +02:00
Laurentiu Palcu 1e3fcb39a6 MLK-20242: drm/imx/dcss: fix brightness for REC.709
The brightness, when REC709 was used in the configuration of the pipes,
was lower than expected.

The reason was the HDR10 configuration application that was used to
create the tables had a parameter that was wrongly set.

The tables were re-generated with the proper setting.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-11-08 15:12:28 +02:00
Robert Chiras ce22c18198 MLK-20181-10: Improve the axi clock usage
Currently, the enable of the axi clock return status is ignored, causing
issues when the enable fails then we try to disable it. Therefore, it is
better to check the return status and disable it only when enable
succeeded.
Also, remove the helper functions around clk_axi, since we can directly
use the clk API function for enable/disable the clock. Those functions
are already checking for NULL clk and returning 0 if that's the case.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>i
Acked-by: Leonard Crestez <leonard.crestez@nxp.com>
2018-11-08 15:07:07 +02:00
Robert Chiras c8e6ebf1c6 MLK-20181-8: drm/mxsfb: Cleanup after upstream backport
Patches related to suspend/resume have been backported from upstream
kernel, therefore some of the mxsfb_drm_private members are no longer
needed, so remove them, among with the code around them.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Acked-by: Leonard Crestez <leonard.crestez@nxp.com>
2018-11-08 15:07:06 +02:00
Leonard Crestez 57aca8a76b MLK-20181-7: drm/mxsfb: Switch to drm_atomic_helper_commit_tail_rpm
The lcdif block is only powered on when display is active so plane
updates when not enabled are not valid. Writing to an unpowered IP block
is mostly ignored but can trigger bus errors on some chips.

Prevent this situation by switching to drm_atomic_helper_commit_tail_rpm
and having the drm core ensure atomic_plane_update is only called while
the crtc is active. This avoids having to keep track of "enabled" bits
inside the mxsfb driver.

This also requires handling the vblank event for disable from
mxsfb_pipe_disable.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Suggested-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/c19c0c00ed42e8e8f7965aa4821ac295abc5cd05.1537191359.git.leonard.crestez@nxp.com
2018-11-08 15:07:06 +02:00
Leonard Crestez 5f5c92ee0a MLK-20181-6: drm/mxsfb: Add PM_SLEEP support
Since power to the lcdif block can be lost on suspend implement
PM_SLEEP_OPS using drm_mode_config_helper_suspend/resume to save/restore
the current mode.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/cfa1a4083eefd112362e640deeb2e120584ac3f5.1537191359.git.leonard.crestez@nxp.com
2018-11-08 15:07:05 +02:00
Noralf Trønnes fba83191e7 MLK-20181-5: drm/modeset-helper: Add simple modeset suspend/resume helpers
Add drm_mode_config_helper_suspend/resume() which takes care of
atomic modeset suspend/resume for simple use cases.
The suspend state is stored in struct drm_mode_config.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171106191812.38927-3-noralf@tronnes.org
2018-11-08 15:07:05 +02:00
Noralf Trønnes b1c4df7077 MLK-20181-4: drm: Add drm_device->fb_helper pointer
drm_fb_helper is *the* way of doing fbdev emulation so add a pointer to
struct drm_device. This makes it possible to add callback helpers for
.last_close and .output_poll_changed further reducing fbdev emulation
footprint in drivers. The pointer is set by drm_fb_helper_init() and
cleared by drm_fb_helper_fini().

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171030153951.56269-3-noralf@tronnes.org
2018-11-08 15:07:04 +02:00
Leonard Crestez 37526cc27b MLK-20181-3: drm/mxsfb: Add pm_runtime calls to pipe_enable/disable
Adding lcdif nodes to a power domain currently results in
black/corrupted screens or hangs because power is not correctly enabled
when required.

Ensure power is on when display is active by adding
pm_runtime_get/put_sync to mxsfb_pipe_enable/disable.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/ee88148399c63494cda4129b05444b0ac331b7a7.1537191359.git.leonard.crestez@nxp.com
2018-11-08 15:07:03 +02:00
Leonard Crestez f83ab92705 MLK-20181-2: drm/mxsfb: Fix initial corrupt frame when activating display
LCDIF will repeatedly display data from CUR_BUF and set CUR_BUF to
NEXT_BUF when done. Since we are only ever writing to NEXT_BUF the
display will show an initial corrupt frame.

Fix by writing the FB paddr to both CUR_BUF and NEXT_BUF when
activating the CRTC.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/7cdac9c064cc2b8a3d237934f186da98cefe6cb3.1537191359.git.leonard.crestez@nxp.com
2018-11-08 15:07:03 +02:00
Leonard Crestez 62bf2343a0 MLK-20181-1: drm/mxsfb: Move axi clk enable/disable to crtc enable/disable
The main axi clk is disabled at the end of mxsfb_crtc_mode_set_nofb and
immediately reenabled in mxsfb_enable_controller.

Avoid this by moving the handling of axi clk one level up to
mxsfb_crtc_enable. Do the same for mxsfb_crtc_disable for symmetry.

This shouldn't have any functional effect.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/985c1f1cad250bd9ca154b3e4b3f913c310eeabd.1537191359.git.leonard.crestez@nxp.com
2018-11-08 15:07:02 +02:00
Sandor Yu 2d2bd93fad MLK-20272: hdp: Correct copyright
Cadence allow customer release these source code as followed copyright.

 * Copyright (C) 2016-2017 Cadence Design Systems, Inc.
 * All rights reserved worldwide.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation and/or
 * other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors
 * may be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
2018-11-08 13:54:41 +08:00
Liu Ying 64fba9b948 MLK-20152 drm/imx: ldb: Correct ch0/1_mode for variants without mux
Unlike i.MX6qdl and i.MX53 LDB variants, the i.MX8 LDB variants(i.MX8qxp
and i.MX8qm) in existence don't have frontend mux, thus, we should split
the logic to program the ch0/1_mode for variants w/wo the mux.  It turns
out LDB_CH0_MODE_EN_TO_DI0 can be used for channel0 in both LDB single
mode and LDB split mode for the i.MX8 LDB variants.  However, based on
test results, for i.MX8qm LDB channel1, LDB_CH1_MODE_EN_TO_DI1 has to be
used in single mode, while, i.MX8qxp may work with LDB_CH1_MODE_EN_TO_DI0
or LDB_CH1_MODE_EN_TO_DI1.  With LDB_CH1_MODE_EN_TO_DI0, i.MX8qm LDB
channel1 would output wrong image in single mode(it looks like color
is wrong based on test results).  The i.MX8 LDB variants channel1 mode
can still be LDB_CH1_MODE_EN_TO_DI0 in split mode(the patch doesn't
touch this).  In essence, this patch fixes the channel1 single mode for
i.MX8qm LDB by correcting the ch1_mode, while all other features
should work as before.  Note that due to hardware issue, we didn't test
the channel1 single mode for i.MX8qm.  We need to populate several
resistors to enable the connectors driven by channel1 in single mode
for either ARM2 platform or MEK board.  Tests are done with IT6263
LVDS to HDMI transmitter driven by LDB0 channel1 after r206, r207, r208
and r209 are populated on the i.MX8qm MEK board.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-11-07 09:48:42 +08:00
Liu Ying 644a119a49 MLK-20121 drm/imx: dpu: plane: Improve readability for helper source_to_id()
This patch contains code-change-only to improve readability
for helper source_to_id().  Less indents are used.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-10-30 14:48:37 +08:00
Liu Ying c441ced3f1 MLK-20110 drm/imx: dpu: crtc: Add pclk and vrefresh dbg info in ->mode_set_nofb
Pixel clock and vrefresh are important information for a video mode.
This patch adds debug information for them in ->mode_set_nofb.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-10-29 14:47:36 +08:00
Laurentiu Palcu 493d5ef800 MLK-20098-2: imx/drm/dcss: fix uninitialized spinlock
After activating CONFIG_DEBUG_SPINLOCK, the following warning was thrown
in kernel log:

[    1.261079] BUG: spinlock bad magic on CPU#0, kworker/0:2/1285
[    1.266928]  lock: 0xffff8000b92f0190, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
[    1.275113] CPU: 0 PID: 1285 Comm: kworker/0:2 Not tainted 4.14.62-05296-gd695a5b #460
[    1.283032] Hardware name: Freescale i.MX8MQ EVK (DT)
[    1.288094] Workqueue: pm pm_runtime_work
[    1.292111] Call trace:
[    1.294567] [<ffff00000808a7d0>] dump_backtrace+0x0/0x3d8
[    1.299974] [<ffff00000808abbc>] show_stack+0x14/0x20
[    1.305032] [<ffff000008dccd40>] dump_stack+0x8c/0xac
[    1.310091] [<ffff000008119858>] spin_dump+0x70/0x90
[    1.315060] [<ffff000008119978>] do_raw_spin_lock+0xc0/0x108
[    1.320726] [<ffff000008de6380>] _raw_spin_lock_irqsave+0x28/0x38
[    1.326825] [<ffff000008677434>] dcss_ctxld_kick+0x2c/0x200
[    1.332402] [<ffff000008677a3c>] dcss_ctxld_suspend+0x1c/0xa0
[    1.338153] [<ffff000008676648>] dcss_runtime_suspend+0x18/0x68
[    1.344079] [<ffff0000086f3740>] pm_generic_runtime_suspend+0x28/0x40
[    1.350523] [<ffff0000086f6558>] __rpm_callback+0xe0/0x268
[    1.356015] [<ffff0000086f6700>] rpm_callback+0x20/0x80
[    1.361246] [<ffff0000086f56ec>] rpm_suspend+0xf4/0x4b8
[    1.366474] [<ffff0000086f5cac>] rpm_idle+0x124/0x168
[    1.371531] [<ffff0000086f70b8>] pm_runtime_work+0xa0/0xb8
[    1.377025] [<ffff0000080ec874>] process_one_work+0x1d4/0x360
[    1.382774] [<ffff0000080eca48>] worker_thread+0x48/0x478
[    1.388180] [<ffff0000080f2e10>] kthread+0x138/0x140
[    1.393151] [<ffff000008084f48>] ret_from_fork+0x10/0x18

The reason was an uninitialized spinlock.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-10-29 11:10:38 +08:00
Laurentiu Palcu f347734899 MLK-20098-1: imx/drm/dcss: Fix potential sleep in IRQ context
Activating CONFIG_SLEEP_ATOMIC_SLEEP detected a couple of potential sleeps
inside IRQ context:

[   23.609203] BUG: sleeping function called from invalid context at kernel/irq/manage.c:112
[   23.617437] in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/2
[   23.624229] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G        W 4.14.62-05295-gf2fa7e6 #454
[   23.632927] Hardware name: Freescale i.MX8MQ EVK (DT)
[   23.637980] Call trace:
[   23.640433] [<ffff00000808a360>] dump_backtrace+0x0/0x3d8
[   23.645834] [<ffff00000808a74c>] show_stack+0x14/0x20
[   23.650891] [<ffff000008dba640>] dump_stack+0x9c/0xbc
[   23.655946] [<ffff0000080f70d4>] ___might_sleep+0xf4/0x118
[   23.661433] [<ffff0000080f7148>] __might_sleep+0x50/0x88
[   23.666750] [<ffff00000811f218>] synchronize_irq+0x30/0x98
[   23.672237] [<ffff00000811f6e8>] disable_irq+0x20/0x30
[   23.677378] [<ffff00000866edb8>] dcss_dpr_irq_enable+0x78/0x98
[   23.683211] [<ffff00000866f798>] dcss_dtg_vblank_irq_enable+0x40/0x78
[   23.689652] [<ffff00000866c79c>] dcss_vblank_irq_enable+0xc/0x18
[   23.695661] [<ffff0000086d3048>] dcss_disable_vblank+0x30/0x50
[   23.701496] [<ffff0000086aaa2c>] drm_vblank_disable_and_save+0xd4/0xe8
[   23.708023] [<ffff0000086aaac8>] vblank_disable_fn+0x88/0xa8
[   23.713685] [<ffff00000813513c>] call_timer_fn.isra.5+0x24/0x80
[   23.719603] [<ffff00000813523c>] expire_timers+0xa4/0xb0
[   23.724914] [<ffff000008135300>] run_timer_softirq+0xb8/0x170
[   23.730660] [<ffff000008081bcc>] __do_softirq+0x12c/0x228
[   23.736062] [<ffff0000080d57bc>] irq_exit+0xc4/0x100
[   23.741025] [<ffff00000811e528>] __handle_domain_irq+0x60/0xb8
[   23.746857] [<ffff000008081998>] gic_handle_irq+0x78/0x17c

These sleep warnings were generated because disable_irq() may sleep. Use
disable_irq_nosync() instead.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-10-29 11:10:38 +08:00
Oliver Brown 7bf220103d MLK-20064 drm: imx: dp: Add link training check for DisplayPort
After link train completes the link status needs to be checked.
If the link is not "good", then link training must be retried.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
2018-10-29 11:10:38 +08:00
Oliver Brown dfa0a7eeef MLK-20063 drm: imx: dp: Correct iMX8M PHY initialization
The DisplayPort PHY initialization does not need the additional
loop gain enabled.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
2018-10-29 11:10:38 +08:00
Laurentiu Palcu b2aae035d8 MLK-19689 drm/imx/dcss: Fix scaler freeze on channel-0
For channel 0 if 1920x1080@NV12 was used when setting a mode would
freeze the scaler. That's because the chroma vertical size was set to
540 (1920 / 2) instead of 544 (which is divisible to 8).

This patch makes sure we round up the chroma vertical size for channel-0
properly.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-10-29 11:10:38 +08:00
Laurentiu Palcu 83b8756e5b MLK-19961 drm/imx/dcss: Fix 27MHz pixel clock platform freeze
When the VIDEO_PLL2 clock code was moved to the DCSS driver, a
regression was introduced and any mode requiring a 27MHz pixel clock
would instantly freeze the platform.

It turns out, after setting the clocks in bypass mode, PLL_CLKE was
never set. Hence, DCSS was not getting any clock. Without a valid clock,
any attempt to access DTG registers will freeze the system.

This patch:
 * sets PLL_CLKE when bypass is used;
 * simplifies the pll code a little;
 * increases the atomic CRTC enable timeout to 500ms to accommodate the
   delay after which the clock is available when bypass is used;

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
CC: Oliver Brown <oliver.brown@nxp.com>
2018-10-29 11:10:38 +08:00
Laurentiu Palcu 80344cc36e MLK-19021: drm/imx/dcss: fix RTRM clock reference
RTRM clock reference was saved in apb_clk, instead of rtrm_clk. Hence,
when blanking and clocks go off, APB clock counter was 2, instead of 1.

Because IRQ_STEER controller uses APB clock as well, the APB clock ref
counter will never go to 0. Unless DCSS is never used.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-10-29 11:10:38 +08:00
Laurentiu Palcu 0f974238db MLK-19906: drm/imx/dcss: lower CTXLD trigger threshold
After PM_QoS was removed by this commit:

f889273 - MLK-19460-2: drm: imx: dcss: remove PM_QoS

interrupt latency increased. Hence, any video playback using tiled
compressed formats will be affected because DTRC uses CTXLD to switch
its register banks. If CTXLD is not armed, at the right time, the DB
trigger moment will be missed. This leads to DTRC not switch to the other
register bank and scaler will be starved, leading to a channel freeze.

This patch will lower the CTXLD trigger time to 90% of frame trace
allowing some more time between arming the context loader and DB trigger
time, in case the latency is too big.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2018-10-29 11:10:38 +08:00
Robert Chiras 37b999a6c0 MLK-18789-4: drm/mxsfb: Update mxsfb to support LCD reset
The eLCDIF controller has control pin for the external LCD reset pin.
Add support for it and assert this pin in enable and de-assert it in
disable.
Also, correct the pm_runtime_enable call, since it was made too early in
the probe, causing issues to DRM enable routines.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
2018-10-29 11:10:38 +08:00
Robert Chiras 9d412df284 MLK-18789-2: drm/bridge: Add driver for legacy Freescale Seiko 43WVFIG adapter
This is an adapter card made for the 4.3", 800x480, LCD panel Seiko
43WVFIG. The LCD panel is a 24bit DPI bus, while the adapter card has
two ports: 18-bit and 24-bit data input. For the 18-bit data input, the
adapter card is demuxing some of the data lines, in order to feed all of
the 24 lines needed by the LCD.
This driver handles both this use-cases.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
2018-10-29 11:10:38 +08:00
Marco Franchi 9c650a2c6d MLK-18789-1: drm/panel: Add driver for Seiko 43WVF1G panel
Add driver for Seiko Instruments Inc. 4.3" WVGA (800 x RGB x 480)
TFT with Touch-Panel.

Datasheet available at:
http://www.glyn.de/data/glyn/media/doc/43wvf1g-0.pdf

Seiko 43WVF1G panel has two power supplies: avdd and dvdd and they
require a specific power on/down sequence.
For this reason the simple panel driver cannot be used to drive this
panel, so create a new one heavily based on simple panel.

Based on initial patch submission from Breno Lima.

Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1500567179-6967-1-git-send-email-marco.franchi@nxp.com
2018-10-29 11:10:38 +08:00
Liu Ying 8dc2e0b9aa MLK-19888 gpu: imx: dpu: common: Use stream1 as the master stream for i.MX8QM
Pixel combiner uses two display streams to drive one single display.
Either one of the two streams can be master stream and the other
slave stream.  If we use stream0 as the master stream, the overlay
covers the two streams could be unsynchronized sometimes. It looks
like there is one frame lag between the two streams.  However, it
turns out that using stream1 as the master stream can workaround
this issue.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2018-10-29 11:10:38 +08:00