Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2223652ybd; Mon, 24 Jun 2019 02:51:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRL5sabSiA4G0iODiPQWMsTjjjyzOtniLXMpksadUbzVIt/YlYVv0aNyTxJE5wiPMQk754 X-Received: by 2002:a17:90a:ad89:: with SMTP id s9mr23911065pjq.41.1561369886257; Mon, 24 Jun 2019 02:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561369886; cv=none; d=google.com; s=arc-20160816; b=BPK2gKXaJ/bngnSlUkNhAwKZIWZYF4Xr9FusEF21UEMjWiGpzQ/+IKnpS2y/E9c10Q wsKvaLsY+rwCbeFh1pr0glNFa0MBXgx5jiHabsSwDH6J3+1YxhBMx320tNfTcjwh2onD dL/ZbJONPKYqgLOAISzK31aq9Yg+OMdRsznI0tvk80kDCec2lzHmU4pP9e/bOxJ8jxJx lrAfuRx0HFVvFeuktQg5sHlOsmz3oU+a9km8cPn2cPNB1oPKDF0bgCXdd5LCiMMUl7WA 7VGQD1o+uGUFdEl6JvrTAK5EZZBNOfC2fUQLWTGz4uHmlw0soIITWQD3kZbrGKxpSTqT rHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0RPOLpBBX28tJFNANxlpvrqq4gxpH6PJzTgYxkwwQAY=; b=s0MDMKySW19RD63Q6gS+Q79cE4BLfx91NfmJeYB5hsmnogysNEF11uy08+RfVyfE/U eLKuPJWaL2EDdb+FQvmv/mG90dGkRt2QAEETaF1oSnIXyC20N2d0PYi/tETSTWoWSaLH SVTWU4/jSAiJXXguFTMvQyIqc9fyPveEwu1CyuoDgp3Dr0XukKfQqLqf9047GR+nGuhu qhALj0V17KVkLVsde3jqf/3YR0DoOkyLrUsZkNneGwKBBK7L48kNQhasHrRV/ZfZcmCL 6s3iRBw1rQCo9V1f5jb3DfDfyzX2Y1Z27p67AN3+ehxp2xjisK3omA4FO4wSr06+Ow04 Xbzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si9703073plq.93.2019.06.24.02.51.10; Mon, 24 Jun 2019 02:51:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728559AbfFXJey (ORCPT + 99 others); Mon, 24 Jun 2019 05:34:54 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:45389 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726331AbfFXJey (ORCPT ); Mon, 24 Jun 2019 05:34:54 -0400 Received: from 79.184.254.216.ipv4.supernova.orange.pl (79.184.254.216) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.267) id cf7b2722c211f831; Mon, 24 Jun 2019 11:34:50 +0200 From: "Rafael J. Wysocki" To: Mika Westerberg Cc: Bjorn Helgaas , Lukas Wunner , Keith Busch , Andy Shevchenko , Frederick Lawler , "Gustavo A . R . Silva" , Sinan Kaya , Kai Heng Feng , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] PCI: pciehp: Do not disable interrupt twice on suspend Date: Mon, 24 Jun 2019 11:34:50 +0200 Message-ID: <2291470.PqBgM8dDTm@kreacher> In-Reply-To: <20190618125051.2382-1-mika.westerberg@linux.intel.com> References: <20190618125051.2382-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, June 18, 2019 2:50:50 PM CEST Mika Westerberg wrote: > We try to keep PCIe hotplug ports runtime suspended when entering system > suspend. Due to the fact that the PCIe portdrv sets NEVER_SKIP driver PM > flag the PM core always calls system suspend/resume hooks even if the > device is left runtime suspended. Since PCIe hotplug driver re-uses the > same function for both it ends up disabling hotplug interrupt twice and > the second time following is printed: > > pciehp 0000:03:01.0:pcie204: pcie_do_write_cmd: no response from device > > Prevent this from happening by checking whether the device is already > runtime suspended when system suspend hook is called. > > Fixes: 9c62f0bfb832 ("PCI: pciehp: Implement runtime PM callbacks") > Reported-by: Kai Heng Feng > Signed-off-by: Mika Westerberg Reviewed-by: Rafael J. Wysocki > --- > drivers/pci/hotplug/pciehp_core.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c > index 6ad0d86762cb..3f8c13ddb3e8 100644 > --- a/drivers/pci/hotplug/pciehp_core.c > +++ b/drivers/pci/hotplug/pciehp_core.c > @@ -248,7 +248,7 @@ static bool pme_is_native(struct pcie_device *dev) > return pcie_ports_native || host->native_pme; > } > > -static int pciehp_suspend(struct pcie_device *dev) > +static void pciehp_disable_interrupt(struct pcie_device *dev) > { > /* > * Disable hotplug interrupt so that it does not trigger > @@ -256,7 +256,19 @@ static int pciehp_suspend(struct pcie_device *dev) > */ > if (pme_is_native(dev)) > pcie_disable_interrupt(get_service_data(dev)); > +} > > +#ifdef CONFIG_PM_SLEEP > +static int pciehp_suspend(struct pcie_device *dev) > +{ > + /* > + * If the port is already runtime suspended we can keep it that > + * way. > + */ > + if (dev_pm_smart_suspend_and_suspended(&dev->port->dev)) > + return 0; > + > + pciehp_disable_interrupt(dev); > return 0; > } > > @@ -274,6 +286,7 @@ static int pciehp_resume_noirq(struct pcie_device *dev) > > return 0; > } > +#endif > > static int pciehp_resume(struct pcie_device *dev) > { > @@ -287,6 +300,12 @@ static int pciehp_resume(struct pcie_device *dev) > return 0; > } > > +static int pciehp_runtime_suspend(struct pcie_device *dev) > +{ > + pciehp_disable_interrupt(dev); > + return 0; > +} > + > static int pciehp_runtime_resume(struct pcie_device *dev) > { > struct controller *ctrl = get_service_data(dev); > @@ -313,10 +332,12 @@ static struct pcie_port_service_driver hpdriver_portdrv = { > .remove = pciehp_remove, > > #ifdef CONFIG_PM > +#ifdef CONFIG_PM_SLEEP > .suspend = pciehp_suspend, > .resume_noirq = pciehp_resume_noirq, > +#endif > .resume = pciehp_resume, > - .runtime_suspend = pciehp_suspend, > + .runtime_suspend = pciehp_runtime_suspend, > .runtime_resume = pciehp_runtime_resume, > #endif /* PM */ > }; >