From patchwork Thu Oct 13 01:16:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 681547 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3svXsL4x8kz9s9c for ; Thu, 13 Oct 2016 12:17:42 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3svXsL49n7zDsyx for ; Thu, 13 Oct 2016 12:17:42 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3svXqn6QPzzDsxm for ; Thu, 13 Oct 2016 12:16:21 +1100 (AEDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9D1DxWo000618 for ; Wed, 12 Oct 2016 21:16:19 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0b-001b2d01.pphosted.com with ESMTP id 261x05n3h8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Oct 2016 21:16:19 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Oct 2016 11:16:16 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Oct 2016 11:16:14 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 261FE2CE8057 for ; Thu, 13 Oct 2016 12:16:14 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9D1GEpC59179254 for ; Thu, 13 Oct 2016 12:16:14 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9D1GDNf019236 for ; Thu, 13 Oct 2016 12:16:13 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u9D1GDQE019230; Thu, 13 Oct 2016 12:16:13 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id B7EE5A016E; Thu, 13 Oct 2016 12:16:13 +1100 (AEDT) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id B2730E3C49; Thu, 13 Oct 2016 12:16:13 +1100 (AEDT) Received: by gwshan (Postfix, from userid 1000) id 61125942DC9; Thu, 13 Oct 2016 12:16:58 +1100 (AEDT) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Thu, 13 Oct 2016 12:16:48 +1100 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1476321413-5245-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1476321413-5245-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101301-0012-0000-0000-000001D61E06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101301-0013-0000-0000-0000063392D1 Message-Id: <1476321413-5245-5-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-12_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610130018 Subject: [Skiboot] [PATCH v2 4/9] core/pci: Update PCI topology after power change 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" When OPAL_SUCCESS is returned from slot->ops.set_power_state(), we need update the PCI toplogy accordingly. This scenario can happen when builtin power control functionality is ignored to accomodate PCI surprise hotplug or not supported at all by the hardware. Signed-off-by: Gavin Shan Reviewed-by: Andrew Donnellan --- core/pci-opal.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/pci-opal.c b/core/pci-opal.c index ba7a261..7ba64f5 100644 --- a/core/pci-opal.c +++ b/core/pci-opal.c @@ -805,8 +805,8 @@ static int64_t opal_pci_set_power_state(uint64_t async_token, return OPAL_PARAMETER; pci_remove_bus(phb, &pd->children); - rc = OPAL_SUCCESS; - break; + phb_unlock(phb); + return OPAL_SUCCESS; case OPAL_PCI_SLOT_ONLINE: if (!pd) return OPAL_PARAMETER; @@ -814,19 +814,29 @@ static int64_t opal_pci_set_power_state(uint64_t async_token, &pd->children, pd, true); pci_add_device_nodes(phb, &pd->children, pd->dn, &phb->lstate, 0); - rc = OPAL_SUCCESS; - break; + phb_unlock(phb); + return OPAL_SUCCESS; default: rc = OPAL_PARAMETER; } - phb_unlock(phb); if (rc == OPAL_ASYNC_COMPLETION) { slot->retries = 500; init_timer(&slot->timer, set_power_timer, slot); schedule_timer(&slot->timer, msecs_to_tb(10)); + } else if (rc == OPAL_SUCCESS) { + if (*state == OPAL_PCI_SLOT_POWER_OFF) { + pci_remove_bus(phb, &pd->children); + } else { + slot->ops.prepare_link_change(slot, true); + pci_scan_bus(phb, pd->secondary_bus, + pd->subordinate_bus, &pd->children, pd, true); + pci_add_device_nodes(phb, &pd->children, pd->dn, + &phb->lstate, 0); + } } + phb_unlock(phb); return rc; } opal_call(OPAL_PCI_SET_POWER_STATE, opal_pci_set_power_state, 3);