Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp648043imu; Fri, 11 Jan 2019 06:46:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN7j/5i8gcCKP+uZoLYsGP4Z1ryTe8FmbiC7vlTitxOzKFtdiNgqeptQcvV4GMb3slEykChu X-Received: by 2002:a17:902:8346:: with SMTP id z6mr14862044pln.340.1547217988146; Fri, 11 Jan 2019 06:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547217988; cv=none; d=google.com; s=arc-20160816; b=QBjAKog7f82kort+wB6qMmc1TPjtMnHCmXVeqPXJhP2XCJ+NsI4lFwrQ++28inO2B5 +L3ZWqUP+UyUw/rEzWjXm4tai5D/gkjUb8q8Vu3rbhakNHDbumVMDiMZSL1/vQqrhZZK zxavH+j6MzIsjpmd1BhFw1FYeCL5sopL9dvAPTqFJZS6o10SrERkpE6xLcl8LDZfcWTR NlUKxuyhxp+WO7dpsi1aIfTXKjpoDpMmV/4+HhLXi8zB/tpllf0Ihjv8wRrQX0KwPqL5 KX2iHKkBL+VYgjFNRiMpjCzlFTylGZ6M1cmgcl88HT+Enf8CFOdAnqOhcaTP49t7955P ySNw== 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=1J/c8IoQZ3dDAKOeQry91dkA/EtgP4VQLXd4qzpV0zQ=; b=O+g5HYxPrhAz2HU/l+Ull4XUHHnXn8hm7BudBwfnWEjn5ZPfKPbiAIXVbDRIFYn/ES N55ataYTg+7RgxGvHcXZ1yd7VLwFllCO7z0unuFr29B5mDdLWHfX1tApCPXaGM8asZk3 BmkKbC9QCnaJzaESWpo4aTebKfBSPdCgkiaEg5Jbw1OPJnXS/HDnTggMeAUeDvIjx3mZ 6HyIW4q9lfMlRctlvDcVOICuJ2BlZtUBqVeW69lW//y+/GRXIK7TuT2iiBFwF91KsuRo Ye6Y3+xwE3wNLG2zMJYGnpMr/MpPNiTDJKoPQq1GBHxfvPXERaF8vP7gRMvuIDsCdv7I W2ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rrhivgbH; 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 v11si71717694plp.85.2019.01.11.06.46.12; Fri, 11 Jan 2019 06:46:28 -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=rrhivgbH; 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 S2391252AbfAKOo3 (ORCPT + 99 others); Fri, 11 Jan 2019 09:44:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:37386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404607AbfAKOoZ (ORCPT ); Fri, 11 Jan 2019 09:44:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 A82A320872; Fri, 11 Jan 2019 14:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217865; bh=b+ha+dOpnQ1IN6Tsb2Jrr+wGN+7hPmOkgnOj1kRaw1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rrhivgbH2yzRfMehNhjmYkMKcW8aBDNtCVe8DAOsZ7RUt5LR8mm9EyaIUUsZcyTfy ZAAl+Axsap9V8xrKV/Xh/8bVS+q0mKzg6ShRSrv3K8qv+KULnLGD/Ru8Fp6az1mLfE 4xPnkgLGnbXpuwQfmkSLHbPPZndt+8K0qB4JdsLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Jarkko Nikula , Bjorn Helgaas , Jean Delvare , "Rafael J. Wysocki" Subject: [PATCH 4.20 37/65] PCI / PM: Allow runtime PM without callback functions Date: Fri, 11 Jan 2019 15:15:23 +0100 Message-Id: <20190111131101.734528578@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jarkko Nikula commit c5eb1190074cfb14c5d9cac692f1912eecf1a5e4 upstream. a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This caused the SMBus PCI device to stay in D0 with /sys/devices/.../power/runtime_status showing "error" when the runtime PM framework attempted to autosuspend the device. This is due to PCI bus runtime PM, which checks for driver runtime PM callbacks and returns -ENOSYS if they are not set. Since i2c-i801.c doesn't need to do anything device-specific for runtime PM, Jean Delvare proposed this be fixed in the PCI core rather than adding dummy runtime PM callback functions in the PCI drivers. Change pci_pm_runtime_suspend()/pci_pm_runtime_resume() so they allow changing the PCI device power state during runtime PM transitions even if the driver supplies no runtime PM callbacks. This fixes the runtime PM regression on i2c-i801.c. It is not obvious why the code previously required the runtime PM callbacks. The test has been there since the code was introduced by 6cbf82148ff2 ("PCI PM: Run-time callbacks for PCI bus type"). On the other hand, a similar change was done to generic runtime PM callbacks in 05aa55dddb9e ("PM / Runtime: Lenient generic runtime pm callbacks"). Fixes: a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") Reported-by: Mika Westerberg Signed-off-by: Jarkko Nikula Signed-off-by: Bjorn Helgaas Reviewed-by: Jean Delvare Reviewed-by: Rafael J. Wysocki Cc: stable@vger.kernel.org # v4.18+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-driver.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1251,30 +1251,29 @@ static int pci_pm_runtime_suspend(struct return 0; } - if (!pm || !pm->runtime_suspend) - return -ENOSYS; - pci_dev->state_saved = false; - error = pm->runtime_suspend(dev); - if (error) { + if (pm && pm->runtime_suspend) { + error = pm->runtime_suspend(dev); /* * -EBUSY and -EAGAIN is used to request the runtime PM core * to schedule a new suspend, so log the event only with debug * log level. */ - if (error == -EBUSY || error == -EAGAIN) + if (error == -EBUSY || error == -EAGAIN) { dev_dbg(dev, "can't suspend now (%pf returned %d)\n", pm->runtime_suspend, error); - else + return error; + } else if (error) { dev_err(dev, "can't suspend (%pf returned %d)\n", pm->runtime_suspend, error); - - return error; + return error; + } } pci_fixup_device(pci_fixup_suspend, pci_dev); - if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0 + if (pm && pm->runtime_suspend + && !pci_dev->state_saved && pci_dev->current_state != PCI_D0 && pci_dev->current_state != PCI_UNKNOWN) { WARN_ONCE(pci_dev->current_state != prev, "PCI PM: State of device not saved by %pF\n", @@ -1292,7 +1291,7 @@ static int pci_pm_runtime_suspend(struct static int pci_pm_runtime_resume(struct device *dev) { - int rc; + int rc = 0; struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; @@ -1306,14 +1305,12 @@ static int pci_pm_runtime_resume(struct if (!pci_dev->driver) return 0; - if (!pm || !pm->runtime_resume) - return -ENOSYS; - pci_fixup_device(pci_fixup_resume_early, pci_dev); pci_enable_wake(pci_dev, PCI_D0, false); pci_fixup_device(pci_fixup_resume, pci_dev); - rc = pm->runtime_resume(dev); + if (pm && pm->runtime_resume) + rc = pm->runtime_resume(dev); pci_dev->runtime_d3cold = false;