Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: aspeed: snoop: Add clock control logic

If LPC SNOOP driver is registered ahead of lpc-ctrl module, LPC
SNOOP block will be enabled without heart beating of LCLK until
lpc-ctrl enables the LCLK. This issue causes improper handling on
host interrupts when the host sends interrupt in that time frame.
Then kernel eventually forcibly disables the interrupt with
dumping stack and printing a 'nobody cared this irq' message out.

To prevent this issue, all LPC sub-nodes should enable LCLK
individually so this patch adds clock control logic into the LPC
SNOOP driver.

Fixes: 3772e5da4454 ("drivers/misc: Aspeed LPC snoop output using misc chardev")
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Signed-off-by: John Wang <wangzhiqiang.bj@bytedance.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20201208091748.1920-1-wangzhiqiang.bj@bytedance.com
Signed-off-by: Joel Stanley <joel@jms.id.au>

authored by

Jae Hyun Yoo and committed by
Joel Stanley
3f94cf15 5c8fe583

+27 -3
+27 -3
drivers/soc/aspeed/aspeed-lpc-snoop.c
··· 11 11 */ 12 12 13 13 #include <linux/bitops.h> 14 + #include <linux/clk.h> 14 15 #include <linux/interrupt.h> 15 16 #include <linux/fs.h> 16 17 #include <linux/kfifo.h> ··· 68 67 struct aspeed_lpc_snoop { 69 68 struct regmap *regmap; 70 69 int irq; 70 + struct clk *clk; 71 71 struct aspeed_lpc_snoop_channel chan[NUM_SNOOP_CHANNELS]; 72 72 }; 73 73 ··· 284 282 return -ENODEV; 285 283 } 286 284 285 + lpc_snoop->clk = devm_clk_get(dev, NULL); 286 + if (IS_ERR(lpc_snoop->clk)) { 287 + rc = PTR_ERR(lpc_snoop->clk); 288 + if (rc != -EPROBE_DEFER) 289 + dev_err(dev, "couldn't get clock\n"); 290 + return rc; 291 + } 292 + rc = clk_prepare_enable(lpc_snoop->clk); 293 + if (rc) { 294 + dev_err(dev, "couldn't enable clock\n"); 295 + return rc; 296 + } 297 + 287 298 rc = aspeed_lpc_snoop_config_irq(lpc_snoop, pdev); 288 299 if (rc) 289 - return rc; 300 + goto err; 290 301 291 302 rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 0, port); 292 303 if (rc) 293 - return rc; 304 + goto err; 294 305 295 306 /* Configuration of 2nd snoop channel port is optional */ 296 307 if (of_property_read_u32_index(dev->of_node, "snoop-ports", 297 308 1, &port) == 0) { 298 309 rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 1, port); 299 - if (rc) 310 + if (rc) { 300 311 aspeed_lpc_disable_snoop(lpc_snoop, 0); 312 + goto err; 313 + } 301 314 } 315 + 316 + return 0; 317 + 318 + err: 319 + clk_disable_unprepare(lpc_snoop->clk); 302 320 303 321 return rc; 304 322 } ··· 330 308 /* Disable both snoop channels */ 331 309 aspeed_lpc_disable_snoop(lpc_snoop, 0); 332 310 aspeed_lpc_disable_snoop(lpc_snoop, 1); 311 + 312 + clk_disable_unprepare(lpc_snoop->clk); 333 313 334 314 return 0; 335 315 }