From patchwork Tue Jul 31 08:43:22 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: 951473 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fqjB133Yz9rxx for ; Tue, 31 Jul 2018 18:43:42 +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="pnADAYH6"; 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 41fqj96RQxzF153 for ; Tue, 31 Jul 2018 18:43:41 +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="pnADAYH6"; 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::541; helo=mail-pg1-x541.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="pnADAYH6"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (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 41fqj46VB6zF14l for ; Tue, 31 Jul 2018 18:43:36 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id p23-v6so8717608pgv.13 for ; Tue, 31 Jul 2018 01:43:36 -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=3USCsLIMDD2NpDPa4LonGs5sN5rcn7ZNYkLo0ccvaVY=; b=pnADAYH6JBUXahvFhSQE39K78Jq6+c31eqZ2sgDIo2VmKdfz8DC2rmvU5jbXr7NtSh dZad0PcBMxJJK1nPiUk6+ShpS7/uIy6WE/y4IIqDE3DwxQrk37lmmNbxQJkw7Jy4pqfC 9xJm+etYZOrsz/RCHOLCMj8yd220gBS1BqBCrGKoKsA+QaItepFTHQ4YHd7qyRM/gdtS Jl2hCwEe5B8szRU/H+/PPe1BFC1c+8uIdSPDwxV7nV8gQuAepyrOPPx2PA7MThtP+lmD fo9C0j4u94IHw9GeSJ2GtDIon9XVqinkDyrLyTVX09vCjxfefYHT+kKM/gWtxeg86MK+ dEjA== 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=3USCsLIMDD2NpDPa4LonGs5sN5rcn7ZNYkLo0ccvaVY=; b=hx+FdN1ezVoIjGyMVSV2EXcu4MagFcPVbsT7K2+imResWgZvfVU0DeqWxky85+piyr bvs1LRP1k3tezWFQwT5UEyr/trzbi7oJbsSeFS0RJLzIK4Q5zNnP8ICQeu8UnEHFATy4 I1FStkghKcnuMCrBVT5sncflGaukHpruyA/UisP1QPScwpxTTBGkU+2ytE7A91M0y8Ww Ym1bXrfMPI4hvaQoKcp72XwWn26oyC6rCZeyYG00/cpd2JEylPMj0w0AOA3cK1ZdqXqI PHeG92Mcb40oMls5Sl2zo6bhWNzvDpI5LHDbrgK40CeerfCxg6NsoJIZvw5xxK8Be2+k ADxg== X-Gm-Message-State: AOUpUlFxXDKnNPVWW59Wl/fu20cZzfKigp9QtDhOEmTwkoI4eSMi2MCD LhDz1WytYM2Tmo/2pL59fM96PCbF X-Google-Smtp-Source: AAOMgpelMvvx9XyKBHdb2GVHiathtfJrRlIopT6Crva2qIqiQQjFIzX6S7wh45YhRrsqFtnGT7mCTw== X-Received: by 2002:a63:67c3:: with SMTP id b186-v6mr19625380pgc.5.1533026614278; Tue, 31 Jul 2018 01:43:34 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d22-v6sm20947627pfk.69.2018.07.31.01.43.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 01:43:33 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 31 Jul 2018 18:43:22 +1000 Message-Id: <20180731084322.25473-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [Skiboot] [PATCH] pci: Clarify power down logic X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 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 pci_scan_bus() unconditionally calls pci_slot_set_power_state() when it's finished scanning a bus. This is one of those things that makes you go "WHAT?" when you first see it and frankly the skiboot PCI code could do with less of that. Signed-off-by: Oliver O'Halloran --- core/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/pci.c b/core/pci.c index 5ec7dabd94eb..cd196b5ab26b 100644 --- a/core/pci.c +++ b/core/pci.c @@ -406,8 +406,10 @@ static void pci_slot_set_power_state(struct phb *phb, if (state == PCI_SLOT_POWER_OFF) { /* Bail if there're something connected */ - if (!list_empty(&pd->children)) + if (!list_empty(&pd->children)) { + PCIERR(phb, pd->bdfn, "Attempted to power off slot with attached devices!\n"); return; + } pci_slot_add_flags(slot, PCI_SLOT_FLAG_BOOTUP); rc = slot->ops.get_power_state(slot, &cur_state); @@ -920,7 +922,9 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus, pci_cfg_write8(phb, pd->bdfn, PCI_CFG_SUBORDINATE_BUS, max_sub); next_bus = max_sub + 1; - pci_slot_set_power_state(phb, pd, PCI_SLOT_POWER_OFF); + /* power off the slot if there's nothing below it */ + if (list_empty(&pd->children)) + pci_slot_set_power_state(phb, pd, PCI_SLOT_POWER_OFF); } return max_sub;