From patchwork Tue Feb 25 05:10:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 1243844 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=V/ctkZSh; dkim-atps=neutral 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 (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48RRpq4bS9z9sPK for ; Tue, 25 Feb 2020 16:10:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 09D4481281; Tue, 25 Feb 2020 06:10:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.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=amarulasolutions.com header.i=@amarulasolutions.com header.b="V/ctkZSh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 342B181295; Tue, 25 Feb 2020 06:10:33 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 4174E80E7C for ; Tue, 25 Feb 2020 06:10:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-wm1-x343.google.com with SMTP id i10so248239wmd.1 for ; Mon, 24 Feb 2020 21:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zvflET1mETmYbMke6Gali60cgIN4H0u6ca6uNN+2P+4=; b=V/ctkZShwW8Fp1HUfszK8OYvdasYxMej0lqSxuVFC6+sQN+aJ+tbPcVEA92yl517Ib f/LYD8MfnAlbF1Y7s33wdJdQANpEEIlzaXIzARPZKvnQ906jWM/eZAERdqukyCsAlxXf 5WqTFb/PqJRkXHbFtLnwLg7bSUg+iotUlbkHE= 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; bh=zvflET1mETmYbMke6Gali60cgIN4H0u6ca6uNN+2P+4=; b=GH0+xxElp9Xq59p/ObkmkATlLX+WYYeSQVyqi+fNpi5Ep/L0l0wgPv614q+8GGs/2T L/Dae5QJOocN7ylXQMh9TsTCfPbShb8RRdmePqP1z8Kuw8MeBThpwwMYmyJTx6s3wEbn bdZnbnjgXGSvJLJm6s7PyYOm8hys1sPclVaVixPZl+L+V/BgRKtmd9nvFqZTaLzMO6LP mcYPLcmM0z4xiNf5PgEhUOv5AguiYxAHcTBpsj4o2kwngz+ls5UzGOMYKuxn2WnnIzTo /Uyk6ye3Tc/djGXoImWDp/7sY+eRXaWUxArlVeT53ME4mfVOwhKbjdKrZPVoBdTUHAiK b2qQ== X-Gm-Message-State: APjAAAWWX5C4AwmnAFRZFFc0yGHcFYoOMpSnGuupvOGiFYok43sOijPO Ypu0+yd2V/q/vGtt7Omdtd13uA== X-Google-Smtp-Source: APXvYqzM5cse//Pciaz6tuTTJQQeMET/JCm1zHiQcqBPmBdB1m0Mmh33b/GHHbmyoibmUKOyaW7m9g== X-Received: by 2002:a05:600c:2944:: with SMTP id n4mr2925371wmd.22.1582607424681; Mon, 24 Feb 2020 21:10:24 -0800 (PST) Received: from localhost.localdomain (static-187-95-145-212.ipcom.comunitel.net. [212.145.95.187]) by smtp.gmail.com with ESMTPSA id y8sm2450690wma.10.2020.02.24.21.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 21:10:24 -0800 (PST) From: Michael Trimarchi To: Simon Glass , Anatolij Gustschin , Neil Armstrong Cc: u-boot@lists.denx.de, u-boot-amlogic@groups.io Subject: [PATCH 1/2] common: fdt: Add a function for reserving memory without kernel linear mapping Date: Tue, 25 Feb 2020 06:10:20 +0100 Message-Id: <20200225051021.15311-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200225051021.15311-1-michael@amarulasolutions.com> References: <20200225051021.15311-1-michael@amarulasolutions.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean The intent is to reserve memory _and_ prevent it from being included in the kernel's linear map. For thos reason it is also necessary to include the 'no-map' property for this reserved-mem node. From Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt: no-map (optional) - empty property - Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region. Signed-off-by: Michael Trimarchi --- Changes: RFC->v1 - Add a better commit message --- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 11 +++++++++++ 2 files changed, 51 insertions(+) diff --git a/common/fdt_support.c b/common/fdt_support.c index 02cf5c6241..a3662f4358 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, return p - (char *)buf; } +int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 size[]) +{ + int offs, len; + const char *subpath; + const char *path = "/reserved-memory"; + fdt32_t address_cells = cpu_to_fdt32(fdt_address_cells(blob, 0)); + fdt32_t size_cells = cpu_to_fdt32(fdt_size_cells(blob, 0)); + u8 temp[16]; /* Up to 64-bit address + 64-bit size */ + + offs = fdt_path_offset(blob, path); + if (offs < 0) { + debug("Node %s not found\n", path); + path = "/"; + subpath = "reserved-memory"; + offs = fdt_path_offset(blob, path); + offs = fdt_add_subnode(blob, offs, subpath); + if (offs < 0) { + printf("Could not create %s%s node.\n", path, subpath); + return -1; + } + path = "/reserved-memory"; + offs = fdt_path_offset(blob, path); + + fdt_setprop(blob, offs, "#address-cells", &address_cells, sizeof(address_cells)); + fdt_setprop(blob, offs, "#size-cells", &size_cells, sizeof(size_cells)); + fdt_setprop(blob, offs, "ranges", NULL, 0); + } + + offs = fdt_add_subnode(blob, offs, area ? : "private"); + if (offs < 0) { + printf("Could not create %s%s node.\n", path, subpath); + return -1; + } + + fdt_setprop(blob, offs, "no-map", NULL, 0); + len = fdt_pack_reg(blob, temp, start, size, 1); + fdt_setprop(blob, offs, "reg", temp, len); + return 0; +} + #if CONFIG_NR_DRAM_BANKS > 4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS #else diff --git a/include/fdt_support.h b/include/fdt_support.h index ba14acd7f6..7c8a280f53 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat, */ int fdt_fixup_memory(void *blob, u64 start, u64 size); +/** + * Setup the memory reserved node in the DT. Creates one if none was existing before. + * + * @param blob FDT blob to update + * @param area Reserved area name + * @param start Begin of DRAM mapping in physical memory + * @param size Size of the single memory bank + * @return 0 if ok, or -1 or -FDT_ERR_... on error + */ +int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 size[]); + /** * Fill the DT memory node with multiple memory banks. * Creates the node if none was existing before. From patchwork Tue Feb 25 05:10:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 1243845 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=GaCY98YA; dkim-atps=neutral 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 (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48RRq16CCcz9sPK for ; Tue, 25 Feb 2020 16:11:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B96FB812A1; Tue, 25 Feb 2020 06:10:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.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=amarulasolutions.com header.i=@amarulasolutions.com header.b="GaCY98YA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9AFBA80E7C; Tue, 25 Feb 2020 06:10:34 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 5D638811FC for ; Tue, 25 Feb 2020 06:10:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-wr1-x442.google.com with SMTP id m16so13036646wrx.11 for ; Mon, 24 Feb 2020 21:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qquyljQ4ZPf+qj0RAerkiHXg0k3ZWtO3CZwbda5Dpnw=; b=GaCY98YA+O1d/SiiQGG/jv/yLaxenFbSPuaBZQDY4dPVBHVKNjtgMhXy9b1JWNMrRr 6f309/Ds0XDMfg2Om0WlERsHBNu+OzPYgFfuRZSQmibTAP53hhFS58pYDU6JP5czCkgD iQ4vHnyb4fzHzTK5NlXpA09WpIF45yNjT7cKM= 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; bh=qquyljQ4ZPf+qj0RAerkiHXg0k3ZWtO3CZwbda5Dpnw=; b=cVUdl+Z+uW63kHNtrwm8MaYsgVoCh8cxxCWMATsI1VTNKXkb0a35BXFG6Ro7mHhCPO P8+TT4HU8Aq50kUySPsw502/J8+SVANCRcZLIgxhS5bgDFpWjHLzIkP2FHOM8XOZR66l 9soNA+s/rrGm2K+GSIGlzDBiEgmgzonK5eEjip9x/t9xTK4N9YQwFh5vGWH2dx5hVY8Z D0oK2pyaZVXI23PNBxLT/3/6EDeZJIJQAaGDaiBHdd0v3KNVoj39OgzZyHwyH3EB8q81 g3dbNRK7SBguxDKQfA8HydClK+qQfc+1CAPH/e8NPbbeQsiANp1kCes4jeKQ0nj9t3pC 4Xlg== X-Gm-Message-State: APjAAAUgI08HS3MP5OFv06hFf0aFCfo9IH+iev4ZiqHmElWRE6TkcgMT nz6azJflbFrDVlKMZwWqTurqag== X-Google-Smtp-Source: APXvYqzwIolpZ5PyYcHHLu589MCvkdkQ8hKbPZ8nzY6o7YdQg2MUQXuMR9NKARA+prTifo8MXeNA4Q== X-Received: by 2002:a5d:504e:: with SMTP id h14mr12185880wrt.82.1582607425823; Mon, 24 Feb 2020 21:10:25 -0800 (PST) Received: from localhost.localdomain (static-187-95-145-212.ipcom.comunitel.net. [212.145.95.187]) by smtp.gmail.com with ESMTPSA id y8sm2450690wma.10.2020.02.24.21.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 21:10:25 -0800 (PST) From: Michael Trimarchi To: Simon Glass , Anatolij Gustschin , Neil Armstrong Cc: u-boot@lists.denx.de, u-boot-amlogic@groups.io Subject: [PATCH 2/2] video: meson: Use reserving memory function without kernel linear mapping Date: Tue, 25 Feb 2020 06:10:21 +0100 Message-Id: <20200225051021.15311-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200225051021.15311-1-michael@amarulasolutions.com> References: <20200225051021.15311-1-michael@amarulasolutions.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Memory reserved for the simple framebuffer should not be used and part of memory linear mapping. See https://patchwork.kernel.org/patch/10486131/ for more detailed background information and discussion. Signed-off-by: Michael Trimarchi --- Changes RFC -> v1: - Fix compilation issue on RFC - change node name from display_reserved to display-reserved --- drivers/video/meson/meson_vpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c index 4eb66398d0..5bfad05d75 100644 --- a/drivers/video/meson/meson_vpu.c +++ b/drivers/video/meson/meson_vpu.c @@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt) * at the end of the RAM and we strip this portion from the kernel * allowed region */ - mem_start = gd->bd->bi_dram[0].start; - mem_size = gd->bd->bi_dram[0].size - meson_fb.fb_size; - ret = fdt_fixup_memory_banks(fdt, &mem_start, &mem_size, 1); + mem_start = meson_fb.base; + mem_size = meson_fb.fb_size; + ret = fdt_fixup_reserved_memory(fdt, "display-reserved", &mem_start, &mem_size); if (ret) { eprintf("Cannot setup simplefb: Error reserving memory\n"); return;