From patchwork Tue Mar 1 08:13:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1599122 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=fail reason="signature verification failed" (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=tyv6Fy+T; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7DKs5rqKz9sGs for ; Tue, 1 Mar 2022 21:40:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FC8583CCB; Tue, 1 Mar 2022 09:13:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="tyv6Fy+T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77A4283D09; Tue, 1 Mar 2022 09:13:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 1BE5983CC6 for ; Tue, 1 Mar 2022 09:13:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x535.google.com with SMTP id h15so20897559edv.7 for ; Tue, 01 Mar 2022 00:13:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Fn4aZL3q3Y+35re7zl1SUKNV/s68XEoNLmTCfjyvp70=; b=tyv6Fy+TSHC9JI3bXWacz2wLrS7+wvnFekfg4iDntRnjOBx0utkoBF2rbqAc8KfF99 XX2TDds3dmWjDnx97emSbwVpP3NGG7FSXEoZk0a22dSQFuU2dXjMO8unacUwD/qJ09pt OY4sZCeARL3pJO1QYrlvBh7nUw5rkHpKkVV+mOmU2zE2BernLsT+3r9JPz581avHnXrz C/XDdQutkgUx7GtDSDKFMrmkJxNG/JqruHNlN09yg2a+np8LkuIh9YQRLIaGuV04B4e+ zHjHcS5zGoOTUkZAAHNLuzy/3oEfYZCIv1jtKLZSfacxMLvurIWoCZMEWof/KaCAFWSY SghQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=Fn4aZL3q3Y+35re7zl1SUKNV/s68XEoNLmTCfjyvp70=; b=IahGquIckPVOckboiW4GaKwtSIU28K1JHPot6+agG2+8VP6Zi65pOVFv1I+f37KSzK GDH9kgCe3ePnUxrc6jd7/QtIhxffYsOCuhQ/h+9Hi3H9sw1EX5694DlDY7Fqz/x5IMlg uESXvHkvVLTa5TMy+4w/TgpcOWYABigqyJeW50Tr+0C1AHscO75P9dpU9BUSSXm3Gwvw ZY6CRqxRUn03OiESmcS72og41si0E+ALGXo009amFZTnoBfl95qzv1KVW4IG4qblTydA urqZ0331ll4FZl6FTwUPdmrQesm+JULMbTyehSvDzbvMvGQ3mOaXY+zDvTbxrjfse0aO p98w== X-Gm-Message-State: AOAM5334F1Dpe2VF9/ycv9Ssc1OnQsQWwYStF2Oz8hV2dPuLc/jVJY2U syivfm+zNI32uCFCnVNzLzT3AW7eKNpUnw== X-Google-Smtp-Source: ABdhPJy28xAvs15own4TeT3yS6MWEeDQ2+8d41rLERv9qS9+5H1xvCvwiWR8DfLNNk5lpBL3iPxIyA== X-Received: by 2002:a50:d0db:0:b0:413:4475:ac5d with SMTP id g27-20020a50d0db000000b004134475ac5dmr22938285edf.76.1646122401492; Tue, 01 Mar 2022 00:13:21 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id d6-20020a056402144600b00412a7d10c20sm6760694edx.60.2022.03.01.00.13.21 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Mar 2022 00:13:21 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek Subject: [PATCH] microblaze: Do not place u-boot to reserved memory location Date: Tue, 1 Mar 2022 09:13:20 +0100 Message-Id: X-Mailer: git-send-email 2.35.1 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 Microblaze can also have reserved space in DT which u-boot has to avoid to placing self to that location. The same change was done in Zynqmp by commit ce39ee28ec31 ("zynqmp: Do not place u-boot to reserved memory location"). This feature was tested with this memory description on kc705: memory { device_type = "memory"; reg = <0x80000000 0x40000000>; }; reserved-memory { #address-cells = <1>; #size-cells = <1>; ranges; alloc@b00000000 { reg = <0xb0000000 0x10000000>; no-map; }; alloc@a8000000 { reg = <0xa8000000 0x00010000>; no-map; }; }; And in U-Boot log you can check u-boot relocation address and reserved locations. U-Boot 2022.01-03974-gb1b4c2dea9b9 (Feb 25 2022 - 11:59:48 +0100) Model: Xilinx MicroBlaze DRAM: 1 GiB Flash: 128 MiB Loading Environment from nowhere... OK In: serial Out: serial Err: serial Model: Xilinx MicroBlaze Net: AXI EMAC: 40c00000, phyaddr 7, interface gmii eth0: ethernet@40c00000 U-BOOT for microblaze-generic U-Boot-mONStR> bdi ... DRAM bank = 0x00000000 -> start = 0x80000000 -> size = 0x40000000 ... relocaddr = 0xaff69000 ... lmb_dump_all: memory.cnt = 0x1 memory[0] [0x80000000-0xbfffffff], 0x40000000 bytes flags: 0 reserved.cnt = 0x3 reserved[0] [0xa8000000-0xa800ffff], 0x00010000 bytes flags: 4 reserved[1] [0xafe87bb0-0xafffffff], 0x00178450 bytes flags: 0 reserved[2] [0xb0000000-0xbfffffff], 0x10000000 bytes flags: 4 Signed-off-by: Michal Simek --- arch/microblaze/include/asm/system.h | 2 ++ .../microblaze-generic/microblaze-generic.c | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/microblaze/include/asm/system.h b/arch/microblaze/include/asm/system.h index 3107748d3bdb..050a8b407636 100644 --- a/arch/microblaze/include/asm/system.h +++ b/arch/microblaze/include/asm/system.h @@ -23,6 +23,8 @@ #endif #include +#define MMU_SECTION_SIZE (1 * 1024 * 1024) + #define prepare_to_switch() do { } while (0) /* diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c index a427ac94a170..f58ecd1590c9 100644 --- a/board/xilinx/microblaze-generic/microblaze-generic.c +++ b/board/xilinx/microblaze-generic/microblaze-generic.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -36,6 +38,25 @@ int dram_init(void) return 0; }; +ulong board_get_usable_ram_top(ulong total_size) +{ + phys_size_t size; + phys_addr_t reg; + struct lmb lmb; + + /* found enough not-reserved memory to relocated U-Boot */ + lmb_init(&lmb); + lmb_add(&lmb, gd->ram_base, gd->ram_size); + boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); + size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); + reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); + + if (!reg) + reg = gd->ram_top - size; + + return reg + size; +} + int board_late_init(void) { ulong max_size;