From 88d700a3f3336d550acd329d40733480c617ca18 Mon Sep 17 00:00:00 2001 From: Joonyoung Shim Date: Thu, 4 Aug 2016 17:04:42 +0900 Subject: [PATCH] spi: exynos5433-isp: Fix doubled clock disable on suspend This patch came from the commit 9d7fd21acb20 ("spi/s3c64xx: Fix doubled clock disable on suspend") and the commit 4fcd9b9e06d4 ("spi: s3c64xx: simplify suspend / resume handlers"). Fix doubled clock disable and unprepare during PM suspend which triggered the warnings: [ 24.258574] WARNING: CPU: 0 PID: 326 at drivers/clk/clk.c:1010 clk_core_disable+0x90/0x14c() [ 24.258580] Modules linked in: [ 24.258589] CPU: 0 PID: 326 Comm: deviced Not tainted 4.1.0-01299-g70114f2-dirty #26 [ 24.258592] Hardware name: Samsung TM2 board (DT) [ 24.258595] Call trace: [ 24.258605] [] dump_backtrace+0x0/0x124 [ 24.258610] [] show_stack+0x10/0x1c [ 24.258618] [] dump_stack+0x78/0xbc [ 24.258624] [] warn_slowpath_common+0x9c/0xd4 [ 24.258628] [] warn_slowpath_null+0x14/0x20 [ 24.258632] [] clk_core_disable+0x8c/0x14c [ 24.258636] [] clk_disable+0x28/0x40 [ 24.258644] [] s3c64xx_spi_suspend+0x3c/0x70 [ 24.258652] [] platform_pm_suspend+0x20/0x50 [ 24.258659] [] dpm_run_callback+0x4c/0x190 [ 24.258664] [] __device_suspend+0xf4/0x380 [ 24.258669] [] dpm_suspend+0x128/0x35c [ 24.258674] [] dpm_suspend_start+0x68/0x78 [ 24.258681] [] suspend_devices_and_enter+0xb8/0x838 [ 24.258685] [] pm_suspend+0x380/0x5d8 [ 24.258690] [] state_store+0x7c/0xf4 [ 24.258697] [] kobj_attr_store+0x10/0x24 [ 24.258705] [] sysfs_kf_write+0x3c/0x50 [ 24.258710] [] kernfs_fop_write+0xbc/0x180 [ 24.258718] [] __vfs_write+0x28/0x10c [ 24.258722] [] vfs_write+0x8c/0x16c [ 24.258726] [] SyS_write+0x40/0xa0 The clocks may be already disabled before suspending. Check PM runtime suspend status and disable clocks only if device is not suspended. During resume do not enable the clocks if device is runtime suspended. Change-Id: I194a5d458744086998b82602146648d34ff7050a Signed-off-by: Joonyoung Shim --- drivers/spi/spi-exynos5433-isp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-exynos5433-isp.c b/drivers/spi/spi-exynos5433-isp.c index de36e21..8a7c92d 100644 --- a/drivers/spi/spi-exynos5433-isp.c +++ b/drivers/spi/spi-exynos5433-isp.c @@ -1394,12 +1394,13 @@ static int s3c64xx_spi_suspend(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); + int ret; spi_master_suspend(master); - /* Disable the clock */ - clk_disable_unprepare(sdd->src_clk); - clk_disable_unprepare(sdd->clk); + ret = pm_runtime_force_suspend(dev); + if (ret < 0) + return ret; sdd->cur_speed = 0; /* Output Clock is stopped */ @@ -1411,13 +1412,14 @@ static int s3c64xx_spi_resume(struct device *dev) struct spi_master *master = dev_get_drvdata(dev); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_info *sci = sdd->cntrlr_info; + int ret; if (sci->cfg_gpio) sci->cfg_gpio(); - /* Enable the clock */ - clk_prepare_enable(sdd->src_clk); - clk_prepare_enable(sdd->clk); + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; s3c64xx_spi_hwinit(sdd, sdd->port_id); -- 2.7.4