Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3685347pxb; Mon, 24 Jan 2022 15:18:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWTh+KKuqzpRQRl7C7hQLRNRaXUGaEGCJSY5X88hEWN5uuKQ+2RyIYdBWFcYM+bGaRfWnC X-Received: by 2002:a17:903:247:b0:149:b6f1:3c8b with SMTP id j7-20020a170903024700b00149b6f13c8bmr16430447plh.83.1643066336974; Mon, 24 Jan 2022 15:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066336; cv=none; d=google.com; s=arc-20160816; b=zpSqFxt+VBeDCV1THowdNO8b96qmCqehP9G0+LE5Km/A3emB/t9h1eBTWMtWLliRZX 1A9ivkk2qdNedvkDJe8yXlIxbnTOsbJH6HyAVFbTCZmEXWw3XN/F0pIFyikBGAZGocSS cBMkyLyr5sFWAMl6E4Mq6036vw27eO1fAazymXjv9A9um1Br0OL1i/aoAQ3zh4oE8O4i hatFFvxO+Y7xfQhtyxJlv/c7p6ZmkcVHKLgUkVG3oha7yZ3VHrp8+t65W0uuWy7t/X4M As7qYJsZ8/XcFacLYXmXbS6OPFdspvJgLTxi++4TfMldpiX2yLiav/fMsWThHx9X6kVH iMmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hO/CoS6fneoSANCf9bxiBmLQpCInDBRM9KB73m5M0BE=; b=nR1Cgu9FZH/xWQQpFV2M4+gvewgj7JTQyv1EVB+bnhtRSNfYBYExAASXHilne4U67w 0ISM9PLGRpQps7zzpftYpqpi2hfNGJMFlp/J//vGTkpIkD70mwp4Pwpp2bY2/KZMRUGu Pnj6zIfkRl6FlJFRu529/LxPJh7IGg4mzRQlJuEe/P2+NOVPjt6TYKliSbcVjLdWUS8q sZUFPPofutxDOdV6I3bXq/PT/YGtfG2Hs3iCA9Yb5NX+O+yUcDzifvcChUpX/7wclUs0 Bv9fTBk7pgRNpCpfU1NtjK7//5VVBJCUWDi6teirvwl6UxJLhot6Fmoc2GDdpAq3KoiE rYOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C1ifqwSs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si10819942pgj.229.2022.01.24.15.18.45; Mon, 24 Jan 2022 15:18:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C1ifqwSs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1845085AbiAXXLP (ORCPT + 99 others); Mon, 24 Jan 2022 18:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1582623AbiAXWPd (ORCPT ); Mon, 24 Jan 2022 17:15:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF6FC04A2C6; Mon, 24 Jan 2022 12:45:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A7656090B; Mon, 24 Jan 2022 20:45:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED58AC340E5; Mon, 24 Jan 2022 20:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057102; bh=4KnP9f2BG2N0gQWpClCCaBlbp1tyU3Pjw2Z1LPrgmQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C1ifqwSsvDfwybRjcENN3ZiV17Adc7KfhKKP0ujE2arw4KM1jsh7N5lhbP1z0d1H4 ASdGiVMEsGmtFO4WRPZeQZWQAArB7FVLVevR12MkPypNXV1wYh3sniCB66JaQYvBNL 4TOcIgm/fZiO/wZ4E7OBWqMrduB21LRRWauzHD28= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joseph Bao , Lukas Wunner , Bjorn Helgaas , Stuart Hayes Subject: [PATCH 5.15 702/846] PCI: pciehp: Fix infinite loop in IRQ handler upon power fault Date: Mon, 24 Jan 2022 19:43:39 +0100 Message-Id: <20220124184125.262745168@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 23584c1ed3e15a6f4bfab8dc5a88d94ab929ee12 upstream. The Power Fault Detected bit in the Slot Status register differs from all other hotplug events in that it is sticky: It can only be cleared after turning off slot power. Per PCIe r5.0, sec. 6.7.1.8: If a power controller detects a main power fault on the hot-plug slot, it must automatically set its internal main power fault latch [...]. The main power fault latch is cleared when software turns off power to the hot-plug slot. The stickiness used to cause interrupt storms and infinite loops which were fixed in 2009 by commits 5651c48cfafe ("PCI pciehp: fix power fault interrupt storm problem") and 99f0169c17f3 ("PCI: pciehp: enable software notification on empty slots"). Unfortunately in 2020 the infinite loop issue was inadvertently reintroduced by commit 8edf5332c393 ("PCI: pciehp: Fix MSI interrupt race"): The hardirq handler pciehp_isr() clears the PFD bit until pciehp's power_fault_detected flag is set. That happens in the IRQ thread pciehp_ist(), which never learns of the event because the hardirq handler is stuck in an infinite loop. Fix by setting the power_fault_detected flag already in the hardirq handler. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214989 Link: https://lore.kernel.org/linux-pci/DM8PR11MB5702255A6A92F735D90A4446868B9@DM8PR11MB5702.namprd11.prod.outlook.com Fixes: 8edf5332c393 ("PCI: pciehp: Fix MSI interrupt race") Link: https://lore.kernel.org/r/66eaeef31d4997ceea357ad93259f290ededecfd.1637187226.git.lukas@wunner.de Reported-by: Joseph Bao Tested-by: Joseph Bao Signed-off-by: Lukas Wunner Signed-off-by: Bjorn Helgaas Cc: stable@vger.kernel.org # v4.19+ Cc: Stuart Hayes Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_hpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -642,6 +642,8 @@ read_status: */ if (ctrl->power_fault_detected) status &= ~PCI_EXP_SLTSTA_PFD; + else if (status & PCI_EXP_SLTSTA_PFD) + ctrl->power_fault_detected = true; events |= status; if (!events) { @@ -651,7 +653,7 @@ read_status: } if (status) { - pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, events); + pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, status); /* * In MSI mode, all event bits must be zero before the port @@ -725,8 +727,7 @@ static irqreturn_t pciehp_ist(int irq, v } /* Check Power Fault Detected */ - if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { - ctrl->power_fault_detected = 1; + if (events & PCI_EXP_SLTSTA_PFD) { ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl)); pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, PCI_EXP_SLTCTL_ATTN_IND_ON);