Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp328433rdf; Tue, 21 Nov 2023 04:07:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFseq1qJ5tnrq+VYuHDwnvv2Niy8DZ3/dLH1G2Jx1D0TyD7QgoLAj0KaIm1ypEsv+/7/CNr X-Received: by 2002:a17:902:ab45:b0:1ca:200b:8dce with SMTP id ij5-20020a170902ab4500b001ca200b8dcemr7513376plb.41.1700568419742; Tue, 21 Nov 2023 04:06:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700568419; cv=none; d=google.com; s=arc-20160816; b=Y7CgG00ozDeriWi5oWM9o6twPrxNFNrSWBJAqUOHaHOIApBPC50zzJ7Uz/M5L910oO K7oS5l09sSN4lRBjIHlln3+UHWYwubpq5jxT/SEy9ZTNMmGEwwri9i6fbILjLD7P1FB0 cGmBBREwQXTVjOrWmR/ECeXadX7Rt7hbwxL0bbAddoRZ6OMrqgJSTiAgT9Wrv+e1riPS hhcwfKdMGUeIAyk6brjTi1yfZ+f/WwIxIVx0gQrM5GygIfH+pnSZ343MhUeU9HUEX4T4 VSc6GAHniNfX3lVtIZ5++3v2lxmgyvXdTYuqWJMqOoGk4AaAsr0iNEWJl4NK7aPFxGLG Kyrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=BsEnHkQSIqEy4u9cei8CQHBkfgu130zGImsOwMHNWFk=; fh=HLYUdU4V9TvUPrEB2/5JeFh/7QHToR4wboUbTqVFXWU=; b=xeRtX4Ed1GRB1MwD3e+3tb+xgFwZjxf9VXpH2zh0bPWaL+I3FQclLTbXZK7OHjiX90 SbEoaVFNDYBi3+sDLNeEDfeRri3AFdgTeutsQgBJS5LSYcuuBTNbkZq9B6f0yakU1cfV ugosw8YRMqBDQgr7g0kVZL18WLyBg/bz0fNHohMgaMlCf7MGZ08jmyIWWO66QqqjQeL/ tXtJuUM/rIg2cRsHTfLR6aAmjADyU7MTXoD9IiqbdALrFL7dZOtnkEI6yAzFNXgZ8ryq vBQKE+oIabm53TdeG8zstDyIE0d+Er67PF7gSWMgb9GmtBG89GNaojAohN50hLHC/mCY NgQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ED/xcfzQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i8-20020a17090332c800b001cc6afede42si10562433plr.354.2023.11.21.04.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 04:06:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ED/xcfzQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E3684807BA39; Tue, 21 Nov 2023 04:06:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232964AbjKUMGr (ORCPT + 99 others); Tue, 21 Nov 2023 07:06:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234707AbjKUMGj (ORCPT ); Tue, 21 Nov 2023 07:06:39 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5641BC for ; Tue, 21 Nov 2023 04:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700568393; x=1732104393; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=t/2bEVeJuujRMjbp/hilDSCjmc2RJ6be3UC2T97ooT4=; b=ED/xcfzQIv3LTTj8DG9/DLNha3FnQsozIc40Zp0sLLPi8Msu+2fGdfyM Ab7k3tjunN7vrTizwx0kzjFH8bpqTvjVspI0hVzaaRHJ/9cL9jgby0cXp mFyfssrcM1Wx4E9hmS2xXIgdUhzVmHnzV+hnMITEiuToUgLk8Xsuz6jS9 SoFKGvXX8F3tdj6u74gkNAY5Gbw3s3rutSEUG3cidD0dPIcVWkzKcH1Y8 uEwNawRE1BYj3TGC+ouiXSvhyh536J2kvm22QcfTmyzM0I3nHWy/CzxnP bD2DdxhJx1kh8zhxcf/EJad5cjj5SOXoVrLW/J3hkJcdsh1Xe3e5ees/t A==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="395751607" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="395751607" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 04:06:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="1013898917" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="1013898917" Received: from ahajda-mobl.ger.corp.intel.com (HELO [10.213.11.238]) ([10.213.11.238]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 04:06:19 -0800 Message-ID: <8dd6f4da-dcc9-4ea3-8395-bf048b0dbc93@intel.com> Date: Tue, 21 Nov 2023 13:06:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Intel-gfx] [PATCH] drm/i915/display: Fix phys_base to be relative not absolute Content-Language: en-US To: Paz Zcharya , Rodrigo Vivi Cc: Subrata Banik , Tvrtko Ursulin , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sean Paul , matthew.auld@intel.com, Daniel Vetter , Marcin Wojtas , Drew Davenport , David Airlie , Nirmoy Das References: <20231105172718.18673-1-pazz@chromium.org> From: Andrzej Hajda Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 04:06:56 -0800 (PST) On 18.11.2023 00:01, Paz Zcharya wrote: > On Tue, Nov 14, 2023 at 10:13:59PM -0500, Rodrigo Vivi wrote: >> On Sun, Nov 05, 2023 at 05:27:03PM +0000, Paz Zcharya wrote: >>> Fix the value of variable `phys_base` to be the relative offset in >>> stolen memory, and not the absolute offset of the GSM. >> >> to me it looks like the other way around. phys_base is the physical >> base address for the frame_buffer. Setting it to zero doesn't seem >> to make that relative. And also doesn't look right. >> >>> >>> Currently, the value of `phys_base` is set to "Surface Base Address," >>> which in the case of Meter Lake is 0xfc00_0000. >> >> I don't believe this is a fixed value. IIRC this comes from the register >> set by video bios, where the idea is to reuse the fb that was used so >> far. >> >> With this in mind I don't understand how that could overflow. Maybe >> the size of the stolen is not right? maybe the size? maybe different >> memory region? >> > > Hi Rodrigo, thanks for the great comments. > > Apologies for using a wrong/confusing terminology. I think 'phys_base' > is supposed to be the offset in the GEM BO, where base (or > "Surface Base Address") is supposed to be the GTT offset. Since base is taken from PLANE_SURF register it should be resolvable via GGTT to physical address pointing to actual framebuffer. I couldn't find anything in the specs. The simplest approach would be then do the same as in case of DGFX: gen8_pte_t __iomem *gte = to_gt(i915)->ggtt->gsm; gen8_pte_t pte; gte += base / I915_GTT_PAGE_SIZE; pte = ioread64(gte); phys_base = pte & I915_GTT_PAGE_MASK; Regards Andrzej > > Other than what I wrote before, I noticed that the function 'i915_vma_pin' > which calls to 'i915_gem_gtt_reserve' is the one that binds the right > address space in the GTT for that stolen region. > > I see that in the function 'i915_vma_insert' (full call stack below), > where if (flags & PIN_OFFSET_FIXED), then when calling 'i915_gem_gtt_reserve' > we add an offset. > > Specifically in MeteorLake, and specifically when using GOP driver, this > offset is equal to 0xfc00_0000. But as you mentioned, this is not strict. > > The if statement always renders true because in the function > 'initial_plane_vma' we always set > pinctl = PIN_GLOBAL | PIN_OFFSET_FIXED | base; > where pinctl == flags (see file 'intel_plane_initial.c' line 145). > > Call stack: > drm_mm_reserve_node > i915_gem_gtt_reserve > i915_vma_insert > i915_vma_pin_ww > i915_vma_pin > initial_plane_vma > intel_alloc_initial_plane_obj > intel_find_initial_plane_obj > > Therefore, I believe the variable 'phys_base' in the > function 'initial_plane_vma,' should be the the offset in the GEM BO > and not the GTT offset, and because the base is added later on > in the function 'i915_gem_gtt_reserve', this value should not be > equal to base and be 0. > > Hope it makes more sense. > >>> This causes the >>> function `i915_gem_object_create_region_at` to fail in line 128, when >>> it attempts to verify that the range does not overflow: >>> >>> if (range_overflows(offset, size, resource_size(&mem->region))) >>> return ERR_PTR(-EINVAL); >>> >>> where: >>> offset = 0xfc000000 >>> size = 0x8ca000 >>> mem->region.end + 1 = 0x4400000 >>> mem->region.start = 0x800000 >>> resource_size(&mem->region) = 0x3c00000 >>> >>> call stack: >>> i915_gem_object_create_region_at >>> initial_plane_vma >>> intel_alloc_initial_plane_obj >>> intel_find_initial_plane_obj >>> intel_crtc_initial_plane_config >>> >>> Looking at the flow coming next, we see that `phys_base` is only used >>> once, in function `_i915_gem_object_stolen_init`, in the context of >>> the offset *in* the stolen memory. Combining that with an >>> examinination of the history of the file seems to indicate the >>> current value set is invalid. >>> >>> call stack (functions using `phys_base`) >>> _i915_gem_object_stolen_init >>> __i915_gem_object_create_region >>> i915_gem_object_create_region_at >>> initial_plane_vma >>> intel_alloc_initial_plane_obj >>> intel_find_initial_plane_obj >>> intel_crtc_initial_plane_config >>> >>> [drm:_i915_gem_object_stolen_init] creating preallocated stolen >>> object: stolen_offset=0x0000000000000000, size=0x00000000008ca000 >>> >>> Signed-off-by: Paz Zcharya >>> --- >>> >>> drivers/gpu/drm/i915/display/intel_plane_initial.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c b/drivers/gpu/drm/i915/display/intel_plane_initial.c >>> index a55c09cbd0e4..e696cb13756a 100644 >>> --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c >>> +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c >>> @@ -90,7 +90,7 @@ initial_plane_vma(struct drm_i915_private *i915, >>> "Using phys_base=%pa, based on initial plane programming\n", >>> &phys_base); >>> } else { >>> - phys_base = base; >>> + phys_base = 0; >>> mem = i915->mm.stolen_region; >>> } >>> >>> -- >>> 2.42.0.869.gea05f2083d-goog >>>