From patchwork Fri Apr 29 09:52:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1624106 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=Jg+kxBza; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KqSTX2wJ2z9sBF for ; Fri, 29 Apr 2022 19:52:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA8F183A79; Fri, 29 Apr 2022 11:52:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="Jg+kxBza"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6102A83989; Fri, 29 Apr 2022 11:52:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 A18FB83989 for ; Fri, 29 Apr 2022 11:52:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x631.google.com with SMTP id g6so14438192ejw.1 for ; Fri, 29 Apr 2022 02:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=j0J0XrSHKkB0tYz+6at29uXTtoYR0Fx15zn4Y+ELEXg=; b=Jg+kxBza8VS2Otjb2qBvyJ0oWjF0LQEc3ymli84zaGeTDMW6/j0VOUZOaag7BtFq3F tZ6LEwbRNGmfTEekwr9sBfosogftFom9bnKetS4uGqWdI82ItoJnNcoYUQ1Xb8NuL3lF 5+kz1W3CmygGZAiWFzvrP9x6GAHeVhPs2bMc4G99L/gt+6V3YqYkyDosI2BB8hs620uu FsS+qEZTAySsJl+T7b7/vVd1h+pES5ZqKP/YzervuAJlb4G/xq2npHgKeNtsVdR31V3o GXuV6cay2p6mNgW0HNKtEuU5o13k39JcWoMdN7FZ1K9UpJ7mwtopBjlK8RlW492Bapbe tyNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=j0J0XrSHKkB0tYz+6at29uXTtoYR0Fx15zn4Y+ELEXg=; b=mo5gZJCuWRuHLnLcAjH3q+V+39G4bfjHEqhsx53TFgsJN1PtG9BaPKeE19KadzEwDV 9dkauXRxfC4Rb6WLobHYwgYhHm/L8y+SUBBXk2j1o7A3jxXr3l2qUqcJPItdU45VYWEN EV4o4ORAMKbdlAGOSDjp8JvVN57po+s+SCJi0HbMCJW2VIUKaGUHCMEjRGErMJ99+Q+b 1Vnd0cnSyfxbRZizp+qrXuG0K42YO6cNZG+0Tz3sl/l6xyLTHZITXkPpsemtXm4bAg+I VBuRQ8U87iRXXGrKRBm+Wo5We/DmOvHQm5Lazxxb1BvkjXNAacXFafDbXDAjn66OZTUk ymaQ== X-Gm-Message-State: AOAM530cl7shwsomJzXwkJPGwGki7inLwKWQSZnwHqprPmzQ3YrorC9H CYGvgNUE+xvjMDtMxymIzQRJIoPW3HyrGw== X-Google-Smtp-Source: ABdhPJzR0TL9LpHgbc1xv+EIGZuqypQCuTJ2k8QNDTiDD5CkpPBpMnbAw7EGouVAyYUVKBkFEf8uRw== X-Received: by 2002:a17:906:804b:b0:6f3:8d78:ffa8 with SMTP id x11-20020a170906804b00b006f38d78ffa8mr24933101ejw.588.1651225951917; Fri, 29 Apr 2022 02:52:31 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id jz8-20020a17090775e800b006f3ef214dd8sm486487ejc.62.2022.04.29.02.52.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Apr 2022 02:52:31 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Subject: [PATCH] xilinx: Handle board_get_usable_ram_top(0) properly Date: Fri, 29 Apr 2022 11:52:27 +0200 Message-Id: <44470619e74f3e480b70deac24578e3e0d5c907e.1651225945.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean board_get_usable_ram_top() was designed for getting the top most location for U-Boot allocation that's why function itself supports via total_size parameter to find out where the right location for U-Boot is. But function itself is also reused by different (EFI) which is passing total_size as 0 to find out where the usable ram top is. For this case doesn't make sense (a waste time) to call any lmb functions. That's why simply return gd->ram_top. And gd->ram_top is filled already based on previous call for U-Boot iself. The same solution is also used by stm32mp by commit 92b611e8b003 ("stm32mp: correctly handle board_get_usable_ram_top(0)") and commit c8510e397fad ("stm32mp: Fix board_get_usable_ram_top()"). Signed-off-by: Michal Simek --- board/xilinx/versal/board.c | 3 +++ board/xilinx/zynqmp/zynqmp.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 2e2807eee463..a88f5bb177e2 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -256,6 +256,9 @@ ulong board_get_usable_ram_top(ulong total_size) phys_addr_t reg; struct lmb lmb; + if (!total_size) + return gd->ram_top; + /* found enough not-reserved memory to relocated U-Boot */ lmb_init(&lmb); lmb_add(&lmb, gd->ram_base, gd->ram_size); diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 41ecc9559c4b..e311aa772cce 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -516,6 +516,9 @@ ulong board_get_usable_ram_top(ulong total_size) phys_addr_t reg; struct lmb lmb; + if (!total_size) + return gd->ram_top; + if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob);