From patchwork Wed May 24 08:09:12 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: 766365 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 3wXlRf2PBnz9sNb for ; Wed, 24 May 2017 18:09:34 +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="XWMjQPd5"; 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 3wXlRd0gz3zDqZX for ; Wed, 24 May 2017 18:09:33 +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="XWMjQPd5"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (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 3wXlRV0TlTzDqL2 for ; Wed, 24 May 2017 18:09:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XWMjQPd5"; dkim-atps=neutral Received: by mail-pf0-x242.google.com with SMTP id n23so32079449pfb.3 for ; Wed, 24 May 2017 01:09:25 -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=LOcdWjVNZtNOQWsjZsCIpRbKxR0RLT1HxLly8nL0OnA=; b=XWMjQPd5n0/o3UeVSStfU08uavs5NOlMoG/WQlytJ/qVUlF/lgfJnuMzmqW9c9TEgn ZK42yHk122xWA8Ve4FGTpjM77/Zv0foXX+1zUcODCZnM9Rhul27bb8lnEH5o8/Fb53N/ bK70v303KlRhgdieeeThzrM5cx/4PZsjf1Zf3i1CtwZhu5rm92yO3/N4FB+UMNZJ8UVh iQP0A60qlnlIq+Y7FNIycWuBEHZhBeeINcPicbJF3a2ZpITTk3na5/HlsDJRqJiIEsyw Hi4S0FpVvcwl15dKYY/MS5pDGJWec43NigTDLuQxlsyHOXIOS5vgBZJDoD5lKaMRW5Su SJ+g== 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=LOcdWjVNZtNOQWsjZsCIpRbKxR0RLT1HxLly8nL0OnA=; b=LMkw8IIV/nKo53ZnbX6a/7VzDJVimdWNHsXoQ4P5s7Ev+C46+WoRPYwltGXVxlKwxI xtRGYzYXRHQiuRFcoJOeYfYx2h4+bZJEtLd+n3pUKII+VtpBY/IbnIIHKUQ7Hxm2L6mR ng56IvlU3t0hbhlELfOcKRzDeigyYDKgGPh7DQCXF9pa0FxyElJXn5dFz2EnIBmFvGCH IxLy2TPUA1SLW12eMGx9CdYgENvZ7UXGZ2P2eYmFWOF8MKjKnpdffoE31+INWKgKmDrn BThauA8ynXlJYr22OTNHTNhYn0ucEN2gF2tr3msE60D4VNN6zk+IVqowIcS6GyfRYwSv 3LlQ== X-Gm-Message-State: AODbwcBuohtVuMt7GZrUNjKOuw/3FpzcRLRMAeVUVtwZNXN61Q9zpOD0 zwdbcVmF8BX6vA== X-Received: by 10.98.212.18 with SMTP id a18mr37350018pfh.28.1495613364406; Wed, 24 May 2017 01:09:24 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id q25sm8864305pgn.9.2017.05.24.01.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 May 2017 01:09:23 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 24 May 2017 18:09:12 +1000 Message-Id: <20170524080912.19870-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [Skiboot] [PATCH] hdata: Check the Host I2C devices array version 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 this is not populated on FSP machines which causes some obnoxious errors to appear in the boot log. We also only want to parse version 1 of this structure since future versions will completely change the array item format. Cc: Vasant Hegde Signed-off-by: Oliver O'Halloran --- hdata/i2c.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hdata/i2c.c b/hdata/i2c.c index f5c5bafe758b..4c3f920e2fda 100644 --- a/hdata/i2c.c +++ b/hdata/i2c.c @@ -149,6 +149,11 @@ static bool is_zeros(const void *p, size_t size) return true; } +struct host_i2c_hdr { + const struct HDIF_array_hdr hdr; + __be32 version; +}; + int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, struct dt_node *xscom) { @@ -156,7 +161,9 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, const struct hdat_i2c_type *type; const struct i2c_dev *dev; const char *label, *name, *compat; + const struct host_i2c_hdr *ahdr; uint32_t i2c_addr; + uint32_t version; uint32_t size; int i, count; @@ -166,6 +173,32 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, */ assert(proc_gen == proc_gen_p9); + /* + * Emit an error if we get a newer version. This is an interim measure + * until the new version format is finalised. + */ + ahdr = HDIF_get_idata(hdr, idata_index, &size); + if (!ahdr || !size) + return 1; + + /* + * Some hostboots don't correctly fill the version field. On these + * the offset from the start of the header to the start of the array + * is 16 bytes. + */ + if (be32_to_cpu(ahdr->hdr.offset) == 16) { + version = 1; + prerror("I2C: HDAT device array has no version! Assuming v1\n"); + } else { + version = be32_to_cpu(hdr->version); + } + + if (version != 1) { + prerror("I2C: HDAT version %d not supported! THIS IS A BUG\n", + version); + return 1; + } + count = HDIF_get_iarray_size(hdr, idata_index); for (i = 0; i < count; i++) { dev = HDIF_get_iarray_item(hdr, idata_index, i, &size);