From patchwork Thu Jun 29 18:00:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 106651 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1384294qge; Thu, 29 Jun 2017 11:01:38 -0700 (PDT) X-Received: by 10.84.169.227 with SMTP id h90mr4638490plb.224.1498759298448; Thu, 29 Jun 2017 11:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498759298; cv=none; d=google.com; s=arc-20160816; b=EYXhCNE1EiKGv4KE1B+6yt0mVGTWLtbbM4R8OX19VBgjG3upLn1NbPWA6FRu8/O5yC wNPnUngUmLr9AEkMXtHBCFOWZcQureQlNHFTL1ehUGZ0ncWBVhNcqxkWddz2ycq4bYva WJrz4sk/gcMUJOWCNNHFWV5JUPmcZ6p03eq6Da20jFYgktVDBwBx9E614uuWZuw2k5pJ DU//nI7FWZFH2WDp90jTO5vpuOyirLA/0X8pUB6drtuoI3W/4q6H5eCyjfdW7c0Atzko fwe//mng6kA+zhbdjW9Ghc50VFWqWH0u0LKlfF9fnJfRp6WTnzq8Ktn5C4QqqluccAZ3 goyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e3pQfoaXoiOWr5tSa0NybcB61gWqgX5gC6z06P3OHrA=; b=G6IoxJcC9X1uqvlJz3q0Im/EY0qTo1RmDWaOa7GJexG+G+0h2IVCO/byJC2K1eFbWm /FPEOy1/b6WbNPlpZZTq4XKUR0Wah704vAAM91Nh+83mpXF32uIu5ZRPV9vPZIBnE938 NtZi12cJIMtLwIi2ytyGUEiu0mDbudxqBmOO4ikIHKY0ze90AM8I64lIChWaMyrbwd5F Ve6YSf9xrB2b5VhF+GXjddRQUVrlM3HjYp85feXDErRPct2wKzrAMZ14sh3tYSOpkrtc hmgnNQ4/ZXUCZOmESlmFb2o0qR+4RCOk3fljEDVZp6VIKxA5L0KB+xgyORDDTmLuLPBF 98TA== ARC-Authentication-Results: i=1; mx.google.com; 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 1si4046809pgs.57.2017.06.29.11.01.38; Thu, 29 Jun 2017 11:01:38 -0700 (PDT) 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; 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 S1753658AbdF2SB1 (ORCPT + 25 others); Thu, 29 Jun 2017 14:01:27 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59316 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753591AbdF2SBG (ORCPT ); Thu, 29 Jun 2017 14:01:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D38880D; Thu, 29 Jun 2017 11:01:00 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 26F683F4FF; Thu, 29 Jun 2017 11:00:59 -0700 (PDT) From: Sudeep Holla To: linux-pm@vger.kernel.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson Subject: [PATCH] PM / Domains: defer dev_pm_domain_set() until genpd->attach_dev succeeds if present Date: Thu, 29 Jun 2017 19:00:51 +0100 Message-Id: <1498759251-11709-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the genpd->attach_dev or genpd->power_on fails, genpd_dev_pm_attach may return -EPROBE_DEFER initially. However genpd_alloc_dev_data sets the PM domain for the device unconditionally. When subsequent attempts are made to call genpd_dev_pm_attach, it may return -EEXISTS checking dev->pm_domain without re-attempting to call attach_dev or power_on. platform_drv_probe then attempts to call drv->probe as the return value -EEXIST != -EPROBE_DEFER, which may end up in a situation where the device is accessed without it's power domain switched on. Cc: "Rafael J. Wysocki" Cc: Kevin Hilman Cc: Ulf Hansson Signed-off-by: Sudeep Holla --- drivers/base/power/domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 Acked-by: Kevin Hilman diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index da49a8383dc3..b195d34de888 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1168,8 +1168,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, spin_unlock_irq(&dev->power.lock); - dev_pm_domain_set(dev, &genpd->domain); - return gpd_data; err_free: @@ -1221,6 +1219,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; + dev_pm_domain_set(dev, &genpd->domain); + genpd->device_count++; genpd->max_off_time_changed = true;