From fb3d5a614a3286a5d89fe15b700d35d4bdaa4898 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 23 May 2016 19:50:37 +0200 Subject: [PATCH] bbswitch_dev: use autosuspend to avoid sleeping too fast --- bbswitch_dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bbswitch_dev.c b/bbswitch_dev.c index f3b96c2..cdfce65 100644 --- a/bbswitch_dev.c +++ b/bbswitch_dev.c @@ -26,14 +26,18 @@ static int bbswitch_pci_probe(struct pci_dev *dev, const struct pci_device_id *i pci_ignore_hotplug(dev); pm_runtime_set_active(&dev->dev); /* clear any errors */ + /* Use autosuspend to avoid lspci waking up the device multiple times. */ + pm_runtime_set_autosuspend_delay(&dev->dev, 2000); + pm_runtime_use_autosuspend(&dev->dev); pm_runtime_allow(&dev->dev); - pm_runtime_put_noidle(&dev->dev); + pm_runtime_put_autosuspend(&dev->dev); return 0; } static void bbswitch_pci_remove(struct pci_dev *dev) { pm_runtime_get_noresume(&dev->dev); + pm_runtime_dont_use_autosuspend(&dev->dev); } static int bbswitch_runtime_suspend(struct device *dev) {