diff mbox series

[1/1] clk: rs9: Fix suspend/resume

Message ID 20230310074940.3475703-1-alexander.stein@ew.tq-group.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/1] clk: rs9: Fix suspend/resume | expand

Commit Message

Alexander Stein March 10, 2023, 7:49 a.m. UTC
Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
without removing cache synchronization in resume path results in a
kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
Enable flat cache again to support resume again. num_reg_defaults_raw
is necessary to read the cache defaults from hardware. Some registers
are strapped in hardware and cannot be provided in software.

Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
There is also a series to not panic when using regcache_sync on
REGCACHE_NONE maps at [1].

[1] https://lore.kernel.org/lkml/20230310073911.3470892-1-alexander.stein@ew.tq-group.com/T/#u

 drivers/clk/clk-renesas-pcie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Boyd March 13, 2023, 10:26 p.m. UTC | #1
Quoting Alexander Stein (2023-03-09 23:49:40)
> Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> without removing cache synchronization in resume path results in a
> kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
> Enable flat cache again to support resume again. num_reg_defaults_raw
> is necessary to read the cache defaults from hardware. Some registers
> are strapped in hardware and cannot be provided in software.
> 
> Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
> There is also a series to not panic when using regcache_sync on
> REGCACHE_NONE maps at [1].

And it was rejected?

> 
> [1] https://lore.kernel.org/lkml/20230310073911.3470892-1-alexander.stein@ew.tq-group.com/T/#u
>
Alexander Stein March 14, 2023, 7:22 a.m. UTC | #2
Am Montag, 13. März 2023, 23:26:54 CET schrieb Stephen Boyd:
> Quoting Alexander Stein (2023-03-09 23:49:40)
> 
> > Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> > without removing cache synchronization in resume path results in a
> > kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
> > Enable flat cache again to support resume again. num_reg_defaults_raw
> > is necessary to read the cache defaults from hardware. Some registers
> > are strapped in hardware and cannot be provided in software.
> > 
> > Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > ---
> > There is also a series to not panic when using regcache_sync on
> > REGCACHE_NONE maps at [1].
> 
> And it was rejected?

v2 has been accepted and is available at [1] in regmap's for-next branch.

Best regards,
Alexander

[1] https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/
commit/?id=fd883d79e4dcd2417c2b80756f22a2ff03b0f6e0
Stephen Boyd March 20, 2023, 7:35 p.m. UTC | #3
Quoting Alexander Stein (2023-03-14 00:22:07)
> Am Montag, 13. M�rz 2023, 23:26:54 CET schrieb Stephen Boyd:
> > Quoting Alexander Stein (2023-03-09 23:49:40)
> > 
> > > Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> > > without removing cache synchronization in resume path results in a
> > > kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
> > > Enable flat cache again to support resume again. num_reg_defaults_raw
> > > is necessary to read the cache defaults from hardware. Some registers
> > > are strapped in hardware and cannot be provided in software.
> > > 
> > > Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > > ---
> > > There is also a series to not panic when using regcache_sync on
> > > REGCACHE_NONE maps at [1].
> > 
> > And it was rejected?
> 
> v2 has been accepted and is available at [1] in regmap's for-next branch.
> 

So this still needs to be applied and backported to fix stable kernels?
Alexander Stein March 21, 2023, 6:20 a.m. UTC | #4
Am Montag, 20. März 2023, 20:35:41 CET schrieb Stephen Boyd:
> Quoting Alexander Stein (2023-03-14 00:22:07)
> 
> > Am Montag, 13. M�rz 2023, 23:26:54 CET schrieb Stephen Boyd:
> > > Quoting Alexander Stein (2023-03-09 23:49:40)
> > > 
> > > > Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C
> > > > accessors")
> > > > without removing cache synchronization in resume path results in a
> > > > kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
> > > > Enable flat cache again to support resume again. num_reg_defaults_raw
> > > > is necessary to read the cache defaults from hardware. Some registers
> > > > are strapped in hardware and cannot be provided in software.
> > > > 
> > > > Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> > > > ---
> > > > There is also a series to not panic when using regcache_sync on
> > > > REGCACHE_NONE maps at [1].
> > > 
> > > And it was rejected?
> > 
> > v2 has been accepted and is available at [1] in regmap's for-next branch.
> 
> So this still needs to be applied and backported to fix stable kernels?

IMHO yes, because without cache nothing will be stored/restored upon suspend/
resume. The other patch in regcache was just to ensure broken drivers (like 
this one in the current state) do not crash the kernel.

Best regards,
Alexander
Stephen Boyd March 21, 2023, 5:47 p.m. UTC | #5
Quoting Alexander Stein (2023-03-09 23:49:40)
> Disabling the cache in commit 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> without removing cache synchronization in resume path results in a
> kernel panic as map->cache_ops is unset, due to REGCACHE_NONE.
> Enable flat cache again to support resume again. num_reg_defaults_raw
> is necessary to read the cache defaults from hardware. Some registers
> are strapped in hardware and cannot be provided in software.
> 
> Fixes: 2ff4ba9e3702 ("clk: rs9: Fix I2C accessors")
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---

Applied to clk-fixes
diff mbox series

Patch

diff --git a/drivers/clk/clk-renesas-pcie.c b/drivers/clk/clk-renesas-pcie.c
index 1e8b196e36f3..3377ee55c4f0 100644
--- a/drivers/clk/clk-renesas-pcie.c
+++ b/drivers/clk/clk-renesas-pcie.c
@@ -149,8 +149,9 @@  static int rs9_regmap_i2c_read(void *context,
 static const struct regmap_config rs9_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
-	.cache_type = REGCACHE_NONE,
+	.cache_type = REGCACHE_FLAT,
 	.max_register = RS9_REG_BCP,
+	.num_reg_defaults_raw = 0x8,
 	.rd_table = &rs9_readable_table,
 	.wr_table = &rs9_writeable_table,
 	.reg_write = rs9_regmap_i2c_write,