From patchwork Fri Nov 17 13:16:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 119149 Delivered-To: patches@linaro.org Received: by 10.80.225.132 with SMTP id k4csp624193edl; Fri, 17 Nov 2017 05:16:16 -0800 (PST) X-Received: by 10.25.193.68 with SMTP id r65mr827963lff.104.1510924576613; Fri, 17 Nov 2017 05:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510924576; cv=none; d=google.com; s=arc-20160816; b=UGmN0cT8lNPqtE99QvM8YesI7j7sXULpY9NoFpEcn+Rf3kCGwSbs9mom6qgwcq23PD S8adsPlnLdKQCrHXlFbUacWtQC9+LtV9ICm/6LjfKr68vNv05wDDioMw8xK/a9Q7jm79 BuCE2sdxFO7sI9C6YaooSdHDGrbqTa2VUPTLVrn/y733a8o8NqcrrnMfTCdi34Z8Smp0 jz4aL4JTqOrKgSedtCbDPk7bVhEdo5wi46l20MqtSyI9W7De09rHM68qwBGCn65nsKi8 Fvncm3mhuDWKUVbnGRxFVgdPD5VOy0HByv2gLFRKrqPQMgljxPj0Spurq8vrBEC4KkDu 59pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=/WczJD1HX0FlZAF+ZGK+Sokmd7ePhrNqWBSniRldkGk=; b=lFXC21hogA8mQmExrrhc4Q4E8iQmeWj4yad8NJvP8DB9yMmKEa1/Bv9Hzjj5ehWuOb a68JKvghOBwIM1ZNVdGvBWMdo+a2BBHPGwf5enPkySMm4dM/H5yJUtvX5a1ZFxxPS0Ks P56RAz+x/142EDC98bU36EYnSjxTACi1Ii7A5qLVNXzhr4C/1vViWJzRQLIq0d695rkG 4OCA/cs+Oj4EUyWoRwJnQhHLQGmkUJVmBJe/IRh8k4U3nAoz2QCDjr+22WuwyCPbqjS/ fO/FOkMWITK4k2iJ7pcRZOpwBkgINMWdoRdiIZ4dWlJmI8EkY+MxTyrxkAhtRREVsohs MfSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYPZUFjF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 79sor664326lje.85.2017.11.17.05.16.16 for (Google Transport Security); Fri, 17 Nov 2017 05:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYPZUFjF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=/WczJD1HX0FlZAF+ZGK+Sokmd7ePhrNqWBSniRldkGk=; b=VYPZUFjFNPOPzEw8qgQ+Eg3aWPdNSg9OPj1xUZ2kQRt5Qg4lhxkrXqcLUVBLCmTDsx r3EHLrTtD9eZHMkANtImCNOdOqyWBwDDCLvI+qw4sMVFyn0bYYIMu7LpEAAlFGwlD3BA iZ8noX1fJyzvwp6+k0Hs3mpkbpCqzfG7c7Sh4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/WczJD1HX0FlZAF+ZGK+Sokmd7ePhrNqWBSniRldkGk=; b=d31LFLvqUsvqwvIa6QSg1mGLb0/fCns3M75yyIbdxwXzRbNjy0DwOe7qCWa+6pmlk2 1/PtgDUV93sng43wE6DWBUmFil8wyLTyol+es3tImQstq/OPFrB4eZCG77ZQjotEA1mt 5GNpDoxCaCGrugWl93+1x93OpXofQ5GY+s5iSRbU8D268PWgarKgwEuK1lqYQhHiU5i5 flhdjAc9k2AHd9IRv6+VU8sITK8A6n1ZR3aawQ7PCJBZqt27Lk77Rha+TZAEDYaFuwPF D22Odhpefe4C6OH+DB9o9NE8GfvAH+Jmysk/ZdPmHqQue7XDA25/N7LvJ2zQl/5+cYcp UIxQ== X-Gm-Message-State: AJaThX6Q5TbmGaeZTo1ZbLH79bHcP7UBn5e9qHtG44FGQtaCS8pqurpM FPmTjBxoGAAb9jOBrlFKvK7OYbKS5pkjig== X-Google-Smtp-Source: AGs4zMben9E0Biko6LfVVhXuK9o26cNghPbiEjU6JyoJw9L4nl+9lcMDMckIj7uQLOKRXAiBZgukUg== X-Received: by 10.46.76.10 with SMTP id z10mr852645lja.19.1510924576030; Fri, 17 Nov 2017 05:16:16 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id w13sm804528ljw.69.2017.11.17.05.16.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Nov 2017 05:16:15 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Alan Stern , Ulf Hansson , linux-pm@vger.kernel.org Cc: Kevin Hilman , Geert Uytterhoeven , Lina Iyer Subject: [PATCH] PM / runtime: Allow an irq-safe parent to be runtime suspended Date: Fri, 17 Nov 2017 14:16:06 +0100 Message-Id: <1510924566-16112-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 When pm_runtime_irq_safe() is a called for a child device, it's assumed that the parent is never also irq-safe. Therefore, is the parent runtime resumed and the usage counter increased for it, as to avoid having an irq-safe child waiting for non-irq-safe parent. Improve this behaviour by taking into account that the parent could also be irq-safe. In such case let's allow it to be runtime suspended. Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index ec059750..d44f520 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1370,13 +1370,13 @@ EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks); * Set the power.irq_safe flag, which tells the PM core that the * ->runtime_suspend() and ->runtime_resume() callbacks for this device should * always be invoked with the spinlock held and interrupts disabled. It also - * causes the parent's usage counter to be permanently incremented, preventing - * the parent from runtime suspending -- otherwise an irq-safe child might have - * to wait for a non-irq-safe parent. + * causes the parent's usage counter to be permanently incremented, unless the + * parent is also irq-safe. This prevents the parent from runtime suspending, + * otherwise an irq-safe child might have to wait for a non-irq-safe parent. */ void pm_runtime_irq_safe(struct device *dev) { - if (dev->parent) + if (dev->parent && !pm_runtime_is_irq_safe(dev->parent)) pm_runtime_get_sync(dev->parent); spin_lock_irq(&dev->power.lock); dev->power.irq_safe = 1; @@ -1507,7 +1507,7 @@ void pm_runtime_reinit(struct device *dev) spin_lock_irq(&dev->power.lock); dev->power.irq_safe = 0; spin_unlock_irq(&dev->power.lock); - if (dev->parent) + if (dev->parent && !pm_runtime_is_irq_safe(dev->parent)) pm_runtime_put(dev->parent); } }