2022-11-23 15:22:42

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

Hi all,

The Renesas RPC-IF provides either HyperFlash or SPI host access.
To handle this, three drivers are used:
1. The RPC-IF core diver,
2. An HyperFlash child driver,
3. An SPI child driver.

Currently this driver collection suffers from a sub-optimal division of
roles and reponsibilities, leading to (un)bind issues: after manually
unbinding the child driver, rebinding the child driver fails with
-EBUSY.

This patch series aims to fix this, by splitting off private data and
making the RPC-IF core driver responsible for resource acquisition.
After that, a few customary cleanups are provided.

This has been tested on the Salvator-X(S) and Ebisu-4D (HyperFlash) and
White-Hawk (QSPI FLASH) development boards.

Changes compared to v1[1]:
- Move the two fixes forward and add Fixes-tags to ease backporting,
as requested by Krzysztof,
- Add Acked-by,
- Rebased cleanups,
- Remove Runtime PM wrappers,
- Drop patch to add system suspend/resume support to the RPC-IF core
driver, as this is apparently not needed on R-Car M3-N and R-Car E3,
nor fixes the issue on R-Car H3 ES2.0. I will reply to the original
patch with my latest investigation results.

Thanks for your comments!

[1] [PATCH 0/7] memory: renesas-rpc-if: Rebind and s2ram fixes
https://lore.kernel.org/r/[email protected]

Geert Uytterhoeven (6):
memory: renesas-rpc-if: Split-off private data from struct rpcif
memory: renesas-rpc-if: Move resource acquisition to .probe()
memory: renesas-rpc-if: Always use dev in rpcif_probe()
memory: renesas-rpc-if: Improve Runtime PM handling
memory: renesas-rpc-if: Pass device instead of rpcif to rpcif_*()
memory: renesas-rpc-if: Remove Runtime PM wrappers

drivers/memory/renesas-rpc-if.c | 152 ++++++++++++++++++++------------
drivers/mtd/hyperbus/rpc-if.c | 18 ++--
drivers/spi/spi-rpc-if.c | 14 +--
include/memory/renesas-rpc-if.h | 34 +------
4 files changed, 118 insertions(+), 100 deletions(-)

--
2.25.1

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


2022-11-23 15:38:50

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH v2 4/6] memory: renesas-rpc-if: Improve Runtime PM handling

