Received: by 10.192.165.148 with SMTP id m20csp1774265imm; Thu, 26 Apr 2018 01:59:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+sNvnUSMB21ShzDvKLwWA1SJJ2B8IAljSe5FIxpDGSRsJB9nppRLjO5vLKW7XccBIC1mS1 X-Received: by 10.101.69.194 with SMTP id m2mr26655732pgr.433.1524733168800; Thu, 26 Apr 2018 01:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524733168; cv=none; d=google.com; s=arc-20160816; b=q7ocWurZS3pbs857dg7bNt1tFgSytQuOMj7MPkqaDW5WjFhj3299mU3guILPm9Um47 xcaPKU0gidXNgd0uTqE8mRDJ8FIT9rFoA4a7KNSpmslmNl8bVTZBvRCtbjt5OeyBLrhI DA/7HL+NtEkaovQTUc5+oSzC7er2pl7MXow6/92rTU9nHVquK4tPXtXr270yI4UJskh1 kPY/KSqVm9qJgB5caQJorCoHFJRgeasBZLBSfi+krKES+yVQnbERmipCi7n6K5LYG2sl Hz7RFlD6akeU1bAD7O11MmrnNrkhq6HwXcnDaZIyie172jLVxOwYIzcfouR+P6yxSU6R l03Q== 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:dkim-signature:arc-authentication-results; bh=erb1SyGANxVl6gHWShUQ9kqj4ktELneZ9u3fj92lBqQ=; b=w77ZZ9Kf6dMm1YzSN9HguYCWDxBPp8FhZ2wN539IfdG2jiXI5U96LvOvA6SfIbJnrj hkNS6XDnCJSqX1WIATOVG9CYXOwF8NXVM83KAVriILuqIPltIRhXDJk5ZqA/BDRrOVBv Lhrf7hTcooU7A5wAF+bKTgiOkc4Za2dJIe3wmrtl9oJ9egKICSoTbrPk6ywSR5qjBqvo rvdjMhFpvFWBuxx5a4oWn9XEaGpx6p1suoY4QL4762VETsMQ43MB50nT4/Q8j+EFXjCA eOC6NgkgRIJMvBWcDy55fOKtUtxu5oPPqobldXnDKL5X+XhlXAR+vvHyNwLUVdEDD5KC 8Q9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cz1EUeiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20si13437324pgc.645.2018.04.26.01.59.14; Thu, 26 Apr 2018 01:59:28 -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; dkim=pass header.i=@linaro.org header.s=google header.b=cz1EUeiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754819AbeDZI5X (ORCPT + 99 others); Thu, 26 Apr 2018 04:57:23 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34867 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754539AbeDZIxT (ORCPT ); Thu, 26 Apr 2018 04:53:19 -0400 Received: by mail-lf0-f66.google.com with SMTP id r125-v6so29532597lfe.2 for ; Thu, 26 Apr 2018 01:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=erb1SyGANxVl6gHWShUQ9kqj4ktELneZ9u3fj92lBqQ=; b=cz1EUeiHl4NbC4RH9BK8Rr4UfAAbIWjpkVSp9BHZa3En8vWutSIOU06QmHyIWWX3X5 rMnT+nU2ht6VOTONGDxf7AMf55c7bEcRBefUZ4w6vYYEJC21R9eadYF4tTpy9LgqlpmO Wwkl5PFXleIpRHfBrS2RGX++kUkPmNQVulyNc= 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:in-reply-to :references; bh=erb1SyGANxVl6gHWShUQ9kqj4ktELneZ9u3fj92lBqQ=; b=K91dk7RT0KDmiwUTzyQBUOIek3gI6Dh5xDgzcXdiU6wnMTyzNLgKKOCRTTtQiV9cpZ +3Gsz6iapV1oW4rozxW1hBiAKejYXKv+iNfQ8zoRJcR9rXMr55GA0eY6Fo7Y+gymasaE fd0X01giXjXp34dePz7OwfbfjRFfKtZIz7/FrMu/mf7G2JKUHQute2JkkyRKXFS7iKcR Fzh7oGxa7Hc8ctMt/D85axfN48tTbBoduiCBsTz7cqAMz4AG2dg3i8k9TFzx0fNBugX/ DwowCF3Ot8jIyqg69vnVPUhlpqJyjkK06HEBh5xTKXxO0RbzOcFpoDRfZvEsw0D2lA5+ LCow== X-Gm-Message-State: ALQs6tBU77K+0Z/otiOQIvJ6J8dOg6v/eVH3zU5gbIklMdz+4q9e8AQh EFiBaB/KTDy5U0NJi65IZ4/tAQ== X-Received: by 2002:a19:fc04:: with SMTP id a4-v6mr16815435lfi.136.1524732797391; Thu, 26 Apr 2018 01:53:17 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id u83-v6sm681097lff.65.2018.04.26.01.53.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 01:53:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: Ulf Hansson , Kevin Hilman , Geert Uytterhoeven , Viresh Kumar , Vincent Guittot , Mark Brown , Vinod Koul , Sanyog Kale , Pierre-Louis Bossart , Wolfram Sang , Russell King , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "# v4 . 11+" Subject: [PATCH 01/11] PM / Domains: Fix error path during attach in genpd Date: Thu, 26 Apr 2018 10:53:00 +0200 Message-Id: <1524732790-2234-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524732790-2234-1-git-send-email-ulf.hansson@linaro.org> References: <1524732790-2234-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case the PM domain fails to be powered on in genpd_dev_pm_attach(), it returns -EPROBE_DEFER, but keeping the device attached to its PM domain. This leads to problems when the next attempt to attach is re-tried. More precisely, in that situation an -EEXIST error code is returned, because the device already has its PM domain pointer assigned, from the first attempt. Now, because of the sloppy error handling by the existing callers of dev_pm_domain_attach(), probing is allowed to continue when -EEXIST is returned. However, in such case there are no guarantees that the PM domain is powered on by genpd, which may lead to hangs when buses/drivers tried to access their devices. Let's fix this behaviour, simply by detaching the device when powering on fails in genpd_dev_pm_attach(). Cc: # v4.11+ Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1ea0e25..ef6cf3d5 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2246,6 +2246,9 @@ int genpd_dev_pm_attach(struct device *dev) genpd_lock(pd); ret = genpd_power_on(pd, 0); genpd_unlock(pd); + + if (ret) + genpd_remove_device(pd, dev); out: return ret ? -EPROBE_DEFER : 0; } -- 2.7.4