From patchwork Thu Mar 21 18:10:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1060363 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lBUDny/o"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44QFM85rnFz9sQt for ; Fri, 22 Mar 2019 05:15:16 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 56C84C220D4; Thu, 21 Mar 2019 18:12:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EBFC6C220CA; Thu, 21 Mar 2019 18:12:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E8005C220CC; Thu, 21 Mar 2019 18:10:34 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 1BBE6C2203D for ; Thu, 21 Mar 2019 18:10:34 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id w2so7644680wrt.11 for ; Thu, 21 Mar 2019 11:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NosESdroXXiFSsZ9LsiwFs7mCMly2vKtrgq2iPhd6kk=; b=lBUDny/oDgWROrk62JnBzjFGKx9wwCv3DvGnGWKZs8m8ZJYvAMD3GchJsCS1lHeXZo /sqDp9Zxdiq0rgdsUhzifjXzCY18ii4D6nbmtgfIlRIGC0VM9hF216RswQtuafVZnCF1 KgTUXauaRHW+/CwceDHKJlPchh3iBprj9gXHgDB/Z2DTciY/jVlPbfmTDOEZzJE0oq9D PpRt/ApXLRrJb6cKzFOcLd5nqZ+HrxbyrxN/0j5ELYS7GGK3OEvzsOP7oYfjBcXUYzKk VojxhoMOdEP9JF660HZbC2SWcYf4bCIWzB5bMCFN1pGdtPObqTNJ4LX6+U+f0AMnvGs/ pguw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NosESdroXXiFSsZ9LsiwFs7mCMly2vKtrgq2iPhd6kk=; b=cCdGVhUU3WmuHl/cQV7McbCBgcfGLNh7Nu46AWmPKgBm9Z+3yc0KBxW4DFYia0I2yw o2ZWyejQeUcGmDAw7a6u1dbcPKK4rXteIEXk0uMzw4BIbqBJpvV5cw+5eZf0ZMdJsBWL UowFRigN3bWqtjqhsnbw5/UFCMfP3pM3d62HUq+dqweX05Y1OQnYJMHUcpicBIEPDm2/ b2gObGSF9g8Grw0y9/fhbCowxPHvM2ed9Mx4rqdwBkCj6cs6xBMkC9P9m3it4ca+22Tb oqycPSlH6OD0ZPV1Os1mO/qKLGapRlU+k9DUfQaCW+T/x7VwPIv1orbShHczgmnXhKUU c9SQ== X-Gm-Message-State: APjAAAViMJ/iL7YV5yeOixuy/GZ7qj3NKUSkPW8Z7V2JVnxagRC9vM4C ZCsOLQApvoqKJXOa1fM7dQ0= X-Google-Smtp-Source: APXvYqwOFCAmtAey29mGihfxPlhouOHN5cDZr+k6Ujhzsi7K4OhpZCCBcRHiyuPWVbjG4sE3mycrpQ== X-Received: by 2002:adf:fb82:: with SMTP id a2mr3411226wrr.214.1553191833667; Thu, 21 Mar 2019 11:10:33 -0700 (PDT) Received: from localhost (pD9E51D2D.dip0.t-ipconnect.de. [217.229.29.45]) by smtp.gmail.com with ESMTPSA id t69sm9565376wmt.16.2019.03.21.11.10.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 11:10:33 -0700 (PDT) From: Thierry Reding To: Tom Warren , Simon Glass Date: Thu, 21 Mar 2019 19:10:10 +0100 Message-Id: <20190321181010.27005-14-thierry.reding@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190321181010.27005-1-thierry.reding@gmail.com> References: <20190321181010.27005-1-thierry.reding@gmail.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, Stephen Warren Subject: [U-Boot] [PATCH v3 13/13] p2771-0000: Add support for framebuffer carveouts X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Thierry Reding If early firmware initialized the display hardware and the display controllers are scanning out a framebuffer (e.g. a splash screen), make sure to pass information about the memory location of that framebuffer to the kernel before booting to avoid the kernel from using that memory for the buddy allocator. This same mechanism can also be used in the kernel to set up early SMMU mappings and avoid SMMU faults caused by the display controller reading from memory for which it has no mapping. Signed-off-by: Thierry Reding Reviewed-by: Simon Glass --- board/nvidia/p2771-0000/p2771-0000.c | 66 ++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c index fe22067f6571..d294c7ae0136 100644 --- a/board/nvidia/p2771-0000/p2771-0000.c +++ b/board/nvidia/p2771-0000/p2771-0000.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -56,7 +57,7 @@ int tegra_pcie_board_init(void) } #endif -int ft_board_setup(void *fdt, bd_t *bd) +static void ft_mac_address_setup(void *fdt) { const void *cboot_fdt = (const void *)cboot_boot_x0; uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN]; @@ -69,13 +70,15 @@ int ft_board_setup(void *fdt, bd_t *bd) path = fdt_get_alias(fdt, "ethernet"); if (!path) - return 0; + return; debug("ethernet alias found: %s\n", path); offset = fdt_path_offset(fdt, path); - if (offset < 0) - return 0; + if (offset < 0) { + printf("ethernet alias points to absent node %s\n", path); + return; + } if (is_valid_ethaddr(local_mac)) { err = fdt_setprop(fdt, offset, "local-mac-address", local_mac, @@ -92,6 +95,61 @@ int ft_board_setup(void *fdt, bd_t *bd) debug("MAC address set: %pM\n", mac); } } +} + +static int ft_copy_carveout(void *dst, const void *src, const char *node) +{ + struct fdt_memory fb; + int err; + + err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb); + if (err < 0) { + if (err != -FDT_ERR_NOTFOUND) + printf("failed to get carveout for %s: %d\n", node, + err); + + return err; + } + + err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer", + &fb); + if (err < 0) { + printf("failed to set carveout for %s: %d\n", node, err); + return err; + } + + return 0; +} + +static void ft_carveout_setup(void *fdt) +{ + const void *cboot_fdt = (const void *)cboot_boot_x0; + static const char * const nodes[] = { + "/host1x@13e00000/display-hub@15200000/display@15200000", + "/host1x@13e00000/display-hub@15200000/display@15210000", + "/host1x@13e00000/display-hub@15200000/display@15220000", + }; + unsigned int i; + int err; + + for (i = 0; i < ARRAY_SIZE(nodes); i++) { + printf("copying carveout for %s...\n", nodes[i]); + + err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]); + if (err < 0) { + if (err != -FDT_ERR_NOTFOUND) + printf("failed to copy carveout for %s: %d\n", + nodes[i], err); + + continue; + } + } +} + +int ft_board_setup(void *fdt, bd_t *bd) +{ + ft_mac_address_setup(fdt); + ft_carveout_setup(fdt); return 0; }