Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2280324ybl; Thu, 19 Dec 2019 10:56:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzTxk0eWg6kkESe6KWNLXU4MlBI2emNfrBOdwR+Ioi8l1/+NEh8ptHvfy2H8GSIKGR7iCCq X-Received: by 2002:a05:6830:3052:: with SMTP id p18mr8044777otr.213.1576781800091; Thu, 19 Dec 2019 10:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781800; cv=none; d=google.com; s=arc-20160816; b=IBaNdnd9R40T8VDylQqzjlMxdl1+qdwnS4Q0XM4tn2iQ9GoPRlZthWHjpMBj8G/1B0 HxgZ4lT5SRnvsW2cyO6q0nBLbWe+txfR9s+hsswUTK0t16XZ2UJ0rxdYEvIHIrltLxTQ dEsaQQd8X9AnFbizYyvhqoXn8XXUkOVflcK7XxBVenJfIBV2wXMVP19bzZTWJ2cvEyyW OYz5xlD2e9ADcHgO2HgFUMYD/gLOWd/HsQu7hAHCOz5pmnbWwj16IQMJaryl57bd5AqG nMpwTxNN5uPObegKEoE4+7b7tMTqVDsNci0U1uNHvlYV+2kNdNJ47yI08LHBnYpVt3qI NO8A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KU0GsfPP6TSe50dS9B4+NHmV8EFbA3tiJ1HNm6eeEpA=; b=CSxGj5ZDMXrRR/H5SVvl+rE5LegA4hohjAp1eDuJtKC9JLJv/r9Q5EoU77AX/ODUyW fkhiGLqNo5jDSkVtPAJoH2p2SLBX+1/V6tYUCKhoHd3WZ/4RJFAz1RT9d6zDZQc7NkGx dGyC3snlZGpn39NWEmFWvzPhgdhmmKxxbBnU6uAPpyUfW2HdSZTE1k02+y1wSBiTLiGZ gRK6KcwM0oobGybf3P5ws/LBKTXM2ZvZPAy3loPcEAmcGgqW1KklMvhGMtDU2fURwcnh 03ZCszDbAzxJ9jDV3JSwlUM+wixRyF8ei92OayHcRdyHYFH9NfmhgK2wJjfZiFKJGM/z j9nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ux7kV5NH; 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 z1si3910826otq.21.2019.12.19.10.56.29; Thu, 19 Dec 2019 10:56:40 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ux7kV5NH; 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 S1730547AbfLSSyn (ORCPT + 99 others); Thu, 19 Dec 2019 13:54:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:50208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730543AbfLSSyl (ORCPT ); Thu, 19 Dec 2019 13:54:41 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDA86227BF; Thu, 19 Dec 2019 18:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781680; bh=zP6kqnQJ5BCUk2R2cL1qnZys2A33AWA+hG5nkb7QpSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ux7kV5NHeq8AftP4pLZ79fKllULU5O0uJnXmoNANvZYMI2ECF0Fl6uks/ZzkuZsdZ CsC2bd+D+ns/vPWWpMA+yKTiADsSRzCyLn9sCZ0jSgl34Dxrvr8kFKZ7QoetJLyDne RZdtKzEkG46n86tPxXHOE7mjSoD4EguUEIF5Fnv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , Bjorn Helgaas , "Rafael J. Wysocki" Subject: [PATCH 5.4 07/80] PCI/PM: Always return devices to D0 when thawing Date: Thu, 19 Dec 2019 19:33:59 +0100 Message-Id: <20191219183038.872792429@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui commit f2c33ccacb2d4bbeae2a255a7ca0cbfd03017b7c upstream. pci_pm_thaw_noirq() is supposed to return the device to D0 and restore its configuration registers, but previously it only did that for devices whose drivers implemented the new power management ops. Hibernation, e.g., via "echo disk > /sys/power/state", involves freezing devices, creating a hibernation image, thawing devices, writing the image, and powering off. The fact that thawing did not return devices with legacy power management to D0 caused errors, e.g., in this path: pci_pm_thaw_noirq if (pci_has_legacy_pm_support(pci_dev)) # true for Mellanox VF driver return pci_legacy_resume_early(dev) # ... legacy PM skips the rest pci_set_power_state(pci_dev, PCI_D0) pci_restore_state(pci_dev) pci_pm_thaw if (pci_has_legacy_pm_support(pci_dev)) pci_legacy_resume drv->resume mlx4_resume ... pci_enable_msix_range ... if (dev->current_state != PCI_D0) # <--- return -EINVAL; which caused these warnings: mlx4_core a6d1:00:02.0: INTx is not supported in multi-function mode, aborting PM: dpm_run_callback(): pci_pm_thaw+0x0/0xd7 returns -95 PM: Device a6d1:00:02.0 failed to thaw: error -95 Return devices to D0 and restore config registers for all devices, not just those whose drivers support new power management. [bhelgaas: also call pci_restore_state() before pci_legacy_resume_early(), update comment, add stable tag, commit log] Link: https://lore.kernel.org/r/KU1P153MB016637CAEAD346F0AA8E3801BFAD0@KU1P153MB0166.APCP153.PROD.OUTLOOK.COM Signed-off-by: Dexuan Cui Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Cc: stable@vger.kernel.org # v4.13+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-driver.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1076,17 +1076,22 @@ static int pci_pm_thaw_noirq(struct devi return error; } - if (pci_has_legacy_pm_support(pci_dev)) - return pci_legacy_resume_early(dev); - /* - * pci_restore_state() requires the device to be in D0 (because of MSI - * restoration among other things), so force it into D0 in case the - * driver's "freeze" callbacks put it into a low-power state directly. + * Both the legacy ->resume_early() and the new pm->thaw_noirq() + * callbacks assume the device has been returned to D0 and its + * config state has been restored. + * + * In addition, pci_restore_state() restores MSI-X state in MMIO + * space, which requires the device to be in D0, so return it to D0 + * in case the driver's "freeze" callbacks put it into a low-power + * state. */ pci_set_power_state(pci_dev, PCI_D0); pci_restore_state(pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) + return pci_legacy_resume_early(dev); + if (drv && drv->pm && drv->pm->thaw_noirq) error = drv->pm->thaw_noirq(dev);