From patchwork Tue Jun 18 20:49:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 13703019 X-Patchwork-Delegate: bhelgaas@google.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B98D017D89D; Tue, 18 Jun 2024 20:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718743794; cv=none; b=fOOhHcKDAwB3mArmvycD/EHn45c2HfasWg7bEWGF5ITRS8BOtq5Qam/1UBZFgCq4jFCTPyrgXG70nxHhHKIVre5RgRw+DCvgCdJBsex68Kyu/Ev3gAgAHUUMzi2tRe8jB09m2lH9uIx8xYhk5NR0V3Z59PWG4gxbIVER9jruynY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718743794; c=relaxed/simple; bh=JHzSKxuAUt5sskKJDUz7UVvUr/rjQm56XYg7g79WgHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=in8EN7CSnSTz0Nbp2e7OVrloGMIg37QhV/ymg5IWAgjyR9oeRKJz9KnSzjI4WTKqysOPPluLoXBDKHPDI1WR/KilXVyMp2thpGwmFA1QwgC0IJGP72BlKCblQZg/F3xcJiV97+aFNYAslFE2LXr8BoO3vgh2N7vFxaksscl4Sss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V1HaqRJP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V1HaqRJP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 049C7C32786; Tue, 18 Jun 2024 20:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718743794; bh=JHzSKxuAUt5sskKJDUz7UVvUr/rjQm56XYg7g79WgHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1HaqRJPzz0zJSG/rrBID1OFWnkvPyXQUHG+2hFSO5FynGak2I85FGd3Iw+wsZPTK rTgSR9XE2n4Uft8hL0UMAfhPVKYDZkcaVAIcBRM0W1sEzYD8FZ3Bo+lZF2RRGn4L4F /xC2B7x5WEaF22/wfFgIhMXWxjiRWxCfjH7iVJDFiENoWSRCrMbkshsxk1QBnJHq8u 1Gt+UxrkNlyAulGCl0fTJ1BL+L+bPpzfNrO0xq8iJC3hEP1Z1ddHLUukq9IrXB+G8c 2YiEdaYr1dvxeaLJIVU1fUXSicM3+dJ1o/084SxMmFybN3tLXBfvV2ae5tSRfq7Axn 9FcmsnYLNW7Xg== From: Bjorn Helgaas To: Kai-Heng Feng Cc: Mahesh J Salgaonkar , Oliver O'Halloran , Bagas Sanjaya , Chaitanya Kulkarni , Christoph Hellwig , Thomas Crider , Keith Busch , Sagi Grimberg , Hannes Reinecke , "Rafael J . Wysocki" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-nvme@lists.infradead.org, regressions@lists.linux.dev, Bjorn Helgaas Subject: [PATCH v9 1/2] PCI/AER: Disable AER service on suspend Date: Tue, 18 Jun 2024 15:49:45 -0500 Message-Id: <20240618204946.1271042-2-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240618204946.1271042-1-helgaas@kernel.org> References: <20240618204946.1271042-1-helgaas@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kai-Heng Feng If the link is powered off during suspend, electrical noise may cause errors that are logged via AER. If the AER interrupt is enabled and shares an IRQ with PME, that causes a spurious wakeup during suspend. Disable the AER interrupt during suspend to prevent this. Clear error status before re-enabling IRQ interrupts during resume so we don't get an interrupt for errors that occurred during the suspend/resume process. Link: https://bugzilla.kernel.org/show_bug.cgi?id=209149 Link: https://bugzilla.kernel.org/show_bug.cgi?id=216295 Link: https://bugzilla.kernel.org/show_bug.cgi?id=218090 Link: https://lore.kernel.org/r/20240416043225.1462548-2-kai.heng.feng@canonical.com Signed-off-by: Kai-Heng Feng [bhelgaas: drop pci_ancestor_pr3_present() etc, commit log] Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/aer.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ac6293c24976..13b8586924ea 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1497,6 +1497,22 @@ static int aer_probe(struct pcie_device *dev) return 0; } +static int aer_suspend(struct pcie_device *dev) +{ + struct aer_rpc *rpc = get_service_data(dev); + + aer_disable_rootport(rpc); + return 0; +} + +static int aer_resume(struct pcie_device *dev) +{ + struct aer_rpc *rpc = get_service_data(dev); + + aer_enable_rootport(rpc); + return 0; +} + /** * aer_root_reset - reset Root Port hierarchy, RCEC, or RCiEP * @dev: pointer to Root Port, RCEC, or RCiEP @@ -1561,6 +1577,8 @@ static struct pcie_port_service_driver aerdriver = { .service = PCIE_PORT_SERVICE_AER, .probe = aer_probe, + .suspend = aer_suspend, + .resume = aer_resume, .remove = aer_remove, }; From patchwork Tue Jun 18 20:49:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 13703020 X-Patchwork-Delegate: bhelgaas@google.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE181849D9; Tue, 18 Jun 2024 20:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718743797; cv=none; b=HnRpYm4tSF+E6xjMAXR7TkqlXTJ3+pGBr5YI7VYnv9PEBvhXq6DrAO0/tl+jLIt1TTF5c37F5HLuv/lGr/h38HrnL33CE3oymAepduDhlwek/nVV8deTG8Gvc/g47w5Pya5dwc67khWpOLXw+swESUc7r55MfrWyaURrQwz4QKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718743797; c=relaxed/simple; bh=nWvu4xD/ZWqP07Vpa00QmystiTTKLULzlnACslOaj5g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CKYDA5VDP31meJy2Q5lKkWQNEueTChsneoEpLCnyV1KVxK4mbecn29diMVX5rQzokgvadzr6jenbGzNnoBApgDCCdgGfBjpdrcrHKKu6vbF1t1XIIi/HY0g9L2fbTh5gRNn7OLs6GpqXW4SLeEqCEBvaZKL7GdPl+YTcuqRV2fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AFOC9i5u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AFOC9i5u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CC5FC3277B; Tue, 18 Jun 2024 20:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718743797; bh=nWvu4xD/ZWqP07Vpa00QmystiTTKLULzlnACslOaj5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFOC9i5uzOEc+h06SkTXVzqBL+SY1r2NhEjiQV1lCcVhfWMQXtOM6EsBH67FIPFov 5ixgjGT9ViA8g1ZGcjWs31USZ+BF2D8sSguljJLOJ8im8co8W1BVbtLcyIlJgzHLAf PLsLIMCnMNcdiTs/kAhA0w/KC0xPKlkcgvbpaaJt0Kj8Cp30vl760uj6zSjK4odXGm tVpbER2+vqq+m6rp40iusBzTPEQULlBjCAf98+vqbJZCCVCz9KHFjWlYJeLjWfz0Mr 8Pq+BSjpyZi4VfV2OT1n4K0WHB/uNmx6eTYffgMpGqy1WbaBtK4HGLp5y+HxnNkCsF bUxlk3Vhf9ZKQ== From: Bjorn Helgaas To: Kai-Heng Feng Cc: Mahesh J Salgaonkar , Oliver O'Halloran , Bagas Sanjaya , Chaitanya Kulkarni , Christoph Hellwig , Thomas Crider , Keith Busch , Sagi Grimberg , Hannes Reinecke , "Rafael J . Wysocki" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-nvme@lists.infradead.org, regressions@lists.linux.dev, Bjorn Helgaas Subject: [PATCH v9 2/2] PCI/DPC: Disable DPC service on suspend Date: Tue, 18 Jun 2024 15:49:46 -0500 Message-Id: <20240618204946.1271042-3-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240618204946.1271042-1-helgaas@kernel.org> References: <20240618204946.1271042-1-helgaas@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kai-Heng Feng If the link is powered off during suspend, electrical noise may cause errors that trigger DPC. If the DPC interrupt is enabled and shares an IRQ with PME, that causes a spurious wakeup during suspend. Disable DPC triggering and the DPC interrupt during suspend to prevent this. Clear DPC interrupt status before re-enabling DPC interrupts during resume so we don't get an interrupt for errors that occurred during the suspend/resume process. Link: https://bugzilla.kernel.org/show_bug.cgi?id=209149 Link: https://bugzilla.kernel.org/show_bug.cgi?id=216295 Link: https://bugzilla.kernel.org/show_bug.cgi?id=218090 Link: https://lore.kernel.org/r/20240416043225.1462548-3-kai.heng.feng@canonical.com Signed-off-by: Kai-Heng Feng [bhelgaas: clear status on resume, add comments, commit log] Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/dpc.c | 60 +++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index a668820696dc..2b6ef7efa3c1 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -412,13 +412,44 @@ void pci_dpc_init(struct pci_dev *pdev) } } +static void dpc_enable(struct pcie_device *dev) +{ + struct pci_dev *pdev = dev->port; + int dpc = pdev->dpc_cap; + u16 ctl; + + /* + * Clear DPC Interrupt Status so we don't get an interrupt for an + * old event when setting DPC Interrupt Enable. + */ + pci_write_config_word(pdev, dpc + PCI_EXP_DPC_STATUS, + PCI_EXP_DPC_STATUS_INTERRUPT); + + pci_read_config_word(pdev, dpc + PCI_EXP_DPC_CTL, &ctl); + ctl &= ~PCI_EXP_DPC_CTL_EN_MASK; + ctl |= PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN; + pci_write_config_word(pdev, dpc + PCI_EXP_DPC_CTL, ctl); +} + +static void dpc_disable(struct pcie_device *dev) +{ + struct pci_dev *pdev = dev->port; + int dpc = pdev->dpc_cap; + u16 ctl; + + /* Disable DPC triggering and DPC interrupts */ + pci_read_config_word(pdev, dpc + PCI_EXP_DPC_CTL, &ctl); + ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN); + pci_write_config_word(pdev, dpc + PCI_EXP_DPC_CTL, ctl); +} + #define FLAG(x, y) (((x) & (y)) ? '+' : '-') static int dpc_probe(struct pcie_device *dev) { struct pci_dev *pdev = dev->port; struct device *device = &dev->device; int status; - u16 ctl, cap; + u16 cap; if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native) return -ENOTSUPP; @@ -433,11 +464,7 @@ static int dpc_probe(struct pcie_device *dev) } pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CAP, &cap); - - pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, &ctl); - ctl &= ~PCI_EXP_DPC_CTL_EN_MASK; - ctl |= PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN; - pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl); + dpc_enable(dev); pci_info(pdev, "enabled with IRQ %d\n", dev->irq); pci_info(pdev, "error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n", @@ -450,14 +477,21 @@ static int dpc_probe(struct pcie_device *dev) return status; } +static int dpc_suspend(struct pcie_device *dev) +{ + dpc_disable(dev); + return 0; +} + +static int dpc_resume(struct pcie_device *dev) +{ + dpc_enable(dev); + return 0; +} + static void dpc_remove(struct pcie_device *dev) { - struct pci_dev *pdev = dev->port; - u16 ctl; - - pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, &ctl); - ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN); - pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl); + dpc_disable(dev); } static struct pcie_port_service_driver dpcdriver = { @@ -465,6 +499,8 @@ static struct pcie_port_service_driver dpcdriver = { .port_type = PCIE_ANY_PORT, .service = PCIE_PORT_SERVICE_DPC, .probe = dpc_probe, + .suspend = dpc_suspend, + .resume = dpc_resume, .remove = dpc_remove, };