From patchwork Thu Nov 21 19:29:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 3220461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A2B109F26C for ; Thu, 21 Nov 2013 19:30:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 154772071C for ; Thu, 21 Nov 2013 19:30:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EAD7720718 for ; Thu, 21 Nov 2013 19:30:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C882FCC4E; Thu, 21 Nov 2013 11:30:02 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f169.google.com (mail-qc0-f169.google.com [209.85.216.169]) by gabe.freedesktop.org (Postfix) with ESMTP id 81E1AFCD83 for ; Thu, 21 Nov 2013 11:29:59 -0800 (PST) Received: by mail-qc0-f169.google.com with SMTP id u18so159734qcx.14 for ; Thu, 21 Nov 2013 11:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=7BG/O8RZcAfMUibwRtbkyP8MiowmkxAwZnuuyw1ZzjQ=; b=uNPwYX869YCdNDWgurfyQW9GSxYxAMmgz3bQaI1eV/CPzmRM6ubQyJ9dKhKUu2yrI7 eEKdZOyvg7yUWomxZpNQtCElCl9G0Eefqp8ruLWeDLM7H5ktrT7Xykvc5Mu+s8Z++3Qm zH6gaEahGolrCI2CXWeZv6DrLTPF/O48I37jQn2VIh8EQqJvDySdHlmQG559Px0wyDXZ gcZ8Zwhar3jbSmOy3v0ReQKh/x3v+ruOv5q0hBcQdqUtl7CYqjl0uDAr7dGsOwsVyVe0 8SPvWhuletLOF3ivmgCfqpLf04CGHC/NpHGJsC/K2XgnZ3LQrRbOoEcn/jly/fwVBa2F qssw== X-Received: by 10.49.28.226 with SMTP id e2mr14360105qeh.80.1385062198878; Thu, 21 Nov 2013 11:29:58 -0800 (PST) Received: from localhost (nat-pool-bos-t.redhat.com. [66.187.233.206]) by mx.google.com with ESMTPSA id f10sm29149617qej.1.2013.11.21.11.29.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Nov 2013 11:29:58 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: add DRM_ERROR_RATELIMITED Date: Thu, 21 Nov 2013 14:29:51 -0500 Message-Id: <1385062191-30854-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.4.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For error traces in situations that can run away, it is nice to have a rate-limited version of DRM_ERROR() to avoid massing log flooding. Signed-off-by: Rob Clark Reviewed-by: Thierry Reding --- include/drm/drmP.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 0a372b2..dd6699e 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -56,6 +56,7 @@ #include #include #include +#include #if defined(__alpha__) || defined(__powerpc__) #include /* For pte_wrprotect */ #endif @@ -180,6 +181,22 @@ int drm_err(const char *func, const char *format, ...); #define DRM_ERROR(fmt, ...) \ drm_err(__func__, fmt, ##__VA_ARGS__) +/** + * Rate limited error output. Like DRM_ERROR() but won't flood the log. + * + * \param fmt printf() like format string. + * \param arg arguments + */ +#define DRM_ERROR_RATELIMITED(fmt, ...) \ +({ \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (__ratelimit(&_rs)) \ + drm_err(__func__, fmt, ##__VA_ARGS__); \ +}) + #define DRM_INFO(fmt, ...) \ printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)