From patchwork Thu Apr 7 13:20:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 65319 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp74888lbl; Thu, 7 Apr 2016 06:21:04 -0700 (PDT) X-Received: by 10.98.87.5 with SMTP id l5mr4652754pfb.7.1460035264749; Thu, 07 Apr 2016 06:21:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si88411pfo.244.2016.04.07.06.21.04; Thu, 07 Apr 2016 06:21:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756114AbcDGNVD (ORCPT + 13 others); Thu, 7 Apr 2016 09:21:03 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:34522 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589AbcDGNVC (ORCPT ); Thu, 7 Apr 2016 09:21:02 -0400 Received: by mail-lf0-f47.google.com with SMTP id j11so56673804lfb.1 for ; Thu, 07 Apr 2016 06:21:01 -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=+WPuyafd8wfFo1g/ydIOisdQvli90VCvBZ0jeMgrP94=; b=NTsI58bXuVee5JxmuM3YNXViDtjLxH8vYQNOgxoRjn8hBF4/+YfjzjyaGbgG/zP5Y0 b19xDl7BEHde/FCFQPx6LnK9ZGuMDKIXDZM7ozwaFalhhDhYRUw65tqx9HxhEIPKnQTo EEKfSubC98+g2PKXHWGieHjrLw5MfABE3v5eI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+WPuyafd8wfFo1g/ydIOisdQvli90VCvBZ0jeMgrP94=; b=EMcYxswxAoSkJKLhcE34Cg9vk9yTuT0GhklGdMuPkBBG7dVHmaxBxiprtzNXOrpHAQ jqoqsLIyPxavsShznAQSIsCcbn/QJD0VYiZTAUMgTGkaG5oCxZSu6PF0Haxfpx0q4z+Z 9Mjzkh9dkclxGLCdilslEyM6bn/9IJa5BY3bG53L38HQOXCfgke962U396kNz/6nHnt+ dCcLdp8/gYJmry37dzhX0j/DKN7nHRz6Pm1/P81RUJzh4P8LmiBMQOZz7eDZgq0VYW9p HCnuZmAIy3QLzl50reYEdOdwqTIPNccsx5pypFwiVMHg5rJt6Kr7YEd1dc8ORZen7YNP yt7w== X-Gm-Message-State: AD7BkJLfvPCaFuw4Rm7L3bzbFTesZwRu0ZW47+/1hwggHIRkaSN7UN5c2f0xjwekmoGqjTMh X-Received: by 10.25.89.136 with SMTP id n130mr1242849lfb.52.1460035260415; Thu, 07 Apr 2016 06:21:00 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e141sm1279018lfe.18.2016.04.07.06.20.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 06:20:59 -0700 (PDT) From: Linus Walleij To: "Rafael J. Wysocki" , Wolfram Sang , Mark Brown , Ulf Hansson Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 2/3] i2c: let I2C masters inherit suspend child ignorance Date: Thu, 7 Apr 2016 15:20:36 +0200 Message-Id: <1460035237-12037-3-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1460035237-12037-1-git-send-email-linus.walleij@linaro.org> References: <1460035237-12037-1-git-send-email-linus.walleij@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When using a certain I2C device with runtime PM enabled on a certain I2C bus adaper the following happens: struct amba_device *foo \ struct i2c_adapter *bar \ struct i2c_client *baz The AMBA device foo has its device PM struct set to ignore children with pm_suspend_ignore_children(&foo->dev, true). This makes runtime PM work just fine locally in the driver: the fact that devices on the bus are suspended or resumed individually does not affect its operation, and the hardware is not power up unless transferring messages. However this child ignorance property is not inherited into the struct i2c_adapter *bar. On system suspend things will work fine. On system resume the following annoying phenomenon occurs: - In the pm_runtime_force_resume() path of struct i2c_client *baz, pm_runtime_set_active(&baz->dev); is eventually called. - This becomes __pm_runtime_set_status(&baz->dev, RPM_ACTIVE); - __pm_runtime_set_status() detects that RPM state is changed, and checks whether the parent is: not active (RPM_ACTIVE) and not ignoring its children If this happens it concludes something is wrong, because a parent that is not ignoring its children must be active before any children activate. - Since the struct i2c_adapter *bar has not inherited the child ignorance and thus flags that it must indeed go online before its children, the check bails out with -EBUSY, i.e. the i2c_client *baz thinks it can't work because it's parent is not online, and it respects its parent. - In the driver the .resume() callback returns -EBUSY from the runtime_force_resume() call as per above. This leaves the device in a suspended state, leading to bad behaviour later when the device is used. The following debug print is made with an extra printg patch but illustrates the problem: [ 17.040832] bh1780 2-0029: parent (i2c-2) is not active parent->power.ignore_children = 0 [ 17.040832] bh1780 2-0029: pm_runtime_force_resume: pm_runtime_set_active() failed (-16) [ 17.040863] dpm_run_callback(): pm_runtime_force_resume+0x0/0x88 returns -16 [ 17.040863] PM: Device 2-0029 failed to resume: error -16 Fix this by letting all struct i2c_adapter:s inherit the child ignorance setting from their parent when registering an adapter. This way the child will realize it is ignored and it can proceed to be resumed. Cc: Wolfram Sang Cc: Mark Brown Cc: Ulf Hansson Signed-off-by: Linus Walleij --- Wolfram: if I can convince you and Rafael that this is the right thing to do, I guess Rafael could eventually merge this oneliner through his PM tree with your ACK. --- drivers/i2c/i2c-core.c | 1 + 1 file changed, 1 insertion(+) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 0f2f8484e8ec..dd12d4a162ed 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1566,6 +1566,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) pm_runtime_no_callbacks(&adap->dev); pm_runtime_enable(&adap->dev); + pm_suspend_inherit_ignore_children(&adap->dev); #ifdef CONFIG_I2C_COMPAT res = class_compat_create_link(i2c_adapter_compat_class, &adap->dev,