From patchwork Wed Sep 12 09:52:45 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: 968930 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429HCv1TZXz9sBZ for ; Wed, 12 Sep 2018 19:53:31 +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="BQvqXxGE"; 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 429HCt71LzzF314 for ; Wed, 12 Sep 2018 19:53:30 +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="BQvqXxGE"; 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::544; helo=mail-pg1-x544.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="BQvqXxGE"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 429HCP53wWzF0Pd for ; Wed, 12 Sep 2018 19:53:05 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id i190-v6so785022pgc.6 for ; Wed, 12 Sep 2018 02:53:05 -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=/owvG9xufRuHGga470x0qn6lBKa5gt3tHaB0ehWt56g=; b=BQvqXxGElf5CgB6IS3CKtnWgxROMPnmQp3eUEdcvgaSXOyfwPXSyidAA62WpzqJVOk GoS3e4qwijSmNMtul0UXA8FVXVIE18kNWzUKl5ycFa3cNW1TRalKtGKG/esubgnSeNip ZNhC1Yf+cz0Mlqd3NeIA1JuzvPj4K/A8tgEnODoClo4onVR9Jmo4nd2/pjoD/y9VJ8vn QIi3PdwvTSh3O6eraI2q74iqozVKzVMyuZ3lovH9M7WczowmVVc8RuAOSoWmOqmKt+Sr xiXIhkRx78D+03SXWS9J2tkOpmEG+WD2R7mexMlB5212XicPijmqfij0dsXc2jkOHeF7 D/Xg== 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=/owvG9xufRuHGga470x0qn6lBKa5gt3tHaB0ehWt56g=; b=QkJEF5yWHop0pGu5UvtU1uk5G46W7UH50DozakFpooqXjBYN22BTUPisNGl8tzig5c aMWTJ7Jt630zZA2OYLw4EAoTgwROdXeToWXhwffJjkg/9OJJheb6fVOW3G5ujgLdsoF4 jkMtu0jUsJTYjlntgvm+YvMLKIW1V70WKCii3+u3ux0iVvXq8ctYFkVJPpQb+AGV4MH2 BCYo/TVRW++xYEhAAi5CisdBuybc08qNaxEDl2sAremq8ZP0tzz/+sl1Gs7seUVlHDyW X3roElmcofK7mGFe9cmseVdHSDs6Ir7J2fLDt3oJoT9Qy79cRqREL6eaSaT5VDUCEOD/ KlLw== X-Gm-Message-State: APzg51BQZ9f3b0B8AAUNT/UnWNywUu3Pi43eqE+1OWn2eyCBxd7tOkY4 wR8ZxztELVB8WZu2SDOutdc4wOER X-Google-Smtp-Source: ANB0VdY9bRbprCLkUShkICbKl7vOpb/rtiVUnk8krjQ573DRcLfFGz0WAFabM0I2K6DyVca+PaFVRA== X-Received: by 2002:a62:51c6:: with SMTP id f189-v6mr1307483pfb.7.1536745983349; Wed, 12 Sep 2018 02:53:03 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d132-v6sm1166307pgc.93.2018.09.12.02.53.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 02:53:02 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 12 Sep 2018 19:52:45 +1000 Message-Id: <20180912095248.27557-2-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180912095248.27557-1-oohall@gmail.com> References: <20180912095248.27557-1-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 1/4] phb4: Rework bdfn filtering in set_pe 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" Signed-off-by: Oliver O'Halloran --- hw/phb4.c | 56 ++++++++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/hw/phb4.c b/hw/phb4.c index d1245dce5adf..f0cbb4852558 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -2159,8 +2159,7 @@ static int64_t phb4_set_pe(struct phb *phb, uint8_t action) { struct phb4 *p = phb_to_phb4(phb); - uint64_t mask, val, tmp, idx; - int32_t all = 0; + uint64_t mask, val, idx; uint16_t *rte; /* Sanity check */ @@ -2174,52 +2173,37 @@ static int64_t phb4_set_pe(struct phb *phb, fcompare > OPAL_COMPARE_RID_FUNCTION_NUMBER) return OPAL_PARAMETER; + /* match everything by default */ + mask = 0; + val = 0; + /* Figure out the RID range */ - if (bcompare == OpalPciBusAny) { - mask = 0x0; - val = 0x0; - all = 0x1; - } else { - tmp = ((0x1 << (bcompare + 1)) - 1) << (15 - bcompare); - mask = tmp; - val = bdfn & tmp; + if (bcompare != OpalPciBusAny) { + mask = ((0x1 << (bcompare + 1)) - 1) << (15 - bcompare); + val = bdfn & mask; } - if (dcompare == OPAL_IGNORE_RID_DEVICE_NUMBER) - all = (all << 1) | 0x1; - else { + if (dcompare != OPAL_IGNORE_RID_DEVICE_NUMBER) { mask |= 0xf8; val |= (bdfn & 0xf8); } - if (fcompare == OPAL_IGNORE_RID_FUNCTION_NUMBER) - all = (all << 1) | 0x1; - else { + if (fcompare != OPAL_IGNORE_RID_FUNCTION_NUMBER) { mask |= 0x7; val |= (bdfn & 0x7); } /* Map or unmap the RTT range */ - if (all == 0x7) { - if (action == OPAL_MAP_PE) { - for (idx = 0; idx < RTT_TABLE_ENTRIES; idx++) - p->rte_cache[idx] = pe_number; - } else { - for (idx = 0; idx < ARRAY_SIZE(p->rte_cache); idx++) - p->rte_cache[idx] = PHB4_RESERVED_PE_NUM(p); - } - memcpy((void *)p->tbl_rtt, p->rte_cache, RTT_TABLE_SIZE); - } else { - rte = (uint16_t *)p->tbl_rtt; - for (idx = 0; idx < RTT_TABLE_ENTRIES; idx++, rte++) { - if ((idx & mask) != val) - continue; - if (action == OPAL_MAP_PE) - p->rte_cache[idx] = pe_number; - else - p->rte_cache[idx] = PHB4_RESERVED_PE_NUM(p); - *rte = p->rte_cache[idx]; - } + rte = (uint16_t *)p->tbl_rtt; + for (idx = 0; idx < RTT_TABLE_ENTRIES; idx++, rte++) { + if ((idx & mask) != val) + continue; + + if (action == OPAL_MAP_PE) + p->rte_cache[idx] = pe_number; + else + p->rte_cache[idx] = PHB4_RESERVED_PE_NUM(p); + *rte = p->rte_cache[idx]; } /* Invalidate the entire RTC */ From patchwork Wed Sep 12 09:52:46 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: 968931 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429HDJ64NLz9sBZ for ; Wed, 12 Sep 2018 19:53:52 +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="rQsKTUoJ"; 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 429HDJ3hmmzF312 for ; Wed, 12 Sep 2018 19:53:52 +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="rQsKTUoJ"; 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::544; helo=mail-pg1-x544.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="rQsKTUoJ"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 429HCR1jDgzF0Pd for ; Wed, 12 Sep 2018 19:53:07 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id x26-v6so769801pge.12 for ; Wed, 12 Sep 2018 02:53:07 -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=9COO0wZWha2Dsy0q42nIEQ8TdlKoVujIF/uTtRT1YUI=; b=rQsKTUoJBI/kHb675/ToDP9oL9tOxHit6KUsNzpb3ijZ+BfVHzI6scoQMxlAcu2MhY BrXbNq/nZMcsIxW1CiIyQ3nYM+uNbMZJZzmEqrjHCoNQeqdhlFt2hJwIyjsTzG0kv+C2 OJmXCqB+zjBFQIl3Da0BvcN3DdjGx9rRIb85mDIROY56EmWwPI9wLB1A7uuZ4FerBBpX d1uJW/7RXuzA+OTbNoTRSR8jf0XqXaCe+BrVIEZiyXPvb3NFZrHhi57LbutLCUsEzNXv VQPme7XdpdQJw23o9KpWOFsxAe0rEMjSlhu/DKA7V5UTZN7ABkj4ucBz6AdhcY9mWu1P 9RoQ== 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=9COO0wZWha2Dsy0q42nIEQ8TdlKoVujIF/uTtRT1YUI=; b=nLOzVuyOBpZ8NoaU0A6DWYkySlWCugBxGVnw8jgtRTTXzHMndU5KmRYWVLocAEpF5Z Inrsnt84io8/WBK65iHgw1oVhUZjXdrYVABl13lsr6wYYP4S8peKRWBTWJC4NnkKIjOr VrM2J9bev90LoZJglgJLEqGYZqmz2VTzmAVZ/Bh5QBmK0s1iLeOZnTxC+zAKsQl/yP1u xH10qpVLscuTWEfiEPWsPr2SD07UwxLDfoKufbz0zjuea1dgSzieVYo05hVWXTKBxCwZ MqP7zEo2TMUTlGIIzDB+bExkhhgp2KkeotJnFJazZ2K0MmB/0mbWX+srIXuiSu27WHvD teqw== X-Gm-Message-State: APzg51Ddy2JbPtC5E8dJxpCbnPP76R7Nn0ARGpOJIQkcwt2wmSjL4Ecy NQ9KBLD6RxOBDOL+8XbG+ZeCez1b X-Google-Smtp-Source: ANB0VdZm3iPlLOiT91jCjTfofFuiIw4hh0R6H+jYiUeKrkKZQV4et7Q10DyI054bWD57Z+IY/4ZAgw== X-Received: by 2002:a62:985a:: with SMTP id q87-v6mr1337888pfd.64.1536745985346; Wed, 12 Sep 2018 02:53:05 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d132-v6sm1166307pgc.93.2018.09.12.02.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 02:53:04 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 12 Sep 2018 19:52:46 +1000 Message-Id: <20180912095248.27557-3-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180912095248.27557-1-oohall@gmail.com> References: <20180912095248.27557-1-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 2/4] phb4: Remove pointless NULL checks 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" When we allocate the various in-memory tables we assert() on the allocation. There's no point in checking if the table pointer is NULL or not at runtime. Signed-off-by: Oliver O'Halloran --- hw/phb4.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/phb4.c b/hw/phb4.c index f0cbb4852558..7666eefdcb6e 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -1164,10 +1164,8 @@ static int64_t phb4_ioda_reset(struct phb *phb, bool purge) /* Additional OPAL specific inits */ /* Clear RTT and PELTV and PEST */ - if (p->tbl_rtt) - memcpy((void *)p->tbl_rtt, p->rte_cache, RTT_TABLE_SIZE); - if (p->tbl_peltv) - memcpy((void *)p->tbl_peltv, p->peltv_cache, p->tbl_peltv_size); + memcpy((void *)p->tbl_rtt, p->rte_cache, RTT_TABLE_SIZE); + memcpy((void *)p->tbl_peltv, p->peltv_cache, p->tbl_peltv_size); /* Clear PEST & PEEV */ for (i = 0; i < p->max_num_pes; i++) { @@ -2163,8 +2161,6 @@ static int64_t phb4_set_pe(struct phb *phb, uint16_t *rte; /* Sanity check */ - if (!p->tbl_rtt) - return OPAL_HARDWARE; if (action != OPAL_MAP_PE && action != OPAL_UNMAP_PE) return OPAL_PARAMETER; if (pe_number >= p->num_pes || bdfn > 0xffff || @@ -2222,8 +2218,6 @@ static int64_t phb4_set_peltv(struct phb *phb, uint32_t idx, mask; /* Sanity check */ - if (!p->tbl_peltv) - return OPAL_HARDWARE; if (parent_pe >= p->num_pes || child_pe >= p->num_pes) return OPAL_PARAMETER; @@ -3670,10 +3664,6 @@ static int64_t phb4_err_inject(struct phb *phb, uint64_t pe_number, uint64_t addr, uint64_t mask, bool is_write); bool is_write; - /* How could we get here without valid RTT? */ - if (!p->tbl_rtt) - return OPAL_HARDWARE; - /* We can't inject error to the reserved PE */ if (pe_number == PHB4_RESERVED_PE_NUM(p) || pe_number >= p->num_pes) return OPAL_PARAMETER; From patchwork Wed Sep 12 09:52:47 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: 968932 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429HDk3mFPz9sBZ for ; Wed, 12 Sep 2018 19:54:14 +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="g5+Wzyxc"; 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 429HDk1kvRzF314 for ; Wed, 12 Sep 2018 19:54:14 +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="g5+Wzyxc"; 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::443; helo=mail-pf1-x443.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="g5+Wzyxc"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (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 429HCT3QVDzF31Z for ; Wed, 12 Sep 2018 19:53:09 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id d4-v6so770511pfn.0 for ; Wed, 12 Sep 2018 02:53:09 -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=0pShKvT5/yzFZP2AVSFOZ7sK5bvOSCYxtvGTUy4qix8=; b=g5+Wzyxcn95IzVJ8FAZm0quw4rXABdfXHLGstvsVNsTiKo9BAleC+ljNjgba00+CxW uJp4Z/aI3Ptl/01XqqGk0L9ach4SkZ//sBS8Je+Zqpqq1BI3fpPZ80vKeaoKcdY0p5sE s0IfJGBtTH5TjvUN8CPXizGaiOJ/HLJjU2xxfl0caHBNnVUVZD31TvGHg8WWpUL/dZIz dTlOhTQH6+X6LfwAlMNt+b2Rd1mxjqR9BcPWZjAZbclueAmMOItY8gAw1nkpAdAIn8N3 bDBBo6o8oihd+EzJaoJ+lc93av7GYCZyU9BCDk88aXIINdAWWoe4dxYnHAyGUEcTdmiP DbNw== 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=0pShKvT5/yzFZP2AVSFOZ7sK5bvOSCYxtvGTUy4qix8=; b=G1Mc3rb2k/xE46XjpxMi5umOerlXePQRyUyTX2MlRCBuPUA5+42eQWp7m0kdpeaA/v ePWSVLRoWkGn14XcqPuYKeIVxSctxcb2rxPqTgH19dr7iIsC6DfokQ2Ru6w51xaBCcoF qBG6LCjZy3sXbOieqQj6hgamPRkmotIj2jc5KHuK8g6NCXoGnDi073DexYIyeZ6zlXj8 PRRv5Z7PNbG5A2hJoxftCMXDGjUe8jFcf6r1Qd2s8K6mNCodmYSCzGlx76aYYGsZJEjQ axPMxjh+mOWcrQKd5qgV1WN7qTAKGjhLCBAN8rTYlMErPSyTT4Sjm+uVCI50a+cFkQEI 55gQ== X-Gm-Message-State: APzg51DU353vTqLHa0uR3upDLzfOKOw8/VIBD5eMnrtnFWcprH/9KW9q XIdoCRv1HK6ztNzZM4pakZeafPlv X-Google-Smtp-Source: ANB0VdY/kL/LYK5s6f9P2oesNnL6idxDI2B7X80FEhHmlr14/vKWaJCT6940fVIhtjnqJPY0gcf6jw== X-Received: by 2002:a62:b20c:: with SMTP id x12-v6mr1271009pfe.201.1536745987241; Wed, 12 Sep 2018 02:53:07 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d132-v6sm1166307pgc.93.2018.09.12.02.53.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 02:53:06 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 12 Sep 2018 19:52:47 +1000 Message-Id: <20180912095248.27557-4-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180912095248.27557-1-oohall@gmail.com> References: <20180912095248.27557-1-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 3/4] hw/phb4: Eliminate p->rte_cache 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" In ancient times we added a caches to struct phb3 for some of the IODA tables that are stored internal to the PHB and can only be accessed indirectly via SCOM. For some reason we also added a cache for the RTT which is an in-memory table that we can just look at directly. This was carried over to phb4 where the RTT has doubled in size to 128KB. There's no real need to have a second copy so remove the "cache" and reference the RTT directly if we need to. This makes struct phb4 smaller and simplifies the code since we don't need to update two copies of the RTT. Signed-off-by: Oliver O'Halloran --- hw/phb4.c | 34 +++++++++++++++------------------- include/phb4.h | 3 +-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/hw/phb4.c b/hw/phb4.c index 7666eefdcb6e..88d7bddfe990 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -276,7 +276,7 @@ static int64_t phb4_pcicfg_check(struct phb4 *p, uint32_t bdfn, return OPAL_HARDWARE; /* Fetch the PE# from cache */ - *pe = p->rte_cache[bdfn]; + *pe = p->tbl_rtt[bdfn]; return OPAL_SUCCESS; } @@ -933,8 +933,6 @@ static void phb4_init_ioda_cache(struct phb4 *p) * ever let a live FF RTT even temporarily when resetting * for EEH etc... (HW278969). */ - for (i = 0; i < ARRAY_SIZE(p->rte_cache); i++) - p->rte_cache[i] = PHB4_RESERVED_PE_NUM(p); memset(p->peltv_cache, 0x0, sizeof(p->peltv_cache)); memset(p->tve_cache, 0x0, sizeof(p->tve_cache)); @@ -1164,7 +1162,9 @@ static int64_t phb4_ioda_reset(struct phb *phb, bool purge) /* Additional OPAL specific inits */ /* Clear RTT and PELTV and PEST */ - memcpy((void *)p->tbl_rtt, p->rte_cache, RTT_TABLE_SIZE); + for (i = 0; i < RTT_TABLE_ENTRIES; i++) + p->tbl_rtt[i] = PHB4_RESERVED_PE_NUM(p); + memcpy((void *)p->tbl_peltv, p->peltv_cache, p->tbl_peltv_size); /* Clear PEST & PEEV */ @@ -2158,7 +2158,6 @@ static int64_t phb4_set_pe(struct phb *phb, { struct phb4 *p = phb_to_phb4(phb); uint64_t mask, val, idx; - uint16_t *rte; /* Sanity check */ if (action != OPAL_MAP_PE && action != OPAL_UNMAP_PE) @@ -2190,16 +2189,14 @@ static int64_t phb4_set_pe(struct phb *phb, } /* Map or unmap the RTT range */ - rte = (uint16_t *)p->tbl_rtt; - for (idx = 0; idx < RTT_TABLE_ENTRIES; idx++, rte++) { + for (idx = 0; idx < RTT_TABLE_ENTRIES; idx++) { if ((idx & mask) != val) continue; if (action == OPAL_MAP_PE) - p->rte_cache[idx] = pe_number; + p->tbl_rtt[idx] = pe_number; else - p->rte_cache[idx] = PHB4_RESERVED_PE_NUM(p); - *rte = p->rte_cache[idx]; + p->tbl_rtt[idx] = PHB4_RESERVED_PE_NUM(p); } /* Invalidate the entire RTC */ @@ -3583,13 +3580,13 @@ static int64_t phb4_err_inject_cfg(struct phb4 *phb, uint64_t pe_number, ctrl = PHB_PAPR_ERR_INJ_CTL_CFG; for (bdfn = 0; bdfn < RTT_TABLE_ENTRIES; bdfn++) { - if (phb->rte_cache[bdfn] != pe_number) + if (phb->tbl_rtt[bdfn] != pe_number) continue; /* The PE can be associated with PCI bus or device */ is_bus_pe = false; if ((bdfn + 8) < RTT_TABLE_ENTRIES && - phb->rte_cache[bdfn + 8] == pe_number) + phb->tbl_rtt[bdfn + 8] == pe_number) is_bus_pe = true; /* Figure out the PCI config address */ @@ -4522,7 +4519,7 @@ static void phb4_init_ioda3(struct phb4 *p) SETFIELD(PHB_LSI_SRC_ID, 0ull, (p->num_irqs - 1) >> 3)); /* Init_20 - RTT BAR */ - out_be64(p->regs + PHB_RTT_BAR, p->tbl_rtt | PHB_RTT_BAR_ENABLE); + out_be64(p->regs + PHB_RTT_BAR, (u64) p->tbl_rtt | PHB_RTT_BAR_ENABLE); /* Init_21 - PELT-V BAR */ out_be64(p->regs + PHB_PELTV_BAR, p->tbl_peltv | PHB_PELTV_BAR_ENABLE); @@ -5019,7 +5016,6 @@ static bool phb4_read_capabilities(struct phb4 *p) static void phb4_allocate_tables(struct phb4 *p) { - uint16_t *rte; uint32_t i; /* XXX Our current memalign implementation sucks, @@ -5028,11 +5024,10 @@ static void phb4_allocate_tables(struct phb4 *p) * the memory and wastes space by always allocating twice * as much as requested (size + alignment) */ - p->tbl_rtt = (uint64_t)local_alloc(p->chip_id, RTT_TABLE_SIZE, RTT_TABLE_SIZE); + p->tbl_rtt = local_alloc(p->chip_id, RTT_TABLE_SIZE, RTT_TABLE_SIZE); assert(p->tbl_rtt); - rte = (uint16_t *)(p->tbl_rtt); - for (i = 0; i < RTT_TABLE_ENTRIES; i++, rte++) - *rte = PHB4_RESERVED_PE_NUM(p); + for (i = 0; i < RTT_TABLE_ENTRIES; i++) + p->tbl_rtt[i] = PHB4_RESERVED_PE_NUM(p); p->tbl_peltv = (uint64_t)local_alloc(p->chip_id, p->tbl_peltv_size, p->tbl_peltv_size); assert(p->tbl_peltv); @@ -5141,7 +5136,8 @@ static void phb4_add_properties(struct phb4 *p) /* Indicators for variable tables */ dt_add_property_cells(np, "ibm,opal-rtt-table", - hi32(p->tbl_rtt), lo32(p->tbl_rtt), RTT_TABLE_SIZE); + hi32((u64) p->tbl_rtt), lo32((u64) p->tbl_rtt), RTT_TABLE_SIZE); + dt_add_property_cells(np, "ibm,opal-peltv-table", hi32(p->tbl_peltv), lo32(p->tbl_peltv), p->tbl_peltv_size); dt_add_property_cells(np, "ibm,opal-pest-table", diff --git a/include/phb4.h b/include/phb4.h index d78bc3175205..b1bdcd7f7660 100644 --- a/include/phb4.h +++ b/include/phb4.h @@ -194,7 +194,7 @@ struct phb4 { uint32_t num_irqs; /* SkiBoot owned in-memory tables */ - uint64_t tbl_rtt; + uint16_t *tbl_rtt; uint64_t tbl_peltv; uint64_t tbl_peltv_size; uint64_t tbl_pest; @@ -212,7 +212,6 @@ struct phb4 { uint64_t mbt_size; uint64_t tvt_size; - uint16_t rte_cache[RTT_TABLE_ENTRIES]; /* FIXME: dynamically allocate only what's needed below */ uint64_t tve_cache[1024]; uint8_t peltv_cache[PELTV_TABLE_SIZE_MAX]; From patchwork Wed Sep 12 09:52:48 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: 968933 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429HFB1tNtz9sBZ for ; Wed, 12 Sep 2018 19:54:38 +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="Ivo6NVU0"; 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 429HFB081SzF35x for ; Wed, 12 Sep 2018 19:54:38 +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="Ivo6NVU0"; 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::544; helo=mail-pg1-x544.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="Ivo6NVU0"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 429HCW0FJWzF35x for ; Wed, 12 Sep 2018 19:53:11 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id d19-v6so797542pgv.1 for ; Wed, 12 Sep 2018 02:53:10 -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=Iv2D/D9OEDXORMZ0pDu6Q4imIjgUz6ta5xVSzJOUfJ8=; b=Ivo6NVU0UOeHb+fqiXJraWUCU3PSQZfAux+ni7PDMop3fJCP2smdgzoNEC2Zi1qj/G hoEhN6Nrt8tj966UyqJXUEXsHyPRLwlZVyt5Izc4DqoUJC0J6DxAToBtjU9NqT6LV9Jw uIyrVdY13d6Kt998v/DgmtWnxaqf7n1/mV1/JrFOXq5yOZ94Yv9zva1ZxX8+AfyN/8xR vYqA+PzdSvUTmoLO7BfaSOWZwGqpQT/NXB2I76q+rHEL6b9CyzuPlfL2zDbFBFb0W80T vOKwFVJuagf1KPShmnaCIGbmX5ZvO03PPUHMrhe3wg3P1ZUoCTMWQbZ42uBOabD2yH7Q NznQ== 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=Iv2D/D9OEDXORMZ0pDu6Q4imIjgUz6ta5xVSzJOUfJ8=; b=ai8/3MumpyxY5ciDUHOCKaSxJZBkhk2bBHemOWhY3v0OuR32SUgYP/TVv1oJLC7Pd3 X3D56sb7d7dDBBy1+FsZfqgvxVNIm0do5IBwk6l3Vb3nd1CSBi/r/AHdgLREhQ8FWAiq rHdaLGOAC8nSY1L9dK03jmKVBzFwA+8en12v1ELWh8GsITdmLugQPZM/vWG1H0BSLO65 ZJp7r7pCJ//AZ1C7sxh+u6IPvaDFnvEATfms1nz+Tj1srPU+I2g/pmHLY2njgvXrrix7 0KZW+6Jh5IEFnxXjmvo2CgEmnJdeQuQaQ7ztGxBlMeCahnD/tcoROL90ErWLIP+mdO6W kgyQ== X-Gm-Message-State: APzg51AhzW/+vUgtx7HXHWPYUfmlMiKC30lj7xKlMCjlmWsladL/5LPG QituOr3lSjaSU5/e9xWv5XFPOw4d X-Google-Smtp-Source: ANB0Vdbo6A/RFp7WDR6wFgINNaB6K8TmFQkPTgWVmVzdZLRsm22Jli1891K3Bo1bdcvcaFXUBBc+GQ== X-Received: by 2002:a63:7217:: with SMTP id n23-v6mr1249520pgc.193.1536745989263; Wed, 12 Sep 2018 02:53:09 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d132-v6sm1166307pgc.93.2018.09.12.02.53.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 02:53:08 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 12 Sep 2018 19:52:48 +1000 Message-Id: <20180912095248.27557-5-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180912095248.27557-1-oohall@gmail.com> References: <20180912095248.27557-1-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 4/4] phb4: Eliminate peltv_cache 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" This is also an in-memory table and there's not a whole lot of point in having two copies of it in the system. This patch removes it and shaves another 128KB off the size of each struct phb4 as a result. Signed-off-by: Oliver O'Halloran --- hw/phb4.c | 30 +++++++++++++----------------- include/phb4.h | 3 +-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/hw/phb4.c b/hw/phb4.c index 88d7bddfe990..a449314e7182 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -933,7 +933,6 @@ static void phb4_init_ioda_cache(struct phb4 *p) * ever let a live FF RTT even temporarily when resetting * for EEH etc... (HW278969). */ - memset(p->peltv_cache, 0x0, sizeof(p->peltv_cache)); memset(p->tve_cache, 0x0, sizeof(p->tve_cache)); /* XXX Should we mask them ? */ @@ -1161,11 +1160,11 @@ static int64_t phb4_ioda_reset(struct phb *phb, bool purge) /* Additional OPAL specific inits */ - /* Clear RTT and PELTV and PEST */ + /* Clear RTT and PELTV */ for (i = 0; i < RTT_TABLE_ENTRIES; i++) p->tbl_rtt[i] = PHB4_RESERVED_PE_NUM(p); - memcpy((void *)p->tbl_peltv, p->peltv_cache, p->tbl_peltv_size); + memset(p->tbl_peltv, 0x0, p->tbl_peltv_size); /* Clear PEST & PEEV */ for (i = 0; i < p->max_num_pes; i++) { @@ -2211,7 +2210,6 @@ static int64_t phb4_set_peltv(struct phb *phb, uint8_t state) { struct phb4 *p = phb_to_phb4(phb); - uint8_t *peltv; uint32_t idx, mask; /* Sanity check */ @@ -2223,15 +2221,10 @@ static int64_t phb4_set_peltv(struct phb *phb, idx += (child_pe / 8); mask = 0x1 << (7 - (child_pe % 8)); - peltv = (uint8_t *)p->tbl_peltv; - peltv += idx; - if (state) { - *peltv |= mask; - p->peltv_cache[idx] |= mask; - } else { - *peltv &= ~mask; - p->peltv_cache[idx] &= ~mask; - } + if (state) + p->tbl_peltv[idx] |= mask; + else + p->tbl_peltv[idx] &= ~mask; return OPAL_SUCCESS; } @@ -4522,7 +4515,8 @@ static void phb4_init_ioda3(struct phb4 *p) out_be64(p->regs + PHB_RTT_BAR, (u64) p->tbl_rtt | PHB_RTT_BAR_ENABLE); /* Init_21 - PELT-V BAR */ - out_be64(p->regs + PHB_PELTV_BAR, p->tbl_peltv | PHB_PELTV_BAR_ENABLE); + out_be64(p->regs + PHB_PELTV_BAR, + (u64) p->tbl_peltv | PHB_PELTV_BAR_ENABLE); /* Init_22 - Setup M32 starting address */ out_be64(p->regs + PHB_M32_START_ADDR, M32_PCI_START); @@ -5029,9 +5023,9 @@ static void phb4_allocate_tables(struct phb4 *p) for (i = 0; i < RTT_TABLE_ENTRIES; i++) p->tbl_rtt[i] = PHB4_RESERVED_PE_NUM(p); - p->tbl_peltv = (uint64_t)local_alloc(p->chip_id, p->tbl_peltv_size, p->tbl_peltv_size); + p->tbl_peltv = local_alloc(p->chip_id, p->tbl_peltv_size, p->tbl_peltv_size); assert(p->tbl_peltv); - memset((void *)p->tbl_peltv, 0, p->tbl_peltv_size); + memset(p->tbl_peltv, 0, p->tbl_peltv_size); p->tbl_pest = (uint64_t)local_alloc(p->chip_id, p->tbl_pest_size, p->tbl_pest_size); assert(p->tbl_pest); @@ -5139,7 +5133,9 @@ static void phb4_add_properties(struct phb4 *p) hi32((u64) p->tbl_rtt), lo32((u64) p->tbl_rtt), RTT_TABLE_SIZE); dt_add_property_cells(np, "ibm,opal-peltv-table", - hi32(p->tbl_peltv), lo32(p->tbl_peltv), p->tbl_peltv_size); + hi32((u64) p->tbl_peltv), lo32((u64) p->tbl_peltv), + p->tbl_peltv_size); + dt_add_property_cells(np, "ibm,opal-pest-table", hi32(p->tbl_pest), lo32(p->tbl_pest), p->tbl_pest_size); diff --git a/include/phb4.h b/include/phb4.h index b1bdcd7f7660..2057fcd0f1b5 100644 --- a/include/phb4.h +++ b/include/phb4.h @@ -195,7 +195,7 @@ struct phb4 { /* SkiBoot owned in-memory tables */ uint16_t *tbl_rtt; - uint64_t tbl_peltv; + uint8_t *tbl_peltv; uint64_t tbl_peltv_size; uint64_t tbl_pest; uint64_t tbl_pest_size; @@ -214,7 +214,6 @@ struct phb4 { /* FIXME: dynamically allocate only what's needed below */ uint64_t tve_cache[1024]; - uint8_t peltv_cache[PELTV_TABLE_SIZE_MAX]; uint64_t mbt_cache[32][2]; uint64_t mdt_cache[512]; /* max num of PEs */ uint64_t mist_cache[4096/4];/* max num of MSIs */