From patchwork Mon Jul 27 09:17:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 6870251 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BD2409F358 for ; Mon, 27 Jul 2015 09:20:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E98C6206A5 for ; Mon, 27 Jul 2015 09:19:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DDC602068A for ; Mon, 27 Jul 2015 09:19:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D259C6E408; Mon, 27 Jul 2015 02:19:57 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id EE9AC6E408; Mon, 27 Jul 2015 02:19:55 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 42763692-1500048 for multiple; Mon, 27 Jul 2015 10:17:36 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 27 Jul 2015 10:17:30 +0100 From: Chris Wilson To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH 1/2] drm: Add DRM_ERROR_ON replacement for WARN_ON Date: Mon, 27 Jul 2015 10:17:27 +0100 Message-Id: <1437988648-3829-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.4.6 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 i915 has a habit of using WARN_ON and spewing stacktraces into the kernel logs and beyond. For the majority of cases, we do not care about the stacktrace, we know precisely where and when the error occurs so hunting down the exact instance is not a concern, we only need the content of the error. Signed-off-by: Chris Wilson --- include/drm/drmP.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 4717449d6aa9..b76af322d812 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -164,6 +164,23 @@ void drm_err(const char *format, ...); drm_err(fmt, ##__VA_ARGS__) /** + * Assertion-esque error output. + * + * \param cond condition on which to *fail* + * \param fmt printf() like format string. + * \param arg arguments + * + * This is similar to WARN_ON but only prints a DRM_ERROR rather than a whole + * stacktrace. + */ +#define DRM_ERROR_ON(cond, fmt, ...) ({ \ + bool __cond = !!(cond); \ + if (unlikely(__cond)) \ + drm_err("assertion failed, %s: " fmt, #cond, ##__VA_ARGS__); \ + unlikely(__cond); \ +}) + +/** * Rate limited error output. Like DRM_ERROR() but won't flood the log. * * \param fmt printf() like format string.