linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Bjorn Helgaas <bhelgaas@google.com>
Cc: Len Brown <lenb@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org
Subject: [PATCH] ACPI / hotplug / PCI: Take runtime PM autosuspend into account
Date: Wed, 13 Nov 2019 18:41:23 +0300	[thread overview]
Message-ID: <20191113154123.75345-1-mika.westerberg@linux.intel.com> (raw)

PCIe ports (the only ones we do runtime PM) are using runtime PM
autosuspend to keep the port powered on for a while after it becomes
idle. However, ACPI hotplug does not take this into account so if we get
multiple hotplug events in a short period of time we may be powering
ports on and off and then back on unnecessarily.

For this reason call pm_runtime_put_autosuspend() for them (with the
accompanying pm_runtime_mark_last_busy()).

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index b3869951c0eb..c8264af40643 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -672,7 +672,8 @@ static void trim_stale_devices(struct pci_dev *dev)
 		list_for_each_entry_safe_reverse(child, tmp, &bus->devices, bus_list)
 			trim_stale_devices(child);
 
-		pm_runtime_put(&dev->dev);
+		pm_runtime_mark_last_busy(&dev->dev);
+		pm_runtime_put_autosuspend(&dev->dev);
 	}
 }
 
@@ -714,8 +715,10 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
 		}
 	}
 
-	if (bridge->pci_dev)
-		pm_runtime_put(&bridge->pci_dev->dev);
+	if (bridge->pci_dev) {
+		pm_runtime_mark_last_busy(&bridge->pci_dev->dev);
+		pm_runtime_put_autosuspend(&bridge->pci_dev->dev);
+	}
 }
 
 /*
-- 
2.24.0


             reply	other threads:[~2019-11-13 16:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 15:41 Mika Westerberg [this message]
2019-11-13 21:50 ` [PATCH] ACPI / hotplug / PCI: Take runtime PM autosuspend into account Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113154123.75345-1-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).