From patchwork Thu Nov 30 16:16:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paz Zcharya X-Patchwork-Id: 171976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp504999vqy; Thu, 30 Nov 2023 08:17:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO57MGzpvn8CBcHjAk72XkKDrFrDDS+7uTNaymEB9DvGKdXn64onknZPXTaa9VLtpIRLPU X-Received: by 2002:a6b:6011:0:b0:7b0:1aa3:1bb9 with SMTP id r17-20020a6b6011000000b007b01aa31bb9mr18402472iog.20.1701361044611; Thu, 30 Nov 2023 08:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701361044; cv=none; d=google.com; s=arc-20160816; b=hV+O15wSJBXK2jmmm/Qm83LbCmShxvNVxonX8eIh7LMuyv7S+2RCGgOLrwuRrA9Z/K 5w7gZAH0N2MH4HaTTmWx/4vvhpQN+Mz+egbtJx8pEnsSjBxoULQXH6Gm+Xw1QrpsHdm6 gkSumjshUNnXi4I7yP/UKNZfDh6V5A+F9uq9JHJCVXGUOkKwohjPz6b4Cel/+CDvFHBU MwPdV2+k14tIPxZSrOpw4Lq7Z1qHMCrGHfDqoH1gA52wXo8U7LuO2nB/BiTe8FJ03veO ZVZILPMeLbNqwrfpaITVUOEzfkXpaN3acYdN6opNMHx15Ai9BPe2o1nzGv7eHqPVqeD3 mJEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7ZVJygFoxlCvYJvp9UVcwgwa6qE6VPVWJwn+rUhq2G4=; fh=gFHSkvC5UqI88oFaJcQD6jpnAPNKHH5xMz/ZjCkL2pc=; b=edX0ayETjB0eOrvOw+qqALegTptF8bilXyoyjTj31ughYVsIJ4nFk8u8W14shfTjqN kHB+pT/4ttZsrLwGyrzskt+rEgbING9SjPtzA2IhOxfV/uO4RUAF3wOFf3Iui/CNmrbZ Ec1uf54IX2KF28GRHzD8g+Y7cp/oie8a+rof4ayOUDr6fq9RKwT71QL5B+whR5mJFoUL EwmwYn9P2BD7hvveYCgfAnEX2AFly96LGAQafx61G4KPDQ/IBEqzn65fv4CEXJTsGz3W tHFJMzoI6OwCPFc13oFjctl+7lDoV5QporVeMG1rp8ZzmZX2vGHZSk1bD5gHFZpHmYXA DH3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FZxeNxU7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u1-20020a6540c1000000b005b882238681si1581923pgp.620.2023.11.30.08.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:17:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FZxeNxU7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 830A5807478D; Thu, 30 Nov 2023 08:17:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232008AbjK3QRM (ORCPT + 99 others); Thu, 30 Nov 2023 11:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjK3QRK (ORCPT ); Thu, 30 Nov 2023 11:17:10 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4231D112 for ; Thu, 30 Nov 2023 08:17:16 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-77d63b733e4so53965285a.2 for ; Thu, 30 Nov 2023 08:17:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701361035; x=1701965835; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7ZVJygFoxlCvYJvp9UVcwgwa6qE6VPVWJwn+rUhq2G4=; b=FZxeNxU7vZCszFCRANxatR6xA8N0DVsIy2e9jyNZUUTiv89KEzHo3LF+XyGM87bcYf SwMmLnWpHS+W6SDXKAM91Exkqph1Y7Qc/wnzkDV/znU87Y+a+72dRcJDUmv6g4Wt/a21 DUi1Wq190KyTl6wdjFiZ9lNynqillHypaM4N4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701361035; x=1701965835; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7ZVJygFoxlCvYJvp9UVcwgwa6qE6VPVWJwn+rUhq2G4=; b=py7Nx/nYiycFNYhYU7yUSSHR/fs9D7+nW+zPwaLLJq+8kXXA8INbY/k73mHjJmGV3Y wArVSK8Kf/xtjqA2seDP4gLxSJcgCzTXEAkHHj1qhADBDxnlJAB7VgY3BfeIQ9A+GZO/ U+z8P/KQAOHvxAvSbIFmPqDemB+nBOW8rA0HEDCGHOoxjCKcifwEt8dbxqXGr4uQuPsY dB/qeTpIVAJkuWXX2v5PU6z091b350hj9jQwEnfq4wZ07Cqpy2R3Y4xrf+QkpUb5spvD 5QX5P8+a7vJ9lazGgsqm/NhtxrZ3uxAV2B2yH0k309EQC/EJMGtdI89Zzn7ddb74hgGq tJeg== X-Gm-Message-State: AOJu0Yz2O/UCXCmx5DmwEAOAjvoKOSBMYX1V2xNkACMNnxRskQors1YZ 5NhgQ7GHjucBg3XiSqQF9UgTxA== X-Received: by 2002:a05:620a:4883:b0:77d:7843:a06b with SMTP id ea3-20020a05620a488300b0077d7843a06bmr27795774qkb.4.1701361035350; Thu, 30 Nov 2023 08:17:15 -0800 (PST) Received: from pazz.c.googlers.com.com (193.132.150.34.bc.googleusercontent.com. [34.150.132.193]) by smtp.gmail.com with ESMTPSA id y13-20020a05620a09cd00b0077731466526sm617093qky.70.2023.11.30.08.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:17:14 -0800 (PST) From: Paz Zcharya To: Andrzej Hajda , Tvrtko Ursulin Cc: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , matthew.auld@intel.com, intel-gfx@lists.freedesktop.org, Drew Davenport , Rodrigo Vivi , Nirmoy Das , Joonas Lahtinen , =?utf-8?q?Jouni_H=C3=B6g?= =?utf-8?q?ander?= , Paz Zcharya , Subrata Banik , dri-devel@lists.freedesktop.org, Manasi Navare , Jani Nikula , Sean Paul , Daniel Vetter , Marcin Wojtas , linux-kernel@vger.kernel.org, David Airlie , Tvrtko Ursulin Subject: [PATCH] drm/i915/display: Check GGTT to determine phys_base Date: Thu, 30 Nov 2023 16:16:37 +0000 Message-ID: <20231130161651.1836047-1-pazz@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 08:17:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784006358895432887 X-GMAIL-MSGID: 1784006358895432887 There was an assumption that for iGPU there should be a 1:1 mapping of GGTT to physical address pointing to actual framebuffer. This assumption is not valid anymore for MTL. Fix that by checking GGTT to determine the phys address. The following algorithm for phys_base should be valid for all platforms: 1. Find pte 2. if(IS_DGFX(i915) && pte & GEN12_GGTT_PTE_LM) mem = i915->mm.regions[INTEL_REGION_LMEM_0] else mem = i915->mm.stolen_region 3. phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start; - On older platforms, stolen_region points to system memory, starting at 0 - on DG2, it uses lmem region which starts at 0 as well - on MTL, stolen_region points to stolen-local which starts at 0x800000 Signed-off-by: Paz Zcharya --- .../drm/i915/display/intel_plane_initial.c | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c b/drivers/gpu/drm/i915/display/intel_plane_initial.c index a55c09cbd0e4..c4bf02ea966c 100644 --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c @@ -51,6 +51,8 @@ initial_plane_vma(struct drm_i915_private *i915, struct intel_memory_region *mem; struct drm_i915_gem_object *obj; struct i915_vma *vma; + gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm; + gen8_pte_t pte; resource_size_t phys_base; u32 base, size; u64 pinctl; @@ -59,44 +61,41 @@ initial_plane_vma(struct drm_i915_private *i915, return NULL; base = round_down(plane_config->base, I915_GTT_MIN_ALIGNMENT); - if (IS_DGFX(i915)) { - gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm; - gen8_pte_t pte; + gte += base / I915_GTT_PAGE_SIZE; - gte += base / I915_GTT_PAGE_SIZE; + pte = ioread64(gte); - pte = ioread64(gte); + if (IS_DGFX(i915)) { if (!(pte & GEN12_GGTT_PTE_LM)) { drm_err(&i915->drm, "Initial plane programming missing PTE_LM bit\n"); return NULL; } - - phys_base = pte & I915_GTT_PAGE_MASK; mem = i915->mm.regions[INTEL_REGION_LMEM_0]; - - /* - * We don't currently expect this to ever be placed in the - * stolen portion. - */ - if (phys_base >= resource_size(&mem->region)) { - drm_err(&i915->drm, - "Initial plane programming using invalid range, phys_base=%pa\n", - &phys_base); - return NULL; - } - - drm_dbg(&i915->drm, - "Using phys_base=%pa, based on initial plane programming\n", - &phys_base); } else { - phys_base = base; mem = i915->mm.stolen_region; } + phys_base = (pte & I915_GTT_PAGE_MASK) - mem->region.start; + if (!mem) return NULL; + /* + * We don't currently expect this to ever be placed in the + * stolen portion. + */ + if (phys_base >= resource_size(&mem->region)) { + drm_err(&i915->drm, + "Initial plane programming using invalid range, phys_base=%pa\n", + &phys_base); + return NULL; + } + + drm_dbg(&i915->drm, + "Using phys_base=%pa, based on initial plane programming\n", + &phys_base); + size = round_up(plane_config->base + plane_config->size, mem->min_page_size); size -= base;