Received: by 10.192.165.148 with SMTP id m20csp4147688imm; Mon, 30 Apr 2018 12:39:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrMgI837LMpx5TGr6GHBUSuMvE5TNh+2DY/7b6Rhk/8PRy7lVVu7NTeG19B+GYKjxx3cKk8 X-Received: by 2002:a17:902:aa03:: with SMTP id be3-v6mr13149956plb.215.1525117168466; Mon, 30 Apr 2018 12:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117168; cv=none; d=google.com; s=arc-20160816; b=JMHmnZJdBqj4rQcXt3YJIHKp0GOTFY2gcvnjO67UF3aMaKWLZcOfzc3141VtbO0P3c axO1qaIlNPMFihNHeekcxvnCIXx3owiAna/yu+JZy8Pu/SO8T5nl8zlDciSGz4PtaAps NzLD6aw1ji1rZjgXr84PXDqfUWeLWgz1/nSEMtHw293DW2rMto/ktj6yj7TJqc9LElLt 8WzWNrLM8GMU3VekCfbhD2Ji11vl7JhZ0seZSpGwajUEd7ayhHWwCMwSuZ1kwT/3hf4b ikYX69LhVUnizrvORNw0JA5ftoPe370gb+6SXXm92/rMhHAXFArstAVxeBHR8CuKCuBi 9edg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=p7ert98goCYXo55PSOWnxv/uxl4/HprvYwhjy1daR8M=; b=PThPTSwEUlqEDXR8PeyhuU8JK+LM62G6JFQHzddi4MbqcrcRwL73COC8HfwS2CdlW2 IE1kDu4BWHILXxNeUh7eoYc7m+zpAklWjr+oororDi6+uLTBMseP2teUVDLFwd/xQvDA OA0GESwGkIX0kIfewZSFcRO0v4oX58fBkKi7hXZMO/94j+GUQCY/QFLmbiaAoIcD0Nx/ xNXfkIircniuqmPYIqs1zvjFP4EB8LjCJpsWxhp9p9YSkvmKarS8J2h0pRp0ROScjjKU K7U14/DDcOqh1hRIMUFTZa9LsXIBiXHIpwokUiSeGZ9FYQ6ZVAasWn1VoD2vEKJnYZl0 TD2A== 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 a87si7970682pfl.165.2018.04.30.12.39.14; Mon, 30 Apr 2018 12:39:28 -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 S932244AbeD3Thx (ORCPT + 99 others); Mon, 30 Apr 2018 15:37:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932328AbeD3T2m (ORCPT ); Mon, 30 Apr 2018 15:28:42 -0400 Received: from localhost (unknown [104.132.1.102]) (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 CA8CD22DCB; Mon, 30 Apr 2018 19:28:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA8CD22DCB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , "Rafael J. Wysocki" Subject: [PATCH 4.16 089/113] PCI / PM: Do not clear state_saved in pci_pm_freeze() when smart suspend is set Date: Mon, 30 Apr 2018 12:25:00 -0700 Message-Id: <20180430184018.963429646@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit ae860a19f37c686e7c5816e96640168b7174a096 upstream. If a driver uses DPM_FLAG_SMART_SUSPEND and the device is already runtime suspended when hibernate is started PCI core skips runtime resuming the device but still clears pci_dev->state_saved. After the hibernation image is written pci_pm_thaw_noirq() makes sure subsequent thaw phases for the device are also skipped leaving it runtime suspended with pci_dev->state_saved == false. When the device is eventually runtime resumed pci_pm_runtime_resume() restores config space by calling pci_restore_standard_config(), however because pci_dev->state_saved == false pci_restore_state() never actually restores the config space leaving the device in a state that is not what the driver might expect. For example here is what happens for intel-lpss I2C devices once the hibernation snapshot is taken: intel-lpss 0000:00:15.0: power state changed by ACPI to D0 intel-lpss 0000:00:1e.0: power state changed by ACPI to D3cold video LNXVIDEO:00: Restoring backlight state PM: hibernation exit i2c_designware i2c_designware.1: Unknown Synopsys component type: 0xffffffff i2c_designware i2c_designware.0: Unknown Synopsys component type: 0xffffffff i2c_designware i2c_designware.1: timeout in disabling adapter i2c_designware i2c_designware.0: timeout in disabling adapter Since PCI config space is not restored the device is still in D3hot making MMIO register reads return 0xffffffff. Fix this by clearing pci_dev->state_saved only if we actually end up runtime resuming the device. Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account) Signed-off-by: Mika Westerberg Cc: 4.15+ # 4.15+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -945,10 +945,11 @@ static int pci_pm_freeze(struct device * * devices should not be touched during freeze/thaw transitions, * however. */ - if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND)) + if (!dev_pm_smart_suspend_and_suspended(dev)) { pm_runtime_resume(dev); + pci_dev->state_saved = false; + } - pci_dev->state_saved = false; if (pm->freeze) { int error;