Received: by 10.192.165.148 with SMTP id m20csp3703165imm; Mon, 23 Apr 2018 10:50:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RHVVyTxSBbzZvhhz51xkftL94+EnEgDHk3PCBH1MlmaKWeoOtYcmfilD5a7MBEowAEIZH X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr22147492plb.179.1524505850109; Mon, 23 Apr 2018 10:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524505850; cv=none; d=google.com; s=arc-20160816; b=xGbadJHgxsXKLyT3XQygXCYsxV9p3bpY8HCo79UWeW4a1Pjd+G6buJPd2OD/ZDPeNn JwHGfr2TWlol9qXkP9TwG18QN5bGMPXMKG3f3jQHy4hWu0KMzZimU06Lhv966WyISsFv 63Q2/lwa/0iOr+3HBAQXRuM6ZvsBWEUnI4usxOeuIF+5kNmOSIm124PVKajxMJMna0aI +/AllznID37/DAJJeFcyhRv4zISxIMmuE2Obcq+p+CMChCXH1KD6sY/99ZW7GI3TWi8l 1PbH8o2Rf7LzFqsXq+B9zuc8EnM6DG1AJAmZ2Au7LlIm5w5HRvjaSuQxU8DLhrXajMbF Eyng== 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=X1T6JsaWF2jeyUZaw2PqTV66HAbmMm8QiPFmTXlblH4=; b=b+lU9a8dr8PJkQdZ+CKWtCBkzjpn+yIwen0J1XOGV/jgP5xTUwdMNO5gq8HQKc69VW TbPCQlf8zfz6FM1BrQb2+JXe9AKBfc5EIG0PKbAuOSQQoIKEv658spth9/J8eh8drhI6 tP+J4ie9LYxHL8FxlTWTNKG/kXz2k7VA1JIzAUUFVWssnMwmXeqDiwd4x3QKgmS+7oHT bNykpO1JlggFJhjkvj29nM3+KDcMrzqjmjvL48/jQeRJftOvijJ2nHIU4aEHksiNs54y kRXtUUiTMvWym5r02dWSrngGcV74Dkfc8/wnF8oTgzans0F078ZvhLNquwbXg6EhmTLS 35vA== 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 r11si11724411pff.160.2018.04.23.10.50.35; Mon, 23 Apr 2018 10:50:50 -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 S932447AbeDWRsj (ORCPT + 99 others); Mon, 23 Apr 2018 13:48:39 -0400 Received: from muru.com ([72.249.23.125]:38396 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932329AbeDWRqd (ORCPT ); Mon, 23 Apr 2018 13:46:33 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id E104D8423; Mon, 23 Apr 2018 17:48:15 +0000 (UTC) From: Tony Lindgren To: linux-omap@vger.kernel.org Cc: Dave Gerlach , Greg Kroah-Hartman , Nishanth Menon , Suman Anna , Tero Kristo , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 11/16] bus: ti-sysc: Improve suspend and resume handling Date: Mon, 23 Apr 2018 10:45:44 -0700 Message-Id: <20180423174549.57412-12-tony@atomide.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180423174549.57412-1-tony@atomide.com> References: <20180423174549.57412-1-tony@atomide.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on testing with more devices I noticed that some devices don't suspend or resume properly. We need to PM runtime suspend and resume devices if we have ddata->needs_resume set. Let's also improve the error handling and add few debug statements to make it easier to notice suspend and resume related issues if DEBUG is set. Signed-off-by: Tony Lindgren --- drivers/bus/ti-sysc.c | 54 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -662,6 +662,7 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev) static int sysc_suspend(struct device *dev) { struct sysc *ddata; + int error; ddata = dev_get_drvdata(dev); @@ -672,14 +673,27 @@ static int sysc_suspend(struct device *dev) if (!ddata->enabled) return 0; + dev_dbg(ddata->dev, "%s %s\n", __func__, + ddata->name ? ddata->name : ""); + + error = pm_runtime_put_sync_suspend(dev); + if (error < 0) { + dev_warn(ddata->dev, "%s not idle %i %s\n", + __func__, error, + ddata->name ? ddata->name : ""); + + return 0; + } + ddata->needs_resume = true; - return sysc_runtime_suspend(dev); + return 0; } static int sysc_resume(struct device *dev) { struct sysc *ddata; + int error; ddata = dev_get_drvdata(dev); @@ -691,9 +705,16 @@ static int sysc_resume(struct device *dev) dev_dbg(ddata->dev, "%s %s\n", __func__, ddata->name ? ddata->name : ""); - ddata->needs_resume = false; + error = pm_runtime_get_sync(dev); + if (error < 0) { + dev_err(ddata->dev, "%s error %i %s\n", + __func__, error, + ddata->name ? ddata->name : ""); - return sysc_runtime_resume(dev); + return error; + } + + ddata->needs_resume = false; } return 0; @@ -735,6 +756,9 @@ static int sysc_noirq_resume(struct device *dev) return 0; if (ddata->needs_resume) { + dev_dbg(ddata->dev, "%s %s\n", __func__, + ddata->name ? ddata->name : ""); + ddata->needs_resume = false; return sysc_runtime_resume(dev); @@ -1069,18 +1093,33 @@ static int sysc_child_suspend_noirq(struct device *dev) ddata = sysc_child_to_parent(dev); + dev_dbg(ddata->dev, "%s %s\n", __func__, + ddata->name ? ddata->name : ""); + error = pm_generic_suspend_noirq(dev); - if (error) + if (error) { + dev_err(dev, "%s error at %i: %i\n", + __func__, __LINE__, error); + return error; + } if (!pm_runtime_status_suspended(dev)) { error = pm_generic_runtime_suspend(dev); - if (error) + if (error) { + dev_err(dev, "%s error at %i: %i\n", + __func__, __LINE__, error); + return error; + } error = sysc_runtime_suspend(ddata->dev); - if (error) + if (error) { + dev_err(dev, "%s error at %i: %i\n", + __func__, __LINE__, error); + return error; + } ddata->child_needs_resume = true; } @@ -1095,6 +1134,9 @@ static int sysc_child_resume_noirq(struct device *dev) ddata = sysc_child_to_parent(dev); + dev_dbg(ddata->dev, "%s %s\n", __func__, + ddata->name ? ddata->name : ""); + if (ddata->child_needs_resume) { ddata->child_needs_resume = false; -- 2.17.0