Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD3AEC001DF for ; Fri, 4 Aug 2023 18:20:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C062586961; Fri, 4 Aug 2023 20:20:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="QbCWL1MU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B16E286961; Fri, 4 Aug 2023 20:20:04 +0200 (CEST) Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 36D158694E for ; Fri, 4 Aug 2023 20:20:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5839f38342fso25967957b3.0 for ; Fri, 04 Aug 2023 11:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1691173201; x=1691778001; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3h/NlvIUH/hV091khF1qj6jQMTDzSQ4MvXllYzAMGKs=; b=QbCWL1MUo7vpxuQeO3v7irJ0UJlHKMosfhFDfi7yWF90a4HOcA7I/tJx6OUC2/8tej oloIC3pocfLRkaA79+14GmW96So7/6xgne7CLdI0GDb4/yT7a+i8qHdYnWV91lpyD75u MXIeLp2ZCVjhZ9Va7D9Kqr/e6KtZ4lw9qKdjE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691173201; x=1691778001; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3h/NlvIUH/hV091khF1qj6jQMTDzSQ4MvXllYzAMGKs=; b=MO9ZjN+8xlfa/Fwoj8VsWZumP0ledgAlwiOycUyf8gVKJB3u2vBN3UEOSFmWOSeCTF K9OgSyuvpJ9Ja4VPcJCwrXtsyVEgIISJlCuRvvwfSC+6i4kbENpRNUtSHwmZ2hCKHIMQ owLQpRie35/PqxWOlnnFIbbKI/IFYJzx2DULsrHxlwmSHzvJK9juAS4gSm0K/ViEt6+w lBqWNBJ3DqLwIu3oYLiajU2Ygq4lVVgVM/xlNijfIPoqDM7/y4OXWFwusxWKAcbAh3SD 1Q825ZBTNSPWlET1TN9f78j34082hkTfePB5YNrdbeMK1HrlDELu6nbzBMVGRwqhT00P yebQ== X-Gm-Message-State: AOJu0Yyr55MiWcqpe+x53k3k3oSF2T+veYY1hRvaxNqKXl/kt5MO7Tls sJucWSQ0Mp26d/J3mSVB7+Puew== X-Google-Smtp-Source: AGHT+IFC12mB34OFRTjxsdnsyGafxyuoZox5yssWllC8NBswrPkgNcl1ro4rVGEk2MpmIZmcVsas/w== X-Received: by 2002:a0d:d84c:0:b0:579:16e0:b1bf with SMTP id a73-20020a0dd84c000000b0057916e0b1bfmr2704982ywe.12.1691173200860; Fri, 04 Aug 2023 11:20:00 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-c37f-6e0c-fce7-d587.res6.spectrum.com. [2603:6081:7b00:6400:c37f:6e0c:fce7:d587]) by smtp.gmail.com with ESMTPSA id t17-20020a81c251000000b005771872a8dbsm865175ywg.132.2023.08.04.11.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 11:20:00 -0700 (PDT) Date: Fri, 4 Aug 2023 14:19:58 -0400 From: Tom Rini To: Devarsh Thakkar Cc: Simon Glass , Bin Meng , ovpanait@gmail.com, pali@kernel.org, u-boot@lists.denx.de, praneeth@ti.com, nm@ti.com, vigneshr@ti.com, a-bhatia1@ti.com, j-luthra@ti.com, nsekhar@ti.com Subject: Re: [PATCH] common: board_f: Move relocation address after framebuffer Message-ID: <20230804181958.GV3630934@bill-the-cat> References: <20230801140414.76216-1-devarsht@ti.com> <7f673cdb-9c61-4207-bb6c-4c7a4dc4a63c@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hvhjzR+QXnUh6Kmr" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean --hvhjzR+QXnUh6Kmr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 04, 2023 at 01:10:10PM +0530, Devarsh Thakkar wrote: > Hi Simon, Tom, Bin, >=20 > Thanks for the quick feedback. >=20 > On 04/08/23 04:58, Simon Glass wrote: > > Hi Devarsh, > >=20 > > On Thu, 3 Aug 2023 at 08:28, Devarsh Thakkar wrote: > >> > >> Hi Simon, > >> > >> On 03/08/23 19:32, Simon Glass wrote: > >>> +Bin Meng > >>> > >>> Hi Devarsh, > >>> > >>> On Tue, 1 Aug 2023 at 08:04, Devarsh Thakkar wrote: > >>>> > >>>> When passing framebuffer address using bloblist, check > >>>> that passed address is overlapping with current relocation > >>>> address, if so move the relocation address after the framebuffer > >>>> region to avoid overlap. > >>>> > >>>> Fixes: 5bc610a7d9d ("common: board_f: Pass frame buffer info from > >>>> SPL to u-boot") > >>>> Signed-off-by: Devarsh Thakkar > >>>> --- > >>>> common/board_f.c | 5 ++++- > >>>> 1 file changed, 4 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/common/board_f.c b/common/board_f.c > >>>> index 7d2c380e91..20fa17207a 100644 > >>>> --- a/common/board_f.c > >>>> +++ b/common/board_f.c > >>>> @@ -419,7 +419,10 @@ static int reserve_video(void) > >>>> if (!ho) > >>>> return log_msg_ret("blf", -ENOENT); > >>>> video_reserve_from_bloblist(ho); > >>>> - gd->relocaddr =3D ho->fb; > >>>> + /* Relocate after framebuffer area to avoid overlap = */ > >>>> + if (gd->relocaddr > (unsigned long)ho->fb) > >>>> + gd->relocaddr =3D ho->fb; > >>>> + > >>>> } else if (CONFIG_IS_ENABLED(VIDEO)) { > >>>> ulong addr; > >>>> int ret; > >>>> -- > >>>> 2.34.1 > >>>> > >>> > >>> Yes this happens to work with qemu-x86_64. However it depends on the > >>> SPL frame buffer being below the current allocation area. Why would it > >>> be below, in general? This seems like a land mine for others to trip > >>> up on. > >>> > >> > >> Basically to avoid overlap, the thing we are enforcing here is that > >> relocaddr should always be below framebuffer so that further areas > >> reserved do not overlap with framebuffer since we decrement relocaddr = to > >> resereve them. If relocaddr is already below framebuffer then there i= s no > >> need to update relocaddr as in your case otherwise we have to do it, h= ence > >> working for both scenarios. > >=20 > > That's not true in general. Say the frame buffer is at 1GB and > > U-Boot's top of memory is at 2GB, then this will create a gap in the > > reservations, so some things are just below 2GB and some others are > > just below 1GB. There will be no indication of this... > >=20 >=20 > Thanks Simon, I understand your point here but I think this problem is st= ill > there even with other approaches like separate Kconfig or SPL blob passin= g to > indicate relocaddr update, as though even in that case SPL will need some= base > to take a decision on whether u-boot proper will require to move relocadd= r or not. >=20 > For e.g. in this case there is a gap of ~1Gb between relocaddr and frameb= uffer > and so we don't want to move relocaddr here since we assume that most lik= ely > ~1Gb is enough for u-boot to carry out and complete it's reservations wit= hout > touching the framebuffer area, but this assumption may not hold true if t= he > gap is in Mb's or Kb's. >=20 > To resolve this, the maximum value required for u-boot to carry out > reservations need to be estimated and then we can make this condition more > intelligent : >=20 > if (gd->relocaddr - gd->video_top < UBOOT_MAX_RESERVE_SIZE) > gd->relocaddr =3D ho->fb; >=20 >=20 > If above looks good then, is it possible to estimate worst case common va= lue > for UBOOT_MAX_RESERVE_SIZE ? Or we want vendors to choose it say using a > separate Kconfig say CONFIG_UBOOT_MAX_RESERVE_SIZE ? >=20 > Kindly let me know your feedback on above approach, I can send a V2 based= on it. >=20 > Also to add, I think different vendors may choose to use different addres= ses > for reserving framebuffer at SPL stage and I am not sure if one approach = be > labelled as more general above other. For e.g. Some vendors may follow sa= me > scheme as u-boot proper by calling reserve_video at SPL too and keep it n= ear > ram_top, some may keep it little away from it and some may keep it even f= arther. My main comment right now is that by "vendors" I hope you mean "SoC vendors" and not "platform vendors". Within a given SoC family the address picked should be right, and if it needs adjusting (say larger display resolution) then it must be well documented how to calculate and in what direction it is safe to change it towards. --=20 Tom --hvhjzR+QXnUh6Kmr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmTNQUAACgkQFHw5/5Y0 tyx2mQv/cwPIzC6nxThjKfOP9+TAiX8sFDTfSJOoU4XQtdzJglcni/ZHzYktaBet 2Naf45OZryrmRA8S8lUDIHP1jz7fI65ZvoSHg3Xb/B5CPh9/wviJ1Cuk6lVe6Uwn GfbV4NQvyUK12S0qgKCFJios3Jaa0N1PRGft4HsxUFb8XP3i/fK9S0aqgOBR5adL m5ECX5dQvHQIRlHNrxtSH2F1T39J2vpZ9o3s/EGw9teI6S6xBzUAg8EVX13MYxL/ OUtXVpywiyN2dXB9QJGyL6wKKxPAa/I3xTRfkhi1VQPzwXbtOHT9YTKoiw5GyMGB OMc7QNY6yg/2jeIhwGrvn8hgrHyJOxlnHCo1siWLxWUnFtUgYFBGzpSHM8j1zSB/ 4NqUHJ/g0l/oRntHoAACLNbOkRpYGsRUTlqemno1sMU1F24a7fVy3fIx2DkzCUMR tHQmavrANi1fwdsV3aAZ6GNSMzqkyQ6DmLaLE+kBcoY55+l2E437UhF+i27oiwPA Yu9TuYcB =K3pp -----END PGP SIGNATURE----- --hvhjzR+QXnUh6Kmr--