From patchwork Thu Feb 22 00:23:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Bobroff X-Patchwork-Id: 876446 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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 3zmw9Z4SMnz9sW9 for ; Thu, 22 Feb 2018 11:25:22 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmw9Z2LNtzF0p5 for ; Thu, 22 Feb 2018 11:25:22 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=sam.bobroff@au1.ibm.com; receiver=) 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 3zmw7l3VrnzF0p8 for ; Thu, 22 Feb 2018 11:23:47 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1M0MKl6112603 for ; Wed, 21 Feb 2018 19:23:44 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2g9hs22jef-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Feb 2018 19:23:44 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Feb 2018 00:23:42 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Feb 2018 00:23:39 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1M0NcNn50331838; Thu, 22 Feb 2018 00:23:38 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 261964C040; Thu, 22 Feb 2018 00:17:15 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C74AF4C044; Thu, 22 Feb 2018 00:17:14 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Feb 2018 00:17:14 +0000 (GMT) Received: from tungsten.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id E5480A00D7; Thu, 22 Feb 2018 11:23:36 +1100 (AEDT) Date: Thu, 22 Feb 2018 11:23:35 +1100 From: Sam Bobroff To: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH RFC 1/1] powerpc/pseries: fix EEH recovery of IOV devices Mail-Followup-To: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, mpe@ellerman.id.au, bhelgaas@google.com, bryantly@linux.vnet.ibm.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.3 (2018-01-21) X-TM-AS-GCONF: 00 x-cbid: 18022200-0020-0000-0000-000003FA49B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022200-0021-0000-0000-0000428E5C87 Message-Id: <4bd50291799b920b42f8a12f5635c40ccae1302e.1519258921.git.sam.bobroff@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-21_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802220003 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bhelgaas@google.com, bryantly@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Currently EEH recovery will fail on pSeries platforms for passed-through physical devices that support IOV, when CONFIG_PCI_IOV is set and the hypervisor doesn't provide a device tree node "ibm,open-sriov-vf-bar-info" for the device. (Found on an IOV capable device using the ipr driver.) EEH recovery fails in pci_enable_resources() at the check on r->parent, because r->flags is set and r->parent is not. This state is due to sriov_init() setting the start, end and flags members of the IOV BARs but the parent not being set later in pseries_pci_fixup_iov_resources(), because the "ibm,open-sriov-vf-bar-info" property is missing, causing it to bail out early. Correct this by zeroing the IOV resources in the bailout path, so that they are not seen by pci_enable_resources(). Signed-off-by: Sam Bobroff --- Hi, This is a fix to allow EEH recovery to succeed in a specific situation, which I've tried to explain in the commit message. But while I'm fairly sure of the situation leading up to the problem, I'm not sure how it should be fixed, which is why I've posted this as an RFC. Just zeroing out the flags is sufficient in my tests but it seemed cleaner to also clear start and end, but other changes would work as well: just clearing the flags, or just removing IORESOURCE_IO and IORESOURCE_MEM or even adding some new flag and also adjusting the test. Perhaps there's something else. I'm not sure what implications these choices have for the generic PCI code so I would appreciate feedback on it. Note that this problem doesn't seem to have been introduced by pseries_pci_fixup_iov_resources() (which was added recently): recovery already failed (in this way) before it's introduction. arch/powerpc/platforms/pseries/setup.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 372d7ada1a0c..019836ffe53d 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -618,13 +618,24 @@ static void pseries_pci_fixup_iov_resources(struct pci_dev *pdev) { const int *indexes; struct device_node *dn = pci_device_to_OF_node(pdev); + int i; + struct resource *r; if (!pdev->is_physfn || pdev->is_added) return; /*Firmware must support open sriov otherwise dont configure*/ indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL); - if (!indexes) + if (!indexes) { + /* Hide the BARs we can't configure, otherwise other + * code may see r->flags != 0 and r->parent == 0 + * and raise an error. */ + pci_warn(pdev, "No hypervisor support for SRIOV on this device, IOV BARs disabled.\n"); + for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { + r = &pdev->resource[PCI_IOV_RESOURCES + i]; + r->start = r->end = r->flags = 0; + } return; + } /* Assign the addresses from device tree*/ of_pci_parse_iov_addrs(pdev, indexes); }