From patchwork Sun Feb 19 23:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 729682 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 3vRNzq6nq4z9s86 for ; Mon, 20 Feb 2017 11:00:07 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vRNzq5sghzDqKP for ; Mon, 20 Feb 2017 11:00:07 +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 3vRNz02XjbzDqH9 for ; Mon, 20 Feb 2017 10:59:24 +1100 (AEDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1JNsGO0022521 for ; Sun, 19 Feb 2017 18:59:21 -0500 Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) by mx0a-001b2d01.pphosted.com with ESMTP id 28q6rfjkqb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 19 Feb 2017 18:59:21 -0500 Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Feb 2017 09:59:18 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Feb 2017 09:59:16 +1000 Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 49B692BB0045 for ; Mon, 20 Feb 2017 10:59:16 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1JNx8Lv29556836 for ; Mon, 20 Feb 2017 10:59:16 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1JNwhGd018826 for ; Mon, 20 Feb 2017 10:58:44 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1JNwhKh018333; Mon, 20 Feb 2017 10:58:43 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 7CB82A03B0; Mon, 20 Feb 2017 10:57:57 +1100 (AEDT) Received: from gwshan.ozlabs.ibm.com (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 708CBE38CA; Mon, 20 Feb 2017 10:57:57 +1100 (AEDT) Received: by gwshan.ozlabs.ibm.com (Postfix, from userid 1000) id 66FBDAC2769; Mon, 20 Feb 2017 10:57:57 +1100 (AEDT) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Mon, 20 Feb 2017 10:57:50 +1100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487548672-20356-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1487548672-20356-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021923-0016-0000-0000-0000021B4B0F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021923-0017-0000-0000-00000671A648 Message-Id: <1487548672-20356-7-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-19_18:, , 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-1612050000 definitions=main-1702190236 Subject: [Skiboot] [PATCH v2 6/8] astbmc/p8dnu: Enable PCI slot's power supply on PEX9733 in hot-add path 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: , Cc: hankmax0000@gmail.com, Gavin Shan , williel@supermicro.com.tw MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This issue is reported from superMicro's "p8dnu" platform. PEX9733 is connected to PHB direct slot. We create dynamic PCI slots for its (5) downstream ports and all of them support surprise hotplug capability. The problem is power supply lost on hot-remove and it isn't turned on automatically on hot-add. It means the PCIe link behind the slot isn't up and the PCI adapter behind the slot can't be probed successfully. This fixes the issue by forcing to turn on the power supply on hardware when user (kernel) requests to do so. Those PCI slots are identified by additional flag (PCI_SLOT_FLAG_FORCE_POWERON). Reported-by: Hank Chang Signed-off-by: Gavin Shan Tested-by: Willie Liauw --- core/pcie-slot.c | 13 ++++++++++--- include/pci-slot.h | 1 + platforms/astbmc/slots.c | 13 +++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/pcie-slot.c b/core/pcie-slot.c index 72068ba..e92aa8d 100644 --- a/core/pcie-slot.c +++ b/core/pcie-slot.c @@ -227,15 +227,22 @@ static int64_t pcie_slot_set_power_state_ext(struct pci_slot *slot, uint8_t val, * only concerned in surprise hotplug path. In managed hot-add path, * the PCIe link should have been ready before we power on the slot. * However, it's not harmful to do so in managed hot-add path. + * + * When flag PCI_SLOT_FLAG_FORCE_POWERON is set for the PCI slot, we + * should turn on the slot's power supply on hardware on user's request + * because that might have been lost. Otherwise, the PCIe link behind + * the slot won't become ready for ever and PCI adapter behind the slot + * can't be probed successfully. */ if (surprise_check && slot->surprise_pluggable) { slot->power_state = val; - if (val == PCI_SLOT_POWER_ON) { + if (val == PCI_SLOT_POWER_OFF) + return OPAL_SUCCESS; + + if (!pci_slot_has_flags(slot, PCI_SLOT_FLAG_FORCE_POWERON)) { pci_slot_set_state(slot, PCI_SLOT_STATE_SPOWER_DONE); return OPAL_ASYNC_COMPLETION; } - - return OPAL_SUCCESS; } pci_slot_set_state(slot, PCI_SLOT_STATE_SPOWER_START); diff --git a/include/pci-slot.h b/include/pci-slot.h index ce3e8dd..7f16ddd 100644 --- a/include/pci-slot.h +++ b/include/pci-slot.h @@ -146,6 +146,7 @@ struct pci_slot_ops { struct pci_slot { uint32_t flags; #define PCI_SLOT_FLAG_BOOTUP 0x1 +#define PCI_SLOT_FLAG_FORCE_POWERON 0x2 struct phb *phb; struct pci_device *pd; diff --git a/platforms/astbmc/slots.c b/platforms/astbmc/slots.c index aeca007..f28ad7d 100644 --- a/platforms/astbmc/slots.c +++ b/platforms/astbmc/slots.c @@ -166,6 +166,19 @@ static void create_dynamic_slot(struct phb *phb, struct pci_device *pd) slot = pcie_slot_create(phb, pd); assert(slot); init_slot_info(slot, true, NULL); + + /* On superMicro's "p8dnu" platform, we create dynamic PCI slots + * for all downstream ports of PEX9733 that is connected to PHB + * direct slot. The power supply to the PCI slot is lost after + * PCI adapter is removed from it. The power supply can't be + * turned on when the slot is in empty state. The power supply + * isn't turned on automatically when inserting PCI adapter to + * the slot at later point. We set a flag to the slot here, to + * turn on the power supply in (suprise or managed) hot-add path. + */ + if (dt_node_is_compatible(dt_root, "supermicro,p8dnu") && + slot->pd && slot->pd->vdid == 0x973310b5) + pci_slot_add_flags(slot, PCI_SLOT_FLAG_FORCE_POWERON); } void slot_table_get_slot_info(struct phb *phb, struct pci_device *pd)