From patchwork Fri Feb 3 23:01:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 93330 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp810539qgi; Fri, 3 Feb 2017 15:01:37 -0800 (PST) X-Received: by 10.84.212.136 with SMTP id e8mr24631269pli.140.1486162897576; Fri, 03 Feb 2017 15:01:37 -0800 (PST) Return-Path: Received: from mail-pg0-x230.google.com (mail-pg0-x230.google.com. [2607:f8b0:400e:c05::230]) by mx.google.com with ESMTPS id v17si16816121pgi.136.2017.02.03.15.01.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 15:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::230 as permitted sender) client-ip=2607:f8b0:400e:c05::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::230 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x230.google.com with SMTP id v184so10127010pgv.3 for ; Fri, 03 Feb 2017 15:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=MtfkrUhDyC8dDM3+GJbGXbOg6STWhpy1kzf5e4JwUsQ=; b=V/XE+kPgp4DfTPiyUfFRbc/EozPJw50h/Vmn7l5SIBcpT7cnCvO/kMkf8UnWIGjaGZ oJtVOB8JGHQB4Fdqhfns7am4jRxPsMJv+lSJQ3+efGFXHP3LFo7CsOzumOVcQ2HZ1QjL t1WP/wMic6usduz0f86MswAOnV6CJB9AdJNz4= 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; bh=MtfkrUhDyC8dDM3+GJbGXbOg6STWhpy1kzf5e4JwUsQ=; b=tpnD+k0OHqlj/WUTXVudCDRF/cyrT8FY/9Io9vjXT5qQWnbrvVIPoYu6xhrcs2/06U pxqR32teNtRpgW2X6fA9wlTFuGeywWiSrewLgIgEMsU4FS0+ykK9kwMLIqqVv4MCST2z CFyannglZpRWftGZIA1KNdi1rTyPoYXrDluOcfyOVSTgoRsZL5PxTZxpWhZZdx3PNeNs kJM9yNksIa9owe/F6/L4hEuRcbadQrp01Q33JL18rAdol54bLaD+bbN1pW6b/T8J7+GE XBmEIxpC78CndMXhAluIvQOjnwnHPvHSVJZxGig3kBxvAmgeZp5dBpe+fotByq06tPrc o7AQ== X-Gm-Message-State: AIkVDXIjj3OKcVjWiHLYfxDufv6UhDUFpWj38kQoF1z1oHhPbbEO1c0W7EM4CRlZzFVwEbAbZSs= X-Received: by 10.84.196.131 with SMTP id l3mr24754705pld.150.1486162897193; Fri, 03 Feb 2017 15:01:37 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id m29sm69611487pfi.54.2017.02.03.15.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Feb 2017 15:01:36 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Wolfram Sang , linux-i2c@vger.kernel.org Subject: [PATCH] i2c: designwear: Fix clk warning on suspend/resume Date: Fri, 3 Feb 2017 15:01:33 -0800 Message-Id: <1486162893-12313-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 On my HiKey board, I'm seeing clk warnings on suspend/resume, which seem to be caused by runtime pm suspending the device, then the same suspend hook being called again on suspend time. Thus this patch adds suspend state tracking to avoid runtime pm and suspend causing double suspend calls on i2c-designware-platdrv. Feedback would be greatly appreciated! Cc: Jarkko Nikula Cc: Andy Shevchenko Cc: Mika Westerberg Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org Signed-off-by: John Stultz --- drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 9 +++++++++ 2 files changed, 10 insertions(+) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h index 26250b4..386cacb 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -126,6 +126,7 @@ struct dw_i2c_dev { void (*release_lock)(struct dw_i2c_dev *dev); bool pm_runtime_disabled; bool dynamic_tar_update_enabled; + bool suspended; }; #define ACCESS_SWAP 0x00000001 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 6ce4313..54084fe 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -340,8 +340,12 @@ static int dw_i2c_plat_suspend(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); + if (i_dev->suspended) + return 0; + i2c_dw_disable(i_dev); i2c_dw_plat_prepare_clk(i_dev, false); + i_dev->suspended = true; return 0; } @@ -351,11 +355,16 @@ static int dw_i2c_plat_resume(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); + if (!i_dev->suspended) + return 0; + i2c_dw_plat_prepare_clk(i_dev, true); if (!i_dev->pm_runtime_disabled) i2c_dw_init(i_dev); + i_dev->suspended = false; + return 0; }