Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp948854rwl; Thu, 10 Aug 2023 04:21:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoeZvMTXLsKYEpGnHeC0IhEyW6pGCf8e5qDQZWunNXn17qMrHI6mezP8xHUSd3b9+uetPr X-Received: by 2002:a05:6a20:1613:b0:10f:1d33:d667 with SMTP id l19-20020a056a20161300b0010f1d33d667mr2695950pzj.5.1691666513382; Thu, 10 Aug 2023 04:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691666513; cv=none; d=google.com; s=arc-20160816; b=zMrwqWgJL+rsqhjyRloa1bV5U1ip07me/JE45MFCml+7yDrTya5qb1hsRGJ/emmayL qRB/ulFF2ruB73iuOxtpY6j8Na9GJ5vsHMgCQmPVpUZyL/jONMo+Mqwdb1KTTMPaBPrN iPjYNS/OPEimfC/Gef64ye84kmzXwIc4775HBOlM3tDvy7av6EuTw5pP59f6TIpOu9Zl JMeCcY0sqE3RJdbRq7uhXkRqzTc+AnE0rGhWHHpmvWZPPsd9hXGywi2ZFuyvB4UoY7Wo 2TRIhP4hPcWED8X898zEaKFZ7CqNlHjC+L2GNNAayzv2NOjzfyOdcAoKP9VwIY13jtDI /S8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=oeKwJFmW37BK6cn5/nObhqPZZebtFjFoICicT3uPJTA=; fh=qV5sGDwWTWbq49qIthAcu/4E+uy/qEb1abYf2DhZHb0=; b=RYEf22U4f6WPwfhlw8syO3Ndt4SFRi2sSY/7a3PMD2qC3sdMJbMz2nLOk8DLxFmyQ9 8R/H1sFNZ9i3468BdwX8qRPV3ZjEtcgMmR884Zqkq8ZDVh/dS+fMqDMi90hQp8RioJt6 N6Rg9/j/GXbbgwL1YIfF9yfxKvB23wQ3vc1ORZgOIHzgKYzeFH2b3s8A4px4UOWRDjDX ES38YGAxmPVPTfcoHxxDJqG5iMFW02E6D+vmjp3+K4Lk9WMQHltI9tGbcnk7u2jqs0OT W+fy1Iyk+ATvxo7A3tVFTyi+u27MlVbYP+4E08Td5EaTxYLJxv4Dsuj1YItqwxjB6BkX X7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bk/Vs3Be"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi41-20020a056a0039a900b00687501ac7dasi1380882pfb.363.2023.08.10.04.21.40; Thu, 10 Aug 2023 04:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bk/Vs3Be"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233729AbjHJKvV (ORCPT + 99 others); Thu, 10 Aug 2023 06:51:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjHJKvU (ORCPT ); Thu, 10 Aug 2023 06:51:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60E74B4; Thu, 10 Aug 2023 03:51:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA68163CF2; Thu, 10 Aug 2023 10:51:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA0CC433C7; Thu, 10 Aug 2023 10:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691664678; bh=L99B55PNTBqp8V4rry9xXV7Cfll06W4h1rJqzyof8fY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=bk/Vs3BeIzSWktA2LqEtqRPaO7y9ya68Fz/rE9R6Fq8rsQWTa18OawPIvL0WdS+Yj OdfJCI/tcLztV8DvKgzKE74xMoKXcSl8dFFS2xjF26YaQLuTDEis6CFLZv6KpxnV9G 4cJ+9c6a2pzXHVvh50quvadTH3e8xHefefm9kRHlMm/iPdhWSzgH6xncGx0sA1Zk+h 9t4Nh5JwbL7NRqUn0Tgq3xidk6H9HE2IintUesb15PMt/Awo7ilE1iuFBVInHys6ZP HzSYF4zRiBfDrHvCR9uPBGcxBwWHOgWsACvkKaIs2U6JjUxRdA3fq1Q670SyJn1Nyq OE/OjclI8K1pg== Date: Thu, 10 Aug 2023 05:51:16 -0500 From: Bjorn Helgaas To: Kai-Heng Feng Cc: sathyanarayanan.kuppuswamy@linux.intel.com, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Rafael J. Wysocki" , Mahesh J Salgaonkar , linux-kernel@vger.kernel.org, koba.ko@canonical.com, Oliver O'Halloran , bhelgaas@google.com, mika.westerberg@linux.intel.com Subject: Re: [PATCH v6 2/3] PCI/AER: Disable AER interrupt on suspend Message-ID: <20230810105116.GA22621@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 10, 2023 at 04:17:21PM +0800, Kai-Heng Feng wrote: > On Thu, Aug 10, 2023 at 2:52 AM Bjorn Helgaas wrote: > > On Fri, Jul 21, 2023 at 11:58:24AM +0800, Kai-Heng Feng wrote: > > > On Tue, Jul 18, 2023 at 7:17 PM Bjorn Helgaas wrote: > > > > On Fri, May 12, 2023 at 08:00:13AM +0800, Kai-Heng Feng wrote: > > > > > PCIe services that share an IRQ with PME, such as AER or DPC, > > > > > may cause a spurious wakeup on system suspend. To prevent this, > > > > > disable the AER interrupt notification during the system suspend > > > > > process. > > > > > > > > I see that in this particular BZ dmesg log, PME, AER, and DPC do share > > > > the same IRQ, but I don't think this is true in general. > > > > > > > > Root Ports usually use MSI or MSI-X. PME and hotplug events use the > > > > Interrupt Message Number in the PCIe Capability, but AER uses the one > > > > in the AER Root Error Status register, and DPC uses the one in the DPC > > > > Capability register. Those potentially correspond to three distinct > > > > MSI/MSI-X vectors. > > > > > > > > I think this probably has nothing to do with the IRQ being *shared*, > > > > but just that putting the downstream component into D3cold, where the > > > > link state is L3, may cause the upstream component to log and signal a > > > > link-related error as the link goes completely down. > > > > > > That's quite likely a better explanation than my wording. > > > Assuming AER IRQ and PME IRQ are not shared, does system get woken up > > > by AER IRQ? > > > > Rafael could answer this better than I can, but > > Documentation/power/suspend-and-interrupts.rst says device interrupts > > are generally disabled during suspend after the "late" phase of > > suspending devices, i.e., > > > > dpm_suspend_noirq > > suspend_device_irqs <-- disable non-wakeup IRQs > > dpm_noirq_suspend_devices > > ... > > pci_pm_suspend_noirq # (I assume) > > pci_prepare_to_sleep > > > > I think the downstream component would be put in D3cold by > > pci_prepare_to_sleep(), so non-wakeup interrupts should be disabled by > > then. > > > > I assume PME would generally *not* be disabled since it's needed for > > wakeup, so I think any interrupt that shares the PME IRQ and occurs > > during suspend may cause a spurious wakeup. > > Yes, that's the case here. > > > If so, it's exactly as you said at the beginning: AER/DPC/etc sharing > > the PME IRQ may cause spurious wakeups, and we would have to disable > > those other interrupts at the source, e.g., by clearing > > PCI_ERR_ROOT_CMD_FATAL_EN etc (exactly as your series does). > > So is the series good to be merged now? If we merge as-is, won't we disable AER & DPC interrupts unnecessarily in the case where the link goes to D3hot? In that case, there's no reason to expect interrupts related to the link going down, but things like PTM messages still work, and they may cause errors that we should know about. > > > > I don't think D0-D3hot should be relevant here because in all those > > > > states, the link should be active because the downstream config space > > > > remains accessible. So I'm not sure if it's possible, but I wonder if > > > > there's a more targeted place we could do this, e.g., in the path that > > > > puts downstream devices in D3cold. > > > > > > Let me try to work on this. > > > > > > Kai-Heng > > > > > > > > > > > > As Per PCIe Base Spec 5.0, section 5.2, titled "Link State Power Management", > > > > > TLP and DLLP transmission are disabled for a Link in L2/L3 Ready (D3hot), L2 > > > > > (D3cold with aux power) and L3 (D3cold) states. So disabling the AER > > > > > notification during suspend and re-enabling them during the resume process > > > > > should not affect the basic functionality. > > > > > > > > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=216295 > > > > > Reviewed-by: Mika Westerberg > > > > > Signed-off-by: Kai-Heng Feng > > > > > --- > > > > > v6: > > > > > v5: > > > > > - Wording. > > > > > > > > > > v4: > > > > > v3: > > > > > - No change. > > > > > > > > > > v2: > > > > > - Only disable AER IRQ. > > > > > - No more check on PME IRQ#. > > > > > - Use helper. > > > > > > > > > > drivers/pci/pcie/aer.c | 22 ++++++++++++++++++++++ > > > > > 1 file changed, 22 insertions(+) > > > > > > > > > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > > > > > index 1420e1f27105..9c07fdbeb52d 100644 > > > > > --- a/drivers/pci/pcie/aer.c > > > > > +++ b/drivers/pci/pcie/aer.c > > > > > @@ -1356,6 +1356,26 @@ 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); > > > > > + struct pci_dev *pdev = rpc->rpd; > > > > > + > > > > > + aer_disable_irq(pdev); > > > > > + > > > > > + return 0; > > > > > +} > > > > > + > > > > > +static int aer_resume(struct pcie_device *dev) > > > > > +{ > > > > > + struct aer_rpc *rpc = get_service_data(dev); > > > > > + struct pci_dev *pdev = rpc->rpd; > > > > > + > > > > > + aer_enable_irq(pdev); > > > > > + > > > > > + return 0; > > > > > +} > > > > > + > > > > > /** > > > > > * aer_root_reset - reset Root Port hierarchy, RCEC, or RCiEP > > > > > * @dev: pointer to Root Port, RCEC, or RCiEP > > > > > @@ -1420,6 +1440,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, > > > > > }; > > > > > > > > > > -- > > > > > 2.34.1 > > > > >