Convert from the deprecated pm_runtime_get_sync() to the new
pm_runtime_resume_and_get(), and add error checking.

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
v2:
- No changes.
---
drivers/memory/renesas-rpc-if.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c
index 83171242f9514c22..9346dcc29a36662e 100644
--- a/drivers/memory/renesas-rpc-if.c
+++ b/drivers/memory/renesas-rpc-if.c
@@ -304,12 +304,13 @@ int rpcif_hw_init(struct rpcif *rpcif, bool hyperflash)
{
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
u32 dummy;
+ int ret;

- pm_runtime_get_sync(rpc->dev);
+ ret = pm_runtime_resume_and_get(rpc->dev);
+ if (ret)
+ return ret;

if (rpc->type == RPCIF_RZ_G2L) {
- int ret;
-
ret = reset_control_reset(rpc->rstc);
if (ret)
return ret;
@@ -482,7 +483,9 @@ int rpcif_manual_xfer(struct rpcif *rpcif)
u32 smenr, smcr, pos = 0, max = rpc->bus_size == 2 ? 8 : 4;
int ret = 0;

- pm_runtime_get_sync(rpc->dev);
+ ret = pm_runtime_resume_and_get(rpc->dev);
+ if (ret < 0)
+ return ret;

regmap_update_bits(rpc->regmap, RPCIF_PHYCNT,
RPCIF_PHYCNT_CAL, RPCIF_PHYCNT_CAL);
@@ -650,11 +653,14 @@ ssize_t rpcif_dirmap_read(struct rpcif *rpcif, u64 offs, size_t len, void *buf)
struct rpcif_priv *rpc = dev_get_drvdata(rpcif->dev);
loff_t from = offs & (rpc->size - 1);
size_t size = rpc->size - from;
+ int ret;

if (len > size)
len = size;

- pm_runtime_get_sync(rpc->dev);
+ ret = pm_runtime_resume_and_get(rpc->dev);
+ if (ret < 0)
+ return ret;

regmap_update_bits(rpc->regmap, RPCIF_CMNCR, RPCIF_CMNCR_MD, 0);
regmap_write(rpc->regmap, RPCIF_DRCR, 0);
--
2.25.1

2022-11-27 21:54:44

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On 23/11/2022 15:41, Geert Uytterhoeven wrote:
> Hi all,
>
> The Renesas RPC-IF provides either HyperFlash or SPI host access.
> To handle this, three drivers are used:
> 1. The RPC-IF core diver,
> 2. An HyperFlash child driver,
> 3. An SPI child driver.
>

Thank you for the patch.
It is too late in the cycle for me to pick it up. I will take it after
the merge window.


Best regards,
Krzysztof

2022-11-27 21:54:54

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On 27/11/2022 22:31, Krzysztof Kozlowski wrote:
> On 23/11/2022 15:41, Geert Uytterhoeven wrote:
>> Hi all,
>>
>> The Renesas RPC-IF provides either HyperFlash or SPI host access.
>> To handle this, three drivers are used:
>> 1. The RPC-IF core diver,
>> 2. An HyperFlash child driver,
>> 3. An SPI child driver.
>>
>
> Thank you for the patch.
> It is too late in the cycle for me to pick it up. I will take it after
> the merge window.

Optionally, if you want to push it via Renesas SoC tree and there are no
conflicts with existing two patches, then these look good:

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Otherwise, I'll pick them up after the merge window.

Best regards,
Krzysztof

2022-11-28 08:02:54

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

Hi Krzysztof,

On Sun, Nov 27, 2022 at 10:34 PM Krzysztof Kozlowski
<[email protected]> wrote:
> On 27/11/2022 22:31, Krzysztof Kozlowski wrote:
> > On 23/11/2022 15:41, Geert Uytterhoeven wrote:
> >> The Renesas RPC-IF provides either HyperFlash or SPI host access.
> >> To handle this, three drivers are used:
> >> 1. The RPC-IF core diver,
> >> 2. An HyperFlash child driver,
> >> 3. An SPI child driver.
> >
> > Thank you for the patch.
> > It is too late in the cycle for me to pick it up. I will take it after
> > the merge window.
>
> Optionally, if you want to push it via Renesas SoC tree and there are no
> conflicts with existing two patches, then these look good:

It's too late for the Renesas tree, too.

> Reviewed-by: Krzysztof Kozlowski <[email protected]>
>
> Otherwise, I'll pick them up after the merge window.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2022-12-05 09:53:12

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On Wed, Nov 23, 2022 at 03:41:16PM +0100, Geert Uytterhoeven wrote:
> Hi all,
>
> The Renesas RPC-IF provides either HyperFlash or SPI host access.
> To handle this, three drivers are used:
> 1. The RPC-IF core diver,
> 2. An HyperFlash child driver,
> 3. An SPI child driver.
>
> Currently this driver collection suffers from a sub-optimal division of
> roles and reponsibilities, leading to (un)bind issues: after manually
> unbinding the child driver, rebinding the child driver fails with
> -EBUSY.
>
> This patch series aims to fix this, by splitting off private data and
> making the RPC-IF core driver responsible for resource acquisition.
> After that, a few customary cleanups are provided.
>
> This has been tested on the Salvator-X(S) and Ebisu-4D (HyperFlash) and
> White-Hawk (QSPI FLASH) development boards.

Sadly, I don't have the bandwidth to do a full review. But from a
glimpse, it all looks good. And from a high level PoV, this all makes a
lot of sense. So:

Acked-by: Wolfram Sang <[email protected]>


Attachments:
(No filename) (1.05 kB)
signature.asc (849.00 B)
Download all attachments

2022-12-27 09:07:44

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On Wed, 23 Nov 2022 15:41:16 +0100, Geert Uytterhoeven wrote:
> Hi all,
>
> The Renesas RPC-IF provides either HyperFlash or SPI host access.
> To handle this, three drivers are used:
> 1. The RPC-IF core diver,
> 2. An HyperFlash child driver,
> 3. An SPI child driver.
>
> [...]

Applied, thanks!

[1/6] memory: renesas-rpc-if: Split-off private data from struct rpcif
https://git.kernel.org/krzk/linux-mem-ctrl/c/f8fa9cb3fb16e06514fec0bac58996015dedc453
[2/6] memory: renesas-rpc-if: Move resource acquisition to .probe()
https://git.kernel.org/krzk/linux-mem-ctrl/c/9bdb35b864fb92c037b3e441ae8f3a7efc6bc679
[3/6] memory: renesas-rpc-if: Always use dev in rpcif_probe()
https://git.kernel.org/krzk/linux-mem-ctrl/c/ef1eabee9d97e263e61aa32c961f8c94cb3e6e5c
[4/6] memory: renesas-rpc-if: Improve Runtime PM handling
https://git.kernel.org/krzk/linux-mem-ctrl/c/f63d7c4d409461aee459c21797a3d7bb6039affd
[5/6] memory: renesas-rpc-if: Pass device instead of rpcif to rpcif_*()
https://git.kernel.org/krzk/linux-mem-ctrl/c/eb66a9971ffddd0dc0640f282768660875445ef1
[6/6] memory: renesas-rpc-if: Remove Runtime PM wrappers
https://git.kernel.org/krzk/linux-mem-ctrl/c/691f04fc5251f79c71975acf1f69ace87496738b

Best regards,
--
Krzysztof Kozlowski <[email protected]>

2022-12-27 09:10:15

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On 27/12/2022 09:59, Krzysztof Kozlowski wrote:
> On Wed, 23 Nov 2022 15:41:16 +0100, Geert Uytterhoeven wrote:
>> Hi all,
>>
>> The Renesas RPC-IF provides either HyperFlash or SPI host access.
>> To handle this, three drivers are used:
>> 1. The RPC-IF core diver,
>> 2. An HyperFlash child driver,
>> 3. An SPI child driver.
>>
>> [...]
>
> Applied, thanks!
>
> [1/6] memory: renesas-rpc-if: Split-off private data from struct rpcif
> https://git.kernel.org/krzk/linux-mem-ctrl/c/f8fa9cb3fb16e06514fec0bac58996015dedc453

Missing checkpatch. I corrected now:
WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1>
("<title line>")' - ie: 'Fixes: ca7d8b980b67 ("memory: add Renesas
RPC-IF driver")'


Best regards,
Krzysztof

2022-12-27 09:31:48

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] memory: renesas-rpc-if: Rebind fixes and misc cleanups

On Tue, Dec 27, 2022 at 10:06 AM Krzysztof Kozlowski
<[email protected]> wrote:
> On 27/12/2022 09:59, Krzysztof Kozlowski wrote:
> > On Wed, 23 Nov 2022 15:41:16 +0100, Geert Uytterhoeven wrote:
> >> The Renesas RPC-IF provides either HyperFlash or SPI host access.
> >> To handle this, three drivers are used:
> >> 1. The RPC-IF core diver,
> >> 2. An HyperFlash child driver,
> >> 3. An SPI child driver.
> >>
> >> [...]
> >
> > Applied, thanks!
> >
> > [1/6] memory: renesas-rpc-if: Split-off private data from struct rpcif
> > https://git.kernel.org/krzk/linux-mem-ctrl/c/f8fa9cb3fb16e06514fec0bac58996015dedc453
>
> Missing checkpatch. I corrected now:
> WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1>
> ("<title line>")' - ie: 'Fixes: ca7d8b980b67 ("memory: add Renesas
> RPC-IF driver")'

Oh well... Merry Xmas ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds