From patchwork Thu Mar 25 21:47:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A98C433DB for ; Thu, 25 Mar 2021 21:48:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B15B619BA for ; Thu, 25 Mar 2021 21:48:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B15B619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD0C16EE4E; Thu, 25 Mar 2021 21:48:14 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FB336EE4E for ; Thu, 25 Mar 2021 21:48:13 +0000 (UTC) IronPort-SDR: 9kN3HcM6DnTI/sxqHcBTdzlZXVf77XZ8Svh8RJOH3fdye6uOMxp7qH+LLOLC7rqlJTozrmt1+j 817RibCtq5Gw== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171004976" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171004976" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:13 -0700 IronPort-SDR: 877Ho/7u3eZjZe3tcKEWOFcWea80h8oa0TnxPiuaJpUxIYW/dtp1phFUwGnAct05IgGnbbic63 XmC/IfS1N7Dw== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235613" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:12 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:44 +0200 Message-Id: <20210325214808.2071517-2-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 01/25] drm/i915: Fix rotation setup during plane HW readout X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The HW plane state is cleared and inited after we store the rotation to it, so store it instead to the uapi state to match what we do with all other plane state until intel_plane_copy_uapi_to_hw_state() is called. Rotation for initial FBs is not supported atm, but let's still fix the plane state setup here. While at it remove the redundant intel_state->uapi.src/dst init, which will be done in intel_plane_copy_uapi_to_hw_state(). v2: Remove redundant intel_state->uapi.src/dst init. (Ville) Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_display.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 17490d29dc133..e345e645a156e 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -2500,11 +2500,11 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, return; valid_fb: - intel_state->hw.rotation = plane_config->rotation; + plane_state->rotation = plane_config->rotation; intel_fill_fb_ggtt_view(&intel_state->view, fb, - intel_state->hw.rotation); + plane_state->rotation); intel_state->color_plane[0].stride = - intel_fb_pitch(fb, 0, intel_state->hw.rotation); + intel_fb_pitch(fb, 0, plane_state->rotation); __i915_vma_pin(vma); intel_state->vma = i915_vma_get(vma); @@ -2522,9 +2522,6 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, plane_state->crtc_w = fb->width; plane_state->crtc_h = fb->height; - intel_state->uapi.src = drm_plane_state_src(plane_state); - intel_state->uapi.dst = drm_plane_state_dest(plane_state); - if (plane_config->tiling) dev_priv->preserve_bios_swizzle = true; From patchwork Thu Mar 25 21:47:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33182C433C1 for ; Thu, 25 Mar 2021 21:48:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7FB1619BA for ; Thu, 25 Mar 2021 21:48:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7FB1619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 906C56EE4F; Thu, 25 Mar 2021 21:48:17 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA3036EE4F for ; Thu, 25 Mar 2021 21:48:14 +0000 (UTC) IronPort-SDR: en2e/l1eUxEnCVDU6+7LPIW9yEVUeKLh0g+22X8kc2IjiUI++6odKLf3tFirjufVxV0SVfj7V0 bLXWRvOCbwBQ== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171004980" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171004980" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:14 -0700 IronPort-SDR: gbxXnVSJpny2MIbVed+aiqtdK5NgOvnXR5V0ynjH/vq4rwZT+WGMvBGlGWwxLjnPgpPeD151Tt HVJ3+XNVVi6Q== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235622" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:13 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:45 +0200 Message-Id: <20210325214808.2071517-3-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 02/25] drm/i915/selftest: Fix error handling in igt_vma_remapped_gtt() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" An inner scope version of err shadows the variable in the outer scope, and err doesn't get set after a failure, fix these. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/selftests/i915_vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 1b6125e4c1ac6..35481cfbb6353 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -890,7 +890,6 @@ static int igt_vma_remapped_gtt(void *arg) struct i915_vma *vma; u32 __iomem *map; unsigned int x, y; - int err; i915_gem_object_lock(obj, NULL); err = i915_gem_object_set_to_gtt_domain(obj, true); @@ -962,6 +961,7 @@ static int igt_vma_remapped_gtt(void *arg) *t == I915_GGTT_VIEW_ROTATED ? "Rotated" : "Remapped", val, exp); i915_vma_unpin_iomap(vma); + err = -EINVAL; goto out; } } From patchwork Thu Mar 25 21:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6D7FC433E1 for ; Thu, 25 Mar 2021 21:48:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A297619EE for ; Thu, 25 Mar 2021 21:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A297619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0C206EE51; Thu, 25 Mar 2021 21:48:17 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A84F6EE4F for ; Thu, 25 Mar 2021 21:48:16 +0000 (UTC) IronPort-SDR: 5D+7xlgvsLkRwDbB44HDj/RphsNLn4HoXtSLRPwYxaF/0GTKXQayssH/GzOHi/GT7b7IzmAueW MZjIiamtDGyg== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171004992" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171004992" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:15 -0700 IronPort-SDR: ZyFcDM7KOxGeIOetiHByeZV9c6Ie/RAujjKLHJm6C4tiiLo2l87+UI+r5/PzRH6Mdq6FYdPOZd R81i/qbb9pKg== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235632" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:14 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:46 +0200 Message-Id: <20210325214808.2071517-4-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 03/25] drm/i915/selftest: Fix debug message in igt_vma_remapped_gtt() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The expected/found values were swapped in a debug message, fix this up. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/selftests/i915_vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 35481cfbb6353..23f6a212a391d 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -959,7 +959,7 @@ static int igt_vma_remapped_gtt(void *arg) if (val != exp) { pr_err("%s VMA write test failed, expected 0x%x, found 0x%x\n", *t == I915_GGTT_VIEW_ROTATED ? "Rotated" : "Remapped", - val, exp); + exp, val); i915_vma_unpin_iomap(vma); err = -EINVAL; goto out; From patchwork Thu Mar 25 21:47:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 143CFC433DB for ; Thu, 25 Mar 2021 21:48:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC9B9619BA for ; Thu, 25 Mar 2021 21:48:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC9B9619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 819AC6EE55; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5240F6EE4F for ; Thu, 25 Mar 2021 21:48:17 +0000 (UTC) IronPort-SDR: D4hxxLyK9QVNgeBn4Wln2EoPR/QCBO4QC3AqAdbl48k9KJKf05LcwFOieb9LXda8YyHaX7Tpps ZIRavrNPrcQA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171004998" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171004998" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:17 -0700 IronPort-SDR: drmvdQdDrxpypVDESURJ/x8oFPsq3msKlIN8tlRlD2dFabUSjiBJdRJZ3Y9IX6eyK56yOyd+KR EoY3ZFVrdRDQ== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235638" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:16 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:47 +0200 Message-Id: <20210325214808.2071517-5-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 04/25] drm/i915: Make sure i915_ggtt_view is inited when creating an FB X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This probably doesn't cause an issue, since the code checks the view type dependent size of the views before comparing them, but let's follow the practice to bzero the whole struct when initializing it. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_display.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index e345e645a156e..c06f51cf3d02d 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -1005,6 +1005,8 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, const struct drm_framebuffer *fb, unsigned int rotation) { + memset(view, 0, sizeof(*view)); + view->type = I915_GGTT_VIEW_NORMAL; if (drm_rotation_90_or_270(rotation)) { view->type = I915_GGTT_VIEW_ROTATED; From patchwork Thu Mar 25 21:47:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3781C433E1 for ; Thu, 25 Mar 2021 21:48:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97DD1619EE for ; Thu, 25 Mar 2021 21:48:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97DD1619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE26B6EE56; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A9116EE53 for ; Thu, 25 Mar 2021 21:48:18 +0000 (UTC) IronPort-SDR: BgTMHyZr/gvrXS8VHlnZBVdigEiYxkbBVt47BdycsTrUXaDLtJ34xtd8PtKuNV9+KdkB9wOK3O DWym669cyVzg== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005002" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005002" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:18 -0700 IronPort-SDR: vw/XVETQm5s3OQn4RmCIdNmoZWyej9poE71DI7d3BYqNI1VVvpAxsZ+0Im1whvtu7WDMyAsDfi lH6s+ClUJyHQ== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235640" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:17 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:48 +0200 Message-Id: <20210325214808.2071517-6-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 05/25] drm/i915/selftest: Make sure to init i915_ggtt_view in igt_vma_rotate_remap() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This probably doesn't cause an issue, since the code checks the view type dependent size of the views before comparing them, but let's follow the practice to bzero the whole struct when initializing it. v2: Use {} instead of { } struct intializer. (Ville) Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/selftests/i915_vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 23f6a212a391d..9dd6799105e66 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -515,7 +515,7 @@ static int igt_vma_rotate_remap(void *arg) for (t = types; *t; t++) { for (a = planes; a->width; a++) { for (b = planes + ARRAY_SIZE(planes); b-- != planes; ) { - struct i915_ggtt_view view; + struct i915_ggtt_view view = {}; unsigned int n, max_offset; max_offset = max(a->stride * a->height, From patchwork Thu Mar 25 21:47:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5929C433E2 for ; Thu, 25 Mar 2021 21:48:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C078619EE for ; Thu, 25 Mar 2021 21:48:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C078619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B7736EE54; Thu, 25 Mar 2021 21:48:23 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id D583E6EE53 for ; Thu, 25 Mar 2021 21:48:19 +0000 (UTC) IronPort-SDR: Kqp7GvaS/9sChbv2/NH7Me6DWI+Zbn79My2nRjx2wwiUz5gGVNU8ht3BLPLz1noa1lUPfanRBV IKE97GVMrfvA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005011" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005011" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:19 -0700 IronPort-SDR: hED93JAJ6g5YMbCdPoiVUsZt8aOU2jkZOu0YJSKoXcDXOPojff7YujrCPuIR1aG/P+q3Mrv9EA QORGrPBNJT7g== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235643" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:18 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:49 +0200 Message-Id: <20210325214808.2071517-7-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 06/25] drm/i915/intel_fb: Pull FB plane functions from intel_display_types.h X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Start collecting all the FB plane related functions into a new intel_fb.c file. v2: Drop display/ part of header includes. (Ville) Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/display/intel_display.c | 1 + .../drm/i915/display/intel_display_types.h | 19 ------------- drivers/gpu/drm/i915/display/intel_fb.c | 28 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_fb.h | 17 +++++++++++ .../drm/i915/display/skl_universal_plane.c | 1 + 6 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_fb.c create mode 100644 drivers/gpu/drm/i915/display/intel_fb.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 14f1ab399ad08..fcaadd52813e3 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -208,6 +208,7 @@ i915-y += \ display/intel_dpll.o \ display/intel_dpll_mgr.o \ display/intel_dsb.o \ + display/intel_fb.o \ display/intel_fbc.o \ display/intel_fdi.o \ display/intel_fifo_underrun.o \ diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index c06f51cf3d02d..d8770e471dcc4 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -54,6 +54,7 @@ #include "display/intel_dpll_mgr.h" #include "display/intel_dsi.h" #include "display/intel_dvo.h" +#include "display/intel_fb.h" #include "display/intel_gmbus.h" #include "display/intel_hdmi.h" #include "display/intel_lvds.h" diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 946e030313a86..80983cfe9d3b0 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1995,14 +1995,6 @@ static inline bool is_ccs_modifier(u64 modifier) modifier == I915_FORMAT_MOD_Yf_TILED_CCS; } -static inline bool is_ccs_plane(const struct drm_framebuffer *fb, int plane) -{ - if (!is_ccs_modifier(fb->modifier)) - return false; - - return plane >= fb->format->num_planes / 2; -} - static inline bool is_gen12_ccs_modifier(u64 modifier) { return modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS || @@ -2010,15 +2002,4 @@ static inline bool is_gen12_ccs_modifier(u64 modifier) modifier == I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS; } -static inline bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane) -{ - return is_gen12_ccs_modifier(fb->modifier) && is_ccs_plane(fb, plane); -} - -static inline bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) -{ - return fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC && - plane == 2; -} - #endif /* __INTEL_DISPLAY_TYPES_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c new file mode 100644 index 0000000000000..ff9094793ee8e --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2021 Intel Corporation + */ + +#include + +#include "intel_display_types.h" +#include "intel_fb.h" + +bool is_ccs_plane(const struct drm_framebuffer *fb, int plane) +{ + if (!is_ccs_modifier(fb->modifier)) + return false; + + return plane >= fb->format->num_planes / 2; +} + +bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane) +{ + return is_gen12_ccs_modifier(fb->modifier) && is_ccs_plane(fb, plane); +} + +bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) +{ + return fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC && + plane == 2; +} diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h new file mode 100644 index 0000000000000..64e6a25213203 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2020-2021 Intel Corporation + */ + +#ifndef __INTEL_FB_H__ +#define __INTEL_FB_H__ + +#include + +struct drm_framebuffer; + +bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); +bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); +bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); + +#endif /* __INTEL_FB_H__ */ diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index c6d7b6c054b56..94e95bf14e889 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -11,6 +11,7 @@ #include "i915_drv.h" #include "intel_atomic_plane.h" #include "intel_display_types.h" +#include "intel_fb.h" #include "intel_pm.h" #include "intel_psr.h" #include "intel_sprite.h" From patchwork Thu Mar 25 21:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCA95C433C1 for ; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92225619EE for ; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92225619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21D346EE53; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12C156EE53 for ; Thu, 25 Mar 2021 21:48:21 +0000 (UTC) IronPort-SDR: 2bFq3y/tEgV0moR++BcDwaKrWFnShI5HH4f90txteyhBn4ncBCDvjkONdoYiV4PT6sHZPipNK1 vyVkp9l6BpmA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005018" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005018" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:20 -0700 IronPort-SDR: JCnWgyWNYbqyksZ1ZqjKyhF0vTdpq62C6/4YK5M43Cob4bMJnE6Vbd12tLNDHsGU/RpT29wXTP e0LDuT1xQGMA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235645" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:19 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:50 +0200 Message-Id: <20210325214808.2071517-8-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 07/25] drm/i915/intel_fb: Pull FB plane functions from skl_universal_plane.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move the FB plane related functions from skl_universal_plane.c to intel_fb.c. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 32 +++++++++++++++++ drivers/gpu/drm/i915/display/intel_fb.h | 4 +++ .../drm/i915/display/skl_universal_plane.c | 34 ------------------- .../drm/i915/display/skl_universal_plane.h | 2 -- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index ff9094793ee8e..40d56eb1914ee 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -26,3 +26,35 @@ bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) return fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC && plane == 2; } + +int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane) +{ + drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || + (main_plane && main_plane >= fb->format->num_planes / 2)); + + return fb->format->num_planes / 2 + main_plane; +} + +int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane) +{ + drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || + ccs_plane < fb->format->num_planes / 2); + + if (is_gen12_ccs_cc_plane(fb, ccs_plane)) + return 0; + + return ccs_plane - fb->format->num_planes / 2; +} + +int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) +{ + struct drm_i915_private *i915 = to_i915(fb->dev); + + if (is_ccs_modifier(fb->modifier)) + return main_to_ccs_plane(fb, main_plane); + else if (DISPLAY_VER(i915) < 11 && + intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier)) + return 1; + else + return 0; +} diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 64e6a25213203..3cde53c75cb35 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -14,4 +14,8 @@ bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); +int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); +int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); +int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); + #endif /* __INTEL_FB_H__ */ diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 94e95bf14e889..5b0f8e5302461 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -915,40 +915,6 @@ static u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, return plane_color_ctl; } -static int -main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane) -{ - drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || - (main_plane && main_plane >= fb->format->num_planes / 2)); - - return fb->format->num_planes / 2 + main_plane; -} - -int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane) -{ - drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || - ccs_plane < fb->format->num_planes / 2); - - if (is_gen12_ccs_cc_plane(fb, ccs_plane)) - return 0; - - return ccs_plane - fb->format->num_planes / 2; -} - -static int -skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) -{ - struct drm_i915_private *i915 = to_i915(fb->dev); - - if (is_ccs_modifier(fb->modifier)) - return main_to_ccs_plane(fb, main_plane); - else if (DISPLAY_VER(i915) < 11 && - intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier)) - return 1; - else - return 0; -} - static void skl_program_plane(struct intel_plane *plane, const struct intel_crtc_state *crtc_state, diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.h b/drivers/gpu/drm/i915/display/skl_universal_plane.h index 8182666536308..351040b64dc74 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.h +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.h @@ -8,7 +8,6 @@ #include -struct drm_framebuffer; struct drm_i915_private; struct intel_crtc; struct intel_initial_plane_config; @@ -26,7 +25,6 @@ void skl_get_initial_plane_config(struct intel_crtc *crtc, int skl_format_to_fourcc(int format, bool rgb_order, bool alpha); -int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); int skl_calc_main_surface_offset(const struct intel_plane_state *plane_state, int *x, int *y, u32 *offset); From patchwork Thu Mar 25 21:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC11C433DB for ; Thu, 25 Mar 2021 21:48:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 965C7619EE for ; Thu, 25 Mar 2021 21:48:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 965C7619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 321C96EE5C; Thu, 25 Mar 2021 21:48:33 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FA116EE54 for ; Thu, 25 Mar 2021 21:48:22 +0000 (UTC) IronPort-SDR: /+onVikERegniFku/tIZAN38a3B8tTl8wf0XZcLZ0eFrglNXUBbnXIeaRn8WocLPbV+RN3dCUb ZbzYF4OrTVRQ== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005027" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005027" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:21 -0700 IronPort-SDR: POrNbVDUVYSGlNChTz6gt92QrqIXV5ZHQaIo7+17D+0YR8QywHKEKN64mxZtpAkeZ6B5KlVxhT GKmP0HL/JivA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235648" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:20 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:51 +0200 Message-Id: <20210325214808.2071517-9-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 08/25] drm/i915/intel_fb: Pull is_surface_linear() from intel_display.c/skl_universal_plane.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move is_surface_linear() to intel_fb.c and export it from here, also removing the duplicate definitions of it. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_display.c | 6 ------ drivers/gpu/drm/i915/display/intel_fb.c | 6 ++++++ drivers/gpu/drm/i915/display/intel_fb.h | 2 ++ drivers/gpu/drm/i915/display/skl_universal_plane.c | 6 ------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index d8770e471dcc4..736ab23bcaef4 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -1294,12 +1294,6 @@ static u32 intel_adjust_tile_offset(int *x, int *y, return new_offset; } -static bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane) -{ - return fb->modifier == DRM_FORMAT_MOD_LINEAR || - is_gen12_ccs_plane(fb, color_plane); -} - static u32 intel_adjust_aligned_offset(int *x, int *y, const struct drm_framebuffer *fb, int color_plane, diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 40d56eb1914ee..17c6bd7680d9b 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -27,6 +27,12 @@ bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) plane == 2; } +bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane) +{ + return fb->modifier == DRM_FORMAT_MOD_LINEAR || + is_gen12_ccs_plane(fb, color_plane); +} + int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane) { drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 3cde53c75cb35..6ea220438f9ac 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -14,6 +14,8 @@ bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); +bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane); + int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 5b0f8e5302461..22f7a13020189 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -562,12 +562,6 @@ icl_program_input_csc(struct intel_plane *plane, PLANE_INPUT_CSC_POSTOFF(pipe, plane_id, 2), 0x0); } -static bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane) -{ - return fb->modifier == DRM_FORMAT_MOD_LINEAR || - is_gen12_ccs_plane(fb, color_plane); -} - static unsigned int skl_plane_stride_mult(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation) { From patchwork Thu Mar 25 21:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D689C433C1 for ; Thu, 25 Mar 2021 21:48:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54C62619EE for ; Thu, 25 Mar 2021 21:48:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54C62619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A290F6EE5A; Thu, 25 Mar 2021 21:48:28 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 864756EE57 for ; Thu, 25 Mar 2021 21:48:23 +0000 (UTC) IronPort-SDR: PIip2mE8e3xvnEmzzox6qRf6rII5bOPeKtjkuv4YhSZIXaDwk9B49ylq0LcNzD/o4duUYFHrPb hQ1UW4MgAsMA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005040" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005040" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:23 -0700 IronPort-SDR: EhlTo+3KALr1x+bw+ZehRruYgUqgtnbwI9w5fqPdtVAiGkZtmMRDAcQTlQHLRfk4n9DE0Au6UV SgDaRMdo60yw== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235651" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:22 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:52 +0200 Message-Id: <20210325214808.2071517-10-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 09/25] drm/i915/intel_fb: Pull FB plane functions from intel_sprite.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move the FB plane specific function from intel_sprite.c to intel_fb.c Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 32 +++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_fb.h | 4 +++ drivers/gpu/drm/i915/display/intel_sprite.c | 32 --------------------- drivers/gpu/drm/i915/display/intel_sprite.h | 1 - 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 17c6bd7680d9b..8b14e069fc710 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -64,3 +64,35 @@ int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) else return 0; } + +int intel_plane_check_stride(const struct intel_plane_state *plane_state) +{ + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); + const struct drm_framebuffer *fb = plane_state->hw.fb; + unsigned int rotation = plane_state->hw.rotation; + u32 stride, max_stride; + + /* + * We ignore stride for all invisible planes that + * can be remapped. Otherwise we could end up + * with a false positive when the remapping didn't + * kick in due the plane being invisible. + */ + if (intel_plane_can_remap(plane_state) && + !plane_state->uapi.visible) + return 0; + + /* FIXME other color planes? */ + stride = plane_state->color_plane[0].stride; + max_stride = plane->max_stride(plane, fb->format->format, + fb->modifier, rotation); + + if (stride > max_stride) { + DRM_DEBUG_KMS("[FB:%d] stride (%d) exceeds [PLANE:%d:%s] max stride (%d)\n", + fb->base.id, stride, + plane->base.base.id, plane->base.name, max_stride); + return -EINVAL; + } + + return 0; +} diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 6ea220438f9ac..8c15f4c9561b1 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -10,6 +10,8 @@ struct drm_framebuffer; +struct intel_plane_state; + bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); @@ -20,4 +22,6 @@ int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); +int intel_plane_check_stride(const struct intel_plane_state *plane_state); + #endif /* __INTEL_FB_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c index d55a13312885b..af2d617d9eb2b 100644 --- a/drivers/gpu/drm/i915/display/intel_sprite.c +++ b/drivers/gpu/drm/i915/display/intel_sprite.c @@ -49,38 +49,6 @@ #include "i9xx_plane.h" #include "intel_vrr.h" -int intel_plane_check_stride(const struct intel_plane_state *plane_state) -{ - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - const struct drm_framebuffer *fb = plane_state->hw.fb; - unsigned int rotation = plane_state->hw.rotation; - u32 stride, max_stride; - - /* - * We ignore stride for all invisible planes that - * can be remapped. Otherwise we could end up - * with a false positive when the remapping didn't - * kick in due the plane being invisible. - */ - if (intel_plane_can_remap(plane_state) && - !plane_state->uapi.visible) - return 0; - - /* FIXME other color planes? */ - stride = plane_state->color_plane[0].stride; - max_stride = plane->max_stride(plane, fb->format->format, - fb->modifier, rotation); - - if (stride > max_stride) { - DRM_DEBUG_KMS("[FB:%d] stride (%d) exceeds [PLANE:%d:%s] max stride (%d)\n", - fb->base.id, stride, - plane->base.base.id, plane->base.name, max_stride); - return -EINVAL; - } - - return 0; -} - int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state) { const struct drm_framebuffer *fb = plane_state->hw.fb; diff --git a/drivers/gpu/drm/i915/display/intel_sprite.h b/drivers/gpu/drm/i915/display/intel_sprite.h index f6989da2dc4bd..c085eb87705cc 100644 --- a/drivers/gpu/drm/i915/display/intel_sprite.h +++ b/drivers/gpu/drm/i915/display/intel_sprite.h @@ -35,7 +35,6 @@ int intel_sprite_set_colorkey_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state); void intel_pipe_update_end(struct intel_crtc_state *new_crtc_state); -int intel_plane_check_stride(const struct intel_plane_state *plane_state); int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state); int chv_plane_check_rotation(const struct intel_plane_state *plane_state); From patchwork Thu Mar 25 21:47:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34287C433C1 for ; Thu, 25 Mar 2021 21:48:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5944619BA for ; Thu, 25 Mar 2021 21:48:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5944619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0567A6EE5D; Thu, 25 Mar 2021 21:48:34 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id B54D46EE57 for ; Thu, 25 Mar 2021 21:48:25 +0000 (UTC) IronPort-SDR: sNP8qhxHneRxSahy3Jcxhfc0Tg1H69wNr4pSxsoatItI2wzOGKkFieVQ7lszhkQWZk7qn+5bap usAAM7ZY1FCg== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005056" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005056" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:25 -0700 IronPort-SDR: Vmucq1diWk8MealdasXDplAogjeLC6iKE9Iuz6H46jOC8zYx+/RJFrnU81VRL/QW3Jr++GKfuS 7ION6PE59YmA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235655" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:23 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:53 +0200 Message-Id: <20210325214808.2071517-11-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 10/25] drm/i915/intel_fb: Pull FB plane functions from intel_display.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move the FB plane specific functions from intel_display.c to intel_fb.c. There's more functions like this, but I leave moving those as well for a follow up, and for now moving only the ones needed by the end of this patchset (adding support for padding tile-rows in an FB GGTT view). Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/i9xx_plane.c | 1 + drivers/gpu/drm/i915/display/intel_cursor.c | 1 + drivers/gpu/drm/i915/display/intel_display.c | 818 ------------------- drivers/gpu/drm/i915/display/intel_display.h | 13 - drivers/gpu/drm/i915/display/intel_fb.c | 807 ++++++++++++++++++ drivers/gpu/drm/i915/display/intel_fb.h | 31 + 6 files changed, 840 insertions(+), 831 deletions(-) diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c index 6919ede20b19b..40266b78247b2 100644 --- a/drivers/gpu/drm/i915/display/i9xx_plane.c +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c @@ -11,6 +11,7 @@ #include "intel_atomic.h" #include "intel_atomic_plane.h" #include "intel_display_types.h" +#include "intel_fb.h" #include "intel_sprite.h" #include "i9xx_plane.h" diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c index 0132ed3cb09d3..84099b7f5c358 100644 --- a/drivers/gpu/drm/i915/display/intel_cursor.c +++ b/drivers/gpu/drm/i915/display/intel_cursor.c @@ -15,6 +15,7 @@ #include "intel_cursor.h" #include "intel_display_types.h" #include "intel_display.h" +#include "intel_fb.h" #include "intel_frontbuffer.h" #include "intel_pm.h" diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 736ab23bcaef4..25eaa8a44baa8 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -856,19 +856,6 @@ void intel_disable_pipe(const struct intel_crtc_state *old_crtc_state) intel_wait_for_pipe_off(old_crtc_state); } -static unsigned int intel_tile_size(const struct drm_i915_private *dev_priv) -{ - return IS_DISPLAY_VER(dev_priv, 2) ? 2048 : 4096; -} - -static bool is_aux_plane(const struct drm_framebuffer *fb, int plane) -{ - if (is_ccs_modifier(fb->modifier)) - return is_ccs_plane(fb, plane); - - return plane == 1; -} - bool intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info, u64 modifier) @@ -877,13 +864,6 @@ intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info, info->num_planes == (is_ccs_modifier(modifier) ? 4 : 2); } -static bool is_semiplanar_uv_plane(const struct drm_framebuffer *fb, - int color_plane) -{ - return intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier) && - color_plane == 1; -} - unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane) { @@ -938,38 +918,6 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane) } } -unsigned int -intel_tile_height(const struct drm_framebuffer *fb, int color_plane) -{ - if (is_gen12_ccs_plane(fb, color_plane)) - return 1; - - return intel_tile_size(to_i915(fb->dev)) / - intel_tile_width_bytes(fb, color_plane); -} - -/* Return the tile dimensions in pixel units */ -static void intel_tile_dims(const struct drm_framebuffer *fb, int color_plane, - unsigned int *tile_width, - unsigned int *tile_height) -{ - unsigned int tile_width_bytes = intel_tile_width_bytes(fb, color_plane); - unsigned int cpp = fb->format->cpp[color_plane]; - - *tile_width = tile_width_bytes / cpp; - *tile_height = intel_tile_height(fb, color_plane); -} - -static unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, - int color_plane) -{ - unsigned int tile_width, tile_height; - - intel_tile_dims(fb, color_plane, &tile_width, &tile_height); - - return fb->pitches[color_plane] * tile_height; -} - unsigned int intel_fb_align_height(const struct drm_framebuffer *fb, int color_plane, unsigned int height) @@ -1001,32 +949,6 @@ unsigned int intel_remapped_info_size(const struct intel_remapped_info *rem_info return size; } -static void -intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, - const struct drm_framebuffer *fb, - unsigned int rotation) -{ - memset(view, 0, sizeof(*view)); - - view->type = I915_GGTT_VIEW_NORMAL; - if (drm_rotation_90_or_270(rotation)) { - view->type = I915_GGTT_VIEW_ROTATED; - view->rotated = to_intel_framebuffer(fb)->rot_info; - } -} - -static unsigned int intel_cursor_alignment(const struct drm_i915_private *dev_priv) -{ - if (IS_I830(dev_priv)) - return 16 * 1024; - else if (IS_I85X(dev_priv)) - return 256; - else if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) - return 32; - else - return 4 * 1024; -} - static unsigned int intel_linear_alignment(const struct drm_i915_private *dev_priv) { if (DISPLAY_VER(dev_priv) >= 9) @@ -1227,15 +1149,6 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags) i915_vma_put(vma); } -static int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, - unsigned int rotation) -{ - if (drm_rotation_90_or_270(rotation)) - return to_intel_framebuffer(fb)->rotated[color_plane].pitch; - else - return fb->pitches[color_plane]; -} - /* * Convert the x/y offsets into a linear offset. * Only valid with 0/180 degree rotation, which is fine since linear @@ -1267,224 +1180,6 @@ void intel_add_fb_offsets(int *x, int *y, *y += state->color_plane[color_plane].y; } -static u32 intel_adjust_tile_offset(int *x, int *y, - unsigned int tile_width, - unsigned int tile_height, - unsigned int tile_size, - unsigned int pitch_tiles, - u32 old_offset, - u32 new_offset) -{ - unsigned int pitch_pixels = pitch_tiles * tile_width; - unsigned int tiles; - - WARN_ON(old_offset & (tile_size - 1)); - WARN_ON(new_offset & (tile_size - 1)); - WARN_ON(new_offset > old_offset); - - tiles = (old_offset - new_offset) / tile_size; - - *y += tiles / pitch_tiles * tile_height; - *x += tiles % pitch_tiles * tile_width; - - /* minimize x in case it got needlessly big */ - *y += *x / pitch_pixels * tile_height; - *x %= pitch_pixels; - - return new_offset; -} - -static u32 intel_adjust_aligned_offset(int *x, int *y, - const struct drm_framebuffer *fb, - int color_plane, - unsigned int rotation, - unsigned int pitch, - u32 old_offset, u32 new_offset) -{ - struct drm_i915_private *dev_priv = to_i915(fb->dev); - unsigned int cpp = fb->format->cpp[color_plane]; - - drm_WARN_ON(&dev_priv->drm, new_offset > old_offset); - - if (!is_surface_linear(fb, color_plane)) { - unsigned int tile_size, tile_width, tile_height; - unsigned int pitch_tiles; - - tile_size = intel_tile_size(dev_priv); - intel_tile_dims(fb, color_plane, &tile_width, &tile_height); - - if (drm_rotation_90_or_270(rotation)) { - pitch_tiles = pitch / tile_height; - swap(tile_width, tile_height); - } else { - pitch_tiles = pitch / (tile_width * cpp); - } - - intel_adjust_tile_offset(x, y, tile_width, tile_height, - tile_size, pitch_tiles, - old_offset, new_offset); - } else { - old_offset += *y * pitch + *x * cpp; - - *y = (old_offset - new_offset) / pitch; - *x = ((old_offset - new_offset) - *y * pitch) / cpp; - } - - return new_offset; -} - -/* - * Adjust the tile offset by moving the difference into - * the x/y offsets. - */ -u32 intel_plane_adjust_aligned_offset(int *x, int *y, - const struct intel_plane_state *state, - int color_plane, - u32 old_offset, u32 new_offset) -{ - return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, - state->hw.rotation, - state->color_plane[color_plane].stride, - old_offset, new_offset); -} - -/* - * Computes the aligned offset to the base tile and adjusts - * x, y. bytes per pixel is assumed to be a power-of-two. - * - * In the 90/270 rotated case, x and y are assumed - * to be already rotated to match the rotated GTT view, and - * pitch is the tile_height aligned framebuffer height. - * - * This function is used when computing the derived information - * under intel_framebuffer, so using any of that information - * here is not allowed. Anything under drm_framebuffer can be - * used. This is why the user has to pass in the pitch since it - * is specified in the rotated orientation. - */ -static u32 intel_compute_aligned_offset(struct drm_i915_private *dev_priv, - int *x, int *y, - const struct drm_framebuffer *fb, - int color_plane, - unsigned int pitch, - unsigned int rotation, - u32 alignment) -{ - unsigned int cpp = fb->format->cpp[color_plane]; - u32 offset, offset_aligned; - - if (!is_surface_linear(fb, color_plane)) { - unsigned int tile_size, tile_width, tile_height; - unsigned int tile_rows, tiles, pitch_tiles; - - tile_size = intel_tile_size(dev_priv); - intel_tile_dims(fb, color_plane, &tile_width, &tile_height); - - if (drm_rotation_90_or_270(rotation)) { - pitch_tiles = pitch / tile_height; - swap(tile_width, tile_height); - } else { - pitch_tiles = pitch / (tile_width * cpp); - } - - tile_rows = *y / tile_height; - *y %= tile_height; - - tiles = *x / tile_width; - *x %= tile_width; - - offset = (tile_rows * pitch_tiles + tiles) * tile_size; - - offset_aligned = offset; - if (alignment) - offset_aligned = rounddown(offset_aligned, alignment); - - intel_adjust_tile_offset(x, y, tile_width, tile_height, - tile_size, pitch_tiles, - offset, offset_aligned); - } else { - offset = *y * pitch + *x * cpp; - offset_aligned = offset; - if (alignment) { - offset_aligned = rounddown(offset_aligned, alignment); - *y = (offset % alignment) / pitch; - *x = ((offset % alignment) - *y * pitch) / cpp; - } else { - *y = *x = 0; - } - } - - return offset_aligned; -} - -u32 intel_plane_compute_aligned_offset(int *x, int *y, - const struct intel_plane_state *state, - int color_plane) -{ - struct intel_plane *intel_plane = to_intel_plane(state->uapi.plane); - struct drm_i915_private *dev_priv = to_i915(intel_plane->base.dev); - const struct drm_framebuffer *fb = state->hw.fb; - unsigned int rotation = state->hw.rotation; - int pitch = state->color_plane[color_plane].stride; - u32 alignment; - - if (intel_plane->id == PLANE_CURSOR) - alignment = intel_cursor_alignment(dev_priv); - else - alignment = intel_surf_alignment(fb, color_plane); - - return intel_compute_aligned_offset(dev_priv, x, y, fb, color_plane, - pitch, rotation, alignment); -} - -/* Convert the fb->offset[] into x/y offsets */ -static int intel_fb_offset_to_xy(int *x, int *y, - const struct drm_framebuffer *fb, - int color_plane) -{ - struct drm_i915_private *dev_priv = to_i915(fb->dev); - unsigned int height; - u32 alignment; - - if (DISPLAY_VER(dev_priv) >= 12 && - is_semiplanar_uv_plane(fb, color_plane)) - alignment = intel_tile_row_size(fb, color_plane); - else if (fb->modifier != DRM_FORMAT_MOD_LINEAR) - alignment = intel_tile_size(dev_priv); - else - alignment = 0; - - if (alignment != 0 && fb->offsets[color_plane] % alignment) { - drm_dbg_kms(&dev_priv->drm, - "Misaligned offset 0x%08x for color plane %d\n", - fb->offsets[color_plane], color_plane); - return -EINVAL; - } - - height = drm_framebuffer_plane_height(fb->height, fb, color_plane); - height = ALIGN(height, intel_tile_height(fb, color_plane)); - - /* Catch potential overflows early */ - if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]), - fb->offsets[color_plane])) { - drm_dbg_kms(&dev_priv->drm, - "Bad offset 0x%08x or pitch %d for color plane %d\n", - fb->offsets[color_plane], fb->pitches[color_plane], - color_plane); - return -ERANGE; - } - - *x = 0; - *y = 0; - - intel_adjust_aligned_offset(x, y, - fb, color_plane, DRM_MODE_ROTATE_0, - fb->pitches[color_plane], - fb->offsets[color_plane], 0); - - return 0; -} - static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier) { switch (fb_modifier) { @@ -1720,519 +1415,6 @@ intel_fb_stride_alignment(const struct drm_framebuffer *fb, int color_plane) return tile_width; } -bool intel_plane_can_remap(const struct intel_plane_state *plane_state) -{ - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); - const struct drm_framebuffer *fb = plane_state->hw.fb; - int i; - - /* We don't want to deal with remapping with cursors */ - if (plane->id == PLANE_CURSOR) - return false; - - /* - * The display engine limits already match/exceed the - * render engine limits, so not much point in remapping. - * Would also need to deal with the fence POT alignment - * and gen2 2KiB GTT tile size. - */ - if (DISPLAY_VER(dev_priv) < 4) - return false; - - /* - * The new CCS hash mode isn't compatible with remapping as - * the virtual address of the pages affects the compressed data. - */ - if (is_ccs_modifier(fb->modifier)) - return false; - - /* Linear needs a page aligned stride for remapping */ - if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { - unsigned int alignment = intel_tile_size(dev_priv) - 1; - - for (i = 0; i < fb->format->num_planes; i++) { - if (fb->pitches[i] & alignment) - return false; - } - } - - return true; -} - -static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) -{ - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - const struct drm_framebuffer *fb = plane_state->hw.fb; - unsigned int rotation = plane_state->hw.rotation; - u32 stride, max_stride; - - /* - * No remapping for invisible planes since we don't have - * an actual source viewport to remap. - */ - if (!plane_state->uapi.visible) - return false; - - if (!intel_plane_can_remap(plane_state)) - return false; - - /* - * FIXME: aux plane limits on gen9+ are - * unclear in Bspec, for now no checking. - */ - stride = intel_fb_pitch(fb, 0, rotation); - max_stride = plane->max_stride(plane, fb->format->format, - fb->modifier, rotation); - - return stride > max_stride; -} - -void -intel_fb_plane_get_subsampling(int *hsub, int *vsub, - const struct drm_framebuffer *fb, - int color_plane) -{ - int main_plane; - - if (color_plane == 0) { - *hsub = 1; - *vsub = 1; - - return; - } - - /* - * TODO: Deduct the subsampling from the char block for all CCS - * formats and planes. - */ - if (!is_gen12_ccs_plane(fb, color_plane)) { - *hsub = fb->format->hsub; - *vsub = fb->format->vsub; - - return; - } - - main_plane = skl_ccs_to_main_plane(fb, color_plane); - *hsub = drm_format_info_block_width(fb->format, color_plane) / - drm_format_info_block_width(fb->format, main_plane); - - /* - * The min stride check in the core framebuffer_check() function - * assumes that format->hsub applies to every plane except for the - * first plane. That's incorrect for the CCS AUX plane of the first - * plane, but for the above check to pass we must define the block - * width with that subsampling applied to it. Adjust the width here - * accordingly, so we can calculate the actual subsampling factor. - */ - if (main_plane == 0) - *hsub *= fb->format->hsub; - - *vsub = 32; -} -static int -intel_fb_check_ccs_xy(struct drm_framebuffer *fb, int ccs_plane, int x, int y) -{ - struct drm_i915_private *i915 = to_i915(fb->dev); - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - int main_plane; - int hsub, vsub; - int tile_width, tile_height; - int ccs_x, ccs_y; - int main_x, main_y; - - if (!is_ccs_plane(fb, ccs_plane) || is_gen12_ccs_cc_plane(fb, ccs_plane)) - return 0; - - intel_tile_dims(fb, ccs_plane, &tile_width, &tile_height); - intel_fb_plane_get_subsampling(&hsub, &vsub, fb, ccs_plane); - - tile_width *= hsub; - tile_height *= vsub; - - ccs_x = (x * hsub) % tile_width; - ccs_y = (y * vsub) % tile_height; - - main_plane = skl_ccs_to_main_plane(fb, ccs_plane); - main_x = intel_fb->normal[main_plane].x % tile_width; - main_y = intel_fb->normal[main_plane].y % tile_height; - - /* - * CCS doesn't have its own x/y offset register, so the intra CCS tile - * x/y offsets must match between CCS and the main surface. - */ - if (main_x != ccs_x || main_y != ccs_y) { - drm_dbg_kms(&i915->drm, - "Bad CCS x/y (main %d,%d ccs %d,%d) full (main %d,%d ccs %d,%d)\n", - main_x, main_y, - ccs_x, ccs_y, - intel_fb->normal[main_plane].x, - intel_fb->normal[main_plane].y, - x, y); - return -EINVAL; - } - - return 0; -} - -static void -intel_fb_plane_dims(int *w, int *h, struct drm_framebuffer *fb, int color_plane) -{ - int main_plane = is_ccs_plane(fb, color_plane) ? - skl_ccs_to_main_plane(fb, color_plane) : 0; - int main_hsub, main_vsub; - int hsub, vsub; - - intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, fb, main_plane); - intel_fb_plane_get_subsampling(&hsub, &vsub, fb, color_plane); - *w = fb->width / main_hsub / hsub; - *h = fb->height / main_vsub / vsub; -} - -/* - * Setup the rotated view for an FB plane and return the size the GTT mapping - * requires for this view. - */ -static u32 -setup_fb_rotation(int plane, const struct intel_remapped_plane_info *plane_info, - u32 gtt_offset_rotated, int x, int y, - unsigned int width, unsigned int height, - unsigned int tile_size, - unsigned int tile_width, unsigned int tile_height, - struct drm_framebuffer *fb) -{ - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *rot_info = &intel_fb->rot_info; - unsigned int pitch_tiles; - struct drm_rect r; - - /* Y or Yf modifiers required for 90/270 rotation */ - if (fb->modifier != I915_FORMAT_MOD_Y_TILED && - fb->modifier != I915_FORMAT_MOD_Yf_TILED) - return 0; - - if (drm_WARN_ON(fb->dev, plane >= ARRAY_SIZE(rot_info->plane))) - return 0; - - rot_info->plane[plane] = *plane_info; - - intel_fb->rotated[plane].pitch = plane_info->height * tile_height; - - /* rotate the x/y offsets to match the GTT view */ - drm_rect_init(&r, x, y, width, height); - drm_rect_rotate(&r, - plane_info->width * tile_width, - plane_info->height * tile_height, - DRM_MODE_ROTATE_270); - x = r.x1; - y = r.y1; - - /* rotate the tile dimensions to match the GTT view */ - pitch_tiles = intel_fb->rotated[plane].pitch / tile_height; - swap(tile_width, tile_height); - - /* - * We only keep the x/y offsets, so push all of the - * gtt offset into the x/y offsets. - */ - intel_adjust_tile_offset(&x, &y, - tile_width, tile_height, - tile_size, pitch_tiles, - gtt_offset_rotated * tile_size, 0); - - /* - * First pixel of the framebuffer from - * the start of the rotated gtt mapping. - */ - intel_fb->rotated[plane].x = x; - intel_fb->rotated[plane].y = y; - - return plane_info->width * plane_info->height; -} - -static int -intel_fill_fb_info(struct drm_i915_private *dev_priv, - struct drm_framebuffer *fb) -{ - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct drm_i915_gem_object *obj = intel_fb_obj(fb); - u32 gtt_offset_rotated = 0; - unsigned int max_size = 0; - int i, num_planes = fb->format->num_planes; - unsigned int tile_size = intel_tile_size(dev_priv); - - for (i = 0; i < num_planes; i++) { - unsigned int width, height; - unsigned int cpp, size; - u32 offset; - int x, y; - int ret; - - /* - * Plane 2 of Render Compression with Clear Color fb modifier - * is consumed by the driver and not passed to DE. Skip the - * arithmetic related to alignment and offset calculation. - */ - if (is_gen12_ccs_cc_plane(fb, i)) { - if (IS_ALIGNED(fb->offsets[i], PAGE_SIZE)) - continue; - else - return -EINVAL; - } - - cpp = fb->format->cpp[i]; - intel_fb_plane_dims(&width, &height, fb, i); - - ret = intel_fb_offset_to_xy(&x, &y, fb, i); - if (ret) { - drm_dbg_kms(&dev_priv->drm, - "bad fb plane %d offset: 0x%x\n", - i, fb->offsets[i]); - return ret; - } - - ret = intel_fb_check_ccs_xy(fb, i, x, y); - if (ret) - return ret; - - /* - * The fence (if used) is aligned to the start of the object - * so having the framebuffer wrap around across the edge of the - * fenced region doesn't really work. We have no API to configure - * the fence start offset within the object (nor could we probably - * on gen2/3). So it's just easier if we just require that the - * fb layout agrees with the fence layout. We already check that the - * fb stride matches the fence stride elsewhere. - */ - if (i == 0 && i915_gem_object_is_tiled(obj) && - (x + width) * cpp > fb->pitches[i]) { - drm_dbg_kms(&dev_priv->drm, - "bad fb plane %d offset: 0x%x\n", - i, fb->offsets[i]); - return -EINVAL; - } - - /* - * First pixel of the framebuffer from - * the start of the normal gtt mapping. - */ - intel_fb->normal[i].x = x; - intel_fb->normal[i].y = y; - - offset = intel_compute_aligned_offset(dev_priv, &x, &y, fb, i, - fb->pitches[i], - DRM_MODE_ROTATE_0, - tile_size); - offset /= tile_size; - - if (!is_surface_linear(fb, i)) { - struct intel_remapped_plane_info plane_info; - unsigned int tile_width, tile_height; - - intel_tile_dims(fb, i, &tile_width, &tile_height); - - plane_info.offset = offset; - plane_info.stride = DIV_ROUND_UP(fb->pitches[i], - tile_width * cpp); - plane_info.width = DIV_ROUND_UP(x + width, tile_width); - plane_info.height = DIV_ROUND_UP(y + height, - tile_height); - - /* how many tiles does this plane need */ - size = plane_info.stride * plane_info.height; - /* - * If the plane isn't horizontally tile aligned, - * we need one more tile. - */ - if (x != 0) - size++; - - gtt_offset_rotated += - setup_fb_rotation(i, &plane_info, - gtt_offset_rotated, - x, y, width, height, - tile_size, - tile_width, tile_height, - fb); - } else { - size = DIV_ROUND_UP((y + height) * fb->pitches[i] + - x * cpp, tile_size); - } - - /* how many tiles in total needed in the bo */ - max_size = max(max_size, offset + size); - } - - if (mul_u32_u32(max_size, tile_size) > obj->base.size) { - drm_dbg_kms(&dev_priv->drm, - "fb too big for bo (need %llu bytes, have %zu bytes)\n", - mul_u32_u32(max_size, tile_size), obj->base.size); - return -EINVAL; - } - - return 0; -} - -static void -intel_plane_remap_gtt(struct intel_plane_state *plane_state) -{ - struct drm_i915_private *dev_priv = - to_i915(plane_state->uapi.plane->dev); - struct drm_framebuffer *fb = plane_state->hw.fb; - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *info = &plane_state->view.rotated; - unsigned int rotation = plane_state->hw.rotation; - int i, num_planes = fb->format->num_planes; - unsigned int tile_size = intel_tile_size(dev_priv); - unsigned int src_x, src_y; - unsigned int src_w, src_h; - u32 gtt_offset = 0; - - memset(&plane_state->view, 0, sizeof(plane_state->view)); - plane_state->view.type = drm_rotation_90_or_270(rotation) ? - I915_GGTT_VIEW_ROTATED : I915_GGTT_VIEW_REMAPPED; - - src_x = plane_state->uapi.src.x1 >> 16; - src_y = plane_state->uapi.src.y1 >> 16; - src_w = drm_rect_width(&plane_state->uapi.src) >> 16; - src_h = drm_rect_height(&plane_state->uapi.src) >> 16; - - drm_WARN_ON(&dev_priv->drm, is_ccs_modifier(fb->modifier)); - - /* Make src coordinates relative to the viewport */ - drm_rect_translate(&plane_state->uapi.src, - -(src_x << 16), -(src_y << 16)); - - /* Rotate src coordinates to match rotated GTT view */ - if (drm_rotation_90_or_270(rotation)) - drm_rect_rotate(&plane_state->uapi.src, - src_w << 16, src_h << 16, - DRM_MODE_ROTATE_270); - - for (i = 0; i < num_planes; i++) { - unsigned int hsub = i ? fb->format->hsub : 1; - unsigned int vsub = i ? fb->format->vsub : 1; - unsigned int cpp = fb->format->cpp[i]; - unsigned int tile_width, tile_height; - unsigned int width, height; - unsigned int pitch_tiles; - unsigned int x, y; - u32 offset; - - intel_tile_dims(fb, i, &tile_width, &tile_height); - - x = src_x / hsub; - y = src_y / vsub; - width = src_w / hsub; - height = src_h / vsub; - - /* - * First pixel of the src viewport from the - * start of the normal gtt mapping. - */ - x += intel_fb->normal[i].x; - y += intel_fb->normal[i].y; - - offset = intel_compute_aligned_offset(dev_priv, &x, &y, - fb, i, fb->pitches[i], - DRM_MODE_ROTATE_0, tile_size); - offset /= tile_size; - - drm_WARN_ON(&dev_priv->drm, i >= ARRAY_SIZE(info->plane)); - info->plane[i].offset = offset; - info->plane[i].stride = DIV_ROUND_UP(fb->pitches[i], - tile_width * cpp); - info->plane[i].width = DIV_ROUND_UP(x + width, tile_width); - info->plane[i].height = DIV_ROUND_UP(y + height, tile_height); - - if (drm_rotation_90_or_270(rotation)) { - struct drm_rect r; - - /* rotate the x/y offsets to match the GTT view */ - drm_rect_init(&r, x, y, width, height); - drm_rect_rotate(&r, - info->plane[i].width * tile_width, - info->plane[i].height * tile_height, - DRM_MODE_ROTATE_270); - x = r.x1; - y = r.y1; - - pitch_tiles = info->plane[i].height; - plane_state->color_plane[i].stride = pitch_tiles * tile_height; - - /* rotate the tile dimensions to match the GTT view */ - swap(tile_width, tile_height); - } else { - pitch_tiles = info->plane[i].width; - plane_state->color_plane[i].stride = pitch_tiles * tile_width * cpp; - } - - /* - * We only keep the x/y offsets, so push all of the - * gtt offset into the x/y offsets. - */ - intel_adjust_tile_offset(&x, &y, - tile_width, tile_height, - tile_size, pitch_tiles, - gtt_offset * tile_size, 0); - - gtt_offset += info->plane[i].width * info->plane[i].height; - - plane_state->color_plane[i].offset = 0; - plane_state->color_plane[i].x = x; - plane_state->color_plane[i].y = y; - } -} - -int -intel_plane_compute_gtt(struct intel_plane_state *plane_state) -{ - const struct intel_framebuffer *fb = - to_intel_framebuffer(plane_state->hw.fb); - unsigned int rotation = plane_state->hw.rotation; - int i, num_planes; - - if (!fb) - return 0; - - num_planes = fb->base.format->num_planes; - - if (intel_plane_needs_remap(plane_state)) { - intel_plane_remap_gtt(plane_state); - - /* - * Sometimes even remapping can't overcome - * the stride limitations :( Can happen with - * big plane sizes and suitably misaligned - * offsets. - */ - return intel_plane_check_stride(plane_state); - } - - intel_fill_fb_ggtt_view(&plane_state->view, &fb->base, rotation); - - for (i = 0; i < num_planes; i++) { - plane_state->color_plane[i].stride = intel_fb_pitch(&fb->base, i, rotation); - plane_state->color_plane[i].offset = 0; - - if (drm_rotation_90_or_270(rotation)) { - plane_state->color_plane[i].x = fb->rotated[i].x; - plane_state->color_plane[i].y = fb->rotated[i].y; - } else { - plane_state->color_plane[i].x = fb->normal[i].x; - plane_state->color_plane[i].y = fb->normal[i].y; - } - } - - /* Rotate src coordinates to match rotated GTT view */ - if (drm_rotation_90_or_270(rotation)) - drm_rect_rotate(&plane_state->uapi.src, - fb->base.width << 16, fb->base.height << 16, - DRM_MODE_ROTATE_270); - - return intel_plane_check_stride(plane_state); -} - static struct i915_vma * initial_plane_vma(struct drm_i915_private *i915, struct intel_initial_plane_config *plane_config) diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h index f056e19cf559a..62ce3b06ff98a 100644 --- a/drivers/gpu/drm/i915/display/intel_display.h +++ b/drivers/gpu/drm/i915/display/intel_display.h @@ -515,7 +515,6 @@ void intel_link_compute_m_n(u16 bpp, int nlanes, void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv); u32 intel_plane_fb_max_stride(struct drm_i915_private *dev_priv, u32 pixel_format, u64 modifier); -bool intel_plane_can_remap(const struct intel_plane_state *plane_state); enum drm_mode_status intel_mode_valid_max_plane_size(struct drm_i915_private *dev_priv, const struct drm_display_mode *mode, @@ -627,10 +626,6 @@ bool intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info, u64 modifier); -int intel_plane_compute_gtt(struct intel_plane_state *plane_state); -u32 intel_plane_compute_aligned_offset(int *x, int *y, - const struct intel_plane_state *state, - int color_plane); int intel_plane_pin_fb(struct intel_plane_state *plane_state); void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state); struct intel_encoder * @@ -639,15 +634,7 @@ intel_get_crtc_new_encoder(const struct intel_atomic_state *state, unsigned int intel_surf_alignment(const struct drm_framebuffer *fb, int color_plane); -void intel_fb_plane_get_subsampling(int *hsub, int *vsub, - const struct drm_framebuffer *fb, - int color_plane); -u32 intel_plane_adjust_aligned_offset(int *x, int *y, - const struct intel_plane_state *state, - int color_plane, - u32 old_offset, u32 new_offset); unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane); -unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane); void intel_display_driver_register(struct drm_i915_private *i915); void intel_display_driver_unregister(struct drm_i915_private *i915); diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 8b14e069fc710..b872eb29fd0d7 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -5,6 +5,7 @@ #include +#include "intel_display.h" #include "intel_display_types.h" #include "intel_fb.h" @@ -27,6 +28,20 @@ bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) plane == 2; } +bool is_aux_plane(const struct drm_framebuffer *fb, int plane) +{ + if (is_ccs_modifier(fb->modifier)) + return is_ccs_plane(fb, plane); + + return plane == 1; +} + +bool is_semiplanar_uv_plane(const struct drm_framebuffer *fb, int color_plane) +{ + return intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier) && + color_plane == 1; +} + bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane) { return fb->modifier == DRM_FORMAT_MOD_LINEAR || @@ -65,6 +80,750 @@ int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) return 0; } +unsigned int intel_tile_size(const struct drm_i915_private *dev_priv) +{ + return IS_DISPLAY_VER(dev_priv, 2) ? 2048 : 4096; +} + +unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane) +{ + if (is_gen12_ccs_plane(fb, color_plane)) + return 1; + + return intel_tile_size(to_i915(fb->dev)) / + intel_tile_width_bytes(fb, color_plane); +} + +/* Return the tile dimensions in pixel units */ +static void intel_tile_dims(const struct drm_framebuffer *fb, int color_plane, + unsigned int *tile_width, + unsigned int *tile_height) +{ + unsigned int tile_width_bytes = intel_tile_width_bytes(fb, color_plane); + unsigned int cpp = fb->format->cpp[color_plane]; + + *tile_width = tile_width_bytes / cpp; + *tile_height = intel_tile_height(fb, color_plane); +} + +unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane) +{ + unsigned int tile_width, tile_height; + + intel_tile_dims(fb, color_plane, &tile_width, &tile_height); + + return fb->pitches[color_plane] * tile_height; +} + +unsigned int intel_cursor_alignment(const struct drm_i915_private *dev_priv) +{ + if (IS_I830(dev_priv)) + return 16 * 1024; + else if (IS_I85X(dev_priv)) + return 256; + else if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) + return 32; + else + return 4 * 1024; +} + +void intel_fb_plane_get_subsampling(int *hsub, int *vsub, + const struct drm_framebuffer *fb, + int color_plane) +{ + int main_plane; + + if (color_plane == 0) { + *hsub = 1; + *vsub = 1; + + return; + } + + /* + * TODO: Deduct the subsampling from the char block for all CCS + * formats and planes. + */ + if (!is_gen12_ccs_plane(fb, color_plane)) { + *hsub = fb->format->hsub; + *vsub = fb->format->vsub; + + return; + } + + main_plane = skl_ccs_to_main_plane(fb, color_plane); + *hsub = drm_format_info_block_width(fb->format, color_plane) / + drm_format_info_block_width(fb->format, main_plane); + + /* + * The min stride check in the core framebuffer_check() function + * assumes that format->hsub applies to every plane except for the + * first plane. That's incorrect for the CCS AUX plane of the first + * plane, but for the above check to pass we must define the block + * width with that subsampling applied to it. Adjust the width here + * accordingly, so we can calculate the actual subsampling factor. + */ + if (main_plane == 0) + *hsub *= fb->format->hsub; + + *vsub = 32; +} + +static void intel_fb_plane_dims(int *w, int *h, struct drm_framebuffer *fb, int color_plane) +{ + int main_plane = is_ccs_plane(fb, color_plane) ? + skl_ccs_to_main_plane(fb, color_plane) : 0; + int main_hsub, main_vsub; + int hsub, vsub; + + intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, fb, main_plane); + intel_fb_plane_get_subsampling(&hsub, &vsub, fb, color_plane); + *w = fb->width / main_hsub / hsub; + *h = fb->height / main_vsub / vsub; +} + +static u32 intel_adjust_tile_offset(int *x, int *y, + unsigned int tile_width, + unsigned int tile_height, + unsigned int tile_size, + unsigned int pitch_tiles, + u32 old_offset, + u32 new_offset) +{ + unsigned int pitch_pixels = pitch_tiles * tile_width; + unsigned int tiles; + + WARN_ON(old_offset & (tile_size - 1)); + WARN_ON(new_offset & (tile_size - 1)); + WARN_ON(new_offset > old_offset); + + tiles = (old_offset - new_offset) / tile_size; + + *y += tiles / pitch_tiles * tile_height; + *x += tiles % pitch_tiles * tile_width; + + /* minimize x in case it got needlessly big */ + *y += *x / pitch_pixels * tile_height; + *x %= pitch_pixels; + + return new_offset; +} + +static u32 intel_adjust_aligned_offset(int *x, int *y, + const struct drm_framebuffer *fb, + int color_plane, + unsigned int rotation, + unsigned int pitch, + u32 old_offset, u32 new_offset) +{ + struct drm_i915_private *dev_priv = to_i915(fb->dev); + unsigned int cpp = fb->format->cpp[color_plane]; + + drm_WARN_ON(&dev_priv->drm, new_offset > old_offset); + + if (!is_surface_linear(fb, color_plane)) { + unsigned int tile_size, tile_width, tile_height; + unsigned int pitch_tiles; + + tile_size = intel_tile_size(dev_priv); + intel_tile_dims(fb, color_plane, &tile_width, &tile_height); + + if (drm_rotation_90_or_270(rotation)) { + pitch_tiles = pitch / tile_height; + swap(tile_width, tile_height); + } else { + pitch_tiles = pitch / (tile_width * cpp); + } + + intel_adjust_tile_offset(x, y, tile_width, tile_height, + tile_size, pitch_tiles, + old_offset, new_offset); + } else { + old_offset += *y * pitch + *x * cpp; + + *y = (old_offset - new_offset) / pitch; + *x = ((old_offset - new_offset) - *y * pitch) / cpp; + } + + return new_offset; +} + +/* + * Adjust the tile offset by moving the difference into + * the x/y offsets. + */ +u32 intel_plane_adjust_aligned_offset(int *x, int *y, + const struct intel_plane_state *state, + int color_plane, + u32 old_offset, u32 new_offset) +{ + return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, + state->hw.rotation, + state->color_plane[color_plane].stride, + old_offset, new_offset); +} + +/* + * Computes the aligned offset to the base tile and adjusts + * x, y. bytes per pixel is assumed to be a power-of-two. + * + * In the 90/270 rotated case, x and y are assumed + * to be already rotated to match the rotated GTT view, and + * pitch is the tile_height aligned framebuffer height. + * + * This function is used when computing the derived information + * under intel_framebuffer, so using any of that information + * here is not allowed. Anything under drm_framebuffer can be + * used. This is why the user has to pass in the pitch since it + * is specified in the rotated orientation. + */ +static u32 intel_compute_aligned_offset(struct drm_i915_private *dev_priv, + int *x, int *y, + const struct drm_framebuffer *fb, + int color_plane, + unsigned int pitch, + unsigned int rotation, + u32 alignment) +{ + unsigned int cpp = fb->format->cpp[color_plane]; + u32 offset, offset_aligned; + + if (!is_surface_linear(fb, color_plane)) { + unsigned int tile_size, tile_width, tile_height; + unsigned int tile_rows, tiles, pitch_tiles; + + tile_size = intel_tile_size(dev_priv); + intel_tile_dims(fb, color_plane, &tile_width, &tile_height); + + if (drm_rotation_90_or_270(rotation)) { + pitch_tiles = pitch / tile_height; + swap(tile_width, tile_height); + } else { + pitch_tiles = pitch / (tile_width * cpp); + } + + tile_rows = *y / tile_height; + *y %= tile_height; + + tiles = *x / tile_width; + *x %= tile_width; + + offset = (tile_rows * pitch_tiles + tiles) * tile_size; + + offset_aligned = offset; + if (alignment) + offset_aligned = rounddown(offset_aligned, alignment); + + intel_adjust_tile_offset(x, y, tile_width, tile_height, + tile_size, pitch_tiles, + offset, offset_aligned); + } else { + offset = *y * pitch + *x * cpp; + offset_aligned = offset; + if (alignment) { + offset_aligned = rounddown(offset_aligned, alignment); + *y = (offset % alignment) / pitch; + *x = ((offset % alignment) - *y * pitch) / cpp; + } else { + *y = *x = 0; + } + } + + return offset_aligned; +} + +u32 intel_plane_compute_aligned_offset(int *x, int *y, + const struct intel_plane_state *state, + int color_plane) +{ + struct intel_plane *intel_plane = to_intel_plane(state->uapi.plane); + struct drm_i915_private *dev_priv = to_i915(intel_plane->base.dev); + const struct drm_framebuffer *fb = state->hw.fb; + unsigned int rotation = state->hw.rotation; + int pitch = state->color_plane[color_plane].stride; + u32 alignment; + + if (intel_plane->id == PLANE_CURSOR) + alignment = intel_cursor_alignment(dev_priv); + else + alignment = intel_surf_alignment(fb, color_plane); + + return intel_compute_aligned_offset(dev_priv, x, y, fb, color_plane, + pitch, rotation, alignment); +} + +/* Convert the fb->offset[] into x/y offsets */ +static int intel_fb_offset_to_xy(int *x, int *y, + const struct drm_framebuffer *fb, + int color_plane) +{ + struct drm_i915_private *dev_priv = to_i915(fb->dev); + unsigned int height; + u32 alignment; + + if (DISPLAY_VER(dev_priv) >= 12 && + is_semiplanar_uv_plane(fb, color_plane)) + alignment = intel_tile_row_size(fb, color_plane); + else if (fb->modifier != DRM_FORMAT_MOD_LINEAR) + alignment = intel_tile_size(dev_priv); + else + alignment = 0; + + if (alignment != 0 && fb->offsets[color_plane] % alignment) { + drm_dbg_kms(&dev_priv->drm, + "Misaligned offset 0x%08x for color plane %d\n", + fb->offsets[color_plane], color_plane); + return -EINVAL; + } + + height = drm_framebuffer_plane_height(fb->height, fb, color_plane); + height = ALIGN(height, intel_tile_height(fb, color_plane)); + + /* Catch potential overflows early */ + if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]), + fb->offsets[color_plane])) { + drm_dbg_kms(&dev_priv->drm, + "Bad offset 0x%08x or pitch %d for color plane %d\n", + fb->offsets[color_plane], fb->pitches[color_plane], + color_plane); + return -ERANGE; + } + + *x = 0; + *y = 0; + + intel_adjust_aligned_offset(x, y, + fb, color_plane, DRM_MODE_ROTATE_0, + fb->pitches[color_plane], + fb->offsets[color_plane], 0); + + return 0; +} + +static int intel_fb_check_ccs_xy(struct drm_framebuffer *fb, int ccs_plane, int x, int y) +{ + struct drm_i915_private *i915 = to_i915(fb->dev); + struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); + int main_plane; + int hsub, vsub; + int tile_width, tile_height; + int ccs_x, ccs_y; + int main_x, main_y; + + if (!is_ccs_plane(fb, ccs_plane) || is_gen12_ccs_cc_plane(fb, ccs_plane)) + return 0; + + intel_tile_dims(fb, ccs_plane, &tile_width, &tile_height); + intel_fb_plane_get_subsampling(&hsub, &vsub, fb, ccs_plane); + + tile_width *= hsub; + tile_height *= vsub; + + ccs_x = (x * hsub) % tile_width; + ccs_y = (y * vsub) % tile_height; + + main_plane = skl_ccs_to_main_plane(fb, ccs_plane); + main_x = intel_fb->normal[main_plane].x % tile_width; + main_y = intel_fb->normal[main_plane].y % tile_height; + + /* + * CCS doesn't have its own x/y offset register, so the intra CCS tile + * x/y offsets must match between CCS and the main surface. + */ + if (main_x != ccs_x || main_y != ccs_y) { + drm_dbg_kms(&i915->drm, + "Bad CCS x/y (main %d,%d ccs %d,%d) full (main %d,%d ccs %d,%d)\n", + main_x, main_y, + ccs_x, ccs_y, + intel_fb->normal[main_plane].x, + intel_fb->normal[main_plane].y, + x, y); + return -EINVAL; + } + + return 0; +} + +static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) +{ + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); + struct drm_i915_private *dev_priv = to_i915(plane->base.dev); + const struct drm_framebuffer *fb = plane_state->hw.fb; + int i; + + /* We don't want to deal with remapping with cursors */ + if (plane->id == PLANE_CURSOR) + return false; + + /* + * The display engine limits already match/exceed the + * render engine limits, so not much point in remapping. + * Would also need to deal with the fence POT alignment + * and gen2 2KiB GTT tile size. + */ + if (DISPLAY_VER(dev_priv) < 4) + return false; + + /* + * The new CCS hash mode isn't compatible with remapping as + * the virtual address of the pages affects the compressed data. + */ + if (is_ccs_modifier(fb->modifier)) + return false; + + /* Linear needs a page aligned stride for remapping */ + if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { + unsigned int alignment = intel_tile_size(dev_priv) - 1; + + for (i = 0; i < fb->format->num_planes; i++) { + if (fb->pitches[i] & alignment) + return false; + } + } + + return true; +} + +int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation) +{ + if (drm_rotation_90_or_270(rotation)) + return to_intel_framebuffer(fb)->rotated[color_plane].pitch; + else + return fb->pitches[color_plane]; +} + +static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) +{ + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); + const struct drm_framebuffer *fb = plane_state->hw.fb; + unsigned int rotation = plane_state->hw.rotation; + u32 stride, max_stride; + + /* + * No remapping for invisible planes since we don't have + * an actual source viewport to remap. + */ + if (!plane_state->uapi.visible) + return false; + + if (!intel_plane_can_remap(plane_state)) + return false; + + /* + * FIXME: aux plane limits on gen9+ are + * unclear in Bspec, for now no checking. + */ + stride = intel_fb_pitch(fb, 0, rotation); + max_stride = plane->max_stride(plane, fb->format->format, + fb->modifier, rotation); + + return stride > max_stride; +} + +/* + * Setup the rotated view for an FB plane and return the size the GTT mapping + * requires for this view. + */ +static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info *plane_info, + u32 gtt_offset_rotated, int x, int y, + unsigned int width, unsigned int height, + unsigned int tile_size, + unsigned int tile_width, unsigned int tile_height, + struct drm_framebuffer *fb) +{ + struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); + struct intel_rotation_info *rot_info = &intel_fb->rot_info; + unsigned int pitch_tiles; + struct drm_rect r; + + /* Y or Yf modifiers required for 90/270 rotation */ + if (fb->modifier != I915_FORMAT_MOD_Y_TILED && + fb->modifier != I915_FORMAT_MOD_Yf_TILED) + return 0; + + if (drm_WARN_ON(fb->dev, plane >= ARRAY_SIZE(rot_info->plane))) + return 0; + + rot_info->plane[plane] = *plane_info; + + intel_fb->rotated[plane].pitch = plane_info->height * tile_height; + + /* rotate the x/y offsets to match the GTT view */ + drm_rect_init(&r, x, y, width, height); + drm_rect_rotate(&r, + plane_info->width * tile_width, + plane_info->height * tile_height, + DRM_MODE_ROTATE_270); + x = r.x1; + y = r.y1; + + /* rotate the tile dimensions to match the GTT view */ + pitch_tiles = intel_fb->rotated[plane].pitch / tile_height; + swap(tile_width, tile_height); + + /* + * We only keep the x/y offsets, so push all of the + * gtt offset into the x/y offsets. + */ + intel_adjust_tile_offset(&x, &y, + tile_width, tile_height, + tile_size, pitch_tiles, + gtt_offset_rotated * tile_size, 0); + + /* + * First pixel of the framebuffer from + * the start of the rotated gtt mapping. + */ + intel_fb->rotated[plane].x = x; + intel_fb->rotated[plane].y = y; + + return plane_info->width * plane_info->height; +} + +int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer *fb) +{ + struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); + struct drm_i915_gem_object *obj = intel_fb_obj(fb); + u32 gtt_offset_rotated = 0; + unsigned int max_size = 0; + int i, num_planes = fb->format->num_planes; + unsigned int tile_size = intel_tile_size(dev_priv); + + for (i = 0; i < num_planes; i++) { + unsigned int width, height; + unsigned int cpp, size; + u32 offset; + int x, y; + int ret; + + /* + * Plane 2 of Render Compression with Clear Color fb modifier + * is consumed by the driver and not passed to DE. Skip the + * arithmetic related to alignment and offset calculation. + */ + if (is_gen12_ccs_cc_plane(fb, i)) { + if (IS_ALIGNED(fb->offsets[i], PAGE_SIZE)) + continue; + else + return -EINVAL; + } + + cpp = fb->format->cpp[i]; + intel_fb_plane_dims(&width, &height, fb, i); + + ret = intel_fb_offset_to_xy(&x, &y, fb, i); + if (ret) { + drm_dbg_kms(&dev_priv->drm, + "bad fb plane %d offset: 0x%x\n", + i, fb->offsets[i]); + return ret; + } + + ret = intel_fb_check_ccs_xy(fb, i, x, y); + if (ret) + return ret; + + /* + * The fence (if used) is aligned to the start of the object + * so having the framebuffer wrap around across the edge of the + * fenced region doesn't really work. We have no API to configure + * the fence start offset within the object (nor could we probably + * on gen2/3). So it's just easier if we just require that the + * fb layout agrees with the fence layout. We already check that the + * fb stride matches the fence stride elsewhere. + */ + if (i == 0 && i915_gem_object_is_tiled(obj) && + (x + width) * cpp > fb->pitches[i]) { + drm_dbg_kms(&dev_priv->drm, + "bad fb plane %d offset: 0x%x\n", + i, fb->offsets[i]); + return -EINVAL; + } + + /* + * First pixel of the framebuffer from + * the start of the normal gtt mapping. + */ + intel_fb->normal[i].x = x; + intel_fb->normal[i].y = y; + + offset = intel_compute_aligned_offset(dev_priv, &x, &y, fb, i, + fb->pitches[i], + DRM_MODE_ROTATE_0, + tile_size); + offset /= tile_size; + + if (!is_surface_linear(fb, i)) { + struct intel_remapped_plane_info plane_info; + unsigned int tile_width, tile_height; + + intel_tile_dims(fb, i, &tile_width, &tile_height); + + plane_info.offset = offset; + plane_info.stride = DIV_ROUND_UP(fb->pitches[i], + tile_width * cpp); + plane_info.width = DIV_ROUND_UP(x + width, tile_width); + plane_info.height = DIV_ROUND_UP(y + height, + tile_height); + + /* how many tiles does this plane need */ + size = plane_info.stride * plane_info.height; + /* + * If the plane isn't horizontally tile aligned, + * we need one more tile. + */ + if (x != 0) + size++; + + gtt_offset_rotated += + setup_fb_rotation(i, &plane_info, + gtt_offset_rotated, + x, y, width, height, + tile_size, + tile_width, tile_height, + fb); + } else { + size = DIV_ROUND_UP((y + height) * fb->pitches[i] + + x * cpp, tile_size); + } + + /* how many tiles in total needed in the bo */ + max_size = max(max_size, offset + size); + } + + if (mul_u32_u32(max_size, tile_size) > obj->base.size) { + drm_dbg_kms(&dev_priv->drm, + "fb too big for bo (need %llu bytes, have %zu bytes)\n", + mul_u32_u32(max_size, tile_size), obj->base.size); + return -EINVAL; + } + + return 0; +} + +static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) +{ + struct drm_i915_private *dev_priv = + to_i915(plane_state->uapi.plane->dev); + struct drm_framebuffer *fb = plane_state->hw.fb; + struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); + struct intel_rotation_info *info = &plane_state->view.rotated; + unsigned int rotation = plane_state->hw.rotation; + int i, num_planes = fb->format->num_planes; + unsigned int tile_size = intel_tile_size(dev_priv); + unsigned int src_x, src_y; + unsigned int src_w, src_h; + u32 gtt_offset = 0; + + memset(&plane_state->view, 0, sizeof(plane_state->view)); + plane_state->view.type = drm_rotation_90_or_270(rotation) ? + I915_GGTT_VIEW_ROTATED : I915_GGTT_VIEW_REMAPPED; + + src_x = plane_state->uapi.src.x1 >> 16; + src_y = plane_state->uapi.src.y1 >> 16; + src_w = drm_rect_width(&plane_state->uapi.src) >> 16; + src_h = drm_rect_height(&plane_state->uapi.src) >> 16; + + drm_WARN_ON(&dev_priv->drm, is_ccs_modifier(fb->modifier)); + + /* Make src coordinates relative to the viewport */ + drm_rect_translate(&plane_state->uapi.src, + -(src_x << 16), -(src_y << 16)); + + /* Rotate src coordinates to match rotated GTT view */ + if (drm_rotation_90_or_270(rotation)) + drm_rect_rotate(&plane_state->uapi.src, + src_w << 16, src_h << 16, + DRM_MODE_ROTATE_270); + + for (i = 0; i < num_planes; i++) { + unsigned int hsub = i ? fb->format->hsub : 1; + unsigned int vsub = i ? fb->format->vsub : 1; + unsigned int cpp = fb->format->cpp[i]; + unsigned int tile_width, tile_height; + unsigned int width, height; + unsigned int pitch_tiles; + unsigned int x, y; + u32 offset; + + intel_tile_dims(fb, i, &tile_width, &tile_height); + + x = src_x / hsub; + y = src_y / vsub; + width = src_w / hsub; + height = src_h / vsub; + + /* + * First pixel of the src viewport from the + * start of the normal gtt mapping. + */ + x += intel_fb->normal[i].x; + y += intel_fb->normal[i].y; + + offset = intel_compute_aligned_offset(dev_priv, &x, &y, + fb, i, fb->pitches[i], + DRM_MODE_ROTATE_0, tile_size); + offset /= tile_size; + + drm_WARN_ON(&dev_priv->drm, i >= ARRAY_SIZE(info->plane)); + info->plane[i].offset = offset; + info->plane[i].stride = DIV_ROUND_UP(fb->pitches[i], + tile_width * cpp); + info->plane[i].width = DIV_ROUND_UP(x + width, tile_width); + info->plane[i].height = DIV_ROUND_UP(y + height, tile_height); + + if (drm_rotation_90_or_270(rotation)) { + struct drm_rect r; + + /* rotate the x/y offsets to match the GTT view */ + drm_rect_init(&r, x, y, width, height); + drm_rect_rotate(&r, + info->plane[i].width * tile_width, + info->plane[i].height * tile_height, + DRM_MODE_ROTATE_270); + x = r.x1; + y = r.y1; + + pitch_tiles = info->plane[i].height; + plane_state->color_plane[i].stride = pitch_tiles * tile_height; + + /* rotate the tile dimensions to match the GTT view */ + swap(tile_width, tile_height); + } else { + pitch_tiles = info->plane[i].width; + plane_state->color_plane[i].stride = pitch_tiles * tile_width * cpp; + } + + /* + * We only keep the x/y offsets, so push all of the + * gtt offset into the x/y offsets. + */ + intel_adjust_tile_offset(&x, &y, + tile_width, tile_height, + tile_size, pitch_tiles, + gtt_offset * tile_size, 0); + + gtt_offset += info->plane[i].width * info->plane[i].height; + + plane_state->color_plane[i].offset = 0; + plane_state->color_plane[i].x = x; + plane_state->color_plane[i].y = y; + } +} + +void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, + const struct drm_framebuffer *fb, + unsigned int rotation) +{ + memset(view, 0, sizeof(*view)); + + view->type = I915_GGTT_VIEW_NORMAL; + if (drm_rotation_90_or_270(rotation)) { + view->type = I915_GGTT_VIEW_ROTATED; + view->rotated = to_intel_framebuffer(fb)->rot_info; + } +} + int intel_plane_check_stride(const struct intel_plane_state *plane_state) { struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); @@ -96,3 +855,51 @@ int intel_plane_check_stride(const struct intel_plane_state *plane_state) return 0; } + +int intel_plane_compute_gtt(struct intel_plane_state *plane_state) +{ + const struct intel_framebuffer *fb = + to_intel_framebuffer(plane_state->hw.fb); + unsigned int rotation = plane_state->hw.rotation; + int i, num_planes; + + if (!fb) + return 0; + + num_planes = fb->base.format->num_planes; + + if (intel_plane_needs_remap(plane_state)) { + intel_plane_remap_gtt(plane_state); + + /* + * Sometimes even remapping can't overcome + * the stride limitations :( Can happen with + * big plane sizes and suitably misaligned + * offsets. + */ + return intel_plane_check_stride(plane_state); + } + + intel_fill_fb_ggtt_view(&plane_state->view, &fb->base, rotation); + + for (i = 0; i < num_planes; i++) { + plane_state->color_plane[i].stride = intel_fb_pitch(&fb->base, i, rotation); + plane_state->color_plane[i].offset = 0; + + if (drm_rotation_90_or_270(rotation)) { + plane_state->color_plane[i].x = fb->rotated[i].x; + plane_state->color_plane[i].y = fb->rotated[i].y; + } else { + plane_state->color_plane[i].x = fb->normal[i].x; + plane_state->color_plane[i].y = fb->normal[i].y; + } + } + + /* Rotate src coordinates to match rotated GTT view */ + if (drm_rotation_90_or_270(rotation)) + drm_rect_rotate(&plane_state->uapi.src, + fb->base.width << 16, fb->base.height << 16, + DRM_MODE_ROTATE_270); + + return intel_plane_check_stride(plane_state); +} diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 8c15f4c9561b1..59f8715e0bdaf 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -10,11 +10,17 @@ struct drm_framebuffer; +struct drm_i915_private; + +struct i915_ggtt_view; + struct intel_plane_state; bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); +bool is_aux_plane(const struct drm_framebuffer *fb, int plane); +bool is_semiplanar_uv_plane(const struct drm_framebuffer *fb, int color_plane); bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane); @@ -24,4 +30,29 @@ int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); int intel_plane_check_stride(const struct intel_plane_state *plane_state); +unsigned int intel_tile_size(const struct drm_i915_private *dev_priv); +unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane); +unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane); + +unsigned int intel_cursor_alignment(const struct drm_i915_private *dev_priv); + +void intel_fb_plane_get_subsampling(int *hsub, int *vsub, + const struct drm_framebuffer *fb, + int color_plane); + +u32 intel_plane_adjust_aligned_offset(int *x, int *y, + const struct intel_plane_state *state, + int color_plane, + u32 old_offset, u32 new_offset); +u32 intel_plane_compute_aligned_offset(int *x, int *y, + const struct intel_plane_state *state, + int color_plane); + +int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation); + +int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer *fb); +void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, const struct drm_framebuffer *fb, + unsigned int rotation); +int intel_plane_compute_gtt(struct intel_plane_state *plane_state); + #endif /* __INTEL_FB_H__ */ From patchwork Thu Mar 25 21:47:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 029D2C433DB for ; Thu, 25 Mar 2021 21:48:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDC29619EE for ; Thu, 25 Mar 2021 21:48:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDC29619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BC3C6EE57; Thu, 25 Mar 2021 21:48:28 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7DF86EE57 for ; Thu, 25 Mar 2021 21:48:26 +0000 (UTC) IronPort-SDR: M32aebumKT2vjrwgGGa5pIASP3X3yT9KOqIs7f0oxjaUprCgRAshj4EfxwHva1HUqUSzLoNHKl +WY7BWXxrrIw== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005063" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005063" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:26 -0700 IronPort-SDR: +x8R76idD8S7i7NIcR79e0R3dhaJoyV5TpBNArY7LOWEjafkX6hG5aCbCgwFHwaObI/KsARyAR LPs3ZkD80TAg== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235660" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:25 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:54 +0200 Message-Id: <20210325214808.2071517-12-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 11/25] drm/i915/intel_fb: Unexport intel_fb_check_stride() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" After the previous patch we can unexport intel_fb_check_stride(), which isn't needed by intel_display.c. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 2 +- drivers/gpu/drm/i915/display/intel_fb.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index b872eb29fd0d7..8cc93d89fc0aa 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -824,7 +824,7 @@ void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, } } -int intel_plane_check_stride(const struct intel_plane_state *plane_state) +static int intel_plane_check_stride(const struct intel_plane_state *plane_state) { struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); const struct drm_framebuffer *fb = plane_state->hw.fb; diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 59f8715e0bdaf..042946f452f09 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -28,8 +28,6 @@ int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); -int intel_plane_check_stride(const struct intel_plane_state *plane_state); - unsigned int intel_tile_size(const struct drm_i915_private *dev_priv); unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane); unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane); From patchwork Thu Mar 25 21:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3658EC433E1 for ; Thu, 25 Mar 2021 21:48:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2F36619BA for ; Thu, 25 Mar 2021 21:48:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2F36619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 789246EE58; Thu, 25 Mar 2021 21:48:28 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id D93E96EE57 for ; Thu, 25 Mar 2021 21:48:27 +0000 (UTC) IronPort-SDR: HgXeoOlnh4qwM2xGZqTelH+Zx6lCVzTsoKSqV3m2L6J8oY/ZTKFHFksGF6AzUa63FIk/A5OjDS oerKBM4ejXEA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005066" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005066" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:27 -0700 IronPort-SDR: gUuV4wXDd3BcOD3hFetDm27+BBLsY5J15Dzib7RV8oh+6kyYtoGi5td0KDWUkGI5h5DnJJaEFX QtplM/Pt38vw== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235664" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:26 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:55 +0200 Message-Id: <20210325214808.2071517-13-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 12/25] drm/i915/intel_fb: s/dev_priv/i915/ X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Rename dev_priv to i915 in the intel_fb.[ch] files. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 66 ++++++++++++------------- drivers/gpu/drm/i915/display/intel_fb.h | 6 +-- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 8cc93d89fc0aa..f4579f306733f 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -80,9 +80,9 @@ int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) return 0; } -unsigned int intel_tile_size(const struct drm_i915_private *dev_priv) +unsigned int intel_tile_size(const struct drm_i915_private *i915) { - return IS_DISPLAY_VER(dev_priv, 2) ? 2048 : 4096; + return IS_DISPLAY_VER(i915, 2) ? 2048 : 4096; } unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane) @@ -115,13 +115,13 @@ unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_pla return fb->pitches[color_plane] * tile_height; } -unsigned int intel_cursor_alignment(const struct drm_i915_private *dev_priv) +unsigned int intel_cursor_alignment(const struct drm_i915_private *i915) { - if (IS_I830(dev_priv)) + if (IS_I830(i915)) return 16 * 1024; - else if (IS_I85X(dev_priv)) + else if (IS_I85X(i915)) return 256; - else if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) + else if (IS_I845G(i915) || IS_I865G(i915)) return 32; else return 4 * 1024; @@ -216,16 +216,16 @@ static u32 intel_adjust_aligned_offset(int *x, int *y, unsigned int pitch, u32 old_offset, u32 new_offset) { - struct drm_i915_private *dev_priv = to_i915(fb->dev); + struct drm_i915_private *i915 = to_i915(fb->dev); unsigned int cpp = fb->format->cpp[color_plane]; - drm_WARN_ON(&dev_priv->drm, new_offset > old_offset); + drm_WARN_ON(&i915->drm, new_offset > old_offset); if (!is_surface_linear(fb, color_plane)) { unsigned int tile_size, tile_width, tile_height; unsigned int pitch_tiles; - tile_size = intel_tile_size(dev_priv); + tile_size = intel_tile_size(i915); intel_tile_dims(fb, color_plane, &tile_width, &tile_height); if (drm_rotation_90_or_270(rotation)) { @@ -277,7 +277,7 @@ u32 intel_plane_adjust_aligned_offset(int *x, int *y, * used. This is why the user has to pass in the pitch since it * is specified in the rotated orientation. */ -static u32 intel_compute_aligned_offset(struct drm_i915_private *dev_priv, +static u32 intel_compute_aligned_offset(struct drm_i915_private *i915, int *x, int *y, const struct drm_framebuffer *fb, int color_plane, @@ -292,7 +292,7 @@ static u32 intel_compute_aligned_offset(struct drm_i915_private *dev_priv, unsigned int tile_size, tile_width, tile_height; unsigned int tile_rows, tiles, pitch_tiles; - tile_size = intel_tile_size(dev_priv); + tile_size = intel_tile_size(i915); intel_tile_dims(fb, color_plane, &tile_width, &tile_height); if (drm_rotation_90_or_270(rotation)) { @@ -337,18 +337,18 @@ u32 intel_plane_compute_aligned_offset(int *x, int *y, int color_plane) { struct intel_plane *intel_plane = to_intel_plane(state->uapi.plane); - struct drm_i915_private *dev_priv = to_i915(intel_plane->base.dev); + struct drm_i915_private *i915 = to_i915(intel_plane->base.dev); const struct drm_framebuffer *fb = state->hw.fb; unsigned int rotation = state->hw.rotation; int pitch = state->color_plane[color_plane].stride; u32 alignment; if (intel_plane->id == PLANE_CURSOR) - alignment = intel_cursor_alignment(dev_priv); + alignment = intel_cursor_alignment(i915); else alignment = intel_surf_alignment(fb, color_plane); - return intel_compute_aligned_offset(dev_priv, x, y, fb, color_plane, + return intel_compute_aligned_offset(i915, x, y, fb, color_plane, pitch, rotation, alignment); } @@ -357,20 +357,20 @@ static int intel_fb_offset_to_xy(int *x, int *y, const struct drm_framebuffer *fb, int color_plane) { - struct drm_i915_private *dev_priv = to_i915(fb->dev); + struct drm_i915_private *i915 = to_i915(fb->dev); unsigned int height; u32 alignment; - if (DISPLAY_VER(dev_priv) >= 12 && + if (DISPLAY_VER(i915) >= 12 && is_semiplanar_uv_plane(fb, color_plane)) alignment = intel_tile_row_size(fb, color_plane); else if (fb->modifier != DRM_FORMAT_MOD_LINEAR) - alignment = intel_tile_size(dev_priv); + alignment = intel_tile_size(i915); else alignment = 0; if (alignment != 0 && fb->offsets[color_plane] % alignment) { - drm_dbg_kms(&dev_priv->drm, + drm_dbg_kms(&i915->drm, "Misaligned offset 0x%08x for color plane %d\n", fb->offsets[color_plane], color_plane); return -EINVAL; @@ -382,7 +382,7 @@ static int intel_fb_offset_to_xy(int *x, int *y, /* Catch potential overflows early */ if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]), fb->offsets[color_plane])) { - drm_dbg_kms(&dev_priv->drm, + drm_dbg_kms(&i915->drm, "Bad offset 0x%08x or pitch %d for color plane %d\n", fb->offsets[color_plane], fb->pitches[color_plane], color_plane); @@ -447,7 +447,7 @@ static int intel_fb_check_ccs_xy(struct drm_framebuffer *fb, int ccs_plane, int static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) { struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); + struct drm_i915_private *i915 = to_i915(plane->base.dev); const struct drm_framebuffer *fb = plane_state->hw.fb; int i; @@ -461,7 +461,7 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) * Would also need to deal with the fence POT alignment * and gen2 2KiB GTT tile size. */ - if (DISPLAY_VER(dev_priv) < 4) + if (DISPLAY_VER(i915) < 4) return false; /* @@ -473,7 +473,7 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) /* Linear needs a page aligned stride for remapping */ if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { - unsigned int alignment = intel_tile_size(dev_priv) - 1; + unsigned int alignment = intel_tile_size(i915) - 1; for (i = 0; i < fb->format->num_planes; i++) { if (fb->pitches[i] & alignment) @@ -580,14 +580,14 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * return plane_info->width * plane_info->height; } -int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer *fb) +int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb) { struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb); u32 gtt_offset_rotated = 0; unsigned int max_size = 0; int i, num_planes = fb->format->num_planes; - unsigned int tile_size = intel_tile_size(dev_priv); + unsigned int tile_size = intel_tile_size(i915); for (i = 0; i < num_planes; i++) { unsigned int width, height; @@ -613,7 +613,7 @@ int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer ret = intel_fb_offset_to_xy(&x, &y, fb, i); if (ret) { - drm_dbg_kms(&dev_priv->drm, + drm_dbg_kms(&i915->drm, "bad fb plane %d offset: 0x%x\n", i, fb->offsets[i]); return ret; @@ -634,7 +634,7 @@ int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer */ if (i == 0 && i915_gem_object_is_tiled(obj) && (x + width) * cpp > fb->pitches[i]) { - drm_dbg_kms(&dev_priv->drm, + drm_dbg_kms(&i915->drm, "bad fb plane %d offset: 0x%x\n", i, fb->offsets[i]); return -EINVAL; @@ -647,7 +647,7 @@ int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer intel_fb->normal[i].x = x; intel_fb->normal[i].y = y; - offset = intel_compute_aligned_offset(dev_priv, &x, &y, fb, i, + offset = intel_compute_aligned_offset(i915, &x, &y, fb, i, fb->pitches[i], DRM_MODE_ROTATE_0, tile_size); @@ -692,7 +692,7 @@ int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer } if (mul_u32_u32(max_size, tile_size) > obj->base.size) { - drm_dbg_kms(&dev_priv->drm, + drm_dbg_kms(&i915->drm, "fb too big for bo (need %llu bytes, have %zu bytes)\n", mul_u32_u32(max_size, tile_size), obj->base.size); return -EINVAL; @@ -703,14 +703,14 @@ int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) { - struct drm_i915_private *dev_priv = + struct drm_i915_private *i915 = to_i915(plane_state->uapi.plane->dev); struct drm_framebuffer *fb = plane_state->hw.fb; struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); struct intel_rotation_info *info = &plane_state->view.rotated; unsigned int rotation = plane_state->hw.rotation; int i, num_planes = fb->format->num_planes; - unsigned int tile_size = intel_tile_size(dev_priv); + unsigned int tile_size = intel_tile_size(i915); unsigned int src_x, src_y; unsigned int src_w, src_h; u32 gtt_offset = 0; @@ -724,7 +724,7 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) src_w = drm_rect_width(&plane_state->uapi.src) >> 16; src_h = drm_rect_height(&plane_state->uapi.src) >> 16; - drm_WARN_ON(&dev_priv->drm, is_ccs_modifier(fb->modifier)); + drm_WARN_ON(&i915->drm, is_ccs_modifier(fb->modifier)); /* Make src coordinates relative to the viewport */ drm_rect_translate(&plane_state->uapi.src, @@ -760,12 +760,12 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) x += intel_fb->normal[i].x; y += intel_fb->normal[i].y; - offset = intel_compute_aligned_offset(dev_priv, &x, &y, + offset = intel_compute_aligned_offset(i915, &x, &y, fb, i, fb->pitches[i], DRM_MODE_ROTATE_0, tile_size); offset /= tile_size; - drm_WARN_ON(&dev_priv->drm, i >= ARRAY_SIZE(info->plane)); + drm_WARN_ON(&i915->drm, i >= ARRAY_SIZE(info->plane)); info->plane[i].offset = offset; info->plane[i].stride = DIV_ROUND_UP(fb->pitches[i], tile_width * cpp); diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 042946f452f09..bd1551c694eb3 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -28,11 +28,11 @@ int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); -unsigned int intel_tile_size(const struct drm_i915_private *dev_priv); +unsigned int intel_tile_size(const struct drm_i915_private *i915); unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane); unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane); -unsigned int intel_cursor_alignment(const struct drm_i915_private *dev_priv); +unsigned int intel_cursor_alignment(const struct drm_i915_private *i915); void intel_fb_plane_get_subsampling(int *hsub, int *vsub, const struct drm_framebuffer *fb, @@ -48,7 +48,7 @@ u32 intel_plane_compute_aligned_offset(int *x, int *y, int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation); -int intel_fill_fb_info(struct drm_i915_private *dev_priv, struct drm_framebuffer *fb); +int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb); void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, const struct drm_framebuffer *fb, unsigned int rotation); int intel_plane_compute_gtt(struct intel_plane_state *plane_state); From patchwork Thu Mar 25 21:47:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E1EDC433C1 for ; Thu, 25 Mar 2021 21:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE5D461494 for ; Thu, 25 Mar 2021 21:48:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE5D461494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E23A6EE66; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 748FE6EE5D for ; Thu, 25 Mar 2021 21:48:29 +0000 (UTC) IronPort-SDR: ULQo/2FpZ6TAy+8sY9FFiM7m8Vye6we3BbkGtAwi36EWIDj+uUS13AbeR69I7ThiVjjbEFJb8+ ML7IFSEY2PIw== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005068" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005068" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:29 -0700 IronPort-SDR: nz5h3sUiUOXFZwIBW7NLHv62Up3cTopOB0XzoZUSBW57aj8GXBopeptx0lVdqAshXKBRAQLj17 UdmZ4yV0A5yQ== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235669" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:27 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:56 +0200 Message-Id: <20210325214808.2071517-14-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 13/25] drm/i915/intel_fb: Factor out convert_plane_offset_to_xy() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Factor out to a new function the logic to convert the FB plane offset to x/y and check the validity of x/y, with the goal to make intel_fill_fb_info() more readable. v2: Use &fb->base instead of a drm_fb alias. (Ville) Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 69 +++++++++++++++---------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index f4579f306733f..25b967220cf04 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -400,10 +400,10 @@ static int intel_fb_offset_to_xy(int *x, int *y, return 0; } -static int intel_fb_check_ccs_xy(struct drm_framebuffer *fb, int ccs_plane, int x, int y) +static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane, int x, int y) { struct drm_i915_private *i915 = to_i915(fb->dev); - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); + const struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); int main_plane; int hsub, vsub; int tile_width, tile_height; @@ -520,6 +520,44 @@ static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) return stride > max_stride; } +static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int color_plane, + int plane_width, int *x, int *y) +{ + struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); + int ret; + + ret = intel_fb_offset_to_xy(x, y, &fb->base, color_plane); + if (ret) { + drm_dbg_kms(fb->base.dev, + "bad fb plane %d offset: 0x%x\n", + color_plane, fb->base.offsets[color_plane]); + return ret; + } + + ret = intel_fb_check_ccs_xy(&fb->base, color_plane, *x, *y); + if (ret) + return ret; + + /* + * The fence (if used) is aligned to the start of the object + * so having the framebuffer wrap around across the edge of the + * fenced region doesn't really work. We have no API to configure + * the fence start offset within the object (nor could we probably + * on gen2/3). So it's just easier if we just require that the + * fb layout agrees with the fence layout. We already check that the + * fb stride matches the fence stride elsewhere. + */ + if (color_plane == 0 && i915_gem_object_is_tiled(obj) && + (*x + plane_width) * fb->base.format->cpp[color_plane] > fb->base.pitches[color_plane]) { + drm_dbg_kms(fb->base.dev, + "bad fb plane %d offset: 0x%x\n", + color_plane, fb->base.offsets[color_plane]); + return -EINVAL; + } + + return 0; +} + /* * Setup the rotated view for an FB plane and return the size the GTT mapping * requires for this view. @@ -611,35 +649,10 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb cpp = fb->format->cpp[i]; intel_fb_plane_dims(&width, &height, fb, i); - ret = intel_fb_offset_to_xy(&x, &y, fb, i); - if (ret) { - drm_dbg_kms(&i915->drm, - "bad fb plane %d offset: 0x%x\n", - i, fb->offsets[i]); - return ret; - } - - ret = intel_fb_check_ccs_xy(fb, i, x, y); + ret = convert_plane_offset_to_xy(intel_fb, i, width, &x, &y); if (ret) return ret; - /* - * The fence (if used) is aligned to the start of the object - * so having the framebuffer wrap around across the edge of the - * fenced region doesn't really work. We have no API to configure - * the fence start offset within the object (nor could we probably - * on gen2/3). So it's just easier if we just require that the - * fb layout agrees with the fence layout. We already check that the - * fb stride matches the fence stride elsewhere. - */ - if (i == 0 && i915_gem_object_is_tiled(obj) && - (x + width) * cpp > fb->pitches[i]) { - drm_dbg_kms(&i915->drm, - "bad fb plane %d offset: 0x%x\n", - i, fb->offsets[i]); - return -EINVAL; - } - /* * First pixel of the framebuffer from * the start of the normal gtt mapping. From patchwork Thu Mar 25 21:47:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E30C433DB for ; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F63D61494 for ; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F63D61494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 143576EE5F; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 431276EE5B for ; Thu, 25 Mar 2021 21:48:30 +0000 (UTC) IronPort-SDR: 23VsKL6XjXoIB5eKyOdvLG5G6fjKKp523wukgYVPc6wu3/9zAw3Y5QIIHOgYoc9lPSY2QqCAap rSaVC3RqPb4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005069" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005069" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:30 -0700 IronPort-SDR: u4Xs8XTG2g1cw2U99T7DDvfH2flWnHz0wZxB15AnqRJerdFv3xQ4iyPNAlbn7lghqHcqGKbnDV pXPUs7XWexYg== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235671" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:29 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:57 +0200 Message-Id: <20210325214808.2071517-15-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 14/25] drm/i915/intel_fb: Factor out calc_plane_aligned_offset() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Factor out to a new function the logic to convert the FB plane x/y values to a tile size based offset and new x/y relative to this offset. This makes intel_fill_fb_info() and intel_plane_remap_gtt() somewhat more readable. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 25b967220cf04..1400a31f0dd6b 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -558,6 +558,20 @@ static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int co return 0; } +static u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int color_plane, int *x, int *y) +{ + struct drm_i915_private *i915 = to_i915(fb->base.dev); + unsigned int tile_size = intel_tile_size(i915); + u32 offset; + + offset = intel_compute_aligned_offset(i915, x, y, &fb->base, color_plane, + fb->base.pitches[color_plane], + DRM_MODE_ROTATE_0, + tile_size); + + return offset / tile_size; +} + /* * Setup the rotated view for an FB plane and return the size the GTT mapping * requires for this view. @@ -660,11 +674,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb intel_fb->normal[i].x = x; intel_fb->normal[i].y = y; - offset = intel_compute_aligned_offset(i915, &x, &y, fb, i, - fb->pitches[i], - DRM_MODE_ROTATE_0, - tile_size); - offset /= tile_size; + offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); if (!is_surface_linear(fb, i)) { struct intel_remapped_plane_info plane_info; @@ -773,10 +783,7 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) x += intel_fb->normal[i].x; y += intel_fb->normal[i].y; - offset = intel_compute_aligned_offset(i915, &x, &y, - fb, i, fb->pitches[i], - DRM_MODE_ROTATE_0, tile_size); - offset /= tile_size; + offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); drm_WARN_ON(&i915->drm, i >= ARRAY_SIZE(info->plane)); info->plane[i].offset = offset; From patchwork Thu Mar 25 21:47:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5FE5C433E0 for ; Thu, 25 Mar 2021 21:48:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE6E6619EE for ; Thu, 25 Mar 2021 21:48:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE6E6619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6A936EE5B; Thu, 25 Mar 2021 21:48:33 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 891A76EE5B for ; Thu, 25 Mar 2021 21:48:31 +0000 (UTC) IronPort-SDR: 7UkALFaacDrsGlM3JYaZdGEgdDnl5ZtkEeMfo0dEQNFVqKaTcWoKInxetWYN+9BZUJMlI1QL/h fSl8JFSzjE5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005071" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005071" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:31 -0700 IronPort-SDR: Pg4ovrM5fD7zxATkAdApWnAparOf+JQC7Ah8SgnmB55+59R6iieVretIxYEz2+aF4SpLwOlCox 3qTx6BIRqpZA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235673" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:30 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:58 +0200 Message-Id: <20210325214808.2071517-16-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 15/25] drm/i915/intel_fb: Factor out calc_plane_normal_size() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Factor out to a new function the logic to calculate an FB plane's normal-view size. Instead of using intel_remapped_plane_info, which is related only to remapping, add a helper to get the tile pitch and rows for an FB plane, so these helpers can be used both by the normal size calculation and the remapping code. Also add a new fb_plane_view_dims struct in which we can pass around the view (either FB plane or plane source) and tile dimensions conveniently to functions calculating further view parameters. v2: - Add back the +1 tile adjustment for x!=0 in calc_plane_normal_size(). (Ville) - s/pages/tiles/ in calc_plane_normal_size(). (Ville) - Add a helper for the plane view width calculation. (Ville) - Return tiles as unsigned int from calc_plane_normal_size(). Cc: Ville Syrjälä Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 97 +++++++++++++++++++------ 1 file changed, 76 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 1400a31f0dd6b..6f8206769c3df 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -632,6 +632,74 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * return plane_info->width * plane_info->height; } +struct fb_plane_view_dims { + unsigned int width, height; + unsigned int tile_width, tile_height; +}; + +static void init_plane_view_dims(const struct intel_framebuffer *fb, int color_plane, + unsigned int width, unsigned int height, + struct fb_plane_view_dims *dims) +{ + dims->width = width; + dims->height = height; + + intel_tile_dims(&fb->base, color_plane, &dims->tile_width, &dims->tile_height); +} + +static unsigned int +plane_view_stride_tiles(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims) +{ + return DIV_ROUND_UP(fb->base.pitches[color_plane], + dims->tile_width * fb->base.format->cpp[color_plane]); +} + +static unsigned int +plane_view_width_tiles(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims, + int x) +{ + return DIV_ROUND_UP(x + dims->width, dims->tile_width); +} + +static unsigned int +plane_view_height_tiles(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims, + int y) +{ + return DIV_ROUND_UP(y + dims->height, dims->tile_height); +} + +/* Return number of tiles @color_plane needs. */ +static unsigned int +calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims, + int x, int y) +{ + struct drm_i915_private *i915 = to_i915(fb->base.dev); + unsigned int tiles; + + if (is_surface_linear(&fb->base, color_plane)) { + unsigned int size; + + size = (y + dims->height) * fb->base.pitches[color_plane] + + x * fb->base.format->cpp[color_plane]; + tiles = DIV_ROUND_UP(size, intel_tile_size(i915)); + } else { + tiles = plane_view_stride_tiles(fb, color_plane, dims) * + plane_view_height_tiles(fb, color_plane, dims, y); + /* + * If the plane isn't horizontally tile aligned, + * we need one more tile. + */ + if (x != 0) + tiles++; + } + + return tiles; +} + int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb) { struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); @@ -642,6 +710,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb unsigned int tile_size = intel_tile_size(i915); for (i = 0; i < num_planes; i++) { + struct fb_plane_view_dims view_dims; unsigned int width, height; unsigned int cpp, size; u32 offset; @@ -667,6 +736,8 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb if (ret) return ret; + init_plane_view_dims(intel_fb, i, width, height, &view_dims); + /* * First pixel of the framebuffer from * the start of the normal gtt mapping. @@ -678,38 +749,22 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb if (!is_surface_linear(fb, i)) { struct intel_remapped_plane_info plane_info; - unsigned int tile_width, tile_height; - - intel_tile_dims(fb, i, &tile_width, &tile_height); plane_info.offset = offset; - plane_info.stride = DIV_ROUND_UP(fb->pitches[i], - tile_width * cpp); - plane_info.width = DIV_ROUND_UP(x + width, tile_width); - plane_info.height = DIV_ROUND_UP(y + height, - tile_height); - - /* how many tiles does this plane need */ - size = plane_info.stride * plane_info.height; - /* - * If the plane isn't horizontally tile aligned, - * we need one more tile. - */ - if (x != 0) - size++; + plane_info.stride = plane_view_stride_tiles(intel_fb, i, &view_dims); + plane_info.width = plane_view_width_tiles(intel_fb, i, &view_dims, x); + plane_info.height = plane_view_height_tiles(intel_fb, i, &view_dims, y); gtt_offset_rotated += setup_fb_rotation(i, &plane_info, gtt_offset_rotated, x, y, width, height, tile_size, - tile_width, tile_height, + view_dims.tile_width, view_dims.tile_height, fb); - } else { - size = DIV_ROUND_UP((y + height) * fb->pitches[i] + - x * cpp, tile_size); } + size = calc_plane_normal_size(intel_fb, i, &view_dims, x, y); /* how many tiles in total needed in the bo */ max_size = max(max_size, offset + size); } From patchwork Thu Mar 25 21:47:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD50C433E0 for ; Thu, 25 Mar 2021 21:48:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61895619EE for ; Thu, 25 Mar 2021 21:48:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61895619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1129B6EE63; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 106FA6EE5B for ; Thu, 25 Mar 2021 21:48:33 +0000 (UTC) IronPort-SDR: LI+lm3o2sGWrtmrOu1DqV7JbjW/w+BzfGoRZ8qp54UliB/kPtpufiPsRtay4olXmUPePcgPHsw ZEZrWlNU82iQ== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005078" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005078" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:32 -0700 IronPort-SDR: qp1t/UMl2dXV5FIPuodMzLSNx90iAyHGGwbiQNVGZNosQL2KdJVpfRw0FooPnwuoIXNfH3lK8Y +yi6oBzCyHDA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235681" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:31 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:47:59 +0200 Message-Id: <20210325214808.2071517-17-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 16/25] drm/i915: Unify the FB and plane state view information into one struct X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To allow the simplification of FB/plane view computation in the follow-up patches, unify the corresponding state in the intel_framebuffer and intel_plane_state structs into a new intel_fb_view struct. This adds some overhead to intel_framebuffer as the rotated view will have now space for 4 color planes instead of the required 2 and it'll also contain the unused offset for each color_plane info. Imo this is an acceptable trade-off to get a simplified way of the remap computation. Use the new intel_fb_view struct for the FB normal view as well, so (in the follow-up patches) we can remove the special casing for normal view calculation wrt. the calculation of remapped/rotated views. This also adds an overhead to the intel_framebuffer struct, as the gtt remap info and per-color plane offset/pitch is not required for the normal view, but imo this is an acceptable trade-off as above. The per-color plane pitch filed will be used by a follow-up patch, so we can retrieve the pitch for each view in the same way. No functional changes in this patch. Suggested-by: Ville Syrjälä Cc: Ville Syrjälä Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/i9xx_plane.c | 20 +++--- drivers/gpu/drm/i915/display/intel_cursor.c | 14 ++-- drivers/gpu/drm/i915/display/intel_display.c | 22 +++--- .../drm/i915/display/intel_display_types.h | 61 ++++++++++------ drivers/gpu/drm/i915/display/intel_fb.c | 66 ++++++++--------- drivers/gpu/drm/i915/display/intel_fb.h | 3 + drivers/gpu/drm/i915/display/intel_fbc.c | 6 +- drivers/gpu/drm/i915/display/intel_sprite.c | 26 +++---- .../drm/i915/display/skl_universal_plane.c | 71 +++++++++---------- 9 files changed, 153 insertions(+), 136 deletions(-) diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c index 40266b78247b2..8ee59490c027a 100644 --- a/drivers/gpu/drm/i915/display/i9xx_plane.c +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c @@ -271,7 +271,7 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state) u32 alignment = intel_surf_alignment(fb, 0); int cpp = fb->format->cpp[0]; - while ((src_x + src_w) * cpp > plane_state->color_plane[0].stride) { + while ((src_x + src_w) * cpp > plane_state->view.color_plane[0].pitch) { if (offset == 0) { drm_dbg_kms(&dev_priv->drm, "Unable to find suitable display surface offset due to X-tiling\n"); @@ -311,9 +311,9 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state) drm_WARN_ON(&dev_priv->drm, src_x > 4095 || src_y > 4095); } - plane_state->color_plane[0].offset = offset; - plane_state->color_plane[0].x = src_x; - plane_state->color_plane[0].y = src_y; + plane_state->view.color_plane[0].offset = offset; + plane_state->view.color_plane[0].x = src_x; + plane_state->view.color_plane[0].y = src_y; return 0; } @@ -424,8 +424,8 @@ static void i9xx_update_plane(struct intel_plane *plane, struct drm_i915_private *dev_priv = to_i915(plane->base.dev); enum i9xx_plane_id i9xx_plane = plane->i9xx_plane; u32 linear_offset; - int x = plane_state->color_plane[0].x; - int y = plane_state->color_plane[0].y; + int x = plane_state->view.color_plane[0].x; + int y = plane_state->view.color_plane[0].y; int crtc_x = plane_state->uapi.dst.x1; int crtc_y = plane_state->uapi.dst.y1; int crtc_w = drm_rect_width(&plane_state->uapi.dst); @@ -439,14 +439,14 @@ static void i9xx_update_plane(struct intel_plane *plane, linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0); if (DISPLAY_VER(dev_priv) >= 4) - dspaddr_offset = plane_state->color_plane[0].offset; + dspaddr_offset = plane_state->view.color_plane[0].offset; else dspaddr_offset = linear_offset; spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); intel_de_write_fw(dev_priv, DSPSTRIDE(i9xx_plane), - plane_state->color_plane[0].stride); + plane_state->view.color_plane[0].pitch); if (DISPLAY_VER(dev_priv) < 4) { /* @@ -531,7 +531,7 @@ g4x_primary_async_flip(struct intel_plane *plane, { struct drm_i915_private *dev_priv = to_i915(plane->base.dev); u32 dspcntr = plane_state->ctl | i9xx_plane_ctl_crtc(crtc_state); - u32 dspaddr_offset = plane_state->color_plane[0].offset; + u32 dspaddr_offset = plane_state->view.color_plane[0].offset; enum i9xx_plane_id i9xx_plane = plane->i9xx_plane; unsigned long irqflags; @@ -552,7 +552,7 @@ vlv_primary_async_flip(struct intel_plane *plane, bool async_flip) { struct drm_i915_private *dev_priv = to_i915(plane->base.dev); - u32 dspaddr_offset = plane_state->color_plane[0].offset; + u32 dspaddr_offset = plane_state->view.color_plane[0].offset; enum i9xx_plane_id i9xx_plane = plane->i9xx_plane; unsigned long irqflags; diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c index 84099b7f5c358..03dad12cf78fc 100644 --- a/drivers/gpu/drm/i915/display/intel_cursor.c +++ b/drivers/gpu/drm/i915/display/intel_cursor.c @@ -45,7 +45,7 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state) else base = intel_plane_ggtt_offset(plane_state); - return base + plane_state->color_plane[0].offset; + return base + plane_state->view.color_plane[0].offset; } static u32 intel_cursor_position(const struct intel_plane_state *plane_state) @@ -125,9 +125,9 @@ static int intel_cursor_check_surface(struct intel_plane_state *plane_state) offset += (src_h * src_w - 1) * fb->format->cpp[0]; } - plane_state->color_plane[0].offset = offset; - plane_state->color_plane[0].x = src_x; - plane_state->color_plane[0].y = src_y; + plane_state->view.color_plane[0].offset = offset; + plane_state->view.color_plane[0].x = src_x; + plane_state->view.color_plane[0].y = src_y; return 0; } @@ -194,7 +194,7 @@ static u32 i845_cursor_ctl(const struct intel_crtc_state *crtc_state, { return CURSOR_ENABLE | CURSOR_FORMAT_ARGB | - CURSOR_STRIDE(plane_state->color_plane[0].stride); + CURSOR_STRIDE(plane_state->view.color_plane[0].pitch); } static bool i845_cursor_size_ok(const struct intel_plane_state *plane_state) @@ -233,7 +233,7 @@ static int i845_check_cursor(struct intel_crtc_state *crtc_state, } drm_WARN_ON(&i915->drm, plane_state->uapi.visible && - plane_state->color_plane[0].stride != fb->pitches[0]); + plane_state->view.color_plane[0].pitch != fb->pitches[0]); switch (fb->pitches[0]) { case 256: @@ -450,7 +450,7 @@ static int i9xx_check_cursor(struct intel_crtc_state *crtc_state, } drm_WARN_ON(&dev_priv->drm, plane_state->uapi.visible && - plane_state->color_plane[0].stride != fb->pitches[0]); + plane_state->view.color_plane[0].pitch != fb->pitches[0]); if (fb->pitches[0] != drm_rect_width(&plane_state->uapi.dst) * fb->format->cpp[0]) { diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 25eaa8a44baa8..4ee7e72142a5f 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -1013,7 +1013,7 @@ static bool intel_plane_uses_fence(const struct intel_plane_state *plane_state) return DISPLAY_VER(dev_priv) < 4 || (plane->has_fbc && - plane_state->view.type == I915_GGTT_VIEW_NORMAL); + plane_state->view.gtt.type == I915_GGTT_VIEW_NORMAL); } struct i915_vma * @@ -1161,7 +1161,7 @@ u32 intel_fb_xy_to_linear(int x, int y, { const struct drm_framebuffer *fb = state->hw.fb; unsigned int cpp = fb->format->cpp[color_plane]; - unsigned int pitch = state->color_plane[color_plane].stride; + unsigned int pitch = state->view.color_plane[color_plane].pitch; return y * pitch + x * cpp; } @@ -1176,8 +1176,8 @@ void intel_add_fb_offsets(int *x, int *y, int color_plane) { - *x += state->color_plane[color_plane].x; - *y += state->color_plane[color_plane].y; + *x += state->view.color_plane[color_plane].x; + *y += state->view.color_plane[color_plane].y; } static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier) @@ -1680,9 +1680,9 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, valid_fb: plane_state->rotation = plane_config->rotation; - intel_fill_fb_ggtt_view(&intel_state->view, fb, + intel_fill_fb_ggtt_view(&intel_state->view.gtt, fb, plane_state->rotation); - intel_state->color_plane[0].stride = + intel_state->view.color_plane[0].pitch = intel_fb_pitch(fb, 0, plane_state->rotation); __i915_vma_pin(vma); @@ -1723,7 +1723,7 @@ intel_plane_fence_y_offset(const struct intel_plane_state *plane_state) int x = 0, y = 0; intel_plane_adjust_aligned_offset(&x, &y, plane_state, 0, - plane_state->color_plane[0].offset, 0); + plane_state->view.color_plane[0].offset, 0); return y; } @@ -6787,8 +6787,6 @@ static int icl_check_nv12_planes(struct intel_crtc_state *crtc_state) linked_state->ctl = plane_state->ctl | PLANE_CTL_YUV420_Y_PLANE; linked_state->color_ctl = plane_state->color_ctl; linked_state->view = plane_state->view; - memcpy(linked_state->color_plane, plane_state->color_plane, - sizeof(linked_state->color_plane)); intel_plane_copy_hw_state(linked_state, plane_state); linked_state->uapi.src = plane_state->uapi.src; @@ -9320,8 +9318,8 @@ static int intel_atomic_check_async(struct intel_atomic_state *state) return -EINVAL; } - if (old_plane_state->color_plane[0].stride != - new_plane_state->color_plane[0].stride) { + if (old_plane_state->view.color_plane[0].pitch != + new_plane_state->view.color_plane[0].pitch) { drm_dbg_kms(&i915->drm, "Stride cannot be changed in async flip\n"); return -EINVAL; } @@ -10546,7 +10544,7 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state) INTEL_INFO(dev_priv)->display.cursor_needs_physical; vma = intel_pin_and_fence_fb_obj(fb, phys_cursor, - &plane_state->view, + &plane_state->view.gtt, intel_plane_uses_fence(plane_state), &plane_state->flags); if (IS_ERR(vma)) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 80983cfe9d3b0..b72861f6f68a7 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -85,20 +85,49 @@ enum intel_broadcast_rgb { INTEL_BROADCAST_RGB_LIMITED, }; +struct intel_fb_view { + /* + * The remap information used in the remapped and rotated views to + * create the DMA scatter-gather list for each FB color plane. This sg + * list is created along with the view type (gtt.type) specific + * i915_vma object and contains the list of FB object pages (reordered + * in the rotated view) that are visible in the view. + * In the normal view the FB object's backing store sg list is used + * directly and hence the remap information here is not used. + */ + struct i915_ggtt_view gtt; + + /* + * The GTT view (gtt.type) specific information for each FB color + * plane. In the normal GTT view all formats (up to 4 color planes), + * in the rotated and remapped GTT view all no-CCS formats (up to 2 + * color planes) are supported. + * + * TODO: add support for CCS formats in the remapped GTT view. + * + * The view information shared by all FB color planes in the FB, + * like dst x/y and src/dst width, is stored separately in + * intel_plane_state. + */ + struct i915_color_plane_view { + u32 offset; + unsigned int x, y; + /* + * Plane pitch (stride) in: + * bytes for 0/180 degree rotation + * pixels for 90/270 degree rotation + */ + unsigned int pitch; + } color_plane[4]; +}; + struct intel_framebuffer { struct drm_framebuffer base; struct intel_frontbuffer *frontbuffer; - struct intel_rotation_info rot_info; - /* for each plane in the normal GTT view */ - struct { - unsigned int x, y; - } normal[4]; - /* for each plane in the rotated GTT view for no-CCS formats */ - struct { - unsigned int x, y; - unsigned int pitch; /* pixels */ - } rotated[2]; + /* Params to remap the FB pages and program the plane registers in each view. */ + struct intel_fb_view normal_view; + struct intel_fb_view rotated_view; }; struct intel_fbdev { @@ -581,21 +610,11 @@ struct intel_plane_state { enum drm_scaling_filter scaling_filter; } hw; - struct i915_ggtt_view view; struct i915_vma *vma; unsigned long flags; #define PLANE_HAS_FENCE BIT(0) - struct { - u32 offset; - /* - * Plane stride in: - * bytes for 0/180 degree rotation - * pixels for 90/270 degree rotation - */ - u32 stride; - int x, y; - } color_plane[4]; + struct intel_fb_view view; /* plane control register */ u32 ctl; diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 6f8206769c3df..b223e16eb6a22 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -259,7 +259,7 @@ u32 intel_plane_adjust_aligned_offset(int *x, int *y, { return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, state->hw.rotation, - state->color_plane[color_plane].stride, + state->view.color_plane[color_plane].pitch, old_offset, new_offset); } @@ -340,7 +340,7 @@ u32 intel_plane_compute_aligned_offset(int *x, int *y, struct drm_i915_private *i915 = to_i915(intel_plane->base.dev); const struct drm_framebuffer *fb = state->hw.fb; unsigned int rotation = state->hw.rotation; - int pitch = state->color_plane[color_plane].stride; + int pitch = state->view.color_plane[color_plane].pitch; u32 alignment; if (intel_plane->id == PLANE_CURSOR) @@ -423,8 +423,8 @@ static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane ccs_y = (y * vsub) % tile_height; main_plane = skl_ccs_to_main_plane(fb, ccs_plane); - main_x = intel_fb->normal[main_plane].x % tile_width; - main_y = intel_fb->normal[main_plane].y % tile_height; + main_x = intel_fb->normal_view.color_plane[main_plane].x % tile_width; + main_y = intel_fb->normal_view.color_plane[main_plane].y % tile_height; /* * CCS doesn't have its own x/y offset register, so the intra CCS tile @@ -435,8 +435,8 @@ static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane "Bad CCS x/y (main %d,%d ccs %d,%d) full (main %d,%d ccs %d,%d)\n", main_x, main_y, ccs_x, ccs_y, - intel_fb->normal[main_plane].x, - intel_fb->normal[main_plane].y, + intel_fb->normal_view.color_plane[main_plane].x, + intel_fb->normal_view.color_plane[main_plane].y, x, y); return -EINVAL; } @@ -487,7 +487,7 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation) { if (drm_rotation_90_or_270(rotation)) - return to_intel_framebuffer(fb)->rotated[color_plane].pitch; + return to_intel_framebuffer(fb)->rotated_view.color_plane[color_plane].pitch; else return fb->pitches[color_plane]; } @@ -584,7 +584,7 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * struct drm_framebuffer *fb) { struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *rot_info = &intel_fb->rot_info; + struct intel_rotation_info *rot_info = &intel_fb->rotated_view.gtt.rotated; unsigned int pitch_tiles; struct drm_rect r; @@ -598,7 +598,7 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * rot_info->plane[plane] = *plane_info; - intel_fb->rotated[plane].pitch = plane_info->height * tile_height; + intel_fb->rotated_view.color_plane[plane].pitch = plane_info->height * tile_height; /* rotate the x/y offsets to match the GTT view */ drm_rect_init(&r, x, y, width, height); @@ -610,7 +610,7 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * y = r.y1; /* rotate the tile dimensions to match the GTT view */ - pitch_tiles = intel_fb->rotated[plane].pitch / tile_height; + pitch_tiles = intel_fb->rotated_view.color_plane[plane].pitch / tile_height; swap(tile_width, tile_height); /* @@ -626,8 +626,8 @@ static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info * * First pixel of the framebuffer from * the start of the rotated gtt mapping. */ - intel_fb->rotated[plane].x = x; - intel_fb->rotated[plane].y = y; + intel_fb->rotated_view.color_plane[plane].x = x; + intel_fb->rotated_view.color_plane[plane].y = y; return plane_info->width * plane_info->height; } @@ -742,8 +742,8 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb * First pixel of the framebuffer from * the start of the normal gtt mapping. */ - intel_fb->normal[i].x = x; - intel_fb->normal[i].y = y; + intel_fb->normal_view.color_plane[i].x = x; + intel_fb->normal_view.color_plane[i].y = y; offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); @@ -785,7 +785,7 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) to_i915(plane_state->uapi.plane->dev); struct drm_framebuffer *fb = plane_state->hw.fb; struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *info = &plane_state->view.rotated; + struct intel_rotation_info *info = &plane_state->view.gtt.rotated; unsigned int rotation = plane_state->hw.rotation; int i, num_planes = fb->format->num_planes; unsigned int tile_size = intel_tile_size(i915); @@ -793,8 +793,8 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) unsigned int src_w, src_h; u32 gtt_offset = 0; - memset(&plane_state->view, 0, sizeof(plane_state->view)); - plane_state->view.type = drm_rotation_90_or_270(rotation) ? + memset(&plane_state->view.gtt, 0, sizeof(plane_state->view.gtt)); + plane_state->view.gtt.type = drm_rotation_90_or_270(rotation) ? I915_GGTT_VIEW_ROTATED : I915_GGTT_VIEW_REMAPPED; src_x = plane_state->uapi.src.x1 >> 16; @@ -835,8 +835,8 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) * First pixel of the src viewport from the * start of the normal gtt mapping. */ - x += intel_fb->normal[i].x; - y += intel_fb->normal[i].y; + x += intel_fb->normal_view.color_plane[i].x; + y += intel_fb->normal_view.color_plane[i].y; offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); @@ -860,13 +860,13 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) y = r.y1; pitch_tiles = info->plane[i].height; - plane_state->color_plane[i].stride = pitch_tiles * tile_height; + plane_state->view.color_plane[i].pitch = pitch_tiles * tile_height; /* rotate the tile dimensions to match the GTT view */ swap(tile_width, tile_height); } else { pitch_tiles = info->plane[i].width; - plane_state->color_plane[i].stride = pitch_tiles * tile_width * cpp; + plane_state->view.color_plane[i].pitch = pitch_tiles * tile_width * cpp; } /* @@ -880,9 +880,9 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) gtt_offset += info->plane[i].width * info->plane[i].height; - plane_state->color_plane[i].offset = 0; - plane_state->color_plane[i].x = x; - plane_state->color_plane[i].y = y; + plane_state->view.color_plane[i].offset = 0; + plane_state->view.color_plane[i].x = x; + plane_state->view.color_plane[i].y = y; } } @@ -895,7 +895,7 @@ void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, view->type = I915_GGTT_VIEW_NORMAL; if (drm_rotation_90_or_270(rotation)) { view->type = I915_GGTT_VIEW_ROTATED; - view->rotated = to_intel_framebuffer(fb)->rot_info; + view->rotated = to_intel_framebuffer(fb)->rotated_view.gtt.rotated; } } @@ -917,7 +917,7 @@ static int intel_plane_check_stride(const struct intel_plane_state *plane_state) return 0; /* FIXME other color planes? */ - stride = plane_state->color_plane[0].stride; + stride = plane_state->view.color_plane[0].pitch; max_stride = plane->max_stride(plane, fb->format->format, fb->modifier, rotation); @@ -955,18 +955,18 @@ int intel_plane_compute_gtt(struct intel_plane_state *plane_state) return intel_plane_check_stride(plane_state); } - intel_fill_fb_ggtt_view(&plane_state->view, &fb->base, rotation); + intel_fill_fb_ggtt_view(&plane_state->view.gtt, &fb->base, rotation); for (i = 0; i < num_planes; i++) { - plane_state->color_plane[i].stride = intel_fb_pitch(&fb->base, i, rotation); - plane_state->color_plane[i].offset = 0; + plane_state->view.color_plane[i].pitch = intel_fb_pitch(&fb->base, i, rotation); + plane_state->view.color_plane[i].offset = 0; if (drm_rotation_90_or_270(rotation)) { - plane_state->color_plane[i].x = fb->rotated[i].x; - plane_state->color_plane[i].y = fb->rotated[i].y; + plane_state->view.color_plane[i].x = fb->rotated_view.color_plane[i].x; + plane_state->view.color_plane[i].y = fb->rotated_view.color_plane[i].y; } else { - plane_state->color_plane[i].x = fb->normal[i].x; - plane_state->color_plane[i].y = fb->normal[i].y; + plane_state->view.color_plane[i].x = fb->normal_view.color_plane[i].x; + plane_state->view.color_plane[i].y = fb->normal_view.color_plane[i].y; } } diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index bd1551c694eb3..8ffc883a83c34 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -14,8 +14,11 @@ struct drm_i915_private; struct i915_ggtt_view; +struct intel_fb_view; struct intel_plane_state; +enum i915_ggtt_view_type; + bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c index 88e02ee3a6312..f95794bda52ed 100644 --- a/drivers/gpu/drm/i915/display/intel_fbc.c +++ b/drivers/gpu/drm/i915/display/intel_fbc.c @@ -716,8 +716,8 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, */ cache->plane.src_w = drm_rect_width(&plane_state->uapi.src) >> 16; cache->plane.src_h = drm_rect_height(&plane_state->uapi.src) >> 16; - cache->plane.adjusted_x = plane_state->color_plane[0].x; - cache->plane.adjusted_y = plane_state->color_plane[0].y; + cache->plane.adjusted_x = plane_state->view.color_plane[0].x; + cache->plane.adjusted_y = plane_state->view.color_plane[0].y; cache->plane.pixel_blend_mode = plane_state->hw.pixel_blend_mode; @@ -725,7 +725,7 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, cache->fb.modifier = fb->modifier; /* FIXME is this correct? */ - cache->fb.stride = plane_state->color_plane[0].stride; + cache->fb.stride = plane_state->view.color_plane[0].pitch; if (drm_rotation_90_or_270(plane_state->hw.rotation)) cache->fb.stride *= fb->format->cpp[0]; diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c index af2d617d9eb2b..2ace363f5aac1 100644 --- a/drivers/gpu/drm/i915/display/intel_sprite.c +++ b/drivers/gpu/drm/i915/display/intel_sprite.c @@ -423,15 +423,15 @@ vlv_update_plane(struct intel_plane *plane, struct drm_i915_private *dev_priv = to_i915(plane->base.dev); enum pipe pipe = plane->pipe; enum plane_id plane_id = plane->id; - u32 sprsurf_offset = plane_state->color_plane[0].offset; + u32 sprsurf_offset = plane_state->view.color_plane[0].offset; u32 linear_offset; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; int crtc_x = plane_state->uapi.dst.x1; int crtc_y = plane_state->uapi.dst.y1; u32 crtc_w = drm_rect_width(&plane_state->uapi.dst); u32 crtc_h = drm_rect_height(&plane_state->uapi.dst); - u32 x = plane_state->color_plane[0].x; - u32 y = plane_state->color_plane[0].y; + u32 x = plane_state->view.color_plane[0].x; + u32 y = plane_state->view.color_plane[0].y; unsigned long irqflags; u32 sprctl; @@ -446,7 +446,7 @@ vlv_update_plane(struct intel_plane *plane, spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); intel_de_write_fw(dev_priv, SPSTRIDE(pipe, plane_id), - plane_state->color_plane[0].stride); + plane_state->view.color_plane[0].pitch); intel_de_write_fw(dev_priv, SPPOS(pipe, plane_id), (crtc_y << 16) | crtc_x); intel_de_write_fw(dev_priv, SPSIZE(pipe, plane_id), @@ -840,15 +840,15 @@ ivb_update_plane(struct intel_plane *plane, { struct drm_i915_private *dev_priv = to_i915(plane->base.dev); enum pipe pipe = plane->pipe; - u32 sprsurf_offset = plane_state->color_plane[0].offset; + u32 sprsurf_offset = plane_state->view.color_plane[0].offset; u32 linear_offset; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; int crtc_x = plane_state->uapi.dst.x1; int crtc_y = plane_state->uapi.dst.y1; u32 crtc_w = drm_rect_width(&plane_state->uapi.dst); u32 crtc_h = drm_rect_height(&plane_state->uapi.dst); - u32 x = plane_state->color_plane[0].x; - u32 y = plane_state->color_plane[0].y; + u32 x = plane_state->view.color_plane[0].x; + u32 y = plane_state->view.color_plane[0].y; u32 src_w = drm_rect_width(&plane_state->uapi.src) >> 16; u32 src_h = drm_rect_height(&plane_state->uapi.src) >> 16; u32 sprctl, sprscale = 0; @@ -870,7 +870,7 @@ ivb_update_plane(struct intel_plane *plane, spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); intel_de_write_fw(dev_priv, SPRSTRIDE(pipe), - plane_state->color_plane[0].stride); + plane_state->view.color_plane[0].pitch); intel_de_write_fw(dev_priv, SPRPOS(pipe), (crtc_y << 16) | crtc_x); intel_de_write_fw(dev_priv, SPRSIZE(pipe), (crtc_h << 16) | crtc_w); if (IS_IVYBRIDGE(dev_priv)) @@ -1168,15 +1168,15 @@ g4x_update_plane(struct intel_plane *plane, { struct drm_i915_private *dev_priv = to_i915(plane->base.dev); enum pipe pipe = plane->pipe; - u32 dvssurf_offset = plane_state->color_plane[0].offset; + u32 dvssurf_offset = plane_state->view.color_plane[0].offset; u32 linear_offset; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; int crtc_x = plane_state->uapi.dst.x1; int crtc_y = plane_state->uapi.dst.y1; u32 crtc_w = drm_rect_width(&plane_state->uapi.dst); u32 crtc_h = drm_rect_height(&plane_state->uapi.dst); - u32 x = plane_state->color_plane[0].x; - u32 y = plane_state->color_plane[0].y; + u32 x = plane_state->view.color_plane[0].x; + u32 y = plane_state->view.color_plane[0].y; u32 src_w = drm_rect_width(&plane_state->uapi.src) >> 16; u32 src_h = drm_rect_height(&plane_state->uapi.src) >> 16; u32 dvscntr, dvsscale = 0; @@ -1198,7 +1198,7 @@ g4x_update_plane(struct intel_plane *plane, spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); intel_de_write_fw(dev_priv, DVSSTRIDE(pipe), - plane_state->color_plane[0].stride); + plane_state->view.color_plane[0].pitch); intel_de_write_fw(dev_priv, DVSPOS(pipe), (crtc_y << 16) | crtc_x); intel_de_write_fw(dev_priv, DVSSIZE(pipe), (crtc_h << 16) | crtc_w); intel_de_write_fw(dev_priv, DVSSCALE(pipe), dvsscale); @@ -1298,7 +1298,7 @@ g4x_sprite_check_scaling(struct intel_crtc_state *crtc_state, int src_x, src_w, src_h, crtc_w, crtc_h; const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; - unsigned int stride = plane_state->color_plane[0].stride; + unsigned int stride = plane_state->view.color_plane[0].pitch; unsigned int cpp = fb->format->cpp[0]; unsigned int width_bytes; int min_width, min_height; diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 22f7a13020189..00a11fb516e52 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -582,7 +582,7 @@ static u32 skl_plane_stride(const struct intel_plane_state *plane_state, { const struct drm_framebuffer *fb = plane_state->hw.fb; unsigned int rotation = plane_state->hw.rotation; - u32 stride = plane_state->color_plane[color_plane].stride; + u32 stride = plane_state->view.color_plane[color_plane].pitch; if (color_plane >= fb->format->num_planes) return 0; @@ -919,14 +919,14 @@ skl_program_plane(struct intel_plane *plane, enum plane_id plane_id = plane->id; enum pipe pipe = plane->pipe; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; - u32 surf_addr = plane_state->color_plane[color_plane].offset; + u32 surf_addr = plane_state->view.color_plane[color_plane].offset; u32 stride = skl_plane_stride(plane_state, color_plane); const struct drm_framebuffer *fb = plane_state->hw.fb; int aux_plane = skl_main_to_aux_plane(fb, color_plane); int crtc_x = plane_state->uapi.dst.x1; int crtc_y = plane_state->uapi.dst.y1; - u32 x = plane_state->color_plane[color_plane].x; - u32 y = plane_state->color_plane[color_plane].y; + u32 x = plane_state->view.color_plane[color_plane].x; + u32 y = plane_state->view.color_plane[color_plane].y; u32 src_w = drm_rect_width(&plane_state->uapi.src) >> 16; u32 src_h = drm_rect_height(&plane_state->uapi.src) >> 16; u8 alpha = plane_state->hw.alpha >> 8; @@ -958,7 +958,7 @@ skl_program_plane(struct intel_plane *plane, } if (aux_plane) { - aux_dist = plane_state->color_plane[aux_plane].offset - surf_addr; + aux_dist = plane_state->view.color_plane[aux_plane].offset - surf_addr; if (DISPLAY_VER(dev_priv) < 12) aux_dist |= skl_plane_stride(plane_state, aux_plane); @@ -1001,7 +1001,8 @@ skl_program_plane(struct intel_plane *plane, if (DISPLAY_VER(dev_priv) < 11) intel_de_write_fw(dev_priv, PLANE_AUX_OFFSET(pipe, plane_id), - (plane_state->color_plane[1].y << 16) | plane_state->color_plane[1].x); + (plane_state->view.color_plane[1].y << 16) | + plane_state->view.color_plane[1].x); if (!drm_atomic_crtc_needs_modeset(&crtc_state->uapi)) intel_psr2_program_plane_sel_fetch(plane, crtc_state, plane_state, color_plane); @@ -1031,7 +1032,7 @@ skl_plane_async_flip(struct intel_plane *plane, unsigned long irqflags; enum plane_id plane_id = plane->id; enum pipe pipe = plane->pipe; - u32 surf_addr = plane_state->color_plane[0].offset; + u32 surf_addr = plane_state->view.color_plane[0].offset; u32 plane_ctl = plane_state->ctl; plane_ctl |= skl_plane_ctl_crtc(crtc_state); @@ -1269,9 +1270,9 @@ skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state, int ccs_plane) { const struct drm_framebuffer *fb = plane_state->hw.fb; - int aux_x = plane_state->color_plane[ccs_plane].x; - int aux_y = plane_state->color_plane[ccs_plane].y; - u32 aux_offset = plane_state->color_plane[ccs_plane].offset; + int aux_x = plane_state->view.color_plane[ccs_plane].x; + int aux_y = plane_state->view.color_plane[ccs_plane].y; + u32 aux_offset = plane_state->view.color_plane[ccs_plane].offset; u32 alignment = intel_surf_alignment(fb, ccs_plane); int hsub; int vsub; @@ -1301,9 +1302,9 @@ skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state, if (aux_x != main_x || aux_y != main_y) return false; - plane_state->color_plane[ccs_plane].offset = aux_offset; - plane_state->color_plane[ccs_plane].x = aux_x; - plane_state->color_plane[ccs_plane].y = aux_y; + plane_state->view.color_plane[ccs_plane].offset = aux_offset; + plane_state->view.color_plane[ccs_plane].x = aux_x; + plane_state->view.color_plane[ccs_plane].y = aux_y; return true; } @@ -1316,7 +1317,7 @@ int skl_calc_main_surface_offset(const struct intel_plane_state *plane_state, struct drm_i915_private *dev_priv = to_i915(plane->base.dev); const struct drm_framebuffer *fb = plane_state->hw.fb; const int aux_plane = skl_main_to_aux_plane(fb, 0); - const u32 aux_offset = plane_state->color_plane[aux_plane].offset; + const u32 aux_offset = plane_state->view.color_plane[aux_plane].offset; const u32 alignment = intel_surf_alignment(fb, 0); const int w = drm_rect_width(&plane_state->uapi.src) >> 16; @@ -1344,7 +1345,7 @@ int skl_calc_main_surface_offset(const struct intel_plane_state *plane_state, if (fb->modifier == I915_FORMAT_MOD_X_TILED) { int cpp = fb->format->cpp[0]; - while ((*x + w) * cpp > plane_state->color_plane[0].stride) { + while ((*x + w) * cpp > plane_state->view.color_plane[0].pitch) { if (*offset == 0) { drm_dbg_kms(&dev_priv->drm, "Unable to find suitable display surface offset due to X-tiling\n"); @@ -1403,8 +1404,8 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) offset, offset - alignment); } - if (x != plane_state->color_plane[aux_plane].x || - y != plane_state->color_plane[aux_plane].y) { + if (x != plane_state->view.color_plane[aux_plane].x || + y != plane_state->view.color_plane[aux_plane].y) { drm_dbg_kms(&dev_priv->drm, "Unable to find suitable display surface offset due to CCS\n"); return -EINVAL; @@ -1413,9 +1414,9 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) drm_WARN_ON(&dev_priv->drm, x > 8191 || y > 8191); - plane_state->color_plane[0].offset = offset; - plane_state->color_plane[0].x = x; - plane_state->color_plane[0].y = y; + plane_state->view.color_plane[0].offset = 0; + plane_state->view.color_plane[0].x = x; + plane_state->view.color_plane[0].y = y; /* * Put the final coordinates back so that the src @@ -1456,7 +1457,7 @@ static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state) if (is_ccs_modifier(fb->modifier)) { int ccs_plane = main_to_ccs_plane(fb, uv_plane); - u32 aux_offset = plane_state->color_plane[ccs_plane].offset; + u32 aux_offset = plane_state->view.color_plane[ccs_plane].offset; u32 alignment = intel_surf_alignment(fb, uv_plane); if (offset > aux_offset) @@ -1477,8 +1478,8 @@ static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state) offset, offset - alignment); } - if (x != plane_state->color_plane[ccs_plane].x || - y != plane_state->color_plane[ccs_plane].y) { + if (x != plane_state->view.color_plane[ccs_plane].x || + y != plane_state->view.color_plane[ccs_plane].y) { drm_dbg_kms(&i915->drm, "Unable to find suitable display surface offset due to CCS\n"); return -EINVAL; @@ -1487,9 +1488,9 @@ static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state) drm_WARN_ON(&i915->drm, x > 8191 || y > 8191); - plane_state->color_plane[uv_plane].offset = offset; - plane_state->color_plane[uv_plane].x = x; - plane_state->color_plane[uv_plane].y = y; + plane_state->view.color_plane[uv_plane].offset = 0; + plane_state->view.color_plane[uv_plane].x = x; + plane_state->view.color_plane[uv_plane].y = y; return 0; } @@ -1526,13 +1527,9 @@ static int skl_check_ccs_aux_surface(struct intel_plane_state *plane_state) plane_state, ccs_plane); - plane_state->color_plane[ccs_plane].offset = offset; - plane_state->color_plane[ccs_plane].x = (x * hsub + - src_x % hsub) / - main_hsub; - plane_state->color_plane[ccs_plane].y = (y * vsub + - src_y % vsub) / - main_vsub; + plane_state->view.color_plane[ccs_plane].offset = offset; + plane_state->view.color_plane[ccs_plane].x = (x * hsub + src_x % hsub) / main_hsub; + plane_state->view.color_plane[ccs_plane].y = (y * vsub + src_y % vsub) / main_vsub; } return 0; @@ -1567,10 +1564,10 @@ static int skl_check_plane_surface(struct intel_plane_state *plane_state) return ret; } - for (i = fb->format->num_planes; i < ARRAY_SIZE(plane_state->color_plane); i++) { - plane_state->color_plane[i].offset = 0; - plane_state->color_plane[i].x = 0; - plane_state->color_plane[i].y = 0; + for (i = fb->format->num_planes; i < ARRAY_SIZE(plane_state->view.color_plane); i++) { + plane_state->view.color_plane[i].offset = 0; + plane_state->view.color_plane[i].x = 0; + plane_state->view.color_plane[i].y = 0; } ret = skl_check_main_surface(plane_state); From patchwork Thu Mar 25 21:48:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 760E4C433DB for ; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C210619BA for ; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C210619BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E4A06EE59; Thu, 25 Mar 2021 21:48:38 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A49C6EE5E for ; Thu, 25 Mar 2021 21:48:34 +0000 (UTC) IronPort-SDR: w7fRQ44XJukjiubW6oo9qRLCPawKfWeyOEh+vBOJppeRZ7Igp4v3cbrc2YUgL+Ng9GudiYD+iR Sc5GbD6fbysg== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005087" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005087" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:33 -0700 IronPort-SDR: LDgwPXeF698gdIAeLyVwOS6Q4lZZMZHBl8LhiJa1ZT7BRtHOjBy96xeD8mFbDHQHKsjB/nkrv9 Hhdm9u6U1q8g== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235693" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:32 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:00 +0200 Message-Id: <20210325214808.2071517-18-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 17/25] drm/i915: Store the normal view FB pitch in FB's intel_fb_view X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Instead of special casing getting the pitch for the normal view, store it during FB creation to the FB normal view struct and retrive it from there during atomic check, as it's done for the rotated view. A follow-up patch does the same for a new FB remapped view. Cc: Ville Syrjälä Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index b223e16eb6a22..31fd8480f707e 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -484,12 +484,14 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) return true; } -int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation) +int intel_fb_pitch(const struct drm_framebuffer *drm_fb, int color_plane, unsigned int rotation) { + struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); + if (drm_rotation_90_or_270(rotation)) - return to_intel_framebuffer(fb)->rotated_view.color_plane[color_plane].pitch; + return fb->rotated_view.color_plane[color_plane].pitch; else - return fb->pitches[color_plane]; + return fb->normal_view.color_plane[color_plane].pitch; } static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) @@ -744,6 +746,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb */ intel_fb->normal_view.color_plane[i].x = x; intel_fb->normal_view.color_plane[i].y = y; + intel_fb->normal_view.color_plane[i].pitch = intel_fb->base.pitches[i]; offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); From patchwork Thu Mar 25 21:48:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 182D5C433E1 for ; Thu, 25 Mar 2021 21:48:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6B31619EE for ; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6B31619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FE166EE6A; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 66EB46EE5E for ; Thu, 25 Mar 2021 21:48:35 +0000 (UTC) IronPort-SDR: D3OsejxEGjk7lK9DIKbPiWRXC6+5vMs05rzxoqIOtJEoQdAKc5KDVxdt1davjsZgwdpZKIOMiH 9qqAuLHzsb/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005090" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005090" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:35 -0700 IronPort-SDR: 4mKWsABZptii9lCcXzBUPv7JzrbXHauOvC2jrep3ntABDePj/VDQz19y+GXjqzvKZv2a8gXTyT a1W3K9Gi8Dsw== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235708" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:33 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:01 +0200 Message-Id: <20210325214808.2071517-19-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 18/25] drm/i915: Simplify copying the FB view state to the plane state X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Instead of copying separately the GTT remapped and color plane view info from the FB to the plane state, do this by copying the whole intel_fb_view struct. For this we make sure the FB view state is fully inited (that is also including the view type) already during FB creation, so this init is not required during atomic check time. This also means the we don't need to reset the unused color plane info during atomic check, as these are already reset during FB creation. I noticed that initial FBs will only work atm if they are page aligned (which BIOS most probably always ensures), but add a comment to sanitize this part once. Also we won't disable the plane if get_initial_plane_config() failed for some reason (for instance due to unsupported rotation), add a TODO: comment for this too. Cc: Ville Syrjälä Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_display.c | 11 ++-- drivers/gpu/drm/i915/display/intel_fb.c | 59 ++++++++----------- drivers/gpu/drm/i915/display/intel_fb.h | 7 +-- .../drm/i915/display/skl_universal_plane.c | 8 +-- 4 files changed, 34 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 4ee7e72142a5f..48b8e2083e14a 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -1629,6 +1629,11 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, struct drm_framebuffer *fb; struct i915_vma *vma; + /* + * TODO: + * Disable planes if get_initial_plane_config() failed. + * Make sure things work if the surface base is not page aligned. + */ if (!plane_config->fb) return; @@ -1680,10 +1685,8 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, valid_fb: plane_state->rotation = plane_config->rotation; - intel_fill_fb_ggtt_view(&intel_state->view.gtt, fb, - plane_state->rotation); - intel_state->view.color_plane[0].pitch = - intel_fb_pitch(fb, 0, plane_state->rotation); + intel_fb_fill_view(to_intel_framebuffer(fb), plane_state->rotation, + &intel_state->view); __i915_vma_pin(vma); intel_state->vma = i915_vma_get(vma); diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 31fd8480f707e..16dcfb538b448 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -484,10 +484,8 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) return true; } -int intel_fb_pitch(const struct drm_framebuffer *drm_fb, int color_plane, unsigned int rotation) +static int intel_fb_pitch(const struct intel_framebuffer *fb, int color_plane, unsigned int rotation) { - struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); - if (drm_rotation_90_or_270(rotation)) return fb->rotated_view.color_plane[color_plane].pitch; else @@ -497,7 +495,7 @@ int intel_fb_pitch(const struct drm_framebuffer *drm_fb, int color_plane, unsign static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) { struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - const struct drm_framebuffer *fb = plane_state->hw.fb; + const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb); unsigned int rotation = plane_state->hw.rotation; u32 stride, max_stride; @@ -516,8 +514,8 @@ static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state) * unclear in Bspec, for now no checking. */ stride = intel_fb_pitch(fb, 0, rotation); - max_stride = plane->max_stride(plane, fb->format->format, - fb->modifier, rotation); + max_stride = plane->max_stride(plane, fb->base.format->format, + fb->base.modifier, rotation); return stride > max_stride; } @@ -702,6 +700,12 @@ calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, return tiles; } +static void intel_fb_view_init(struct intel_fb_view *view, enum i915_ggtt_view_type view_type) +{ + memset(view, 0, sizeof(*view)); + view->gtt.type = view_type; +} + int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb) { struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); @@ -711,6 +715,9 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb int i, num_planes = fb->format->num_planes; unsigned int tile_size = intel_tile_size(i915); + intel_fb_view_init(&intel_fb->normal_view, I915_GGTT_VIEW_NORMAL); + intel_fb_view_init(&intel_fb->rotated_view, I915_GGTT_VIEW_ROTATED); + for (i = 0; i < num_planes; i++) { struct fb_plane_view_dims view_dims; unsigned int width, height; @@ -796,9 +803,9 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) unsigned int src_w, src_h; u32 gtt_offset = 0; - memset(&plane_state->view.gtt, 0, sizeof(plane_state->view.gtt)); - plane_state->view.gtt.type = drm_rotation_90_or_270(rotation) ? - I915_GGTT_VIEW_ROTATED : I915_GGTT_VIEW_REMAPPED; + intel_fb_view_init(&plane_state->view, + drm_rotation_90_or_270(rotation) ? I915_GGTT_VIEW_ROTATED : + I915_GGTT_VIEW_REMAPPED); src_x = plane_state->uapi.src.x1 >> 16; src_y = plane_state->uapi.src.y1 >> 16; @@ -889,17 +896,13 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) } } -void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, - const struct drm_framebuffer *fb, - unsigned int rotation) +void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation, + struct intel_fb_view *view) { - memset(view, 0, sizeof(*view)); - - view->type = I915_GGTT_VIEW_NORMAL; - if (drm_rotation_90_or_270(rotation)) { - view->type = I915_GGTT_VIEW_ROTATED; - view->rotated = to_intel_framebuffer(fb)->rotated_view.gtt.rotated; - } + if (drm_rotation_90_or_270(rotation)) + *view = fb->rotated_view; + else + *view = fb->normal_view; } static int intel_plane_check_stride(const struct intel_plane_state *plane_state) @@ -939,13 +942,10 @@ int intel_plane_compute_gtt(struct intel_plane_state *plane_state) const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb); unsigned int rotation = plane_state->hw.rotation; - int i, num_planes; if (!fb) return 0; - num_planes = fb->base.format->num_planes; - if (intel_plane_needs_remap(plane_state)) { intel_plane_remap_gtt(plane_state); @@ -958,20 +958,7 @@ int intel_plane_compute_gtt(struct intel_plane_state *plane_state) return intel_plane_check_stride(plane_state); } - intel_fill_fb_ggtt_view(&plane_state->view.gtt, &fb->base, rotation); - - for (i = 0; i < num_planes; i++) { - plane_state->view.color_plane[i].pitch = intel_fb_pitch(&fb->base, i, rotation); - plane_state->view.color_plane[i].offset = 0; - - if (drm_rotation_90_or_270(rotation)) { - plane_state->view.color_plane[i].x = fb->rotated_view.color_plane[i].x; - plane_state->view.color_plane[i].y = fb->rotated_view.color_plane[i].y; - } else { - plane_state->view.color_plane[i].x = fb->normal_view.color_plane[i].x; - plane_state->view.color_plane[i].y = fb->normal_view.color_plane[i].y; - } - } + intel_fb_fill_view(fb, rotation, &plane_state->view); /* Rotate src coordinates to match rotated GTT view */ if (drm_rotation_90_or_270(rotation)) diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h index 8ffc883a83c34..0ea9da360450d 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.h +++ b/drivers/gpu/drm/i915/display/intel_fb.h @@ -15,6 +15,7 @@ struct drm_i915_private; struct i915_ggtt_view; struct intel_fb_view; +struct intel_framebuffer; struct intel_plane_state; enum i915_ggtt_view_type; @@ -49,11 +50,9 @@ u32 intel_plane_compute_aligned_offset(int *x, int *y, const struct intel_plane_state *state, int color_plane); -int intel_fb_pitch(const struct drm_framebuffer *fb, int color_plane, unsigned int rotation); - int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb); -void intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, const struct drm_framebuffer *fb, - unsigned int rotation); +void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation, + struct intel_fb_view *view); int intel_plane_compute_gtt(struct intel_plane_state *plane_state); #endif /* __INTEL_FB_H__ */ diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 00a11fb516e52..00a53512ef6cd 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -1538,7 +1538,7 @@ static int skl_check_ccs_aux_surface(struct intel_plane_state *plane_state) static int skl_check_plane_surface(struct intel_plane_state *plane_state) { const struct drm_framebuffer *fb = plane_state->hw.fb; - int ret, i; + int ret; ret = intel_plane_compute_gtt(plane_state); if (ret) @@ -1564,12 +1564,6 @@ static int skl_check_plane_surface(struct intel_plane_state *plane_state) return ret; } - for (i = fb->format->num_planes; i < ARRAY_SIZE(plane_state->view.color_plane); i++) { - plane_state->view.color_plane[i].offset = 0; - plane_state->view.color_plane[i].x = 0; - plane_state->view.color_plane[i].y = 0; - } - ret = skl_check_main_surface(plane_state); if (ret) return ret; From patchwork Thu Mar 25 21:48:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88056C433E3 for ; Thu, 25 Mar 2021 21:48:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F881619EE for ; Thu, 25 Mar 2021 21:48:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F881619EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5D7C6EE69; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id CED606EE5E for ; Thu, 25 Mar 2021 21:48:36 +0000 (UTC) IronPort-SDR: YteCfgOYdJEC5OfqxVay3Svv0Jf6AyRuGaaiFQacxzVD2MYYQnjF0S9xEBr102m+8TvmGgHzEZ DrUf3lTzbvTQ== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005097" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005097" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:36 -0700 IronPort-SDR: mN/bPruZwfHRsBIypNi89oIpIFsCfEsHFxgcWD/AOTLOm0KpyG++NTbxHgcjTS1C/miuXiPCft tKUPKfjaeJsA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235720" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:35 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:02 +0200 Message-Id: <20210325214808.2071517-20-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 19/25] drm/i915/intel_fb: Factor out calc_plane_remap_info() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Factor out to a new function the logic to calculate the FB remapping parameters both during creating the FB and when flipping to it. Add a new intel_fb_plane_remap_info struct that can be used in a follow-up patch to add a new remapped view when creating an FB. Also move intel_framebuffer::rot_info into this new struct, to better group all the remapping related info. v2: - Keep stride next to offset calculation. (Ville) - Enclose check_array_bounds macro arguments in parentheses. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 203 +++++++++--------------- 1 file changed, 77 insertions(+), 126 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 16dcfb538b448..b56c432e0415f 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -9,6 +9,8 @@ #include "intel_display_types.h" #include "intel_fb.h" +#define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a)) + bool is_ccs_plane(const struct drm_framebuffer *fb, int plane) { if (!is_ccs_modifier(fb->modifier)) @@ -572,66 +574,6 @@ static u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int col return offset / tile_size; } -/* - * Setup the rotated view for an FB plane and return the size the GTT mapping - * requires for this view. - */ -static u32 setup_fb_rotation(int plane, const struct intel_remapped_plane_info *plane_info, - u32 gtt_offset_rotated, int x, int y, - unsigned int width, unsigned int height, - unsigned int tile_size, - unsigned int tile_width, unsigned int tile_height, - struct drm_framebuffer *fb) -{ - struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *rot_info = &intel_fb->rotated_view.gtt.rotated; - unsigned int pitch_tiles; - struct drm_rect r; - - /* Y or Yf modifiers required for 90/270 rotation */ - if (fb->modifier != I915_FORMAT_MOD_Y_TILED && - fb->modifier != I915_FORMAT_MOD_Yf_TILED) - return 0; - - if (drm_WARN_ON(fb->dev, plane >= ARRAY_SIZE(rot_info->plane))) - return 0; - - rot_info->plane[plane] = *plane_info; - - intel_fb->rotated_view.color_plane[plane].pitch = plane_info->height * tile_height; - - /* rotate the x/y offsets to match the GTT view */ - drm_rect_init(&r, x, y, width, height); - drm_rect_rotate(&r, - plane_info->width * tile_width, - plane_info->height * tile_height, - DRM_MODE_ROTATE_270); - x = r.x1; - y = r.y1; - - /* rotate the tile dimensions to match the GTT view */ - pitch_tiles = intel_fb->rotated_view.color_plane[plane].pitch / tile_height; - swap(tile_width, tile_height); - - /* - * We only keep the x/y offsets, so push all of the - * gtt offset into the x/y offsets. - */ - intel_adjust_tile_offset(&x, &y, - tile_width, tile_height, - tile_size, pitch_tiles, - gtt_offset_rotated * tile_size, 0); - - /* - * First pixel of the framebuffer from - * the start of the rotated gtt mapping. - */ - intel_fb->rotated_view.color_plane[plane].x = x; - intel_fb->rotated_view.color_plane[plane].y = y; - - return plane_info->width * plane_info->height; -} - struct fb_plane_view_dims { unsigned int width, height; unsigned int tile_width, tile_height; @@ -671,6 +613,69 @@ plane_view_height_tiles(const struct intel_framebuffer *fb, int color_plane, return DIV_ROUND_UP(y + dims->height, dims->tile_height); } +static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims, + u32 obj_offset, u32 gtt_offset, int x, int y, + struct intel_fb_view *view) +{ + struct drm_i915_private *i915 = to_i915(fb->base.dev); + struct intel_remapped_plane_info *remap_info = &view->gtt.remapped.plane[color_plane]; + struct i915_color_plane_view *color_plane_info = &view->color_plane[color_plane]; + unsigned int tile_width = dims->tile_width; + unsigned int tile_height = dims->tile_height; + unsigned int tile_size = intel_tile_size(i915); + unsigned int pitch_tiles; + struct drm_rect r; + + remap_info->offset = obj_offset; + remap_info->stride = plane_view_stride_tiles(fb, color_plane, dims); + remap_info->width = plane_view_width_tiles(fb, color_plane, dims, x); + remap_info->height = plane_view_height_tiles(fb, color_plane, dims, y); + + if (view->gtt.type == I915_GGTT_VIEW_ROTATED) { + check_array_bounds(i915, view->gtt.rotated.plane, color_plane); + + /* rotate the x/y offsets to match the GTT view */ + drm_rect_init(&r, x, y, dims->width, dims->height); + drm_rect_rotate(&r, + remap_info->width * tile_width, + remap_info->height * tile_height, + DRM_MODE_ROTATE_270); + + color_plane_info->x = r.x1; + color_plane_info->y = r.y1; + + pitch_tiles = remap_info->height; + color_plane_info->pitch = pitch_tiles * tile_height; + + /* rotate the tile dimensions to match the GTT view */ + swap(tile_width, tile_height); + } else { + drm_WARN_ON(&i915->drm, view->gtt.type != I915_GGTT_VIEW_REMAPPED); + + check_array_bounds(i915, view->gtt.remapped.plane, color_plane); + + color_plane_info->x = x; + color_plane_info->y = y; + + pitch_tiles = remap_info->width; + color_plane_info->pitch = pitch_tiles * tile_width * + fb->base.format->cpp[color_plane]; + } + + /* + * We only keep the x/y offsets, so push all of the gtt offset into + * the x/y offsets. x,y will hold the first pixel of the framebuffer + * plane from the start of the remapped/rotated gtt mapping. + */ + intel_adjust_tile_offset(&color_plane_info->x, &color_plane_info->y, + tile_width, tile_height, + tile_size, pitch_tiles, + gtt_offset * tile_size, 0); + + return remap_info->width * remap_info->height; +} + /* Return number of tiles @color_plane needs. */ static unsigned int calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, @@ -757,22 +762,12 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); - if (!is_surface_linear(fb, i)) { - struct intel_remapped_plane_info plane_info; - - plane_info.offset = offset; - plane_info.stride = plane_view_stride_tiles(intel_fb, i, &view_dims); - plane_info.width = plane_view_width_tiles(intel_fb, i, &view_dims, x); - plane_info.height = plane_view_height_tiles(intel_fb, i, &view_dims, y); - - gtt_offset_rotated += - setup_fb_rotation(i, &plane_info, - gtt_offset_rotated, - x, y, width, height, - tile_size, - view_dims.tile_width, view_dims.tile_height, - fb); - } + /* Y or Yf modifiers required for 90/270 rotation */ + if (fb->modifier == I915_FORMAT_MOD_Y_TILED || + fb->modifier == I915_FORMAT_MOD_Yf_TILED) + gtt_offset_rotated += calc_plane_remap_info(intel_fb, i, &view_dims, + offset, gtt_offset_rotated, x, y, + &intel_fb->rotated_view); size = calc_plane_normal_size(intel_fb, i, &view_dims, x, y); /* how many tiles in total needed in the bo */ @@ -795,10 +790,8 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) to_i915(plane_state->uapi.plane->dev); struct drm_framebuffer *fb = plane_state->hw.fb; struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); - struct intel_rotation_info *info = &plane_state->view.gtt.rotated; unsigned int rotation = plane_state->hw.rotation; int i, num_planes = fb->format->num_planes; - unsigned int tile_size = intel_tile_size(i915); unsigned int src_x, src_y; unsigned int src_w, src_h; u32 gtt_offset = 0; @@ -827,20 +820,18 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) for (i = 0; i < num_planes; i++) { unsigned int hsub = i ? fb->format->hsub : 1; unsigned int vsub = i ? fb->format->vsub : 1; - unsigned int cpp = fb->format->cpp[i]; - unsigned int tile_width, tile_height; + struct fb_plane_view_dims view_dims; unsigned int width, height; - unsigned int pitch_tiles; unsigned int x, y; u32 offset; - intel_tile_dims(fb, i, &tile_width, &tile_height); - x = src_x / hsub; y = src_y / vsub; width = src_w / hsub; height = src_h / vsub; + init_plane_view_dims(intel_fb, i, width, height, &view_dims); + /* * First pixel of the src viewport from the * start of the normal gtt mapping. @@ -850,49 +841,9 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); - drm_WARN_ON(&i915->drm, i >= ARRAY_SIZE(info->plane)); - info->plane[i].offset = offset; - info->plane[i].stride = DIV_ROUND_UP(fb->pitches[i], - tile_width * cpp); - info->plane[i].width = DIV_ROUND_UP(x + width, tile_width); - info->plane[i].height = DIV_ROUND_UP(y + height, tile_height); - - if (drm_rotation_90_or_270(rotation)) { - struct drm_rect r; - - /* rotate the x/y offsets to match the GTT view */ - drm_rect_init(&r, x, y, width, height); - drm_rect_rotate(&r, - info->plane[i].width * tile_width, - info->plane[i].height * tile_height, - DRM_MODE_ROTATE_270); - x = r.x1; - y = r.y1; - - pitch_tiles = info->plane[i].height; - plane_state->view.color_plane[i].pitch = pitch_tiles * tile_height; - - /* rotate the tile dimensions to match the GTT view */ - swap(tile_width, tile_height); - } else { - pitch_tiles = info->plane[i].width; - plane_state->view.color_plane[i].pitch = pitch_tiles * tile_width * cpp; - } - - /* - * We only keep the x/y offsets, so push all of the - * gtt offset into the x/y offsets. - */ - intel_adjust_tile_offset(&x, &y, - tile_width, tile_height, - tile_size, pitch_tiles, - gtt_offset * tile_size, 0); - - gtt_offset += info->plane[i].width * info->plane[i].height; - - plane_state->view.color_plane[i].offset = 0; - plane_state->view.color_plane[i].x = x; - plane_state->view.color_plane[i].y = y; + gtt_offset += calc_plane_remap_info(intel_fb, i, &view_dims, + offset, gtt_offset, x, y, + &plane_state->view); } } From patchwork Thu Mar 25 21:48:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 697CEC433E0 for ; Thu, 25 Mar 2021 21:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31E4B61494 for ; Thu, 25 Mar 2021 21:48:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31E4B61494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76A2E6EE65; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA4CB6EE59 for ; Thu, 25 Mar 2021 21:48:37 +0000 (UTC) IronPort-SDR: v2sYeMKgCdpSEiZpQCom9lXGd7SZ9mVqjO3Y/chA+M/bPjV965fOcPnbr71v+pZjkXr7RQNLGc H1U9N6735AWg== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005102" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005102" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:37 -0700 IronPort-SDR: BlFLoG/BdMGqx5l++y28hZ+hIu1TsI+4iA3JUhL4NmeN+b6Q43CXnN/od9oWvA/Q0O0RbX03qt Cls5an1I20Yw== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235723" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:36 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:03 +0200 Message-Id: <20210325214808.2071517-21-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 20/25] drm/i915: Shrink the size of intel_remapped_plane_info struct X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Save some place in the GTT VMAs by using a u16 instead of unsigned int to store the view dimensions. The maximum FB stride is 256kB which is 4096 tiles in the worst case (yf-tiles), the maximum FB height is 16k pixels, which is 16384 tiles in the worst case (linear 4x1 tiled FB). v2: - Fix worst case tile height formula in commit log. (Ville) - Add an assign_chk_ovf helper to simplify the related assignments. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 15 +++++++++++---- drivers/gpu/drm/i915/i915_vma_types.h | 12 ++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index b56c432e0415f..e153f6ae1298c 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -613,6 +613,11 @@ plane_view_height_tiles(const struct intel_framebuffer *fb, int color_plane, return DIV_ROUND_UP(y + dims->height, dims->tile_height); } +#define assign_chk_ovf(i915, var, val) ({ \ + drm_WARN_ON(&(i915)->drm, overflows_type(val, var)); \ + var = val; \ +}) + static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_plane, const struct fb_plane_view_dims *dims, u32 obj_offset, u32 gtt_offset, int x, int y, @@ -627,10 +632,10 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p unsigned int pitch_tiles; struct drm_rect r; - remap_info->offset = obj_offset; - remap_info->stride = plane_view_stride_tiles(fb, color_plane, dims); - remap_info->width = plane_view_width_tiles(fb, color_plane, dims, x); - remap_info->height = plane_view_height_tiles(fb, color_plane, dims, y); + assign_chk_ovf(i915, remap_info->offset, obj_offset); + assign_chk_ovf(i915, remap_info->stride, plane_view_stride_tiles(fb, color_plane, dims)); + assign_chk_ovf(i915, remap_info->width, plane_view_width_tiles(fb, color_plane, dims, x)); + assign_chk_ovf(i915, remap_info->height, plane_view_height_tiles(fb, color_plane, dims, y)); if (view->gtt.type == I915_GGTT_VIEW_ROTATED) { check_array_bounds(i915, view->gtt.rotated.plane, color_plane); @@ -676,6 +681,8 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p return remap_info->width * remap_info->height; } +#undef assign_chk_ovf + /* Return number of tiles @color_plane needs. */ static unsigned int calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h index f5cb848b7a7eb..358b4306fc002 100644 --- a/drivers/gpu/drm/i915/i915_vma_types.h +++ b/drivers/gpu/drm/i915/i915_vma_types.h @@ -97,12 +97,16 @@ enum i915_cache_level; struct intel_remapped_plane_info { /* in gtt pages */ - unsigned int width, height, stride, offset; + u32 offset; + u16 width; + u16 height; + u16 stride; + u16 unused_mbz; } __packed; struct intel_remapped_info { struct intel_remapped_plane_info plane[2]; - unsigned int unused_mbz; + u32 unused_mbz; } __packed; struct intel_rotation_info { @@ -123,9 +127,9 @@ enum i915_ggtt_view_type { static inline void assert_i915_gem_gtt_types(void) { - BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 8*sizeof(unsigned int)); + BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 2 * sizeof(u32) + 8 * sizeof(u16)); BUILD_BUG_ON(sizeof(struct intel_partial_info) != sizeof(u64) + sizeof(unsigned int)); - BUILD_BUG_ON(sizeof(struct intel_remapped_info) != 9*sizeof(unsigned int)); + BUILD_BUG_ON(sizeof(struct intel_remapped_info) != 3 * sizeof(u32) + 8 * sizeof(u16)); /* Check that rotation/remapped shares offsets for simplicity */ BUILD_BUG_ON(offsetof(struct intel_remapped_info, plane[0]) != From patchwork Thu Mar 25 21:48:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D105C433DB for ; Thu, 25 Mar 2021 21:48:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E72861494 for ; Thu, 25 Mar 2021 21:48:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E72861494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1A246EE64; Thu, 25 Mar 2021 21:48:55 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A8286EE68 for ; Thu, 25 Mar 2021 21:48:39 +0000 (UTC) IronPort-SDR: 8lk0GVCL2wM67zclCGgN4u3gl1KBDNBEgV+aO6tCuh6g/e0gOHZl9CfxIvZ7W5zZPlGZkxZFMy 5/o70ABDfjJA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005104" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005104" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:38 -0700 IronPort-SDR: gmsdgdWHTj6V+wPy9vPAmIp410+KsgzDfPYSGcaAllkePdWy5tLTH2PJlh32IenPYlL4zHA8EV +X1FnUCOJSqA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235733" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:37 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:04 +0200 Message-Id: <20210325214808.2071517-22-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 21/25] drm/i915/selftest: Unify use of intel_remapped_plane_info in igt_vma_rotate_remap() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Always use the modified copy of the intel_remapped_plane_info variables. An upcoming patch updates the dst_stride field in these copies after which we can't use the original versions. v2: Init view in igt_vma_rotate_remap() when declaring it. (Ville) Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/selftests/i915_vma.c | 63 ++++++++++++----------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 9dd6799105e66..95dd6712ac905 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -515,22 +515,24 @@ static int igt_vma_rotate_remap(void *arg) for (t = types; *t; t++) { for (a = planes; a->width; a++) { for (b = planes + ARRAY_SIZE(planes); b-- != planes; ) { - struct i915_ggtt_view view = {}; + struct i915_ggtt_view view = { + .type = *t, + .remapped.plane[0] = *a, + .remapped.plane[1] = *b, + }; + struct intel_remapped_plane_info *plane_info = view.remapped.plane; unsigned int n, max_offset; - max_offset = max(a->stride * a->height, - b->stride * b->height); + max_offset = max(plane_info[0].stride * plane_info[0].height, + plane_info[1].stride * plane_info[1].height); GEM_BUG_ON(max_offset > max_pages); max_offset = max_pages - max_offset; - view.type = *t; - view.rotated.plane[0] = *a; - view.rotated.plane[1] = *b; - - for_each_prime_number_from(view.rotated.plane[0].offset, 0, max_offset) { - for_each_prime_number_from(view.rotated.plane[1].offset, 0, max_offset) { + for_each_prime_number_from(plane_info[0].offset, 0, max_offset) { + for_each_prime_number_from(plane_info[1].offset, 0, max_offset) { struct scatterlist *sg; struct i915_vma *vma; + unsigned int expected_pages; vma = checked_vma_instance(obj, vm, &view); if (IS_ERR(vma)) { @@ -544,25 +546,27 @@ static int igt_vma_rotate_remap(void *arg) goto out_object; } + expected_pages = rotated_size(&plane_info[0], &plane_info[1]); + if (view.type == I915_GGTT_VIEW_ROTATED && - vma->size != rotated_size(a, b) * PAGE_SIZE) { + vma->size != expected_pages * PAGE_SIZE) { pr_err("VMA is wrong size, expected %lu, found %llu\n", - PAGE_SIZE * rotated_size(a, b), vma->size); + PAGE_SIZE * expected_pages, vma->size); err = -EINVAL; goto out_object; } if (view.type == I915_GGTT_VIEW_REMAPPED && - vma->size > rotated_size(a, b) * PAGE_SIZE) { + vma->size > expected_pages * PAGE_SIZE) { pr_err("VMA is wrong size, expected %lu, found %llu\n", - PAGE_SIZE * rotated_size(a, b), vma->size); + PAGE_SIZE * expected_pages, vma->size); err = -EINVAL; goto out_object; } - if (vma->pages->nents > rotated_size(a, b)) { + if (vma->pages->nents > expected_pages) { pr_err("sg table is wrong sizeo, expected %u, found %u nents\n", - rotated_size(a, b), vma->pages->nents); + expected_pages, vma->pages->nents); err = -EINVAL; goto out_object; } @@ -590,14 +594,14 @@ static int igt_vma_rotate_remap(void *arg) pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n", view.type == I915_GGTT_VIEW_ROTATED ? "rotated" : "remapped", n, - view.rotated.plane[0].width, - view.rotated.plane[0].height, - view.rotated.plane[0].stride, - view.rotated.plane[0].offset, - view.rotated.plane[1].width, - view.rotated.plane[1].height, - view.rotated.plane[1].stride, - view.rotated.plane[1].offset); + plane_info[0].width, + plane_info[0].height, + plane_info[0].stride, + plane_info[0].offset, + plane_info[1].width, + plane_info[1].height, + plane_info[1].stride, + plane_info[1].offset); err = -EINVAL; goto out_object; } @@ -887,6 +891,7 @@ static int igt_vma_remapped_gtt(void *arg) .type = *t, .rotated.plane[0] = *p, }; + struct intel_remapped_plane_info *plane_info = view.rotated.plane; struct i915_vma *vma; u32 __iomem *map; unsigned int x, y; @@ -912,15 +917,15 @@ static int igt_vma_remapped_gtt(void *arg) goto out; } - for (y = 0 ; y < p->height; y++) { - for (x = 0 ; x < p->width; x++) { + for (y = 0 ; y < plane_info[0].height; y++) { + for (x = 0 ; x < plane_info[0].width; x++) { unsigned int offset; u32 val = y << 16 | x; if (*t == I915_GGTT_VIEW_ROTATED) - offset = (x * p->height + y) * PAGE_SIZE; + offset = (x * plane_info[0].height + y) * PAGE_SIZE; else - offset = (y * p->width + x) * PAGE_SIZE; + offset = (y * plane_info[0].width + x) * PAGE_SIZE; iowrite32(val, &map[offset / sizeof(*map)]); } @@ -943,8 +948,8 @@ static int igt_vma_remapped_gtt(void *arg) goto out; } - for (y = 0 ; y < p->height; y++) { - for (x = 0 ; x < p->width; x++) { + for (y = 0 ; y < plane_info[0].height; y++) { + for (x = 0 ; x < plane_info[0].width; x++) { unsigned int offset, src_idx; u32 exp = y << 16 | x; u32 val; From patchwork Thu Mar 25 21:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86D75C433E3 for ; Thu, 25 Mar 2021 21:48:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48A6C619D3 for ; Thu, 25 Mar 2021 21:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48A6C619D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 916976EE67; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF1666EE61 for ; Thu, 25 Mar 2021 21:48:40 +0000 (UTC) IronPort-SDR: uEvDkM0jGdtz0eS4IsDnNL4z+o29dqpgE/OReuEsoQVSkX472LUf0iJ41cXKSiJpKsAgawORkc 9eruZ8qQvgRw== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005106" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005106" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:40 -0700 IronPort-SDR: y+K4lhIJdgXBWc5fayr7N6tfCV1JiM0CCIeWZCzq+ZgzZ+dCFzhqdiOTiQLhGOlEPpz9QLo7yA 8iWU6h00OO3g== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235739" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:39 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:05 +0200 Message-Id: <20210325214808.2071517-23-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 22/25] drm/i915: s/stride/src_stride/ in the intel_remapped_plane_info struct X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" An upcoming patch adds a new dst_stride field to the intel_remapped_plane_info struct, so for clarity rename the current stride field to src_stride. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_fb.c | 8 +-- drivers/gpu/drm/i915/gt/intel_ggtt.c | 4 +- drivers/gpu/drm/i915/i915_debugfs.c | 8 +-- drivers/gpu/drm/i915/i915_vma_types.h | 2 +- drivers/gpu/drm/i915/selftests/i915_vma.c | 60 +++++++++++------------ 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index e153f6ae1298c..dcf7e811d1425 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -590,8 +590,8 @@ static void init_plane_view_dims(const struct intel_framebuffer *fb, int color_p } static unsigned int -plane_view_stride_tiles(const struct intel_framebuffer *fb, int color_plane, - const struct fb_plane_view_dims *dims) +plane_view_src_stride_tiles(const struct intel_framebuffer *fb, int color_plane, + const struct fb_plane_view_dims *dims) { return DIV_ROUND_UP(fb->base.pitches[color_plane], dims->tile_width * fb->base.format->cpp[color_plane]); @@ -633,7 +633,7 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p struct drm_rect r; assign_chk_ovf(i915, remap_info->offset, obj_offset); - assign_chk_ovf(i915, remap_info->stride, plane_view_stride_tiles(fb, color_plane, dims)); + assign_chk_ovf(i915, remap_info->src_stride, plane_view_src_stride_tiles(fb, color_plane, dims)); assign_chk_ovf(i915, remap_info->width, plane_view_width_tiles(fb, color_plane, dims, x)); assign_chk_ovf(i915, remap_info->height, plane_view_height_tiles(fb, color_plane, dims, y)); @@ -699,7 +699,7 @@ calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, x * fb->base.format->cpp[color_plane]; tiles = DIV_ROUND_UP(size, intel_tile_size(i915)); } else { - tiles = plane_view_stride_tiles(fb, color_plane, dims) * + tiles = plane_view_src_stride_tiles(fb, color_plane, dims) * plane_view_height_tiles(fb, color_plane, dims, y); /* * If the plane isn't horizontally tile aligned, diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c index c2fc49495029b..cb048d0e369ce 100644 --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c @@ -1320,7 +1320,7 @@ intel_rotate_pages(struct intel_rotation_info *rot_info, for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) { sg = rotate_pages(obj, rot_info->plane[i].offset, rot_info->plane[i].width, rot_info->plane[i].height, - rot_info->plane[i].stride, st, sg); + rot_info->plane[i].src_stride, st, sg); } return st; @@ -1404,7 +1404,7 @@ intel_remap_pages(struct intel_remapped_info *rem_info, for (i = 0 ; i < ARRAY_SIZE(rem_info->plane); i++) { sg = remap_pages(obj, rem_info->plane[i].offset, rem_info->plane[i].width, rem_info->plane[i].height, - rem_info->plane[i].stride, st, sg); + rem_info->plane[i].src_stride, st, sg); } i915_sg_trim(st); diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index b00c828f90a7f..9c4b9d475793b 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -176,11 +176,11 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", vma->ggtt_view.rotated.plane[0].width, vma->ggtt_view.rotated.plane[0].height, - vma->ggtt_view.rotated.plane[0].stride, + vma->ggtt_view.rotated.plane[0].src_stride, vma->ggtt_view.rotated.plane[0].offset, vma->ggtt_view.rotated.plane[1].width, vma->ggtt_view.rotated.plane[1].height, - vma->ggtt_view.rotated.plane[1].stride, + vma->ggtt_view.rotated.plane[1].src_stride, vma->ggtt_view.rotated.plane[1].offset); break; @@ -188,11 +188,11 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) seq_printf(m, ", remapped [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", vma->ggtt_view.remapped.plane[0].width, vma->ggtt_view.remapped.plane[0].height, - vma->ggtt_view.remapped.plane[0].stride, + vma->ggtt_view.remapped.plane[0].src_stride, vma->ggtt_view.remapped.plane[0].offset, vma->ggtt_view.remapped.plane[1].width, vma->ggtt_view.remapped.plane[1].height, - vma->ggtt_view.remapped.plane[1].stride, + vma->ggtt_view.remapped.plane[1].src_stride, vma->ggtt_view.remapped.plane[1].offset); break; diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h index 358b4306fc002..f7f2aa168c9ef 100644 --- a/drivers/gpu/drm/i915/i915_vma_types.h +++ b/drivers/gpu/drm/i915/i915_vma_types.h @@ -100,7 +100,7 @@ struct intel_remapped_plane_info { u32 offset; u16 width; u16 height; - u16 stride; + u16 src_stride; u16 unused_mbz; } __packed; diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 95dd6712ac905..9aaf7201e2421 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -361,7 +361,7 @@ static unsigned long rotated_index(const struct intel_rotation_info *r, unsigned int x, unsigned int y) { - return (r->plane[n].stride * (r->plane[n].height - y - 1) + + return (r->plane[n].src_stride * (r->plane[n].height - y - 1) + r->plane[n].offset + x); } @@ -411,7 +411,7 @@ static unsigned long remapped_index(const struct intel_remapped_info *r, unsigned int x, unsigned int y) { - return (r->plane[n].stride * y + + return (r->plane[n].src_stride * y + r->plane[n].offset + x); } @@ -479,21 +479,21 @@ static int igt_vma_rotate_remap(void *arg) struct i915_address_space *vm = &ggtt->vm; struct drm_i915_gem_object *obj; const struct intel_remapped_plane_info planes[] = { - { .width = 1, .height = 1, .stride = 1 }, - { .width = 2, .height = 2, .stride = 2 }, - { .width = 4, .height = 4, .stride = 4 }, - { .width = 8, .height = 8, .stride = 8 }, + { .width = 1, .height = 1, .src_stride = 1 }, + { .width = 2, .height = 2, .src_stride = 2 }, + { .width = 4, .height = 4, .src_stride = 4 }, + { .width = 8, .height = 8, .src_stride = 8 }, - { .width = 3, .height = 5, .stride = 3 }, - { .width = 3, .height = 5, .stride = 4 }, - { .width = 3, .height = 5, .stride = 5 }, + { .width = 3, .height = 5, .src_stride = 3 }, + { .width = 3, .height = 5, .src_stride = 4 }, + { .width = 3, .height = 5, .src_stride = 5 }, - { .width = 5, .height = 3, .stride = 5 }, - { .width = 5, .height = 3, .stride = 7 }, - { .width = 5, .height = 3, .stride = 9 }, + { .width = 5, .height = 3, .src_stride = 5 }, + { .width = 5, .height = 3, .src_stride = 7 }, + { .width = 5, .height = 3, .src_stride = 9 }, - { .width = 4, .height = 6, .stride = 6 }, - { .width = 6, .height = 4, .stride = 6 }, + { .width = 4, .height = 6, .src_stride = 6 }, + { .width = 6, .height = 4, .src_stride = 6 }, { } }, *a, *b; enum i915_ggtt_view_type types[] = { @@ -523,8 +523,8 @@ static int igt_vma_rotate_remap(void *arg) struct intel_remapped_plane_info *plane_info = view.remapped.plane; unsigned int n, max_offset; - max_offset = max(plane_info[0].stride * plane_info[0].height, - plane_info[1].stride * plane_info[1].height); + max_offset = max(plane_info[0].src_stride * plane_info[0].height, + plane_info[1].src_stride * plane_info[1].height); GEM_BUG_ON(max_offset > max_pages); max_offset = max_pages - max_offset; @@ -596,11 +596,11 @@ static int igt_vma_rotate_remap(void *arg) "rotated" : "remapped", n, plane_info[0].width, plane_info[0].height, - plane_info[0].stride, + plane_info[0].src_stride, plane_info[0].offset, plane_info[1].width, plane_info[1].height, - plane_info[1].stride, + plane_info[1].src_stride, plane_info[1].offset); err = -EINVAL; goto out_object; @@ -853,21 +853,21 @@ static int igt_vma_remapped_gtt(void *arg) { struct drm_i915_private *i915 = arg; const struct intel_remapped_plane_info planes[] = { - { .width = 1, .height = 1, .stride = 1 }, - { .width = 2, .height = 2, .stride = 2 }, - { .width = 4, .height = 4, .stride = 4 }, - { .width = 8, .height = 8, .stride = 8 }, + { .width = 1, .height = 1, .src_stride = 1 }, + { .width = 2, .height = 2, .src_stride = 2 }, + { .width = 4, .height = 4, .src_stride = 4 }, + { .width = 8, .height = 8, .src_stride = 8 }, - { .width = 3, .height = 5, .stride = 3 }, - { .width = 3, .height = 5, .stride = 4 }, - { .width = 3, .height = 5, .stride = 5 }, + { .width = 3, .height = 5, .src_stride = 3 }, + { .width = 3, .height = 5, .src_stride = 4 }, + { .width = 3, .height = 5, .src_stride = 5 }, - { .width = 5, .height = 3, .stride = 5 }, - { .width = 5, .height = 3, .stride = 7 }, - { .width = 5, .height = 3, .stride = 9 }, + { .width = 5, .height = 3, .src_stride = 5 }, + { .width = 5, .height = 3, .src_stride = 7 }, + { .width = 5, .height = 3, .src_stride = 9 }, - { .width = 4, .height = 6, .stride = 6 }, - { .width = 6, .height = 4, .stride = 6 }, + { .width = 4, .height = 6, .src_stride = 6 }, + { .width = 6, .height = 4, .src_stride = 6 }, { } }, *p; enum i915_ggtt_view_type types[] = { From patchwork Thu Mar 25 21:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A21E4C433DB for ; Thu, 25 Mar 2021 21:48:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CCF1619D3 for ; Thu, 25 Mar 2021 21:48:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CCF1619D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91EE36EE68; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id E00C16EE5F for ; Thu, 25 Mar 2021 21:48:41 +0000 (UTC) IronPort-SDR: yDeXhr4ftaUPr0bJ705kmpbns4YMKCR40Ou2/LicEcbYH7TiOMSkRq7KDrwmBtS79TugfAikxJ fnCEBxaBRIEw== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005108" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005108" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:41 -0700 IronPort-SDR: STw1nqsg8hvMv7MEzj0sUX+tkmlePKiuyS7fkVfsN/tsSBfVP3GAVlWEzgY8oPsvPuZSsj6QRR I2FrXdwo6fKA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235746" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:40 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:06 +0200 Message-Id: <20210325214808.2071517-24-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 23/25] drm/i915: Add support for FBs requiring a POT stride alignment X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" An upcoming platform has a restriction that the FB stride must be power-of-two aligned. To support framebuffer layouts that are not in this layout add a logic that pads the tile rows to the POT aligned size. The HW won't read the padding PTEs, so these don't have to point to an allocated address, or even have their valid flag set. So use a NULL PTE instead for instance the scratch page, which is simple and keeps the SG table compact. v2: - Simplify plane_view_dst_stride(). (Ville) - Pass pitch_tiles as unsigned int. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/display/intel_display.c | 6 +- .../drm/i915/display/intel_display_types.h | 1 + drivers/gpu/drm/i915/display/intel_fb.c | 49 +++++++++++++--- drivers/gpu/drm/i915/gt/intel_ggtt.c | 58 +++++++++++++++---- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++- drivers/gpu/drm/i915/i915_vma_types.h | 2 +- drivers/gpu/drm/i915/selftests/i915_vma.c | 13 +++++ 7 files changed, 113 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 48b8e2083e14a..3550db51ab7ae 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -933,7 +933,7 @@ unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info int i; for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) - size += rot_info->plane[i].width * rot_info->plane[i].height; + size += rot_info->plane[i].dst_stride * rot_info->plane[i].width; return size; } @@ -944,7 +944,7 @@ unsigned int intel_remapped_info_size(const struct intel_remapped_info *rem_info int i; for (i = 0 ; i < ARRAY_SIZE(rem_info->plane); i++) - size += rem_info->plane[i].width * rem_info->plane[i].height; + size += rem_info->plane[i].dst_stride * rem_info->plane[i].height; return size; } @@ -1685,7 +1685,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, valid_fb: plane_state->rotation = plane_config->rotation; - intel_fb_fill_view(to_intel_framebuffer(fb), plane_state->rotation, + intel_fb_fill_view(to_intel_framebuffer(fb), plane_config->rotation, &intel_state->view); __i915_vma_pin(vma); diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index b72861f6f68a7..586976c1a9701 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -128,6 +128,7 @@ struct intel_framebuffer { /* Params to remap the FB pages and program the plane registers in each view. */ struct intel_fb_view normal_view; struct intel_fb_view rotated_view; + struct intel_fb_view remapped_view; }; struct intel_fbdev { diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index dcf7e811d1425..a8fced4570e30 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -486,10 +486,17 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) return true; } +static bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb) +{ + return false; +} + static int intel_fb_pitch(const struct intel_framebuffer *fb, int color_plane, unsigned int rotation) { if (drm_rotation_90_or_270(rotation)) return fb->rotated_view.color_plane[color_plane].pitch; + else if (intel_fb_needs_pot_stride_remap(fb)) + return fb->remapped_view.color_plane[color_plane].pitch; else return fb->normal_view.color_plane[color_plane].pitch; } @@ -597,6 +604,16 @@ plane_view_src_stride_tiles(const struct intel_framebuffer *fb, int color_plane, dims->tile_width * fb->base.format->cpp[color_plane]); } +static unsigned int +plane_view_dst_stride_tiles(const struct intel_framebuffer *fb, int color_plane, + unsigned int pitch_tiles) +{ + if (intel_fb_needs_pot_stride_remap(fb)) + return roundup_pow_of_two(pitch_tiles); + else + return pitch_tiles; +} + static unsigned int plane_view_width_tiles(const struct intel_framebuffer *fb, int color_plane, const struct fb_plane_view_dims *dims, @@ -629,8 +646,8 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p unsigned int tile_width = dims->tile_width; unsigned int tile_height = dims->tile_height; unsigned int tile_size = intel_tile_size(i915); - unsigned int pitch_tiles; struct drm_rect r; + u32 size; assign_chk_ovf(i915, remap_info->offset, obj_offset); assign_chk_ovf(i915, remap_info->src_stride, plane_view_src_stride_tiles(fb, color_plane, dims)); @@ -640,6 +657,9 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p if (view->gtt.type == I915_GGTT_VIEW_ROTATED) { check_array_bounds(i915, view->gtt.rotated.plane, color_plane); + assign_chk_ovf(i915, remap_info->dst_stride, + plane_view_dst_stride_tiles(fb, color_plane, remap_info->height)); + /* rotate the x/y offsets to match the GTT view */ drm_rect_init(&r, x, y, dims->width, dims->height); drm_rect_rotate(&r, @@ -650,22 +670,26 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p color_plane_info->x = r.x1; color_plane_info->y = r.y1; - pitch_tiles = remap_info->height; - color_plane_info->pitch = pitch_tiles * tile_height; + color_plane_info->pitch = remap_info->dst_stride * tile_height; + + size = remap_info->dst_stride * remap_info->width; /* rotate the tile dimensions to match the GTT view */ swap(tile_width, tile_height); } else { drm_WARN_ON(&i915->drm, view->gtt.type != I915_GGTT_VIEW_REMAPPED); - check_array_bounds(i915, view->gtt.remapped.plane, color_plane); + assign_chk_ovf(i915, remap_info->dst_stride, + plane_view_dst_stride_tiles(fb, color_plane, remap_info->width)); + color_plane_info->x = x; color_plane_info->y = y; - pitch_tiles = remap_info->width; - color_plane_info->pitch = pitch_tiles * tile_width * + color_plane_info->pitch = remap_info->dst_stride * tile_width * fb->base.format->cpp[color_plane]; + + size = remap_info->dst_stride * remap_info->height; } /* @@ -675,10 +699,10 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p */ intel_adjust_tile_offset(&color_plane_info->x, &color_plane_info->y, tile_width, tile_height, - tile_size, pitch_tiles, + tile_size, remap_info->dst_stride, gtt_offset * tile_size, 0); - return remap_info->width * remap_info->height; + return size; } #undef assign_chk_ovf @@ -723,12 +747,14 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb); u32 gtt_offset_rotated = 0; + u32 gtt_offset_remapped = 0; unsigned int max_size = 0; int i, num_planes = fb->format->num_planes; unsigned int tile_size = intel_tile_size(i915); intel_fb_view_init(&intel_fb->normal_view, I915_GGTT_VIEW_NORMAL); intel_fb_view_init(&intel_fb->rotated_view, I915_GGTT_VIEW_ROTATED); + intel_fb_view_init(&intel_fb->remapped_view, I915_GGTT_VIEW_REMAPPED); for (i = 0; i < num_planes; i++) { struct fb_plane_view_dims view_dims; @@ -776,6 +802,11 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb offset, gtt_offset_rotated, x, y, &intel_fb->rotated_view); + if (intel_fb_needs_pot_stride_remap(intel_fb)) + gtt_offset_remapped += calc_plane_remap_info(intel_fb, i, &view_dims, + offset, gtt_offset_remapped, x, y, + &intel_fb->remapped_view); + size = calc_plane_normal_size(intel_fb, i, &view_dims, x, y); /* how many tiles in total needed in the bo */ max_size = max(max_size, offset + size); @@ -859,6 +890,8 @@ void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotatio { if (drm_rotation_90_or_270(rotation)) *view = fb->rotated_view; + else if (intel_fb_needs_pot_stride_remap(fb)) + *view = fb->remapped_view; else *view = fb->normal_view; } diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c index cb048d0e369ce..6114f5c99ce71 100644 --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c @@ -1267,14 +1267,16 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt) static struct scatterlist * rotate_pages(struct drm_i915_gem_object *obj, unsigned int offset, unsigned int width, unsigned int height, - unsigned int stride, + unsigned int src_stride, unsigned int dst_stride, struct sg_table *st, struct scatterlist *sg) { unsigned int column, row; unsigned int src_idx; for (column = 0; column < width; column++) { - src_idx = stride * (height - 1) + column + offset; + unsigned int left; + + src_idx = src_stride * (height - 1) + column + offset; for (row = 0; row < height; row++) { st->nents++; /* @@ -1286,9 +1288,27 @@ rotate_pages(struct drm_i915_gem_object *obj, unsigned int offset, sg_dma_address(sg) = i915_gem_object_get_dma_address(obj, src_idx); sg_dma_len(sg) = I915_GTT_PAGE_SIZE; + sg = sg_next(sg); - src_idx -= stride; + src_idx -= src_stride; } + + left = (dst_stride - height) * I915_GTT_PAGE_SIZE; + + if (!left) + continue; + + st->nents++; + + /* + * The DE ignores the PTEs for the padding tiles, the sg entry + * here is just a conenience to indicate how many padding PTEs + * to insert at this spot. + */ + sg_set_page(sg, NULL, left, 0); + sg_dma_address(sg) = 0; + sg_dma_len(sg) = left; + sg = sg_next(sg); } return sg; @@ -1317,11 +1337,12 @@ intel_rotate_pages(struct intel_rotation_info *rot_info, st->nents = 0; sg = st->sgl; - for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) { + for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) sg = rotate_pages(obj, rot_info->plane[i].offset, rot_info->plane[i].width, rot_info->plane[i].height, - rot_info->plane[i].src_stride, st, sg); - } + rot_info->plane[i].src_stride, + rot_info->plane[i].dst_stride, + st, sg); return st; @@ -1339,7 +1360,7 @@ intel_rotate_pages(struct intel_rotation_info *rot_info, static struct scatterlist * remap_pages(struct drm_i915_gem_object *obj, unsigned int offset, unsigned int width, unsigned int height, - unsigned int stride, + unsigned int src_stride, unsigned int dst_stride, struct sg_table *st, struct scatterlist *sg) { unsigned int row; @@ -1356,7 +1377,6 @@ remap_pages(struct drm_i915_gem_object *obj, unsigned int offset, * the entries so the sg list can be happily traversed. * The only thing we need are DMA addresses. */ - addr = i915_gem_object_get_dma_address_len(obj, offset, &length); length = min(left, length); @@ -1372,7 +1392,24 @@ remap_pages(struct drm_i915_gem_object *obj, unsigned int offset, left -= length; } - offset += stride - width; + offset += src_stride - width; + + left = (dst_stride - width) * I915_GTT_PAGE_SIZE; + + if (!left) + continue; + + st->nents++; + + /* + * The DE ignores the PTEs for the padding tiles, the sg entry + * here is just a conenience to indicate how many padding PTEs + * to insert at this spot. + */ + sg_set_page(sg, NULL, left, 0); + sg_dma_address(sg) = 0; + sg_dma_len(sg) = left; + sg = sg_next(sg); } return sg; @@ -1404,7 +1441,8 @@ intel_remap_pages(struct intel_remapped_info *rem_info, for (i = 0 ; i < ARRAY_SIZE(rem_info->plane); i++) { sg = remap_pages(obj, rem_info->plane[i].offset, rem_info->plane[i].width, rem_info->plane[i].height, - rem_info->plane[i].src_stride, st, sg); + rem_info->plane[i].src_stride, rem_info->plane[i].dst_stride, + st, sg); } i915_sg_trim(st); diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 9c4b9d475793b..b654b7498bcde 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -173,26 +173,30 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) break; case I915_GGTT_VIEW_ROTATED: - seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", + seq_printf(m, ", rotated [(%ux%u, src_stride=%u, dst_stride=%u, offset=%u), (%ux%u, src_stride=%u, dst_stride=%u, offset=%u)]", vma->ggtt_view.rotated.plane[0].width, vma->ggtt_view.rotated.plane[0].height, vma->ggtt_view.rotated.plane[0].src_stride, + vma->ggtt_view.rotated.plane[0].dst_stride, vma->ggtt_view.rotated.plane[0].offset, vma->ggtt_view.rotated.plane[1].width, vma->ggtt_view.rotated.plane[1].height, vma->ggtt_view.rotated.plane[1].src_stride, + vma->ggtt_view.rotated.plane[1].dst_stride, vma->ggtt_view.rotated.plane[1].offset); break; case I915_GGTT_VIEW_REMAPPED: - seq_printf(m, ", remapped [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", + seq_printf(m, ", remapped [(%ux%u, src_stride=%u, dst_stride=%u, offset=%u), (%ux%u, src_stride=%u, dst_stride=%u, offset=%u)]", vma->ggtt_view.remapped.plane[0].width, vma->ggtt_view.remapped.plane[0].height, vma->ggtt_view.remapped.plane[0].src_stride, + vma->ggtt_view.remapped.plane[0].dst_stride, vma->ggtt_view.remapped.plane[0].offset, vma->ggtt_view.remapped.plane[1].width, vma->ggtt_view.remapped.plane[1].height, vma->ggtt_view.remapped.plane[1].src_stride, + vma->ggtt_view.remapped.plane[1].dst_stride, vma->ggtt_view.remapped.plane[1].offset); break; diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h index f7f2aa168c9ef..6b1bfa230b825 100644 --- a/drivers/gpu/drm/i915/i915_vma_types.h +++ b/drivers/gpu/drm/i915/i915_vma_types.h @@ -101,7 +101,7 @@ struct intel_remapped_plane_info { u16 width; u16 height; u16 src_stride; - u16 unused_mbz; + u16 dst_stride; } __packed; struct intel_remapped_info { diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 9aaf7201e2421..6aadcd31d75a9 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -528,6 +528,15 @@ static int igt_vma_rotate_remap(void *arg) GEM_BUG_ON(max_offset > max_pages); max_offset = max_pages - max_offset; + if (!plane_info[0].dst_stride) + plane_info[0].dst_stride = view.type == I915_GGTT_VIEW_ROTATED ? + plane_info[0].height : + plane_info[0].width; + if (!plane_info[1].dst_stride) + plane_info[1].dst_stride = view.type == I915_GGTT_VIEW_ROTATED ? + plane_info[1].height : + plane_info[1].width; + for_each_prime_number_from(plane_info[0].offset, 0, max_offset) { for_each_prime_number_from(plane_info[1].offset, 0, max_offset) { struct scatterlist *sg; @@ -902,6 +911,10 @@ static int igt_vma_remapped_gtt(void *arg) if (err) goto out; + if (!plane_info[0].dst_stride) + plane_info[0].dst_stride = *t == I915_GGTT_VIEW_ROTATED ? + p->height : p->width; + vma = i915_gem_object_ggtt_pin(obj, &view, 0, 0, PIN_MAPPABLE); if (IS_ERR(vma)) { err = PTR_ERR(vma); From patchwork Thu Mar 25 21:48:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE94DC433E1 for ; Thu, 25 Mar 2021 21:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD8C661494 for ; Thu, 25 Mar 2021 21:48:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD8C661494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1E136EE6B; Thu, 25 Mar 2021 21:48:45 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0549E6EE62 for ; Thu, 25 Mar 2021 21:48:42 +0000 (UTC) IronPort-SDR: yEnqa+s69Hc5ZqQC3v7eOBhwcJKZ+tGALnPpj1FCX8ZW9h5dD5gFZortM91qTWaZPKh4RWTqNf HjJGQkpcxGBA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005109" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005109" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:42 -0700 IronPort-SDR: eAsx2xve2laP4cOfLaOj/sfdN39QAx9Oy1FEh5wbeQqrwzA+3vUPc4nXWO5y0QckYEp5cvg2fj QfLB876MIKFA== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235752" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:41 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:07 +0200 Message-Id: <20210325214808.2071517-25-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 24/25] drm/i915/selftest: Add remap/rotate vma subtests when dst_stride!=width/height X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add selftests to test the POT stride padding functionality added in the previous patch. Signed-off-by: Imre Deak Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/selftests/i915_vma.c | 93 +++++++++++++++++++++-- 1 file changed, 86 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 6aadcd31d75a9..5fe7b80ca0bd9 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -373,6 +373,8 @@ assert_rotated(struct drm_i915_gem_object *obj, unsigned int x, y; for (x = 0; x < r->plane[n].width; x++) { + unsigned int left; + for (y = 0; y < r->plane[n].height; y++) { unsigned long src_idx; dma_addr_t src; @@ -401,6 +403,31 @@ assert_rotated(struct drm_i915_gem_object *obj, sg = sg_next(sg); } + + left = (r->plane[n].dst_stride - y) * PAGE_SIZE; + + if (!left) + continue; + + if (!sg) { + pr_err("Invalid sg table: too short at plane %d, (%d, %d)!\n", + n, x, y); + return ERR_PTR(-EINVAL); + } + + if (sg_dma_len(sg) != left) { + pr_err("Invalid sg.length, found %d, expected %u for rotated page (%d, %d)\n", + sg_dma_len(sg), left, x, y); + return ERR_PTR(-EINVAL); + } + + if (sg_dma_address(sg) != 0) { + pr_err("Invalid address, found %pad, expected 0 for remapped page (%d, %d)\n", + &sg_dma_address(sg), x, y); + return ERR_PTR(-EINVAL); + } + + sg = sg_next(sg); } return sg; @@ -462,15 +489,55 @@ assert_remapped(struct drm_i915_gem_object *obj, if (!left) sg = sg_next(sg); } + + if (left) { + pr_err("Unexpected sg tail with %d size for remapped page (%d, %d)\n", + left, + x, y); + return ERR_PTR(-EINVAL); + } + + left = (r->plane[n].dst_stride - r->plane[n].width) * PAGE_SIZE; + + if (!left) + continue; + + if (!sg) { + pr_err("Invalid sg table: too short at plane %d, (%d, %d)!\n", + n, x, y); + return ERR_PTR(-EINVAL); + } + + if (sg_dma_len(sg) != left) { + pr_err("Invalid sg.length, found %u, expected %u for remapped page (%d, %d)\n", + sg_dma_len(sg), left, + x, y); + return ERR_PTR(-EINVAL); + } + + if (sg_dma_address(sg) != 0) { + pr_err("Invalid address, found %pad, expected 0 for remapped page (%d, %d)\n", + &sg_dma_address(sg), + x, y); + return ERR_PTR(-EINVAL); + } + + sg = sg_next(sg); + left = 0; } return sg; } -static unsigned int rotated_size(const struct intel_remapped_plane_info *a, - const struct intel_remapped_plane_info *b) +static unsigned int remapped_size(enum i915_ggtt_view_type view_type, + const struct intel_remapped_plane_info *a, + const struct intel_remapped_plane_info *b) { - return a->width * a->height + b->width * b->height; + + if (view_type == I915_GGTT_VIEW_ROTATED) + return a->dst_stride * a->width + b->dst_stride * b->width; + else + return a->dst_stride * a->height + b->dst_stride * b->height; } static int igt_vma_rotate_remap(void *arg) @@ -494,6 +561,11 @@ static int igt_vma_rotate_remap(void *arg) { .width = 4, .height = 6, .src_stride = 6 }, { .width = 6, .height = 4, .src_stride = 6 }, + + { .width = 2, .height = 2, .src_stride = 2, .dst_stride = 2 }, + { .width = 3, .height = 3, .src_stride = 3, .dst_stride = 4 }, + { .width = 5, .height = 6, .src_stride = 7, .dst_stride = 8 }, + { } }, *a, *b; enum i915_ggtt_view_type types[] = { @@ -555,7 +627,7 @@ static int igt_vma_rotate_remap(void *arg) goto out_object; } - expected_pages = rotated_size(&plane_info[0], &plane_info[1]); + expected_pages = remapped_size(view.type, &plane_info[0], &plane_info[1]); if (view.type == I915_GGTT_VIEW_ROTATED && vma->size != expected_pages * PAGE_SIZE) { @@ -600,16 +672,18 @@ static int igt_vma_rotate_remap(void *arg) else sg = assert_remapped(obj, &view.remapped, n, sg); if (IS_ERR(sg)) { - pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n", + pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d, %d), (%d, %d, %d, %d, %d)]\n", view.type == I915_GGTT_VIEW_ROTATED ? "rotated" : "remapped", n, plane_info[0].width, plane_info[0].height, plane_info[0].src_stride, + plane_info[0].dst_stride, plane_info[0].offset, plane_info[1].width, plane_info[1].height, plane_info[1].src_stride, + plane_info[1].dst_stride, plane_info[1].offset); err = -EINVAL; goto out_object; @@ -877,6 +951,11 @@ static int igt_vma_remapped_gtt(void *arg) { .width = 4, .height = 6, .src_stride = 6 }, { .width = 6, .height = 4, .src_stride = 6 }, + + { .width = 2, .height = 2, .src_stride = 2, .dst_stride = 2 }, + { .width = 3, .height = 3, .src_stride = 3, .dst_stride = 4 }, + { .width = 5, .height = 6, .src_stride = 7, .dst_stride = 8 }, + { } }, *p; enum i915_ggtt_view_type types[] = { @@ -936,9 +1015,9 @@ static int igt_vma_remapped_gtt(void *arg) u32 val = y << 16 | x; if (*t == I915_GGTT_VIEW_ROTATED) - offset = (x * plane_info[0].height + y) * PAGE_SIZE; + offset = (x * plane_info[0].dst_stride + y) * PAGE_SIZE; else - offset = (y * plane_info[0].width + x) * PAGE_SIZE; + offset = (y * plane_info[0].dst_stride + x) * PAGE_SIZE; iowrite32(val, &map[offset / sizeof(*map)]); } From patchwork Thu Mar 25 21:48:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 12165077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A442C433E2 for ; Thu, 25 Mar 2021 21:48:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E524361494 for ; Thu, 25 Mar 2021 21:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E524361494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C7396EE62; Thu, 25 Mar 2021 21:48:46 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C0526EE5F for ; Thu, 25 Mar 2021 21:48:44 +0000 (UTC) IronPort-SDR: pJjDzKYINiq9avARZMQ4J83N8l3AvpBuv/YAQ7RVofBpMzC6dkp5U4/YKYUvH0n6vEZmXTED8c skGXfMpB221Q== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="171005111" X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="171005111" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:43 -0700 IronPort-SDR: 7siLiNOfR2kUr+sIbU/wCcmQz2IK9aoIn4VICa1XOSpn/BSKpAXO5LZUOc0FxxK5u1gmiG5PDW r/LlVnqNUhkQ== X-IronPort-AV: E=Sophos;i="5.81,278,1610438400"; d="scan'208";a="375235757" Received: from ideak-desk.fi.intel.com ([10.237.68.141]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 14:48:42 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Mar 2021 23:48:08 +0200 Message-Id: <20210325214808.2071517-26-imre.deak@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325214808.2071517-1-imre.deak@intel.com> References: <20210325214808.2071517-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 25/25] drm/i915: For-CI: Force remapping the FB with a POT aligned stride X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To test the POT stride padding functionality until it's taken into use by the actual platform needing it, enable the padding whenever the FB remapping is possible. An exception is to pad linear FBs when this would be otherwise possible (stride is page size aligned), because this won't be anyway needed. Padding of linear FBs will be still tested whenever a big stride requires remapping (so by igt/kms_big_fb). By this both the FB creation time and commit time remapping setup will be tested. Signed-off-by: Imre Deak --- drivers/gpu/drm/i915/display/intel_fb.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index a8fced4570e30..2094fb9b5ecab 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -446,17 +446,25 @@ static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane return 0; } +static bool intel_fb_can_remap(const struct drm_framebuffer *fb); + static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) { struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); - struct drm_i915_private *i915 = to_i915(plane->base.dev); const struct drm_framebuffer *fb = plane_state->hw.fb; - int i; /* We don't want to deal with remapping with cursors */ if (plane->id == PLANE_CURSOR) return false; + return intel_fb_can_remap(fb); +} + +static bool intel_fb_can_remap(const struct drm_framebuffer *fb) +{ + struct drm_i915_private *i915 = to_i915(fb->dev); + int i; + /* * The display engine limits already match/exceed the * render engine limits, so not much point in remapping. @@ -486,9 +494,13 @@ static bool intel_plane_can_remap(const struct intel_plane_state *plane_state) return true; } +#define FORCE_POT_STRIDE_REMAP true + static bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb) { - return false; + return FORCE_POT_STRIDE_REMAP && + fb->base.modifier != DRM_FORMAT_MOD_LINEAR && + intel_fb_can_remap(&fb->base); } static int intel_fb_pitch(const struct intel_framebuffer *fb, int color_plane, unsigned int rotation)