From patchwork Fri Sep 15 05:40:56 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: 814071 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 3xtkq923xJz9sPr for ; Fri, 15 Sep 2017 15:44:05 +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="MzySG6j/"; 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 3xtkq90wPXzDrZx for ; Fri, 15 Sep 2017 15:44:05 +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="MzySG6j/"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MzySG6j/"; dkim-atps=neutral Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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 3xtkmM1DrCzDrXc for ; Fri, 15 Sep 2017 15:41:39 +1000 (AEST) Received: by mail-pf0-x243.google.com with SMTP id i23so765896pfi.2 for ; Thu, 14 Sep 2017 22:41:38 -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; bh=Mdag2b8rUu1mZ0vILwviFngS3tvBAlLXS/DDovK8nNQ=; b=MzySG6j/4LHZFBpP/w7jGbLIWCyQZUb+/w6CstgISb9eMdeHxTStMT63EP8HjAUgee d5hAyoQYwuBs0XM6kkykYDMdS5R0u94hZA+wiZwxnmpm8QiYFYRtsAe4hcYAScDaaXQc zKPk1pIXMlc7GQnG+45ei9MnvXOuzzzUlfofhn+We8zJnSenxqOwxxKgbCiN2B+/d3hK LnpjBoYvv3DUf1oLbjSO4yR6Z9B5jz31GGhu52+u7K4utqvMPmDjT4HYR5LaTrdKRa7A 0SZo56H1/Syn/br/ObTj3h2xlA2JqV3yhKyNMu5C27dt5/MM1I9ERW3Y1Pd3vy6YxeHj LG6w== 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=Mdag2b8rUu1mZ0vILwviFngS3tvBAlLXS/DDovK8nNQ=; b=QCfb+zuNRGkesOxksMmHNZTwO3IV0RMhtpoDcrsnjWTTb4uLbYzhGrA3mX2RFvQuJK 93Lv3oH7DUSeiBAgwgcyQAWrngFfI9dClGFMjjB/2bySNbk7B5AxvqGTMuFSYz/SWWPf Q81MMaGSbKv+K2iFGsWClqNyDr6/X0qsLdjJvrv5JVSSqnE6DKVMa3MYXw7Q1O2T0xEE iSTsMxEXATqwBhhPje154fnWrLtUIlEiioxXhFqfCrwJTxo3IvmvWRapjG7XQn6pqN79 zVYXwiNSpNvcZrQaZ3G5qUhVLyB4eRm1abGygf+YVx1ePFAke5FhuvtTI6QY5A/aC2xr +uEg== X-Gm-Message-State: AHPjjUgJFClGzFtCwNHhTbYOyVEqgfmN+N0Vdn2y8HuiKdPxcptOWZIl yH2nU+rfyblGXfLS X-Google-Smtp-Source: ADKCNb6Fx/HKbNQhcYwGb4Blh/9cv8Y7Zm7lWiBDWonjflJ35qXur2h0mSm1MroDQArM1rBNkdMjbg== X-Received: by 10.84.224.134 with SMTP id s6mr27438987plj.413.1505454096759; Thu, 14 Sep 2017 22:41:36 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id z8sm280581pgc.93.2017.09.14.22.41.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 22:41:36 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 15 Sep 2017 15:40:56 +1000 Message-Id: <20170915054059.32109-11-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170915054059.32109-1-oohall@gmail.com> References: <20170915054059.32109-1-oohall@gmail.com> Subject: [Skiboot] [PATCH 11/14] hdata: Add xscom_to_pcrd() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 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" Iterating the SPPCRD structures (per chip data) is a fairly common operation in the HDAT parser. Iterating the tuples directly is somewhat irritating since we need to check for disabled chips, etc on every pass. A better way to handle this is to iterate throught he xscom nodes (generated from the SPPCRD data) and map from the xscom node to the originating structure. This patch adds a function to do that. Signed-off-by: Oliver O'Halloran --- hdata/spira.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hdata/spira.c b/hdata/spira.c index b58be7c1a009..240f344d8a41 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -290,6 +290,42 @@ static struct dt_node *add_xscom_node(uint64_t base, uint32_t hw_id, return node; } +/* + * Given a xscom@ node this will return a pointer into the SPPCRD + * structure corresponding to that node + */ +#define GET_HDIF_HDR -1 +static const void *xscom_to_pcrd(struct dt_node *xscom, int idata_index) +{ + struct spira_ntuple *t = &spira.ntuples.proc_chip; + const struct HDIF_common_hdr *hdif; + const void *idata; + unsigned int size; + uint32_t i; + void *base; + + i = dt_prop_get_u32_def(xscom, DT_PRIVATE "sppcrd-index", 0xffffffff); + if (i == 0xffffffff) + return NULL; + + base = get_hdif(t, "SPPCRD"); + assert(base); + assert(i < be16_to_cpu(t->act_cnt)); + + hdif = base + i * be32_to_cpu(t->alloc_len); + if (!hdif) + return NULL; + + if (idata_index == GET_HDIF_HDR) + return hdif; + + idata = HDIF_get_idata(hdif, idata_index, &size); + if (!idata || !size) + return NULL; + + return idata; +} + struct dt_node *find_xscom_for_chip(uint32_t chip_id) { struct dt_node *node; @@ -447,6 +483,9 @@ static bool add_xscom_sppcrd(uint64_t xscom_base) if (!np) continue; + + dt_add_property_cells(np, DT_PRIVATE "sppcrd-index", i); + version = be16_to_cpu(hdif->version); /* Version 0A has additional OCC related stuff */