Jiasheng Jiang
96bc86cac0
drm/ast: potential dereference of null pointer
...
[ Upstream commit fea3fdf975dd9f3e5248afaab8fe023db313f005 ]
The return value of kzalloc() needs to be checked.
To avoid use of null pointer '&ast_state->base' in case of the
failure of alloc.
Fixes: f0adbc382b
("drm/ast: Allocate initial CRTC state of the correct size")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn >
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Link: https://patchwork.freedesktop.org/patch/msgid/20211214014126.2211535-1-jiasheng@iscas.ac.cn
Signed-off-by: Sasha Levin <sashal@kernel.org >
2021-12-22 09:30:54 +01:00
Thomas Zimmermann
2c518667f9
drm/ast: Fix invalid usage of AST_MAX_HWC_WIDTH in cursor atomic_check
...
[ Upstream commit ee4a92d690f30f3793df942939726bec0338e65b ]
Use AST_MAX_HWC_HEIGHT for setting offset_y in the cursor plane's
atomic_check. The code used AST_MAX_HWC_WIDTH instead. This worked
because both constants has the same value.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20210209134632.12157-3-tzimmermann@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org >
2021-05-11 14:47:22 +02:00
Thomas Zimmermann
10e26e749f
drm/ast: Reload gamma LUT after changing primary plane's color format
...
The gamma LUT has to be reloaded after changing the primary plane's
color format. This used to be done implicitly by the CRTC atomic_enable()
helper after updating the primary plane. With the recent reordering of
the steps, the primary plane's setup was moved last and invalidated
the gamma LUT. Fix this by setting the LUT from within atomic_flush().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Fixes: 2f0ddd89fe
("drm/ast: Enable CRTC before planes")
Cc: Thomas Zimmermann <tzimmermann@suse.de >
Cc: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: Dave Airlie <airlied@redhat.com >
Cc: dri-devel@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200922144655.23624-1-tzimmermann@suse.de
(cherry-picked from 8e3784dfef8a03143b13e7e4011f276a954f1bc6)
2020-11-25 09:13:20 +01:00
Thomas Zimmermann
2f0ddd89fe
drm/ast: Enable CRTC before planes
...
An active cursor plane requires a valid display mode. Change the
commit_tail callback, so that it sets up the CRTC's mode before
updating planes.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Link: https://patchwork.freedesktop.org/patch/msgid/20200914072236.19398-5-tzimmermann@suse.de
2020-09-16 13:08:10 +02:00
Thomas Zimmermann
f3901b5fee
drm/ast: Program display mode in CRTC's atomic_enable()
...
This change simplifies ast's modesetting code. The display mode
is now programmed from within the CRTC's atomic_enable(), which
only runs if we actually want to program the mode.
Corresponding code in atomic_flush() is being removed. Also removed
is atomic_begin(), which serves no purpose at all.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Link: https://patchwork.freedesktop.org/patch/msgid/20200914072236.19398-4-tzimmermann@suse.de
2020-09-16 13:08:05 +02:00
Thomas Zimmermann
39edb28780
drm/ast: Disable planes while switching display modes
...
The ast HW cursor requires the primary plane and CRTC to display at
a valid mode and format. This is not the case while switching
display modes, which can lead to the screen turing permanently dark.
As a workaround, the ast driver now disables active planes while the
mode or format switch takes place. It also synchronizes with the vertical
refresh to give CRTC and planes some time to catch up on each other.
The active planes planes (primary or cursor) will be re-enabled by
each plane's atomic_update() function.
v3:
* move the logic into the CRTC's atomic_disable function
v2:
* move the logic into the commit-tail function
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Link: https://patchwork.freedesktop.org/patch/msgid/20200914072236.19398-3-tzimmermann@suse.de
2020-09-16 13:08:01 +02:00
Thomas Zimmermann
5638c82cda
drm/ast: Set format registers in primary plane's update
...
The atomic modesetting code tried to distinguish format changes from
full modesetting operations. But the implementation was buggy and the
format registers were often updated even for simple pageflips.
Fix this problem by handling format changes in the primary plane's
update function.
v3:
* program format in primary plane's update function
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Link: https://patchwork.freedesktop.org/patch/msgid/20200914072236.19398-2-tzimmermann@suse.de
2020-09-16 13:07:25 +02:00
Thomas Zimmermann
e0f5a738cf
drm/ast: Embed struct drm_device in struct ast_private
...
Turns struct ast_private into a subclass of struct drm_device by
embedding the latter. This allows for using DRM's managed device
allocation.
The use of struct drm_device.dev_private is deprecated. The patch
converts the last remaining users to to_ast_private().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-7-tzimmermann@suse.de
2020-08-03 09:04:28 +02:00
Thomas Zimmermann
21d79b690e
drm/ast: Don't use ast->dev if dev is available
...
Several places in ast use ast->dev, when a dev pointer is already
available within the function. Remove the extra indirection. No
functional changes made.
This is just a small cleanup before embedding the DRM device instance
in struct ast_private.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-6-tzimmermann@suse.de
2020-08-03 09:04:18 +02:00
Thomas Zimmermann
365c0e70da
drm/ast: Replace struct_drm_device.dev_private with to_ast_private()
...
The ast code still references dev_private in several place when looking
up the ast device structure. Convert the remaining locations to use
to_ast_private().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-5-tzimmermann@suse.de
2020-08-03 09:04:10 +02:00
Thomas Zimmermann
6a470dc2a1
drm/ast: Embed CRTC and connector in struct ast_private
...
Only single instances of CRTC and connector are supported per
device. Embed both in ast's structure and remove the individual
memory allocations. DRM's CRTC cleanup helpers replace the rsp.
destroy function in ast.
While at it, also convert to_ast_connector() to a function.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-2-tzimmermann@suse.de
2020-08-03 09:03:47 +02:00
Thomas Zimmermann
e6949ff3ca
drm/ast: Initialize mode setting in ast_mode_config_init()
...
There's modesetting init code in ast_main.c. Move it to ast_mode.c and
merge it with the modesetting init code in ast_mode_init(). The result
is ast_mode_config_init(), which initalizes the whole modesetting.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-15-tzimmermann@suse.de
2020-07-07 11:12:06 +02:00
Thomas Zimmermann
1728bf6402
drm/ast: Use managed mode-config init
...
Using drmm_mode_config_init() sets up managed release of modesetting
resources. The existing modesetting's finalizer is empty, so remove it.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-14-tzimmermann@suse.de
2020-07-07 11:12:03 +02:00
Thomas Zimmermann
c35da0ed48
drm/ast: Replace struct ast_crtc with struct drm_crtc
...
Struct ast_crtc has been cleaned up and it's now a wrapper around the
DRM CRTC structure struct drm_crtc. This patch converts the driver to
struct drm_crtc and removes struct ast_crtc.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-13-tzimmermann@suse.de
2020-07-07 11:11:59 +02:00
Thomas Zimmermann
6bb18c9be6
drm/ast: Init cursors before creating modesetting structures
...
The cursor helpers reserve buffer objects in VRAM and update their
content. So although tied to modesetting, cursor helpers are more
of a memory manager. The modesetting's cursor plane requires this
functionality, so initialize cursors before modesetting.
While at it, also add an error check for ast_cursor_init().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-12-tzimmermann@suse.de
2020-07-07 11:11:55 +02:00
Thomas Zimmermann
3e9d787371
drm/ast: Managed cursor release
...
Register a release function to finalize cursors. The _fini() function
gets un-exported from the source file.
The function ast_mode_fini() is now empty and will be removed by a
later patch.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-11-tzimmermann@suse.de
2020-07-07 11:11:51 +02:00
Thomas Zimmermann
c91eadd110
drm/ast: Add helper to hide cursor
...
As the inverse to ast_cursor_show(), ast_cursor_hide() disables the
HW cursor.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-9-tzimmermann@suse.de
2020-07-07 11:11:44 +02:00
Thomas Zimmermann
6567bc9824
drm/ast: Don't enable HW cursors twice during atomic update
...
The ast_cursor_show() helper enables the cursor to be displayed. No need
to repeat that operation in the plane's atomic-update function.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-8-tzimmermann@suse.de
2020-07-07 11:11:39 +02:00
Thomas Zimmermann
81039adc92
drm/ast: Replace ast_cursor_move() with ast_cursor_show()
...
Having a cursor move function is misleading, as it actually enables the
cursor's image for displaying. So rename it to ast_cursor_show(). It's
semantics is to show a cursor at the specified location on the screen.
The displayed cursor is always the image in the cursor front BO.
This change also simplifies struct ast_crtc to being a mere wrapper around
around struct drm_crtc. It will be removed by a later patch.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-7-tzimmermann@suse.de
2020-07-07 11:11:35 +02:00
Thomas Zimmermann
75d9d8e66d
drm/ast: Move cursor pageflip into helper
...
The new helper ast_cursor_page_flip() switches the cursor's front and
back BOs. This simplifies the cursor plane's update helper.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-6-tzimmermann@suse.de
2020-07-07 11:11:31 +02:00
Thomas Zimmermann
dd004b9a55
drm/ast: Move cursor fb pinning and mapping into helper
...
The new helper ast_cursor_blit() updates a cursor's backbuffer HW
BO from a framebuffer structure. The cursor plane's prepare_fb()
function now uses the new interface.
Pinning and mapping of BOs is done automatically by the helper. This
includes the source BO, which was not pinned by the original code in
prepare_fb().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-4-tzimmermann@suse.de
2020-07-07 11:11:24 +02:00
Thomas Zimmermann
beb2355eec
drm/ast: Pass struct ast_private instance to cursor init/fini functions
...
Removes some typecasting.
v2:
* use to_ast_private() instead of struct drm_device.dev_private
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-3-tzimmermann@suse.de
2020-07-07 11:11:22 +02:00
Thomas Zimmermann
2ccebf561e
drm/ast: Move cursor functions to ast_cursor.c
...
The cursor manipulation functions are unrelated to modesetting. Move
them into their own file.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200702115029.5281-2-tzimmermann@suse.de
2020-07-07 11:11:15 +02:00
Maarten Lankhorst
60e9eabf41
Backmerge remote-tracking branch 'drm/drm-next' into drm-misc-next
...
Some conflicts with ttm_bo->offset removal, but drm-misc-next needs updating to v5.8.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com >
2020-06-29 12:16:26 +02:00
Thomas Zimmermann
1a19b4cb16
drm/ast: Use per-device logging macros
...
Converts the ast driver to drm_info(), drm_err() and drm_WARN_*(). No
functional changes are made.
v2:
* also convert WARN_*() macros
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20200617080340.29584-5-tzimmermann@suse.de
2020-06-22 13:40:33 +02:00
Thomas Zimmermann
fa7dbd7688
drm/ast: Upcast from DRM device to ast structure via to_ast_private()
...
All upcasting from struct drm_device to struct ast_private is now
performed via to_ast_private(). Using struct drm_device.dev_private
is deprecated. The ast variable in ast_crtc_helper_atomic_check() is
unused, so removed it.
v2:
* fix typo in commit message
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200617080340.29584-4-tzimmermann@suse.de
2020-06-22 13:40:33 +02:00
Thomas Zimmermann
05f13f5b59
drm/ast: Remove unused code paths for AST 1180
...
The ast driver contains code paths for AST 1180 chips. The chip is not
supported and the rsp code has never been tested. Simplify the driver by
removing the AST 1180 code.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20200617080340.29584-2-tzimmermann@suse.de
2020-06-22 13:38:32 +02:00
Colin Ian King
291ddeb621
drm/ast: fix missing break in switch statement for format->cpp[0] case 4
...
Currently the switch statement for format->cpp[0] value 4 assigns
color_index which is never read again and then falls through to the
default case and returns. This looks like a missing break statement
bug. Fix this by adding a break statement.
Addresses-Coverity: ("Unused value")
Fixes: 259d14a76a
("drm/ast: Split ast_set_vbios_mode_info()")
Signed-off-by: Colin Ian King <colin.king@canonical.com >
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Tested-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Link: https://patchwork.freedesktop.org/patch/msgid/20200610115804.1132338-1-colin.king@canonical.com
2020-06-11 09:05:31 +02:00
Thomas Zimmermann
d6ddbd5c97
drm/ast: Don't check new mode if CRTC is being disabled
...
Suspending failed because there's no mode if the CRTC is being
disabled. Early-out in this case. This fixes runtime PM for ast.
v3:
* fixed commit message
v2:
* added Tested-by/Reported-by tags
* added Fixes tags and CC (Sam)
* improved comment
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reported-by: Cary Garrett <cogarre@gmail.com >
Tested-by: Cary Garrett <cogarre@gmail.com >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Fixes: b48e1b6ffd
("drm/ast: Add CRTC helpers for atomic modesetting")
Cc: Thomas Zimmermann <tzimmermann@suse.de >
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Dave Airlie <airlied@redhat.com >
Cc: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: <stable@vger.kernel.org > # v5.6+
Link: https://patchwork.freedesktop.org/patch/msgid/20200507090640.21561-1-tzimmermann@suse.de
2020-05-08 09:29:18 +02:00
Samuel Zou
3a53230e1c
drm/ast: Make ast_primary_plane_helper_atomic_update static
...
Fix the following sparse warning:
drivers/gpu/drm/ast/ast_mode.c:564:6: warning:
symbol 'ast_primary_plane_helper_atomic_update'
was not declared. Should it be static?
Reported-by: Hulk Robot <hulkci@huawei.com >
Signed-off-by: Samuel Zou <zou_wei@huawei.com >
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Link: https://patchwork.freedesktop.org/patch/msgid/1588819206-11406-1-git-send-email-zou_wei@huawei.com
2020-05-08 08:48:56 +02:00
Jason Yan
ef54569966
drm/ast: remove duplicate assignment of ast_crtc_funcs member
...
The struct member 'set_config' was assigned twice:
static const struct drm_crtc_funcs ast_crtc_funcs = {
.reset = ast_crtc_reset,
.set_config = drm_crtc_helper_set_config,
......
.set_config = drm_atomic_helper_set_config,
......
};
Since the second one is which we use now in fact, we can remove the
first one.
This fixes the following coccicheck warning:
drivers/gpu/drm/ast/ast_mode.c:932:50-51: set_config: first occurrence
line 934, second occurrence line 937
Signed-off-by: Jason Yan <yanaijie@huawei.com >
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Link: https://patchwork.freedesktop.org/patch/msgid/20200429141010.8445-1-yanaijie@huawei.com
2020-04-30 10:41:05 +02:00
Daniel Vetter
a7aed875e3
drm/ast: Drop explicit connector register/unregister
...
This is only needed for hotpluggable connectors set up after
drm_dev_register().
Reviewed-by: Thomas Zimemrmann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com >
Cc: Dave Airlie <airlied@redhat.com >
Cc: Thomas Zimmermann <tzimmermann@suse.de >
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Emil Velikov <emil.velikov@collabora.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-59-daniel.vetter@ffwll.ch
2020-04-28 16:13:47 +02:00
Thomas Zimmermann
f0adbc382b
drm/ast: Allocate initial CRTC state of the correct size
...
The ast driver inherits from DRM's CRTC state, but still uses the atomic
helper for struct drm_crtc_funcs.reset, drm_atomic_helper_crtc_reset().
The helper only allocates enough memory for the core CRTC state. That
results in an out-ouf-bounds access when duplicating the initial CRTC
state. Simplified backtrace shown below:
[ 21.469321] ==================================================================
[ 21.469434] BUG: KASAN: slab-out-of-bounds in ast_crtc_atomic_duplicate_state+0x84/0x100 [ast]
[ 21.469445] Read of size 8 at addr ffff888036c1c5f8 by task systemd-udevd/382
[ 21.469451]
[ 21.469464] CPU: 2 PID: 382 Comm: systemd-udevd Tainted: G E 5.5.0-rc6-1-default+ #214
[ 21.469473] Hardware name: Sun Microsystems SUN FIRE X2270 M2/SUN FIRE X2270 M2, BIOS 2.05 07/01/2010
[ 21.469480] Call Trace:
[ 21.469501] dump_stack+0xb8/0x110
[ 21.469528] print_address_description.constprop.0+0x1b/0x1e0
[ 21.469557] ? ast_crtc_atomic_duplicate_state+0x84/0x100 [ast]
[ 21.469581] ? ast_crtc_atomic_duplicate_state+0x84/0x100 [ast]
[ 21.469597] __kasan_report.cold+0x1a/0x35
[ 21.469640] ? ast_crtc_atomic_duplicate_state+0x84/0x100 [ast]
[ 21.469665] kasan_report+0xe/0x20
[ 21.469693] ast_crtc_atomic_duplicate_state+0x84/0x100 [ast]
[ 21.469733] drm_atomic_get_crtc_state+0xbf/0x1c0
[ 21.469768] __drm_atomic_helper_set_config+0x81/0x5a0
[ 21.469803] ? drm_atomic_plane_check+0x690/0x690
[ 21.469843] ? drm_client_rotation+0xae/0x240
[ 21.469876] drm_client_modeset_commit_atomic+0x230/0x390
[ 21.469888] ? __mutex_lock+0x8f0/0xbe0
[ 21.469929] ? drm_client_firmware_config.isra.0+0xa60/0xa60
[ 21.469948] ? drm_client_modeset_commit_force+0x28/0x230
[ 21.470031] ? memset+0x20/0x40
[ 21.470078] drm_client_modeset_commit_force+0x90/0x230
[ 21.470110] drm_fb_helper_restore_fbdev_mode_unlocked+0x5f/0xc0
[ 21.470132] drm_fb_helper_set_par+0x59/0x70
[ 21.470155] fbcon_init+0x61d/0xad0
[ 21.470185] ? drm_fb_helper_restore_fbdev_mode_unlocked+0xc0/0xc0
[ 21.470232] visual_init+0x187/0x240
[ 21.470266] do_bind_con_driver+0x2e3/0x460
[ 21.470321] do_take_over_console+0x20a/0x290
[ 21.470371] do_fbcon_takeover+0x85/0x100
[ 21.470402] register_framebuffer+0x2fd/0x490
[ 21.470425] ? kzalloc.constprop.0+0x10/0x10
[ 21.470503] __drm_fb_helper_initial_config_and_unlock+0xf2/0x140
[ 21.470533] drm_fbdev_client_hotplug+0x162/0x250
[ 21.470563] drm_fbdev_generic_setup+0xd2/0x155
[ 21.470602] ast_driver_load+0x688/0x850 [ast]
<...>
[ 21.472625] ==================================================================
Allocating enough memory for struct ast_crtc_state in a custom ast CRTC
reset handler fixes the problem.
v2:
* implement according to drm_atomic_helper_crtc_reset()
* update state with __drm_atomic_helper_crtc_reset()
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Fixes: 83be6a3ceb
("drm/ast: Introduce struct ast_crtc_state")
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Dave Airlie <airlied@redhat.com >
Cc: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: Alex Deucher <alexander.deucher@amd.com >
Cc: "Noralf Trønnes" <noralf@tronnes.org >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20200130094012.32140-1-tzimmermann@suse.de
2020-04-20 15:48:23 +02:00
Thomas Zimmermann
4220fdf027
drm/ast: Use simple encoder
...
The ast driver uses an empty implementation for its encoder. Replace
the code with the generic simple encoder.
v2:
* rebase onto new simple-encoder interface
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200228081828.18463-3-tzimmermann@suse.de
2020-03-02 09:22:43 +01:00
Thomas Zimmermann
bd2b7eb6d2
drm/ast: Don't set struct drm_crtc_state.no_vblank explicitly
...
As ast does not initialize vblanking, atomic helpers initialize the
value of struct drm_crtc_state.no_vblank to be true. No need to set
it from within the driver.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Link: https://patchwork.freedesktop.org/patch/msgid/20200129120531.6891-4-tzimmermann@suse.de
2020-01-30 09:00:33 +01:00
Thomas Zimmermann
a4d46a8e26
drm/vram-helper: Remove BO device from public interface
...
TTM is an implementation detail of the VRAM helpers and therefore
shouldn't be exposed to the callers. There's only one correct value
for the BO device anyway, which is the one stored in the DRM device.
So remove struct ttm_bo_device from the VRAM-helper interface and
use the device's VRAM manager unconditionally. The GEM initializer
function fails if the VRAM manager has not been initialized.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200106125745.13797-8-tzimmermann@suse.de
2020-01-07 11:53:19 +01:00
Thomas Zimmermann
ebe9428b3f
drm/vram-helper: Remove interruptible flag from public interface
...
The flag 'interruptible', which is passed to various functions,
is always set to be false. Remove it and hard-code the value.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Suggested-by: Daniel Vetter <daniel@ffwll.ch >
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch >
Acked-by: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20200106125745.13797-7-tzimmermann@suse.de
2020-01-07 11:53:19 +01:00
Thomas Zimmermann
3339fdf574
drm/ast: Store primary-plane format in struct ast_crtc_state
...
Reading the primary plane's framebuffer from the CRTC's atomic_flush()
function is fragile as the plane state or framebuffer can be NULL.
Instead, we let the plane's atomic_check() store the framebuffer format
in the CRTC state. The CRTC always receives the framebuffer format that
is currently programmed, or NULL if no mode has been set yet.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-8-tzimmermann@suse.de
2019-12-10 14:28:43 +01:00
Thomas Zimmermann
e7d70cd494
drm/ast: Store VBIOS mode info in struct ast_crtc_state
...
After looking up VBIOS mode information in CRTC's atomic_check(), we
can reuse it in atomic_flush(). No need for a second look-up.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-7-tzimmermann@suse.de
2019-12-10 14:28:04 +01:00
Thomas Zimmermann
83be6a3ceb
drm/ast: Introduce struct ast_crtc_state
...
AST-specific CRTC state can be placed in the new struct ast_crtc_state.
The atomic check functions of the CRTC and the primary plane will store
the VBIOS mode info and the framebuffer format here. The CRTC will consume
these during atomic_flush().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-6-tzimmermann@suse.de
2019-12-10 14:26:13 +01:00
Thomas Zimmermann
ae46a57d52
drm/ast: Add plane atomic_check() functions
...
Introducing atomic_check() for priamry and cursor plane. The functions
validate the plane state and will later set format information for the
CRTC's atomic_flush().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-5-tzimmermann@suse.de
2019-12-10 14:25:59 +01:00
Thomas Zimmermann
ae37025d14
drm/ast: Clean up arguments of register functions
...
In preparation of an update of the primary-plane code, this patch
changes the arguments of several register-setting functions. No
functional changes are made. The function ast_set_dac_reg() has no
effect and therefore gets removed entirely.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-4-tzimmermann@suse.de
2019-12-10 14:25:47 +01:00
Thomas Zimmermann
2fbeec03e1
drm/ast: Enable and disable screen in primary-plane functions
...
Enabling and disabling the screen used to be done in the register
initialization and the DPMS function. None of these places is related
to the screen's output.
Now the primary plane's update and disable functions handle screen
display state. The primary plane can now be switched off without
displaying garbage.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-3-tzimmermann@suse.de
2019-12-10 14:25:28 +01:00
Thomas Zimmermann
71d873cc99
drm/ast: Move modesetting code to CRTC's atomic_flush()
...
When enabling the CRTC after waking up from a power-saving mode, the
primary plane's framebuffer might be NULL, which leads to a stack trace
as shown below.
[ 632.624608] BUG: kernel NULL pointer dereference, address: 0000000000000048
[ 632.624631] #PF: supervisor read access in kernel mode
[ 632.624639] #PF: error_code(0x0000) - not-present page
[ 632.624647] PGD 0 P4D 0
[ 632.624654] Oops: 0000 [#1 ] SMP PTI
[ 632.624662] CPU: 0 PID: 2082 Comm: gnome-shell Tainted: G E 5.4.0-rc7-1-default+ #114
[ 632.624673] Hardware name: Sun Microsystems SUN FIRE X2270 M2/SUN FIRE X2270 M2, BIOS 2.05 07/01/2010
[ 632.624689] RIP: 0010:ast_crtc_helper_atomic_enable+0x7d/0x680 [ast]
[ 632.624698] Code: 48 8b 80 e0 02 00 00 4c 8b 60 10 31 c0 f3 48 ab 48 8b 83 78 04 00 00 4c 89 ef 48 8d 70 18 e8 9a e9 55 ce 48 8b 83 78 04 00 00 <49> 8b 7c 24 48 4c 89 ea 4c 8d 44 24 28 48 8d 4c 24 20 48 8d 70 18
[ 632.624718] RSP: 0018:ffffbe9ec123fa40 EFLAGS: 00010246
[ 632.624726] RAX: ffff95a13cfd3400 RBX: ffff95a13cf32000 RCX: 0000000000000000
[ 632.624735] RDX: 0000000000000000 RSI: ffff95a13cfd34e8 RDI: ffffbe9ec123fb40
[ 632.624744] RBP: ffffbe9ec123fb80 R08: 0000000000000000 R09: 0000000000000003
[ 632.624753] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
[ 632.624762] R13: ffffbe9ec123fa70 R14: ffff95a13beb7000 R15: ffff95a13cf32800
[ 632.624772] FS: 00007f6d2763e140(0000) GS:ffff95a134000000(0000) knlGS:0000000000000000
[ 632.624782] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 632.624790] CR2: 0000000000000048 CR3: 00000001192f8004 CR4: 00000000000206f0
[ 632.624800] Call Trace:
[ 632.624811] ? __lock_acquire+0x409/0x7c0
[ 632.624830] drm_atomic_helper_commit_modeset_enables+0x1af/0x200
[ 632.624840] drm_atomic_helper_commit_tail+0x32/0x70
[ 632.624849] commit_tail+0xc7/0x110
[ 632.624857] drm_atomic_helper_commit+0x121/0x130
[ 632.624867] drm_atomic_connector_commit_dpms+0xd7/0x100
[ 632.624878] set_property_atomic+0xaf/0x110
[ 632.624890] drm_mode_obj_set_property_ioctl+0xbb/0x190
[ 632.624899] ? drm_mode_obj_find_prop_id+0x40/0x40
[ 632.624909] drm_ioctl_kernel+0x86/0xd0
[ 632.624918] drm_ioctl+0x1e4/0x36b
[ 632.624925] ? drm_mode_obj_find_prop_id+0x40/0x40
[ 632.624939] do_vfs_ioctl+0x4bd/0x6e0
[ 632.624949] ksys_ioctl+0x5e/0x90
[ 632.624957] __x64_sys_ioctl+0x16/0x20
[ 632.624966] do_syscall_64+0x5a/0x220
[ 632.624976] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 632.624984] RIP: 0033:0x7f6d2b0de387
[ 632.624991] Code: 00 00 90 48 8b 05 f9 9a 0c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c9 9a 0c 00 f7 d8 64 89 01 48
[ 632.625011] RSP: 002b:00007fffb49def38 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 632.625021] RAX: ffffffffffffffda RBX: 00007fffb49def70 RCX: 00007f6d2b0de387
[ 632.625030] RDX: 00007fffb49def70 RSI: 00000000c01864ba RDI: 0000000000000009
[ 632.625040] RBP: 00000000c01864ba R08: 0000000000000000 R09: 00000000c0c0c0c0
[ 632.625049] R10: 0000000000000030 R11: 0000000000000246 R12: 000055bc367eb920
[ 632.625058] R13: 0000000000000009 R14: 0000000000000002 R15: 0000000000000000
[ 632.625071] Modules linked in: ebtable_filter(E) ebtables(E) ip6table_filter(E) ip6_tables(E) iptable_filter(E) ip_tables(E) x_tables(E) af_packet(E) scsi_transport_iscsi(E) dmi_sysfs(E) msr(E) xfs(E) intel_powerclamp(E) coretemp(E) k)
[ 632.625185] CR2: 0000000000000048
The STR is
* start gdm and wait for it to switch off the display
* wake up the display by pressing a key
CRTC modesetting depends on the new state of the CRTC and the primary
plane's framebuffer. The bugfix moves the modesetting code into the
CRTC's atomic_flush() function, where it is protected from the plane's
framebuffer being NULL.
The CRTC's atomic-enable function, which is the modesetting's original
location, still contains DPMS state handling. It's exactly the inverse
of the atomic-disable function.
v3:
* protect modesetting from from fb == NULL
v2:
* do an atomic check for plane
* reject invisible primary planes
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Fixes: b48e1b6ffd
("drm/ast: Add CRTC helpers for atomic modesetting")
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Dave Airlie <airlied@redhat.com >
Cc: Daniel Vetter <daniel.vetter@ffwll.ch >
Cc: "Y.C. Chen" <yc_chen@aspeedtech.com >
Cc: Sam Ravnborg <sam@ravnborg.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-2-tzimmermann@suse.de
2019-12-10 14:25:15 +01:00
Thomas Zimmermann
4961eb60f1
drm/ast: Enable atomic modesetting
...
This commit sets the remaining atomic-modesetting helpers and the flag
DRIVER_ATOMIC. Legacy cursor functions are removed in favor of the cursor
plane. For power management, atomic helpers replace the indvidual
operations that the driver currently runs.
Atomic modesetting is enabled with this commit.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-10-tzimmermann@suse.de
2019-11-08 11:04:51 +01:00
Thomas Zimmermann
02f3bb751a
drm/ast: Add cursor plane
...
The cursor plane uses an internal format of ARGB4444. To userspace, we
announce ARGB8888 and do the transformation internally.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scope
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-9-tzimmermann@suse.de
2019-11-08 11:04:45 +01:00
Thomas Zimmermann
b48e1b6ffd
drm/ast: Add CRTC helpers for atomic modesetting
...
As the CRTC code has already been prepared for a split between mode
setting and plane handling, most of the CRTC's atomic modesetting is
build upon primitives of the non-atomic implementation.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-8-tzimmermann@suse.de
2019-11-08 11:04:45 +01:00
Thomas Zimmermann
a6ff807b71
drm/ast: Add primary plane
...
Like the original mode-setting code, the primary plane supports XRGB888,
RGB565 and C8. The plane itself only pins BOs and sets the base address
and scanline offset. The mode-setting code will be located in the CRTC's
atomic helpers.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scope
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-7-tzimmermann@suse.de
2019-11-08 11:04:28 +01:00
Thomas Zimmermann
259d14a76a
drm/ast: Split ast_set_vbios_mode_info()
...
The implementation of ast_set_vbios_mode() converts a DRM display mode
and framebuffer into an adjusted mode and stores information for the
video BIOS to several scratch regsiters.
Here we split the function into individual functions that do the
conversion, set the VBIOS mode information and format information.
This makes it compatible with support for primary planes and atomic
modesetting.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-6-tzimmermann@suse.de
2019-11-08 11:03:20 +01:00
Thomas Zimmermann
0d45ad989d
drm/ast: Split ast_set_ext_reg() into color and threshold function
...
In ast_set_ext_reg() sets several framebuffer options and CRT threshold
parameters. The former is mostly state of the primary plane; the latter
is constant. Hence, split the function in two and make it work with
atomic modesetting.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Gerd Hoffmann <kraxel@redhat.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20191107083404.6852-5-tzimmermann@suse.de
2019-11-08 11:03:10 +01:00