Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/crc: Only report a single overflow when a CRC fd is opened

This reduces the amount of spam when you debug a CRC reading
program.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
[mlankhorst: Change bool overflow to was_overflow (Ville)]
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180418125121.72081-1-maarten.lankhorst@linux.intel.com

+10 -2
+8 -1
drivers/gpu/drm/drm_debugfs_crc.c
··· 139 139 static void crtc_crc_cleanup(struct drm_crtc_crc *crc) 140 140 { 141 141 kfree(crc->entries); 142 + crc->overflow = false; 142 143 crc->entries = NULL; 143 144 crc->head = 0; 144 145 crc->tail = 0; ··· 392 391 tail = crc->tail; 393 392 394 393 if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) { 394 + bool was_overflow = crc->overflow; 395 + 396 + crc->overflow = true; 395 397 spin_unlock(&crc->lock); 396 - DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n"); 398 + 399 + if (!was_overflow) 400 + DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n"); 401 + 397 402 return -ENOBUFS; 398 403 } 399 404
+2 -1
include/drm/drm_debugfs_crc.h
··· 43 43 * @lock: protects the fields in this struct 44 44 * @source: name of the currently configured source of CRCs 45 45 * @opened: whether userspace has opened the data file for reading 46 + * @overflow: whether an overflow occured. 46 47 * @entries: array of entries, with size of %DRM_CRC_ENTRIES_NR 47 48 * @head: head of circular queue 48 49 * @tail: tail of circular queue ··· 53 52 struct drm_crtc_crc { 54 53 spinlock_t lock; 55 54 const char *source; 56 - bool opened; 55 + bool opened, overflow; 57 56 struct drm_crtc_crc_entry *entries; 58 57 int head, tail; 59 58 size_t values_cnt;