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 */