From patchwork Tue Jul 28 13:14:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 6884511 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1CDC3C05AC for ; Tue, 28 Jul 2015 13:16:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17A4D206AC for ; Tue, 28 Jul 2015 13:16:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9C749206D2 for ; Tue, 28 Jul 2015 13:16:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D1186E9E2; Tue, 28 Jul 2015 06:16:48 -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 9FAA16E9DF; Tue, 28 Jul 2015 06:16:46 -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 42832964-1500048 for multiple; Tue, 28 Jul 2015 14:14:36 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Tue, 28 Jul 2015 14:14:26 +0100 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Add DRM_NOTICE_IF Date: Tue, 28 Jul 2015 14:14:24 +0100 Message-Id: <1438089264-8482-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 Cc: intel-gfx@lists.freedesktop.org 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.6 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 Styled after WARN_ON/DRM_ERROR_ON, this prints a mild warning message (a KERN_NOTICE for significant but mild events) that allows us to insert interesting events without alarming the user or bug reporting tools. For an example I have changed a DRM_ERROR for being unable to set a performance enhancement in i915. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_lrc.c | 5 ++--- include/drm/drmP.h | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 184d5f2dce21..f62cd78f8691 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -1902,13 +1902,12 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req) if (ret) return ret; - ret = intel_rcs_context_init_mocs(req); /* * Failing to program the MOCS is non-fatal.The system will not * run at peak performance. So generate an error and carry on. */ - if (ret) - DRM_ERROR("MOCS failed to program: expect performance issues.\n"); + DRM_NOTICE_IF(intel_rcs_context_init_mocs(req), + "MOCS failed to program: expect performance issues.\n"); return intel_lr_context_render_state_init(req); } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index b76af322d812..f2d68d185274 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -181,6 +181,26 @@ void drm_err(const char *format, ...); }) /** + * Mild warning on assertion-esque failure. + * + * \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 NOTICE rather than a warning + * and the whole stacktrace. It is only intended for mild issues which + * while significant do not critically impact the user (such as a performance + * issue). + */ +#define DRM_NOTICE_IF(cond, fmt, ...) ({ \ + bool __cond = !!(cond); \ + if (unlikely(__cond)) \ + printk(KERN_NOTICE "[" DRM_NAME ":%s] " fmt, \ + __func__, ##__VA_ARGS__); \ + unlikely(__cond); \ +}) + +/** * Rate limited error output. Like DRM_ERROR() but won't flood the log. * * \param fmt printf() like format string.