From patchwork Tue Oct 29 07:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 839319 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp222474wrb; Tue, 29 Oct 2024 00:19:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU842XnfDx6xdFYfhx1m29CoMRhI8ATmZj1pUKC4jwen0YkBQN2W0E198INt6b9CkKv1wrKSQ==@linaro.org X-Google-Smtp-Source: AGHT+IGqm3iMjWYkk91QDdOYWKlbXVNy6IvfeaLFP6o2nHVAPDQZOEcDoykHILohj6ovyeKbEz9C X-Received: by 2002:adf:ec86:0:b0:37d:525d:5a60 with SMTP id ffacd0b85a97d-380610f2554mr7377413f8f.8.1730186351869; Tue, 29 Oct 2024 00:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730186351; cv=none; d=google.com; s=arc-20240605; b=jtaSow6yyPAeg9xGK8eyG+kmOGQ70cVXrILtrlHg0qlaKc6BCrXAU5SY85fS+xuyZl 4KeJ33jm7JRbMUtHw/QJj5y9NU41LP3GJVRww0bYGMh2dRbGZIxCnxZk8wtPL2Novp7H eq+/e6uNLpHOLfJPi3Gb3l1oJoDQKMz6K1beAjiEJadADKIPqos066TG750Z7WYCM/Oa 0RC6O3vig1lTkhMqwoh0ETWnl/OxSB0ae2ijkSk0JGQWAMjsyOooQhv0OiVWshvH6uzQ iN1EcroxA53zDeXstnQ1B7u4ya9I7ijhmHDTy5TPth8mW8VTCozszM/on3CH94sSkOll Xrsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=re7si9BmclmuX22e5gqqsb3FpDrYH2sj6rQueCTXyMs=; fh=OxxVRYIH4L4eYe/dMxxa1SHIXOF10gIqAtiKzoQmGVc=; b=Y8qfBex9QNZ9aH9TT6/qNHe7U+h3LeByKKTiEAdxer506XgE4c9ryLGwmWdx6yIZCk 28cn3QTV7T+dbM4T9dApnwHRoJpQJ5bjjs6MHpk1SFpGOupizJapebqE5jKgYSKhB9XS 7KBfUSq6YUmhsmfRZrnK9CrHal4T6RqrJLdBkkhtixYCj33LtiMex4qcQAHR0uRZ4Yd9 9Jwcu0Cf+mqop0ypD5v0ErpaLNfs4VqsDZ78kHh5Wb2n5HS5W1JTcfQaPNChRkLbG0ao tUXPmUhn8vTDW2CGvazmiq/SVfRhjCgjp4ESz3E14hzI1+Bv2jY/bTJTf+UrptQZEMSc j4XQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-38058988d8bsi5233773f8f.0.2024.10.29.00.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D8DC8910C; Tue, 29 Oct 2024 08:19:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 83B378915B; Tue, 29 Oct 2024 08:19:04 +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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 626768914D for ; Tue, 29 Oct 2024 08:19:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EF9113D5; Tue, 29 Oct 2024 00:19:30 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACD783F66E; Tue, 29 Oct 2024 00:18:58 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Janne Grunau , Mark Kettenis , Tom Rini , Sughosh Ganu Subject: [RFC PATCH 1/2] lmb: refactor lmb push and pop functions Date: Tue, 29 Oct 2024 12:48:45 +0530 Message-Id: <20241029071846.514559-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029071846.514559-1-sughosh.ganu@linaro.org> References: <20241029071846.514559-1-sughosh.ganu@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean The LMB module uses a separate instance of the lmb structure when running tests. Setting up the correct instance is done using the lmb_push() and lmb_pop() functions. In addition to pushing and popping the lmb instances, these functions are also doing some test specific operations. Move these operations to lmb_test_push() and lmb_test_pop() functions, so that lmb_push() and lmb_pop() can be called from elsewhere. Signed-off-by: Sughosh Ganu --- include/lmb.h | 4 +++- lib/lmb.c | 20 ++++++++++++++++---- test/lib/lmb.c | 18 +++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index e46abf400c6..72d7093023a 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -171,8 +171,10 @@ void lmb_dump_all_force(void); void lmb_arch_add_memory(void); struct lmb *lmb_get(void); -int lmb_push(struct lmb *store); +void lmb_push(struct lmb *store); void lmb_pop(struct lmb *store); +int lmb_test_push(struct lmb *store); +void lmb_test_pop(struct lmb *store); static inline int lmb_read_check(phys_addr_t addr, phys_size_t len) { diff --git a/lib/lmb.c b/lib/lmb.c index eec99c185ee..2960c05abfc 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -892,12 +892,23 @@ struct lmb *lmb_get(void) return &lmb; } +void lmb_push(struct lmb *store) +{ + *store = lmb; +} + +void lmb_pop(struct lmb *store) +{ + lmb = *store; +} + #if CONFIG_IS_ENABLED(UNIT_TEST) -int lmb_push(struct lmb *store) +int lmb_test_push(struct lmb *store) { int ret; - *store = lmb; + lmb_push(store); + ret = lmb_setup(true); if (ret) return ret; @@ -905,10 +916,11 @@ int lmb_push(struct lmb *store) return 0; } -void lmb_pop(struct lmb *store) +void lmb_test_pop(struct lmb *store) { alist_uninit(&lmb.free_mem); alist_uninit(&lmb.used_mem); - lmb = *store; + + lmb_pop(store); } #endif /* UNIT_TEST */ diff --git a/test/lib/lmb.c b/test/lib/lmb.c index b2c54fb4bcb..64e619eff22 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -63,7 +63,7 @@ static int setup_lmb_test(struct unit_test_state *uts, struct lmb *store, { struct lmb *lmb; - ut_assertok(lmb_push(store)); + ut_assertok(lmb_test_push(store)); lmb = lmb_get(); *mem_lstp = &lmb->free_mem; *used_lstp = &lmb->used_mem; @@ -194,7 +194,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ut_asserteq(mem[0].size, ram_size); } - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -293,7 +293,7 @@ static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram) ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, alloc_64k_addr, 0x10000, 0, 0, 0, 0); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -373,7 +373,7 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram, ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -446,7 +446,7 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts) ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -499,7 +499,7 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40000000, 0x40000, 0, 0, 0, 0); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -619,7 +619,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ut_asserteq(ret, 0); } - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -691,7 +691,7 @@ static int test_get_unreserved_size(struct unit_test_state *uts, s = lmb_get_free_size(ram_end - 4); ut_asserteq(s, 4); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } @@ -797,7 +797,7 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) ut_asserteq(lmb_is_nomap(&used[1]), 0); ut_asserteq(lmb_is_nomap(&used[2]), 1); - lmb_pop(&store); + lmb_test_pop(&store); return 0; } From patchwork Tue Oct 29 07:18:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 839320 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp222526wrb; Tue, 29 Oct 2024 00:19:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9j3A+faBRSi917J1DRfQqzPB6lVjUFEnJ1E/lWrN7+61Jc/peASAzs3cIEefXbdcv114xSg==@linaro.org X-Google-Smtp-Source: AGHT+IGkR4hsg1kawKZYWnDhYTAq891Sk2MsMsaz2lRvAML+K9PuUpSAVSvGowk2xnfaN+w9ZIDg X-Received: by 2002:adf:f884:0:b0:37c:d1ea:f1ce with SMTP id ffacd0b85a97d-380611a46famr9483202f8f.25.1730186360886; Tue, 29 Oct 2024 00:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730186360; cv=none; d=google.com; s=arc-20240605; b=DOMylC5WysW249/RHI3UFyr01fpFVl0MaVm2Xc6g14pognFOu8VhH31g2JzanylWAV WtxK7jQ2KOgNVJvL44yvp3ud1CJt93YTWd0Jj7tIL8aUMUXzuECDbpxLpypbTaU3dpvH 3mxGjC1UFLEkVTRTWUfYETJL/XlgJqS5qiJphYwOvkLOpsRh//YRS3WO1myxjzG2BQ1O ZuAqV2gjWzdO1yVUfzQMVXkPJhScsGu/YHL24sMiY2UXsqqlejhjfxl6P1nFJtRBNDts yaN/3kuJBr7gcRgQdgWiaK/Ar5a29GKyz6SRHKn7FB50PCJld3qzWXCHJHLrNbsywDV1 wL8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=MtS1eBlqP9ZMJIOShTZ5IYNlqokh7rd4b58LitH7w2Y=; fh=OxxVRYIH4L4eYe/dMxxa1SHIXOF10gIqAtiKzoQmGVc=; b=FLjUgHQtKjzMMdlky4aCWshaTri5q4G3yfMgMRyuMURdASwJpDWXzAzBXVqmbV0YCy 9Ssq5lIiVPBwd/IzAa9eY2hzzgome/Uof5fnQ5nlKboFE7BXDeUfSUwFC1JzPkjpcEZX hVSNrzqIyYyW1vhYBV+uyk80IKybHXo5mbxOc9BgldmeGm7Xr9GaaIdYgM+rdSaaJqU+ V0aWEm38fu4lWy++luiHtIzGJcodeMnIuQMCk2z05zOGtKrfgRHRDM/g5sPZ0+Ca7iQl cWl9Ik8Sj9PLUo/KAsiTUhvpueJkxoXmMf1+0tlFpWCIQIcPGBvRSEWTt+lKHMxAkerD QgsQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-43193594adesi56840245e9.83.2024.10.29.00.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B65A889182; Tue, 29 Oct 2024 08:19:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B40B08910C; Tue, 29 Oct 2024 08:19:05 +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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 83302890D1 for ; Tue, 29 Oct 2024 08:19:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B8F6513D5; Tue, 29 Oct 2024 00:19:32 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 22E103F66E; Tue, 29 Oct 2024 00:19:00 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Janne Grunau , Mark Kettenis , Tom Rini , Sughosh Ganu Subject: [RFC PATCH 2/2] apple: dart: use driver specific instance of LMB Date: Tue, 29 Oct 2024 12:48:46 +0530 Message-Id: <20241029071846.514559-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029071846.514559-1-sughosh.ganu@linaro.org> References: <20241029071846.514559-1-sughosh.ganu@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean The LMB module is typically used for managing the platform's RAM memory. RAM memory gets added to the module's memory map, and subsequently allocated through various LMB API's. The IOMMU driver for the apple platforms also uses the LMB API's for allocating device virtual addresses(VA). These addresses are different from the RAM addresses, and cannot be added to the RAM memory map. Add a separate instance of LMB memory map for the device VA's, which gets managed by the IOMMU driver. Use lmb_push() and lmb_pop() functions to set-up the relevant lmb instance. Signed-off-by: Sughosh Ganu --- drivers/iommu/apple_dart.c | 67 +++++++++++++++++++++++++++++++++++++- include/lmb.h | 2 ++ lib/lmb.c | 1 - 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/apple_dart.c b/drivers/iommu/apple_dart.c index 611ac7cd6de..55f60287b0e 100644 --- a/drivers/iommu/apple_dart.c +++ b/drivers/iommu/apple_dart.c @@ -3,6 +3,7 @@ * Copyright (C) 2021 Mark Kettenis */ +#include #include #include #include @@ -70,6 +71,8 @@ struct apple_dart_priv { void *base; + struct lmb apple_dart_lmb; + struct lmb ram_lmb; u64 *l1, *l2; int bypass, shift; @@ -87,6 +90,56 @@ struct apple_dart_priv { void (*flush_tlb)(struct apple_dart_priv *priv); }; +static int apple_dart_lmb_init(struct apple_dart_priv *priv) +{ + bool ret; + struct lmb *almb = &priv->apple_dart_lmb; + + ret = alist_init(&almb->free_mem, sizeof(struct lmb_region), + (uint)LMB_ALIST_INITIAL_SIZE); + if (!ret) { + log_debug("Unable to initialise the list for LMB free memory\n"); + return -ENOMEM; + } + + ret = alist_init(&almb->used_mem, sizeof(struct lmb_region), + (uint)LMB_ALIST_INITIAL_SIZE); + if (!ret) { + log_debug("Unable to initialise the list for LMB used memory\n"); + return -ENOMEM; + } + + return 0; +} + +static void apple_dart_lmb_uninit(struct apple_dart_priv *priv) +{ + struct lmb *almb = &priv->apple_dart_lmb; + + alist_uninit(&almb->free_mem); + alist_uninit(&almb->used_mem); +} + +static void apple_dart_lmb_setup(struct apple_dart_priv *priv) +{ + struct lmb *almb = &priv->apple_dart_lmb; + struct lmb *rlmb = &priv->ram_lmb; + + lmb_push(rlmb); + + lmb_pop(almb); +} + +static void apple_dart_lmb_pop(struct apple_dart_priv *priv) +{ + struct lmb *almb = &priv->apple_dart_lmb; + struct lmb *rlmb = &priv->ram_lmb; + + lmb_push(almb); + + lmb_pop(rlmb); +} + static void apple_dart_t8020_flush_tlb(struct apple_dart_priv *priv) { dsb(); @@ -123,7 +176,9 @@ static dma_addr_t apple_dart_map(struct udevice *dev, void *addr, size_t size) off = (phys_addr_t)addr - paddr; psize = ALIGN(size + off, DART_PAGE_SIZE); + apple_dart_lmb_setup(priv); dva = lmb_alloc(psize, DART_PAGE_SIZE); + apple_dart_lmb_pop(priv); idx = dva / DART_PAGE_SIZE; for (i = 0; i < psize / DART_PAGE_SIZE; i++) { @@ -159,7 +214,9 @@ static void apple_dart_unmap(struct udevice *dev, dma_addr_t addr, size_t size) (unsigned long)&priv->l2[idx + i]); priv->flush_tlb(priv); + apple_dart_lmb_setup(priv); lmb_free(dva, psize); + apple_dart_lmb_pop(priv); } static struct iommu_ops apple_dart_ops = { @@ -173,7 +230,7 @@ static int apple_dart_probe(struct udevice *dev) dma_addr_t addr; phys_addr_t l2; int ntte, nl1, nl2; - int sid, i; + int sid, i, ret; u32 params2, params4; priv->base = dev_read_addr_ptr(dev); @@ -212,7 +269,13 @@ static int apple_dart_probe(struct udevice *dev) priv->dvabase = DART_PAGE_SIZE; priv->dvaend = SZ_4G - DART_PAGE_SIZE; + ret = apple_dart_lmb_init(priv); + if (ret) + return ret; + + apple_dart_lmb_setup(priv); lmb_add(priv->dvabase, priv->dvaend - priv->dvabase); + apple_dart_lmb_pop(priv); /* Disable translations. */ for (sid = 0; sid < priv->nsid; sid++) @@ -294,6 +357,8 @@ static int apple_dart_remove(struct udevice *dev) } priv->flush_tlb(priv); + apple_dart_lmb_uninit(priv); + return 0; } diff --git a/include/lmb.h b/include/lmb.h index 72d7093023a..a39b48a9a97 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -14,6 +14,8 @@ * Copyright (C) 2001 Peter Bergner, IBM Corp. */ +#define LMB_ALIST_INITIAL_SIZE 4 + /** * enum lmb_flags - definition of memory region attributes * @LMB_NONE: no special request diff --git a/lib/lmb.c b/lib/lmb.c index 2960c05abfc..959236f6e5a 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -28,7 +28,6 @@ DECLARE_GLOBAL_DATA_PTR; #define MAP_OP_ADD (u8)0x3 #define LMB_ALLOC_ANYWHERE 0 -#define LMB_ALIST_INITIAL_SIZE 4 static struct lmb lmb;