From patchwork Fri Jun 9 06:55:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Brown X-Patchwork-Id: 773684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wkY4S3g4nz9s8F for ; Fri, 9 Jun 2017 16:56:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dEyQfIGk"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wkY4S2NFRzDqLf for ; Fri, 9 Jun 2017 16:56:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dEyQfIGk"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wkY3y6DC9zDqN2 for ; Fri, 9 Jun 2017 16:56:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dEyQfIGk"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id u1so7672655pfg.1 for ; Thu, 08 Jun 2017 23:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=heRylOtp2fCDSq0clwCj74VyO/EKzrML+PF4AQmE79g=; b=dEyQfIGkWWwmA+OJz+NlqcxIUgZVV7AjEEo8XUh7o1JpbuWPoFcIRaDJdhpUm8gX1v 5GPKfMIj6wg0pFCjTw6176sjDlylzr10cDGbiCSPrh17sWZZHxnHXDPXbC03CDCoAp8q M7USJAhjBExodA0lIUQP0ORJRuEfYXRANjhVir9LGg+iTwE4W2uyT5kJCncdp3l5jU/B MUXsvQuH57vMsZFwX/aYppX5zX6XDSvhhR4rx9/VFEPSlvHTvG2SVHihjKW8O722hjyU d2nSghBcfoeqeM4h2RWJYamsQq8M7pwhC2z4YLpom95CZIAB41w1c0OD1tkxQNjX7R29 K7CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=heRylOtp2fCDSq0clwCj74VyO/EKzrML+PF4AQmE79g=; b=aGX3a8DeZrB1cGOsOsmisHcAXoUpPmOXkcmCK5eV3Rb5/uEIsLxGJE9/cm/amDi/y8 Z4S818+wrzIynGie5rfYO+dEDWJ7hpDeF9SC8H0GFIAkmqBudCn4VDyFEXab6MWPxCxR aO/R8wtj2WoDjUnjEnqRfCZl+1BU/7exr8zw4902vXtUWFJ8GquwH8YjbjI+AHwK6Wz6 lfDG/wihRGGKhxc1R5uAuPY48E7PyVy07OfXWhE0fETxE6QD8+vmLHs56r2Bu3QkjZdF wQF+M+vaC2Bqy9UlqSkfVHkE8dt0cgI5gWxhR3/li404M3T94gXvDI2u6IDrnkRnCbDh 4AuQ== X-Gm-Message-State: AODbwcBcKnAKSy4Yqqfzyvp0ArEh2keyyfUsmf8995i8dfAA9LrxQ9L0 7OG1BpSHm+HC88Xw X-Received: by 10.84.233.198 with SMTP id m6mr38470686pln.292.1496991388506; Thu, 08 Jun 2017 23:56:28 -0700 (PDT) Received: from matt.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 81sm653535pge.46.2017.06.08.23.56.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 23:56:28 -0700 (PDT) From: Matt Brown To: skiboot@lists.ozlabs.org Date: Fri, 9 Jun 2017 16:55:39 +1000 Message-Id: <20170609065546.28963-3-matthew.brown.dev@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170609065546.28963-1-matthew.brown.dev@gmail.com> References: <20170609065546.28963-1-matthew.brown.dev@gmail.com> Subject: [Skiboot] [PATCH 03/10] core/device: Allow for large DT props X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" As the skiboot heap is only 16MB, we cannot allocate large amounts of memory using malloc. By using local_alloc we can allocate beyond the skiboot heap. This is useful for allocating large DT properties. Any DT properties with size > 1MB will now be allocated using local_alloc instead of malloc. Signed-off-by: Matt Brown --- core/device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/device.c b/core/device.c index 76c2f84..869deae 100644 --- a/core/device.c +++ b/core/device.c @@ -376,11 +376,19 @@ struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle) return NULL; } +/* Any property larger than MAX_ALLOC will be allocated using local_alloc */ +#define MAX_MALLOC 1048576 + static struct dt_property *new_property(struct dt_node *node, const char *name, size_t size) { - struct dt_property *p = malloc(sizeof(*p) + size); char *path; + struct dt_property *p; + + if (size > MAX_MALLOC) + p = local_alloc(0, sizeof(*p)+size, 0x10000); + else + p = malloc(sizeof(*p) + size); if (!p) { path = dt_get_path(node);