From patchwork Mon Sep 24 07:14:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 973845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Jb6x2dbJz9sB4 for ; Mon, 24 Sep 2018 17:14:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ftI2p/c0"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42Jb6x10tszF26H for ; Mon, 24 Sep 2018 17:14:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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="ftI2p/c0"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ftI2p/c0"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (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 42Jb6p4cpDzDqjx for ; Mon, 24 Sep 2018 17:14:26 +1000 (AEST) Received: by mail-pl1-x641.google.com with SMTP id b12-v6so8712538plr.8 for ; Mon, 24 Sep 2018 00:14:26 -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=6OEtdL95z9jCGtx7dmTQpbaCtWmCQOaN8a8SBm9VYlA=; b=ftI2p/c0ZaEVqVxKCqx5LuoPX9MOvk1Hj7+a8z94T9g049JXoAUGLmtClwGAQA/NDe lkkgdB3BIUWsJejFIK12Gk76OAUafw6r/VotOZfYVdDXet4GcC0lU4iKc1aBRB5gTpZ8 HlPY8nE6D7o0u4GiGkGffg3OXj5Si1QbAr0iWVMjXCHqN1DFsffvm/Jmd1w5G0ueWUen nUyZvNROpwTFlmNo0X1kSSTXh2zGCMguhqUk3MKK52pJvSkg4vUk+e3IuZvJeWZtc5iY rX2EoYii1BaIyXaw13nYbCfdAPN9a+A2DwCFUb0rgUgCq73prueUDvx45A/xhT2nlyP9 JTEw== 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=6OEtdL95z9jCGtx7dmTQpbaCtWmCQOaN8a8SBm9VYlA=; b=PHh9TzREIIJ7GsAfQpdFfX3n+YLRNq7dJ9l0bxd0l6RWucOJho9TOHPQYmoZ36Ho6Y XPkHcF+yJ6ELruE7QawaPmtWKDZ6/iJIL4m6yLp6WIpqG6PGFwM94ju96u60+3g5vJXS ZDE2HUUY7OMShpHsJbvxx4mwj0m1S9otuTgS2q65E+VFV/u/clq2qSPtzLlwzy4xRxlF Sykays1nNVVaqHf32/J55Qd5Hj6f8PXFIP+8UqRmA3+obpZOeY4yzxyOa9rcXnPJ5Hmz fbcB/CK27hks4/2OjIMZUB0z/NJUnXef9OZFUl2dHeB1mYoyOTKRJ5ZbBn3XxQIoogou 3+lA== X-Gm-Message-State: ABuFfoggzzzA/S75UboeGB3GWXxucfyxrNNa57s2fnsE4DdwnUB2LsAb Z5StAqKBVTByTaOCQkshEJUM2Rmr X-Google-Smtp-Source: ACcGV63ytC6PVLpg0xuD1dYIfkIvztr0kFXJ350jLMTAbuGUEx4GrD/IYN1HELHDgD/lKUgFhjFkFA== X-Received: by 2002:a17:902:6501:: with SMTP id b1-v6mr9317926plk.31.1537773264110; Mon, 24 Sep 2018 00:14:24 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id f15-v6sm4083662pgv.66.2018.09.24.00.14.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Sep 2018 00:14:23 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Mon, 24 Sep 2018 17:14:07 +1000 Message-Id: <20180924071408.11897-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [Skiboot] [PATCH 1/2] hdata/i2c: Add whitelisting for Host I2C devices X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 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" Many of the devices that we get information about through HDAT are for use by firmware rather than the host operating system. This patch adds a boolean flag to hdat_i2c_info structure that indicates whether devices with a given purpose should be reserved for use inside of OPAL (or some other firmware component, such as the OCC). Signed-off-by: Oliver O'Halloran Reviewed-by: Vasant Hegde --- hdata/i2c.c | 68 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/hdata/i2c.c b/hdata/i2c.c index 9bbec665728c..5a6d8506c4e4 100644 --- a/hdata/i2c.c +++ b/hdata/i2c.c @@ -129,30 +129,31 @@ static struct hdat_i2c_type hdat_i2c_devs[] = { { 0x13, "i2c", "nxp,lpc11u35" }, }; -struct hdat_i2c_label { +struct hdat_i2c_info { uint32_t id; + bool whitelist; /* true if the host may use the device */ const char *label; }; -static struct hdat_i2c_label hdat_i2c_labels[] = { - { 0x1, "led-controller" }, - { 0x2, "pci-hotplug-pgood" }, - { 0x3, "pci-hotplug-control" }, - { 0x4, "tpm" }, - { 0x5, "module-vpd" }, - { 0x6, "dimm SPD" }, - { 0x7, "proc-vpd" }, - { 0x8, "sbe-eeprom" }, - { 0x9, "planar-vpd" }, - { 0xa, "opencapi-topology" }, - { 0xb, "opencapi-micro-reset" }, - { 0xc, "nvlink-cable" }, - { 0xd, "secure-window-open" }, - { 0xe, "physical-presence" }, - { 0xf, "mex-fpga" }, - { 0x10, "thermal-sensor" }, - { 0x11, "host-i2c-enable" }, - { 0x12, "gpu-config" }, +static struct hdat_i2c_info hdat_i2c_extra_info[] = { + { 0x1, false, "led-controller" }, + { 0x2, false, "pci-hotplug-pgood" }, + { 0x3, false, "pci-hotplug-control" }, + { 0x4, true, "tpm" }, + { 0x5, true, "module-vpd" }, + { 0x6, true, "dimm-spd" }, + { 0x7, true, "proc-vpd" }, + { 0x8, false, "sbe-eeprom"}, + { 0x9, true, "planar-vpd" }, + { 0xa, false, "opencapi-topology" }, + { 0xb, false, "opencapi-micro-reset" }, + { 0xc, false, "nvlink-cable" }, + { 0xd, false, "secure-window-open" }, + { 0xe, false, "physical-presence" }, + { 0xf, false, "mex-fpga" }, + { 0x10, false, "thermal-sensor" }, + { 0x11, false, "host-i2c-enable" }, + { 0x12, false, "gpu-config" }, }; /* @@ -171,15 +172,17 @@ static struct hdat_i2c_type *map_type(uint32_t type) return NULL; } -static const char *map_label(uint32_t type) +static struct hdat_i2c_info *get_info(uint32_t type) { + static struct hdat_i2c_info no_info = + { .id = 0x0, .whitelist = false, .label = "" }; int i; - for (i = 0; i < ARRAY_SIZE(hdat_i2c_labels); i++) - if (hdat_i2c_labels[i].id == type) - return hdat_i2c_labels[i].label; + for (i = 0; i < ARRAY_SIZE(hdat_i2c_extra_info); i++) + if (hdat_i2c_extra_info[i].id == type) + return &hdat_i2c_extra_info[i]; - return NULL; + return &no_info; } static bool is_zeros(const void *p, size_t size) @@ -204,8 +207,9 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, { struct dt_node *i2cm, *bus, *node; const struct hdat_i2c_type *type; + const struct hdat_i2c_info *info; const struct i2c_dev *dev; - const char *label, *name, *compat; + const char *name, *compat; const struct host_i2c_hdr *ahdr; uint32_t dev_addr; uint32_t version; @@ -284,7 +288,7 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, purpose = be32_to_cpu(dev->purpose); type = map_type(dev->type); - label = map_label(purpose); + info = get_info(purpose); /* HACK: Hostboot doesn't export the correct type information * for the DIMM SPD EEPROMs. This is a problem because SPD @@ -316,11 +320,11 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, if (!type || dev->type == 0xFF) prlog(PR_WARNING, "HDAT I2C: found e%dp%d - %s@%x dp:%02x (%#x:%s)\n", dev->i2cm_engine, dev->i2cm_port, name, dev_addr, - dev->dev_port, purpose, label); + dev->dev_port, purpose, info->label); else prlog(PR_DEBUG, "HDAT I2C: found e%dp%d - %s@%x dp:%02x (%#x:%s)\n", dev->i2cm_engine, dev->i2cm_port, name, dev_addr, - dev->dev_port, purpose, label); + dev->dev_port, purpose, info->label); /* * Multi-port device require special handling since we need to @@ -340,8 +344,10 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index, be32_to_cpu(dev->i2c_link)); if (compat) dt_add_property_string(node, "compatible", compat); - if (label) - dt_add_property_string(node, "label", label); + if (info->label) + dt_add_property_string(node, "label", info->label); + if (!info->whitelist) + dt_add_property_string(node, "status", "reserved"); /* * Set a default timeout of 2s on the ports with a TPM. This is