From patchwork Fri Oct 7 13:34:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9366113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7541A60487 for ; Fri, 7 Oct 2016 13:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6633C295AA for ; Fri, 7 Oct 2016 13:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AA60295F6; Fri, 7 Oct 2016 13:34:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF4BA295AA for ; Fri, 7 Oct 2016 13:34:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A22776EBA0; Fri, 7 Oct 2016 13:34:37 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA5266EB9A for ; Fri, 7 Oct 2016 13:34:30 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id f193so3026475wmg.2 for ; Fri, 07 Oct 2016 06:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2DLoGifcC6KMqL2ciYjCQn2BXcgodGkIn/FnbEkaRKc=; b=iqUnqe8UlXcHotR3xpEm14CsTdi4LiiW/GwfuCrSj8STee/bQAmKxonT4NNn+Xfakw 9Mi0CcgmxO/CDiOOCZfbcLqYrXmkL5zY0FtCsP0RDLUJ09neBG5TXlwY7T9ILNCgJkji FUUCqNH4+N9ZTT6PjdIrhUg5W0ijzKgIUN9dvkyW66/zIPrLzRJA8iMmE9u23E+f68f1 zU6grbuvYvktMdTl1/SRlsiggR9RtSpB+io9a5pLBjp1Am/pR7h/tDwCH7Q0HdSgsQJQ IEzkmQLR+0c1Xnup64wye/Np5YU2UBAdVwKZp5d19xZrlFvQa8a1EMq+OE61IQIK4TwE 8YHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2DLoGifcC6KMqL2ciYjCQn2BXcgodGkIn/FnbEkaRKc=; b=h8KtD+ovV1JzzGAHD+xpy6YGgORzcyKbRSfjEb3YXZzeeDSxx+FKq7/3ZIcJ2mx32g /vbwAcrwonwQrwvTauTWwFY+p0/lXLIgtDKWJs6hTxTRHDWoss1vqwGXfcyLjtAF/jLw Mnh0Ls6lI7aCNoW1U0+NrHatn3dMx7GL9NZ34zHp33kW19ZUlFhQvt3XhcWEgf4SF/mk gMd2t0PaqYtEum1i3pMBIe0nFMsXyyxFDdiaWd14+LNq5WCNTy/tE2fYZvZpNFh6yrPX TaEJYtj4Udm2M0J0x1S8+2F2MS+2ToKzjBdw+Up3MiA1BYX5TFZGb9NS7UPYIwUxfzBq qgCA== X-Gm-Message-State: AA6/9RmdNLGXz6iJrXNappR8pK8EqxNpRaZH6kcG2citNiYVFo0sVKdunKJC5pgAA8uOEw== X-Received: by 10.28.50.199 with SMTP id y190mr30747839wmy.61.1475847269132; Fri, 07 Oct 2016 06:34:29 -0700 (PDT) Received: from localhost.localdomain ([2a02:c7d:9b6d:e300:916a:6cab:ac67:71c2]) by smtp.gmail.com with ESMTPSA id pj2sm19795081wjb.8.2016.10.07.06.34.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Oct 2016 06:34:28 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 7 Oct 2016 14:34:12 +0100 Message-Id: <1475847252-31580-10-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475847252-31580-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1475847252-31580-1-git-send-email-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 9/9] drm/i915: Tidy watermark computation local types X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Convert to from signed to unsigned and from longs to integers where appropriate. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/intel_pm.c | 60 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 308edc4378fa..1203a7a80e9e 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -711,14 +711,14 @@ static bool g4x_compute_wm0(struct drm_device *dev, unsigned int display_latency_ns, const struct intel_watermark_params *cursor, unsigned int cursor_latency_ns, - int *plane_wm, - int *cursor_wm) + unsigned int *plane_wm, + unsigned int *cursor_wm) { struct drm_crtc *crtc; const struct drm_display_mode *adjusted_mode; int htotal, hdisplay, clock, cpp; - int line_time_us, line_count; - int entries, tlb_miss; + unsigned int line_time_us, line_count, entries; + int tlb_miss; crtc = intel_get_crtc_for_plane(dev, plane); if (!intel_crtc_active(crtc)) { @@ -740,7 +740,7 @@ static bool g4x_compute_wm0(struct drm_device *dev, entries += tlb_miss; entries = DIV_ROUND_UP(entries, display->cacheline_size); *plane_wm = entries + display->guard_size; - if (*plane_wm > (int)display->max_wm) + if (*plane_wm > display->max_wm) *plane_wm = display->max_wm; /* Use the large buffer method to calculate cursor watermark */ @@ -752,8 +752,8 @@ static bool g4x_compute_wm0(struct drm_device *dev, entries += tlb_miss; entries = DIV_ROUND_UP(entries, cursor->cacheline_size); *cursor_wm = entries + cursor->guard_size; - if (*cursor_wm > (int)cursor->max_wm) - *cursor_wm = (int)cursor->max_wm; + if (*cursor_wm > cursor->max_wm) + *cursor_wm = cursor->max_wm; return true; } @@ -766,21 +766,21 @@ static bool g4x_compute_wm0(struct drm_device *dev, * must be disabled. */ static bool g4x_check_srwm(struct drm_device *dev, - int display_wm, int cursor_wm, + unsigned int display_wm, unsigned int cursor_wm, const struct intel_watermark_params *display, const struct intel_watermark_params *cursor) { - DRM_DEBUG_KMS("SR watermark: display plane %d, cursor %d\n", + DRM_DEBUG_KMS("SR watermark: display plane %u, cursor %u\n", display_wm, cursor_wm); if (display_wm > display->max_wm) { - DRM_DEBUG_KMS("display watermark is too large(%d/%u), disabling\n", + DRM_DEBUG_KMS("display watermark is too large(%u/%u), disabling\n", display_wm, display->max_wm); return false; } if (cursor_wm > cursor->max_wm) { - DRM_DEBUG_KMS("cursor watermark is too large(%d/%u), disabling\n", + DRM_DEBUG_KMS("cursor watermark is too large(%u/%u), disabling\n", cursor_wm, cursor->max_wm); return false; } @@ -798,15 +798,13 @@ static bool g4x_compute_srwm(struct drm_device *dev, unsigned int latency_ns, const struct intel_watermark_params *display, const struct intel_watermark_params *cursor, - int *display_wm, int *cursor_wm) + unsigned int *display_wm, unsigned int *cursor_wm) { struct drm_crtc *crtc; const struct drm_display_mode *adjusted_mode; int hdisplay, htotal, cpp, clock; - unsigned long line_time_us; - int line_count, line_size; - int small, large; - int entries; + unsigned int line_time_us, line_count, line_size; + unsigned int small, large, entries; if (!latency_ns) { *display_wm = *cursor_wm = 0; @@ -836,9 +834,7 @@ static bool g4x_compute_srwm(struct drm_device *dev, entries = DIV_ROUND_UP(entries, cursor->cacheline_size); *cursor_wm = entries + cursor->guard_size; - return g4x_check_srwm(dev, - *display_wm, *cursor_wm, - display, cursor); + return g4x_check_srwm(dev, *display_wm, *cursor_wm, display, cursor); } #define FW_WM_VLV(value, plane) \ @@ -1386,8 +1382,9 @@ static void g4x_update_wm(struct drm_crtc *crtc) struct drm_device *dev = crtc->dev; static const unsigned int sr_latency_ns = 12000; struct drm_i915_private *dev_priv = to_i915(dev); - int planea_wm, planeb_wm, cursora_wm, cursorb_wm; - int plane_sr, cursor_sr; + unsigned int planea_wm, planeb_wm; + unsigned int cursora_wm, cursorb_wm; + unsigned int plane_sr, cursor_sr; unsigned int enabled = 0; bool cxsr_enabled; @@ -1416,8 +1413,8 @@ static void g4x_update_wm(struct drm_crtc *crtc) plane_sr = cursor_sr = 0; } - DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%d, cursor=%d, " - "B: plane=%d, cursor=%d, SR: plane=%d, cursor=%d\n", + DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%u, cursor=%u, " + "B: plane=%u, cursor=%u, SR: plane=%u, cursor=%u\n", planea_wm, cursora_wm, planeb_wm, cursorb_wm, plane_sr, cursor_sr); @@ -1458,8 +1455,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc) int htotal = adjusted_mode->crtc_htotal; int hdisplay = to_intel_crtc(crtc)->config->pipe_src_w; int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); - unsigned long line_time_us; - int entries; + unsigned int line_time_us, entries; line_time_us = max(htotal * 1000 / clock, 1); @@ -1518,9 +1514,10 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) struct drm_device *dev = unused_crtc->dev; struct drm_i915_private *dev_priv = to_i915(dev); const struct intel_watermark_params *wm_info; - uint32_t fwater_lo; - uint32_t fwater_hi; - int cwm, srwm = 1; + u32 fwater_lo; + u32 fwater_hi; + unsigned int cwm; + int srwm = 1; unsigned int fifo_size, planea_wm, planeb_wm; struct drm_crtc *crtc, *enabled = NULL; @@ -1604,8 +1601,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) int htotal = adjusted_mode->crtc_htotal; int hdisplay = to_intel_crtc(enabled)->config->pipe_src_w; int cpp = drm_format_plane_cpp(enabled->primary->state->fb->pixel_format, 0); - unsigned long line_time_us; - int entries; + unsigned int line_time_us, entries; if (IS_I915GM(dev) || IS_I945GM(dev)) cpp = 4; @@ -1616,7 +1612,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * cpp * hdisplay; entries = DIV_ROUND_UP(entries, wm_info->cacheline_size); - DRM_DEBUG_KMS("self-refresh entries: %d\n", entries); + DRM_DEBUG_KMS("self-refresh entries: %u\n", entries); srwm = wm_info->fifo_size - entries; if (srwm < 0) srwm = 1; @@ -1628,7 +1624,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) I915_WRITE(FW_BLC_SELF, srwm & 0x3f); } - DRM_DEBUG_KMS("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n", + DRM_DEBUG_KMS("Setting FIFO watermarks - A: %u, B: %u, C: %u, SR %d\n", planea_wm, planeb_wm, cwm, srwm); fwater_lo = ((planeb_wm & 0x3f) << 16) | (planea_wm & 0x3f);