From patchwork Thu May 24 08:33:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 136717 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1906576lji; Thu, 24 May 2018 01:33:46 -0700 (PDT) X-Received: by 2002:a19:e1c2:: with SMTP id l63-v6mr3687819lfk.102.1527150826480; Thu, 24 May 2018 01:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527150826; cv=none; d=google.com; s=arc-20160816; b=SzX49ozPceYimaRl00EXlUM+oTr7ZpxvW7XDAO702xaVg2dbJ/e299ZqwEm2acqsxd RdWugEo3P+M7nKGwchlYSM8NNN9ljH533u/kOE0nEaCQL9qjlBnKGu8fzhVh4PObsUNB koikIIFRKDp7dCc7Yktq4sGX5z7d1HLy/vhlvgarGy50VUJf9rWcQqxc/gRUJSF6a8Pv 91janDSWRS/aSGj/enoGidwY5Xbp70RzjzKaF7h5VnTUqBLlKZQy0UfiPNZG+MJXxjdw 6OqK4JtZf9x2Rq/ffUrjLor87AD3w0D5PFNvFaGYUrtpe1BhG47Vj3jvVdYmbW2j9dvC ifog== 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=tRd75Ro7KAnq5vLrEM/PtLPi7L85Jit7GBlL7cfTkX4=; b=VLM0poAP9OP8rGEjgxrVAXRSS7B+YYK60FtrXg4KS5LuoWTDogTwuqarx4Bh98ELwC FtwaRN6f0VrpaloHjbyrSimC8/YlqJcP/+sXnHyOf8xKXLTVSOhZv6OaGaFiitkzTNj6 vYu9rC/lGUx3EBIFrCqhtFwfF4+gB0lhpZjPSnWbMoIt7AOOTSuZnvHvD2ifzY9PF+1f P+CrkUQNazaoRybPauSzg2+uC3Tv0H3kNI95Z+dXokYodJ4yiXC5/R2gVZY4dyMzkOvm Yjwmh83M8sXTnGEYEC0XALCJYXa/JGVyvBqSwPCvFbgha/9DKYUDe2Ho5AQn+55aW6Lf 8IQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MYduOAdN; 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 d82-v6sor5188669lfl.22.2018.05.24.01.33.46 for (Google Transport Security); Thu, 24 May 2018 01:33:46 -0700 (PDT) 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=MYduOAdN; 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=tRd75Ro7KAnq5vLrEM/PtLPi7L85Jit7GBlL7cfTkX4=; b=MYduOAdNDlg8Y14IvnMxdehmVhcrALNZPWMfysgNpw88Ix/YgmQZvEN3shuBFs3k/T I0oY5/BmJdzu+u11/0M0/uQU0AC5/eLYxmKAszlFk4y7Ru/nQWV02N/FXu+zeMdHNLCE iKxJ6WhQ5cYUlpMoBhVE424m6nYvSqVv+Q/eg= 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=tRd75Ro7KAnq5vLrEM/PtLPi7L85Jit7GBlL7cfTkX4=; b=T/dzxH2v9aGYqKNy7PFrEVF/JrJLE45BfMyt0uTUMuiJL1nWIxqm9fM23ap5IK7yDu 99ApWcJMYX0Qm5k7kPnc0t2fivGhpqmqM01IoJfT7EWUe4A3+J6UAbCUe4mOaWLk9Q93 xKnpwGkrfil4uC1DxQgdHVV/9d5U/d2XN51xKgCesYPZ48JqifhmuNd3/LmpDdmFPfxt r4lX7F7Atc11/N4BSRKUTLCdX9GYMIUtSevl/HXzdkLhKg/SuRVUvIMvoaUHvSN4EVvR ee+wgJdBgxz2IAVrLDj+KIsPkiVPehfSyKdJeVHq/TnPauOcrS1aNMPvY3sOljEw8PlK BrHg== X-Gm-Message-State: ALKqPweeeRbWNJpncsp+EGmf+gSXAojUgckK1xg0K7qqojHqK8UoUMAM CHZj9VHSulQGVh53Fe5scM5cq54s X-Google-Smtp-Source: AB8JxZpwmu0zB7dZwEZhRK7YAEM7jbVfmifj+Q0m8MpJDd25aN+yGcXWk8WTfnJa7l/ZNigJ3c1VCw== X-Received: by 2002:a19:c9d1:: with SMTP id z200-v6mr3701198lff.0.1527150826223; Thu, 24 May 2018 01:33:46 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id u8-v6sm3904641ljg.40.2018.05.24.01.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 May 2018 01:33:45 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: Ulf Hansson , Viresh Kumar , Vincent Guittot , Todor Tomov , Rajendra Nayak , Jon Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] PM / runtime: Drop usage count for suppliers at device link removal Date: Thu, 24 May 2018 10:33:36 +0200 Message-Id: <1527150816-8459-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In the case consumer device is runtime resumed, while the link to the supplier is removed, the earlier call to pm_runtime_get_sync() made from rpm_get_suppliers() does not get properly balanced with a corresponding call to pm_runtime_put(). This leads to that suppliers remains to be runtime resumed forever, while they don't need to. Let's fix the behaviour by calling rpm_put_suppliers() when dropping a device link. Not that, since rpm_put_suppliers() checks the link->rpm_active flag, we can correctly avoid to call pm_runtime_put() in cases when we shouldn't. Reported-by: Todor Tomov Fixes: 21d5c57b3726 ("PM / runtime: Use device links") Signed-off-by: Ulf Hansson --- Rafael, I am not sure if this is safe from locking point of view. The device link write lock has been taken when pm_runtime_drop_link() is called, hence I assume calling rpm_put_suppliers() should be fine!? If not, can you please advise how to change? Kind regards Uffe --- drivers/base/power/runtime.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8bef3cb..beb85c3 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1607,6 +1607,8 @@ void pm_runtime_new_link(struct device *dev) void pm_runtime_drop_link(struct device *dev) { + rpm_put_suppliers(dev); + spin_lock_irq(&dev->power.lock); WARN_ON(dev->power.links_count == 0); dev->power.links_count--;