Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3022084imm; Sun, 1 Jul 2018 10:28:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGLeCoE01cVWRSvYwC9XndCeI8d3l6YRsSOQ0X1fSAvKR4BZ34FPqhxbjpQEfKN8BhzE9h X-Received: by 2002:a63:383:: with SMTP id 125-v6mr19206480pgd.421.1530466134674; Sun, 01 Jul 2018 10:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530466134; cv=none; d=google.com; s=arc-20160816; b=GrPO4D4VpceSmaeqG8sDTilZI74Z5031/EqJ8PhG8GxfEsBPsLF9WK3hp+PHGllvrl 8cCQhq/uX0AfzzH0FfuobipyN1HHtj4vepe/3Fg0w9JNWgfA4JURDP2V+j9yvokdP/yu 5CXsWHvffmOnXRxLogju9OA7K1BVuzMUNpZCCQVAH9h8kTwaD5dIUVjVIME+5oRfsyNL KjYxH8vsnY/MhQe2YU5EhD3WPZYC/DsvWoIrt2Th2oautrQfE028VQYbNrSZ86d3ho11 emESKNsDkSd6L357HmemGcGROru5IfYDgEaOHUf9r2/vIY5Z6J7rrPCDgYrdM6pnNv5R gd1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7k9vKYslcFE8x/w5dhoClXEsjLl5oQYorSdGom0caZw=; b=fW7V9VcjyFFvpHSqoHc3VeEWuWNw8Lg3eVbjOA8SnDPeOuMqtod1eO/su25zKWoTON WpERP3yt4RAmDLBX0O0/HV5w07IhHes6B0CUtr9wSy6dTBU+lIpWHmjSQTkdjvPAvVM4 iXvCutCMb0LiCMOmmQ3GgpESgRY55Rw9YGIy8oTBCpuP1+V1CVT4lGwzoTqRb1ANH/1F XDX4uFzvpS8T33Bk//WTWa7VX7vjElv43SKvVK4+009rT6EW+7JqLYz+StUZ5cclGGLG aOldRTzCtLlBCXpIVZauq5lP4QiiH2/6/h+eImdI/+x8uD3kMUqn60qO+REvtNillxuz Wf4g== 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 z18-v6si11661047pfl.209.2018.07.01.10.28.40; Sun, 01 Jul 2018 10:28:54 -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 S1030913AbeGAQhU (ORCPT + 99 others); Sun, 1 Jul 2018 12:37:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36200 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031367AbeGAQhN (ORCPT ); Sun, 1 Jul 2018 12:37:13 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 44B9892B; Sun, 1 Jul 2018 16:37:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , "Rafael J. Wysocki" Subject: [PATCH 4.17 018/220] PM / Domains: Fix error path during attach in genpd Date: Sun, 1 Jul 2018 18:20:42 +0200 Message-Id: <20180701160909.106655221@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ulf Hansson commit 72038df3c580c4c326b83c86149d7ac34007532a upstream. 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+ # v4.11+ Signed-off-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/domain.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2246,6 +2246,9 @@ int genpd_dev_pm_attach(struct device *d 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; }