From patchwork Thu Jul 20 06:09:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 791416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xCk5n66zPz9t2J for ; Thu, 20 Jul 2017 16:10:21 +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="IYWLeexY"; 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 3xCk5n52mzzDrFn for ; Thu, 20 Jul 2017 16:10:21 +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="IYWLeexY"; 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 3xCk5c2JD1zDqnv for ; Thu, 20 Jul 2017 16:10:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IYWLeexY"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id c23so1653230pfe.5 for ; Wed, 19 Jul 2017 23:10:12 -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; bh=iHHVt2Q7vBpCMClyOajrW0MtLnJgWELB0JBeRjcU0Gs=; b=IYWLeexYdXIaK4U7Pv+n4jKIJZ5HcUiw/sifmOSzA1oXVCQ0BbXGltkzmmZEwZMrVx MDzEBT8V36KjoLm1e5ESAAQcBws1QV4J9jCH+vusQHUJ44YVHM12cAOyIAdE0ICRXTRR 1DTDWamNEiqmWnpjfetvmDscWk84f6bDNXIzjTTUVIyaNK8yZcz7qCbRFj7HmVxxd22f ohGfN2vMF3hCzHxoNDXKBrWNXk4Z5H4hl+C6Mzj8WQlNXKSRbJp2VIhem9GlBpdFSVGJ D9YFkCNvTimIOtXbpenFsD06Yzq62lahZTNMaTcugPzWVvhW1iPR4oa1DNBPPxyH9S/i Zqtw== 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; bh=iHHVt2Q7vBpCMClyOajrW0MtLnJgWELB0JBeRjcU0Gs=; b=kEnVk4B7TZViYT96+/wFXLS/9HeJI1QWvtqu6pUdygHpbVrdCQZSsg5+KCbFhoPOPH 160pvQqc8IoQb9pm85BtsgvjtVtWDNAB95wuAPq9900skWpzjx+FcMLfmCo+3sfeCKp+ EjLC0ZiEImhMUNyqDclQC3hV/9WfouvjI0jc3GEVmVlpBvz2Tu/au2jzTEHzl4Udu03C 1zMHZdPuYMkHTv8tLxqPsqDaMr0k0G96nlOW3b0wsl2q8dTWwtWLSaCcGFThrK79BuOS NoRAd6kuqDsUMU+a8ludQ2wIZA43vzQVMZrH3mvN9kx+fzsIOPVIP4aD0uaTz+kzeJ+G 9bDg== X-Gm-Message-State: AIVw112t2l/jiQ4/CzgxVpidJMiz2kkg8vBAFe9kiYYyZ8LyRqsRVrgl 2SlgckKNOaj89Qux X-Received: by 10.84.231.207 with SMTP id g15mr3042708pln.146.1500531009744; Wed, 19 Jul 2017 23:10:09 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y26sm2622889pfk.46.2017.07.19.23.10.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jul 2017 23:10:09 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 20 Jul 2017 16:09:58 +1000 Message-Id: <20170720060958.32396-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.4 Subject: [Skiboot] [PATCH] hdata/memory: Add memory reservations to the DT 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" Currently we just add these to a list of pre-boot reserved regions which is then converted into a the contents of the /reserved-memory/ node just before Skiboot jumps into the firmware kernel. This approach is insufficent because we need to add the ibm,prd-instance labels to the various hostboot reserved regions. To do this we want to create these resevation nodes inside the HDAT parser rather than having the mem_region flattening code handle it. On P8 systems Hostboot placed its memory reservations under the /ibm,hostboot/ node and this patch makes the HDAT parser do the same. Signed-off-by: Oliver O'Halloran --- hdata/memory.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- hdata/spira.h | 5 ++++- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/hdata/memory.c b/hdata/memory.c index d6550e61f584..b80d33cde860 100644 --- a/hdata/memory.c +++ b/hdata/memory.c @@ -403,12 +403,42 @@ static void get_msareas(struct dt_node *root, } } +static struct dt_node *dt_hb_reserves; + +static struct dt_node *add_hb_reserve_node(const char *name, u64 start, u64 end) +{ + struct dt_node *node, *hb; + + if (!dt_hb_reserves) { + hb = dt_new_check(dt_root, "ibm,hostboot"); + dt_add_property_cells(hb, "#size-cells", 2); + dt_add_property_cells(hb, "#address-cells", 2); + + dt_hb_reserves = dt_new_check(hb, "reserved-memory"); + dt_add_property(dt_hb_reserves, "ranges", NULL, 0); + dt_add_property_cells(dt_hb_reserves, "#size-cells", 2); + dt_add_property_cells(dt_hb_reserves, "#address-cells", 2); + } + + node = dt_new_addr(dt_hb_reserves, name, start); + if (!node) { + prerror("Unable to create node for %s@%llx\n", + name, (unsigned long long) start); + return NULL; + } + + dt_add_property_u64s(node, "reg", start, end - start + 1); + + return node; +} + #define HRMOR_BIT (1ul << 63) static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd) { const struct msvpd_hb_reserved_mem *hb_resv_mem; u64 start_addr, end_addr, label_size; + struct dt_node *node; int count, i; char *label; @@ -472,7 +502,17 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd) prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 " (type/inst=0x%08x)\n", label, start_addr, end_addr, be32_to_cpu(hb_resv_mem->type_instance)); - mem_reserve_fw(label, start_addr, end_addr - start_addr + 1); + node = add_hb_reserve_node(label, start_addr, end_addr); + if (!node) { + prerror("unable to add node?\n"); + continue; + } + + /* the three low bytes of type_instance is the instance data */ + dt_add_property_cells(node, "ibm,prd-instance", + (be32_to_cpu(hb_resv_mem->type_instance) & 0xffffff)); + + dt_add_property_string(node, "ibm,prd-label", label); } } @@ -502,6 +542,7 @@ static void parse_trace_reservations(struct HDIF_common_hdr *ms_vpd) for (i = 0; i < count; i++) { const struct msvpd_trace *trace_area; + struct dt_node *node; u64 start, end; trace_area = HDIF_get_iarray_item(ms_vpd, @@ -514,10 +555,17 @@ static void parse_trace_reservations(struct HDIF_common_hdr *ms_vpd) end = be64_to_cpu(trace_area->end) & ~HRMOR_BIT; prlog(PR_INFO, - "MSVPD: Trace area: 0x%.16"PRIx64"-0x%.16"PRIx64"\n", + "MS VPD: Trace area: 0x%.16"PRIx64"-0x%.16"PRIx64"\n", start, end); - mem_reserve_hwbuf("trace-area", start, end - start); + node = add_hb_reserve_node("trace-area", start, end); + if (!node) { + prerror("MEM: Unable to reserve trace area %p-%p\n", + (void *) start, (void *) end); + continue; + } + + dt_add_property(node, "no-map", NULL, 0); } } diff --git a/hdata/spira.h b/hdata/spira.h index caea057e3b79..4867b6d1ae5b 100644 --- a/hdata/spira.h +++ b/hdata/spira.h @@ -530,7 +530,10 @@ struct msvpd_hb_reserved_mem { __be64 end_addr; __be32 label_size; uint8_t label[64]; - __be64 reserved; + uint8_t rw_perms; +#define HB_RESERVE_READABLE 0x80 +#define HB_RESERVE_WRITEABLE 0x40 + uint8_t reserved[7]; } __packed; /* Child index 0: MS area child structure */