aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_debugfs_crc.c
AgeCommit message (Collapse)AuthorFilesLines
2018-08-22Revert "drm: crc: Wait for a frame before returning from open()"Mahesh Kumar1-16/+0
This reverts commit e8fa5671183c80342d520ad81d14fa79a9d4a680. Don't wait for first CRC during crtc_crc_open. It avoids one frame wait during open. If application want to wait after read call, it can use poll/read blocking read() call. Suggested-by: Ville Syrjälä <[email protected]> Signed-off-by: Mahesh Kumar <[email protected]> Cc: [email protected] Cc: Tomeu Vizoso <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-08-22drm/crc: Cleanup crtc_crc_open functionMahesh Kumar1-32/+29
This patch make changes to allocate crc-entries buffer before enabling CRC generation. It moves all the failure check early in the function before setting the source or memory allocation. Now set_crc_source takes only two variable inputs, values_cnt we already gets as part of verify_crc_source. Changes since V1: - refactor code to use single spin lock Changes since V2: - rebase Changes since V3: - rebase on top of VKMS driver Signed-off-by: Mahesh Kumar <[email protected]> Cc: [email protected] Cc: Laurent Pinchart <[email protected]> Cc: Haneen Mohammed <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Acked-by: Leo Li <[email protected]> (V2) Reviewed-by: Laurent Pinchart <[email protected]> (V3) Signed-off-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-08-13drm: crc: Introduce get_crc_sources callbackMahesh Kumar1-1/+22
This patch introduce a callback function "get_crc_sources" which will be called during read of control node. It is an optional callback function and if driver implements this callback, driver should return a constant pointer to an array of crc sources list and update count according to the number of source in the list. Changes Since V1: (Daniel) - return const pointer to an array of crc sources list - do validation of sources in CRC-core Changes Since V2: - update commit message - update callback documentation - print one source name per line Signed-off-by: Mahesh Kumar <[email protected]> Cc: [email protected] Cc: Laurent Pinchart <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-08-13drm: crc: Introduce verify_crc_source callbackMahesh Kumar1-0/+8
This patch adds a new callback function "verify_crc_source" which will be used during setting the crc source in control node. This will help in avoiding setting of wrong string for source. Changes since V1: - do not yet verify_crc_source during open. Changes since V1: - improve callback description Signed-off-by: Mahesh Kumar <[email protected]> Cc: [email protected] Cc: Laurent Pinchart <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-07-06drm/crc: Only report a single overflow when a CRC fd is openedMaarten Lankhorst1-1/+8
This reduces the amount of spam when you debug a CRC reading program. Signed-off-by: Maarten Lankhorst <[email protected]> [mlankhorst: Change bool overflow to was_overflow (Ville)] Reviewed-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-02-05drm/crc: Add support for polling on the data fd.Maarten Lankhorst1-0/+19
This will make it possible for userspace to know whether reading will block, without blocking on the fd. This makes it possible to drain all queued CRC's in blocking mode, without having to reopen the fd. Signed-off-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Ville Syrjälä <[email protected]> [mlankhorst: Use POLLIN|POLLRDNORM, based on Ville's suggestion]
2017-09-13drm/atomic: Prepare drm_modeset_lock infrastructure for interruptible ↵Maarten Lankhorst1-1/+1
waiting, v2. When we want to make drm_atomic_commit interruptible, there are a lot of places that call the lock function, which we don't have control over. Rather than trying to convert every single one, it's easier to toggle interruptible waiting per acquire_ctx. If drm_modeset_acquire_init is called with DRM_MODESET_ACQUIRE_INTERRUPTIBLE, then we will perform interruptible waits in drm_modeset_lock and drm_modeset_backoff. Changes since v1: - Fix locking example in drm_modeset_lock.c to be compatible with interruptible waiting (xexaxo) and make it default. Uninterruptible waiting shouldn't happen except in corner cases, but the example will still apply if the flag is removed. - Add drm_modeset_lock_single_interruptible() to documentation. - Fix dead link to removed drm_modeset_lock_interruptible() in drm_modeset_lock(). Signed-off-by: Maarten Lankhorst <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> #v1 Cc: Emil Velikov <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Emil Velikov <[email protected]>
2017-07-17drm/crc: Only open CRC on atomic drivers when the CRTC is active.Maarten Lankhorst1-0/+13
Commit e8fa5671183c ("drm: crc: Wait for a frame before returning from open()") adds a wait for CRC frame, but with the CRTC off this will never be generated. For atomic drivers we know if a CRTC is active through crtc_state->active, so when inactive reject the open with -EIO. Just like with the previous patch changing debugfs opening semantics, this patch has been tested against igt. Signed-off-by: Maarten Lankhorst <[email protected]> Fixes: e8fa5671183c ("drm: crc: Wait for a frame before returning from open()") Testcase: debugfs_test.read_all_entries Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Daniel Vetter <[email protected]>
2017-07-17drm/crc: Handle opening and closing crc betterMaarten Lankhorst1-15/+31
When I was doing a grep . -r /sys/kernel/debug/dri/0 I noticed a WARN appearing when I aborted the grep with ^C. After investigating I've also noticed that the error handling was lacking and there are race conditions involving multiple calls to open/close simultaneously. Fix this by setting the opened flag first and using crc->entries to decide when crc can be collected. Also call unset crc source before cleaning up, this way there is no race with a future open(). This patch has been tested with all the tests in igt with CRC in their name. Signed-off-by: Maarten Lankhorst <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Tomeu Vizoso <[email protected]> [mlankhorst: Add description that this patch has been tested with IGT, based on tomeu's feedback]
2017-04-07Revert "drm: Don't allow interruptions when opening debugfs/crc"Sean Paul1-1/+5
This reverts commit b8dfa821c27046ede9bf8eb14cc8109d379428e9 Author: Chris Wilson <[email protected]> Date: Fri Apr 7 12:17:12 2017 +0100 drm: Don't allow interruptions when opening debugfs/crc It reportedly breaks things, so let's revert now and try again later. Fixes: b8dfa821c270 ("drm: Don't allow interruptions when opening debugfs/crc") Cc: Chris Wilson <[email protected]> Cc: Tomeu Vizoso <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: [email protected] Reported-by: Chris Wilson <[email protected]> Acked-by: Chris Wilson <[email protected]> Acked-by: Daniel Vetter <[email protected]> Signed-off-by: Sean Paul <[email protected]>
2017-04-07drm: Don't allow interruptions when opening debugfs/crcChris Wilson1-5/+1
The code does not like to be interrupted when waiting for the first vblank after opening a debugfs/crc channel, so don't. [66285.716870] WARNING: CPU: 1 PID: 16615 at drivers/gpu/drm/drm_debugfs_crc.c:185 crtc_crc_open+0x1d0/0x1f0 [drm] [66285.716877] Modules linked in: i915 intel_powerclamp crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel cryptd intel_gtt i2c_algo_bit lpc_ich mfd_core drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops prime_numbers drm video button autofs4 sd_mod ahci libahci libata i2c_i801 scsi_mod i2c_designware_platform i2c_designware_core i2c_core [66285.716929] CPU: 1 PID: 16615 Comm: kms_frontbuffer Not tainted 4.11.0-rc5+ #7 [66285.716935] Hardware name: GIGABYTE GB-BXBT-1900/MZBAYAB-00, BIOS F8 03/02/2016 [66285.716941] Call Trace: [66285.716955] dump_stack+0x4d/0x6f [66285.716966] __warn+0xc1/0xe0 [66285.716975] warn_slowpath_null+0x18/0x20 [66285.717004] crtc_crc_open+0x1d0/0x1f0 [drm] [66285.717014] ? wake_atomic_t_function+0x50/0x50 [66285.717024] full_proxy_open+0xf0/0x1b0 [66285.717032] ? full_proxy_release+0x80/0x80 [66285.717042] do_dentry_open.isra.17+0x14b/0x2d0 [66285.717051] vfs_open+0x42/0x60 [66285.717064] path_openat+0x5e7/0x13d0 [66285.717074] ? refcount_dec_and_test+0x11/0x20 [66285.717081] ? down_read+0xd/0x30 [66285.717087] do_filp_open+0x85/0xf0 [66285.717093] ? __vfs_write+0x23/0x120 [66285.717100] ? __alloc_fd+0x3a/0x170 [66285.717107] do_sys_open+0x11e/0x1f0 [66285.717113] ? do_sys_open+0x11e/0x1f0 [66285.717119] SyS_openat+0xf/0x20 [66285.717125] entry_SYSCALL_64_fastpath+0x17/0x98 [66285.717131] RIP: 0033:0x7f5f2235146a [66285.717135] RSP: 002b:00007ffd892e6bc0 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 [66285.717142] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5f2235146a [66285.717147] RDX: 0000000000000000 RSI: 00007ffd892e6c40 RDI: 0000000000000006 [66285.717151] RBP: 00007ffd892e6b20 R08: 0000000000000000 R09: 000000000000000f [66285.717156] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 [66285.717161] R13: 00007ffd892e6b10 R14: 0000000000000004 R15: 00000000007e61f4 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100610 Fixes: e8fa5671183c ("drm: crc: Wait for a frame before returning from open()") Signed-off-by: Chris Wilson <[email protected]> Cc: Tomeu Vizoso <[email protected]> Cc: Daniel Vetter <[email protected]> Reviewed-by: Tomeu Vizoso <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2017-03-24drm: document driver interface for CRC capturingDaniel Vetter1-11/+6
This was missed in Tomeu's patch. Also remove the kerneldoc for the internal function, we don't document that in general. While at it word-smith the docs slightly for more clarity. Cc: Tomeu Vizoso <[email protected]> Reviewed-by: Tomeu Vizoso <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2017-01-06drm: crc: Call wake_up_interruptible() each time there is a new CRC entryBenjamin Gaignard1-0/+2
Each time new data has being added in CRC list inform reader by calling wake_up_interruptible(). This should avoid to do it in all drivers. Signed-off-by: Benjamin Gaignard <[email protected]> Cc: Tomeu Vizoso <[email protected]> Cc: Daniel Vetter <[email protected]> Reviewed-by: Tomeu Vizoso <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2017-01-05drm: crc: Wait for a frame before returning from open()Tomeu Vizoso1-6/+17
Don't return from the open() call on the crc/data file until the HW has produced a first frame, as there's great variability in when the HW is able to do that and userspace shouldn't have to guess when this specific HW is ready to start giving frame CRCs. Signed-off-by: Tomeu Vizoso <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2017-01-05drm: Move locking into drm_debugfs_crtc_crc_addTomeu Vizoso1-2/+7
There's no reason any more for callers of this function to take the lock themselves, so just move the lock to the function to avoid confusion and bugs when more callers are contributed. Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Robert Foss <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2016-10-19drm: fix sparse warnings on undeclared symbols in crc debugfsJani Nikula1-2/+3
Fixes sparse warnings: drivers/gpu/drm/drm_debugfs_crc.c:118:30: warning: symbol 'drm_crtc_crc_control_fops' was not declared. Should it be static? drivers/gpu/drm/drm_debugfs_crc.c:264:30: warning: symbol 'drm_crtc_crc_data_fops' was not declared. Should it be static? drivers/gpu/drm/drm_debugfs_crc.c:281:5: warning: symbol 'drm_debugfs_crtc_crc_add' was not declared. Should it be static? Fixes: 9edbf1fa600a ("drm: Add API for capturing frame CRCs") Cc: Benjamin Gaignard <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Emil Velikov <[email protected]> Cc: Tomeu Vizoso <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2016-10-17drm: Add API for capturing frame CRCsTomeu Vizoso1-0/+351
Adds files and directories to debugfs for controlling and reading frame CRCs, per CRTC: dri/0/crtc-0/crc dri/0/crtc-0/crc/control dri/0/crtc-0/crc/data Drivers can implement the set_crc_source callback() in drm_crtc_funcs to start and stop generating frame CRCs and can add entries to the output by calling drm_crtc_add_crc_entry. v2: - Lots of good fixes suggested by Thierry. - Added documentation. - Changed the debugfs layout. - Moved to allocate the entries circular queue once when frame generation gets enabled for the first time. v3: - Use the control file just to select the source, and start and stop capture when the data file is opened and closed, respectively. - Make variable the number of CRC values per entry, per source. - Allocate entries queue each time we start capturing as now there isn't a fixed number of CRC values per entry. - Store the frame counter in the data file as a 8-digit hex number. - For sources that cannot provide useful frame numbers, place XXXXXXXX in the frame field. v4: - Build only if CONFIG_DEBUG_FS is enabled. - Use memdup_user_nul. - Consolidate calculation of the size of an entry in a helper. - Add 0x prefix to hex numbers in the data file. - Remove unnecessary snprintf and strlen usage in read callback. v5: - Made the crcs array in drm_crtc_crc_entry fixed-size - Lots of other smaller improvements suggested by Emil Velikov v7: - Move definition of drm_debugfs_crtc_crc_add to drm_internal.h v8: - Call debugfs_remove_recursive when we fail to create the minor device v9: - Register the debugfs directory for a crtc from drm_crtc_register_all() v10: - Don't let debugfs failures interrupt CRTC registration (Emil Velikov) v11: - Remove extra brace that broke compilation. Sorry! Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Acked-by: Benjamin Gaignard <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]