From patchwork Wed Jul 26 10:07:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 108749 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp632726obm; Wed, 26 Jul 2017 03:07:47 -0700 (PDT) X-Received: by 10.98.103.137 with SMTP id t9mr342460pfj.273.1501063667699; Wed, 26 Jul 2017 03:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501063667; cv=none; d=google.com; s=arc-20160816; b=KhDaE745ZtNembvGDSMDwkxXm/IVzbdgiiF3kfMkaBBW3bf7JudPqsfC1A6dL/zWYe NWR7o9jOy+BCM+xx961l5wh5JB8JKDbXxz6BBag3zQViedXDTmnd3+c5nc2JzrnwkgS4 McH5O/TsVtdVMXdCDhvST/e2dJ09Yo/KdAqP+WW0oEZpKuxomYdn3Ey+PSOT1KEwvsuy 8ZnaeJa+6st49rE5g+LPV8I7bfRF66SK8HwFsUhtQLU8ZO1TXTBbMMRNGGPkV2WsuNtB UZ/ybgnjBp1e1QpgxXyWLA4eEolo5jdN+m/JsubTEL6VMaURv3SN4TRltyyivAK6fXVE 5NpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=n7k0ypsFKtUYxI06vx25RaQ6QKe8rbDqxIEYNLqy8M0=; b=GwcnRdtvbRZt1pDYwEtokMxg4DcUfKbD3txr8m8EjsybeQntvTx1WwOM9ceg3azVBd CBwCJe49UeJxbG+9wW8WGMRktHNXDzFq0ym9z9yTNACbuw3mrIYmCgX40RjW1nhHX3Si TaWfKVz9DZbY0IFxnxHby8rYTV6X9ZqKW8DTFD13FMXXB8Zywu3bS9eq3chUEPq/hZ9S p/NTz8egWL4xZVBsn//fGaSq5NWW5sp0Gk7n0y+T5ukr+wdbPrq8t0c5DWUtvwnGXTdJ exlY5gRKx11+P5Q0oTpdLpPoKmGnlieYi3k3dvnkPvN8YKSZvOg3kGLVNjOgz+paaEP8 MmUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 q26si9525066pge.526.2017.07.26.03.07.47; Wed, 26 Jul 2017 03:07:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751593AbdGZKHq (ORCPT + 6 others); Wed, 26 Jul 2017 06:07:46 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58594 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587AbdGZKHq (ORCPT ); Wed, 26 Jul 2017 06:07:46 -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 121AD80D; Wed, 26 Jul 2017 03:07:46 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.211.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A1CCC3F577; Wed, 26 Jul 2017 03:07:44 -0700 (PDT) From: Sudeep Holla To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: rafael.j.wysocki@intel.com, ulf.hansson@linaro.org, Sudeep Holla Subject: [PATCH v4.4 STABLE] PM / Domains: defer setting dev->pm_domain until genpd->attach_dev succeeds if present Date: Wed, 26 Jul 2017 11:07:35 +0100 Message-Id: <1501063655-30208-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501005276213126@kroah.com> References: <1501005276213126@kroah.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org commit 975e83cfb8dc16e7a2fdc58188c77c0c605876c2 upstream. 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. Fixes: f104e1e5ef57 (PM / Domains: Re-order initialization of generic_pm_domain_data) Cc: 4.4+ # v4.4+ Signed-off-by: Sudeep Holla Acked-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki --- drivers/base/power/domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index a48824deabc5..da5718e7fbb7 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1188,7 +1188,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, } dev->power.subsys_data->domain_data = &gpd_data->base; - dev->pm_domain = &genpd->domain; spin_unlock_irq(&dev->power.lock); @@ -1207,7 +1206,6 @@ static void genpd_free_dev_data(struct device *dev, { spin_lock_irq(&dev->power.lock); - dev->pm_domain = NULL; dev->power.subsys_data->domain_data = NULL; spin_unlock_irq(&dev->power.lock); @@ -1248,6 +1246,8 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; + dev->pm_domain = &genpd->domain; + genpd->device_count++; genpd->max_off_time_changed = true; @@ -1299,6 +1299,8 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, if (genpd->detach_dev) genpd->detach_dev(genpd, dev); + dev->pm_domain = NULL; + list_del_init(&pdd->list_node); mutex_unlock(&genpd->lock);