From patchwork Thu Jan 14 12:02:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kumar, Shobhit" X-Patchwork-Id: 8031151 Return-Path: X-Original-To: patchwork-intel-gfx@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 B6F5C9F88A for ; Thu, 14 Jan 2016 12:03:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB7DD2042C for ; Thu, 14 Jan 2016 12:03:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DA20720426 for ; Thu, 14 Jan 2016 12:03:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 278278A657; Thu, 14 Jan 2016 04:03:05 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 065978A649 for ; Thu, 14 Jan 2016 04:03:03 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 14 Jan 2016 04:03:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,294,1449561600"; d="scan'208";a="726853645" Received: from skumar40-mobl.iind.intel.com ([10.223.176.41]) by orsmga003.jf.intel.com with ESMTP; 14 Jan 2016 04:03:02 -0800 From: Shobhit Kumar To: intel-gfx@lists.freedesktop.org Date: Thu, 14 Jan 2016 17:32:44 +0530 Message-Id: <1452772968-24772-4-git-send-email-shobhit.kumar@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1452772968-24772-1-git-send-email-shobhit.kumar@intel.com> References: <1452772968-24772-1-git-send-email-shobhit.kumar@intel.com> Subject: [Intel-gfx] [PATCH 3/7] drm/i915/skl+: calculate ddb minimum allocation 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-Spam-Status: No, score=-4.2 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 From: "Kumar, Mahesh" don't always use 8 ddb as minimum, instead calculate using proper algorithm. Signed-off-by: Kumar, Mahesh --- drivers/gpu/drm/i915/intel_pm.c | 57 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index d33c4ff..64b39ec 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -2994,6 +2994,59 @@ skl_get_total_relative_data_rate(const struct intel_crtc_state *cstate) return total_data_rate; } +static uint16_t +skl_ddb_min_alloc(const struct intel_crtc *crtc, + const struct drm_plane *plane, int y) +{ + struct drm_framebuffer *fb = plane->state->fb; + struct intel_plane_state *pstate = to_intel_plane_state(plane->state); + uint16_t min_alloc; + uint32_t src_w, src_h; + + /* For packed formats, no y-plane, return 0 */ + if (y && !(fb->pixel_format == DRM_FORMAT_NV12)) + return 0; + + if (drm_rect_width(&pstate->src)) { + src_w = drm_rect_width(&pstate->src) >> 16; + src_h = drm_rect_height(&pstate->src) >> 16; + } else { + src_w = crtc->config->pipe_src_w; + src_h = crtc->config->pipe_src_h; + } + + if (intel_rotation_90_or_270(plane->state->rotation)) + swap(src_w, src_h); + + if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || + fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) { + uint32_t min_scanlines = 8; + uint8_t bytes_per_pixel = + y ? drm_format_plane_cpp(fb->pixel_format, 1) : + drm_format_plane_cpp(fb->pixel_format, 0); + + if (intel_rotation_90_or_270(plane->state->rotation)) { + switch (bytes_per_pixel) { + case 1: + min_scanlines = 32; + break; + case 2: + min_scanlines = 16; + break; + case 8: + WARN(1, "Unsupported pixel depth for rotation"); + } + } + min_alloc = DIV_ROUND_UP((4 * src_w / (y ? 1 : 2) * + bytes_per_pixel), 512) * min_scanlines/4 + 3; + } else { + min_alloc = 8; + } + + return min_alloc; +} + + static void skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, struct skl_ddb_allocation *ddb /* out */) @@ -3038,9 +3091,9 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate, if (plane->type == DRM_PLANE_TYPE_CURSOR) continue; - minimum[id] = 8; + minimum[id] = skl_ddb_min_alloc(intel_crtc, plane, 0); alloc_size -= minimum[id]; - y_minimum[id] = (fb->pixel_format == DRM_FORMAT_NV12) ? 8 : 0; + y_minimum[id] = skl_ddb_min_alloc(intel_crtc, plane, 1); alloc_size -= y_minimum[id]; }