Skip to contentSkip to conversation

spi: Fix manual relocation calling more times

PATCH New Michal Simek 3 participants 11 messages Sep 17, 2019 – Sep 20, 2019 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +19 -15
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	struct dm_spi_ops *ops = spi_get_ops(bus);
-
-	if (ops->claim_bus)
-		ops->claim_bus += gd->reloc_off;
-	if (ops->release_bus)
-		ops->release_bus += gd->reloc_off;
-	if (ops->set_wordlen)
-		ops->set_wordlen += gd->reloc_off;
-	if (ops->xfer)
-		ops->xfer += gd->reloc_off;
-	if (ops->set_speed)
-		ops->set_speed += gd->reloc_off;
-	if (ops->set_mode)
-		ops->set_mode += gd->reloc_off;
-	if (ops->cs_info)
-		ops->cs_info += gd->reloc_off;
+	static int reloc_done;
+
+	if (!reloc_done) {
+		if (ops->claim_bus)
+			ops->claim_bus += gd->reloc_off;
+		if (ops->release_bus)
+			ops->release_bus += gd->reloc_off;
+		if (ops->set_wordlen)
+			ops->set_wordlen += gd->reloc_off;
+		if (ops->xfer)
+			ops->xfer += gd->reloc_off;
+		if (ops->set_speed)
+			ops->set_speed += gd->reloc_off;
+		if (ops->set_mode)
+			ops->set_mode += gd->reloc_off;
+		if (ops->cs_info)
+			ops->cs_info += gd->reloc_off;
+		reloc_done++;
+	}
 #endif
 
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 10 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Quoted 8 lines

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

Would like to take it coming MW? since we are close to release.

#2 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 16 lines · Jagan Teki
Quoted 15 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

Quoted 7 lines
Quoted 3 lines

---

Would like to take it coming MW? since we are close to release.

Taking it for next release is fine.

M

#3 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

In reply to Michal Simek
Quoted 36 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -6
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
-
-       if (ops->claim_bus)
-               ops->claim_bus += gd->reloc_off;
-       if (ops->release_bus)
-               ops->release_bus += gd->reloc_off;
-       if (ops->set_wordlen)

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice *bus) · line 132

Quoted 10 lines
drivers/spi/spi-uclass.c +1 -9
-               ops->set_wordlen += gd->reloc_off;
-       if (ops->xfer)
-               ops->xfer += gd->reloc_off;
-       if (ops->set_speed)
-               ops->set_speed += gd->reloc_off;
-       if (ops->set_mode)
-               ops->set_mode += gd->reloc_off;
-       if (ops->cs_info)
-               ops->cs_info += gd->reloc_off;
+       static int reloc_done;

So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple (differen) spi (or watchdog, sf, gpio) drivers?

Regards,
Simon

Quoted 28 lines
drivers/spi/spi-uclass.c +18 -1
+
+       if (!reloc_done) {
+               if (ops->claim_bus)
+                       ops->claim_bus += gd->reloc_off;
+               if (ops->release_bus)
+                       ops->release_bus += gd->reloc_off;
+               if (ops->set_wordlen)
+                       ops->set_wordlen += gd->reloc_off;
+               if (ops->xfer)
+                       ops->xfer += gd->reloc_off;
+               if (ops->set_speed)
+                       ops->set_speed += gd->reloc_off;
+               if (ops->set_mode)
+                       ops->set_mode += gd->reloc_off;
+               if (ops->cs_info)
+                       ops->cs_info += gd->reloc_off;
+               reloc_done++;
+       }
 #endif
 
        return 0;
--

2.17.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#4 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 42 lines · Simon Goldschmidt
Quoted 41 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -11
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
-
-       if (ops->claim_bus)
-               ops->claim_bus += gd->reloc_off;
-       if (ops->release_bus)
-               ops->release_bus += gd->reloc_off;
-       if (ops->set_wordlen)
-               ops->set_wordlen += gd->reloc_off;
-       if (ops->xfer)
-               ops->xfer += gd->reloc_off;
-       if (ops->set_speed)
-               ops->set_speed += gd->reloc_off;
Quoted 8 lines

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice *bus) · line 132

Quoted 5 lines
drivers/spi/spi-uclass.c +1 -4
-       if (ops->set_mode)
-               ops->set_mode += gd->reloc_off;
-       if (ops->cs_info)
-               ops->cs_info += gd->reloc_off;
+       static int reloc_done;

So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple (differen) spi (or watchdog, sf, gpio) drivers?

If you look at commits above you will see that several subsystems support multiple instances already.
We can check others as well.

M

#5 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 53 lines · Michal Simek
Quoted 42 lines · Simon Goldschmidt
Quoted 41 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -11
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
-
-       if (ops->claim_bus)
-               ops->claim_bus += gd->reloc_off;
-       if (ops->release_bus)
-               ops->release_bus += gd->reloc_off;
-       if (ops->set_wordlen)
-               ops->set_wordlen += gd->reloc_off;
-       if (ops->xfer)
-               ops->xfer += gd->reloc_off;
-       if (ops->set_speed)
-               ops->set_speed += gd->reloc_off;
Quoted 8 lines

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice *bus) · line 132

Quoted 5 lines
drivers/spi/spi-uclass.c +1 -4
-       if (ops->set_mode)
-               ops->set_mode += gd->reloc_off;
-       if (ops->cs_info)
-               ops->cs_info += gd->reloc_off;
+       static int reloc_done;

So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple (differen) spi (or watchdog, sf, gpio) drivers?

Quoted 3 lines

If you look at commits above you will see that several subsystems support multiple instances already.
We can check others as well.

I have looked at the commits above, that's why I ask. To me, this code relocates the ops of the device called first. If a second device has different ops, it won't get relocated, or am I wrong?

Given your other similar commits that were already accepted, I don't want to hold this one, but I still would like to understand.

Regards,
Simon

Quoted 6 lines

M

#6 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 58 lines · Simon Goldschmidt
Quoted 53 lines · Michal Simek
Quoted 42 lines · Simon Goldschmidt
Quoted 41 lines · Michal Simek

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs") commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC") commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -11
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
-
-       if (ops->claim_bus)
-               ops->claim_bus += gd->reloc_off;
-       if (ops->release_bus)
-               ops->release_bus += gd->reloc_off;
-       if (ops->set_wordlen)
-               ops->set_wordlen += gd->reloc_off;
-       if (ops->xfer)
-               ops->xfer += gd->reloc_off;
-       if (ops->set_speed)
-               ops->set_speed += gd->reloc_off;
Quoted 8 lines

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice *bus) · line 132

Quoted 5 lines
drivers/spi/spi-uclass.c +1 -4
-       if (ops->set_mode)
-               ops->set_mode += gd->reloc_off;
-       if (ops->cs_info)
-               ops->cs_info += gd->reloc_off;
+       static int reloc_done;

So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple (differen) spi (or watchdog, sf, gpio) drivers?

Quoted 3 lines

If you look at commits above you will see that several subsystems support multiple instances already.
We can check others as well.

Quoted 6 lines

I have looked at the commits above, that's why I ask. To me, this code relocates the ops of the device called first. If a second device has different ops, it won't get relocated, or am I wrong?

Given your other similar commits that were already accepted, I don't want to hold this one, but I still would like to understand.

I think you are right. It should be called once per driver and after relocation. That means that this should be the part variable should be the part of every ops and there should be also handling in connection to bind/unbind method.
On microblaze which is one architecture common systems only one driver is in place that's why none has found any issue with it.

Let me play with this a little bit to see if we can setup system with also bind/unbind to see how this is exactly working.

Thanks,
Michal

#7 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Michal Simek <[email protected]> schrieb am Do., 19. Sep. 2019, 16:22:

Quoted 79 lines · Simon Goldschmidt
Quoted 1 line

On Tue, Sep 17, 2019 at 2:48 PM Michal Simek <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines · Simon Goldschmidt
Quoted 1 line

On Tue, Sep 17, 2019 at 1:22 PM Michal Simek <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Ashok Reddy Soma <[email protected]>

When two instances of AXI QSPI with flash are added and tested simultaneously the spi driver operations are relocated twice. As a result code is accessing addresses outside of RAM when relocated second time which is causing a crash.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Tested on Microblaze.

Similar change was done in past by:
commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for

watchdogs")

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

commit 2588f2ddfd60 ("dm: sf: Add support for all targets which

requires MANUAL_RELOC")

Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 23 lines

commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")

---

 drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -6
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice *bus)
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
-
-       if (ops->claim_bus)
-               ops->claim_bus += gd->reloc_off;
-       if (ops->release_bus)
-               ops->release_bus += gd->reloc_off;
-       if (ops->set_wordlen)

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice *bus) · line 132

Quoted 10 lines
drivers/spi/spi-uclass.c +1 -9
-               ops->set_wordlen += gd->reloc_off;
-       if (ops->xfer)
-               ops->xfer += gd->reloc_off;
-       if (ops->set_speed)
-               ops->set_speed += gd->reloc_off;
-       if (ops->set_mode)
-               ops->set_mode += gd->reloc_off;
-       if (ops->cs_info)
-               ops->cs_info += gd->reloc_off;
+       static int reloc_done;

So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple (differen) spi (or watchdog, sf, gpio) drivers?

Quoted 6 lines
Quoted 3 lines

If you look at commits above you will see that several subsystems support multiple instances already.
We can check others as well.

I have looked at the commits above, that's why I ask. To me, this code relocates the ops of the device called first. If a second device has

different

Quoted 3 lines

ops, it won't get relocated, or am I wrong?

Given your other similar commits that were already accepted, I don't

want to

Quoted 1 line

hold this one, but I still would like to understand.

I think you are right. It should be called once per driver and after relocation. That means that this should be the part variable should be the part of every ops and there should be also handling in connection to bind/unbind method.
On microblaze which is one architecture common systems only one driver is in place that's why none has found any issue with it.

Quoted 3 lines

Let me play with this a little bit to see if we can setup system with also bind/unbind to see how this is exactly working.

Right, that's what I came to when thinking about it again. That way, it could even be the framework that relocates all ops...

Regards,
Simon

Quoted 3 lines

Thanks,
Michal

#8 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 93 lines · Simon Goldschmidt

Michal Simek <michal.simek at xilinx.com <mailto:[email protected]>> schrieb am Do., 19. Sep. 2019, 16:22:

    On 17. 09. 19 14:53, Simon Goldschmidt wrote:
    > On Tue, Sep 17, 2019 at 2:48 PM Michal Simek
    <michal.simek at xilinx.com <mailto:[email protected]>> wrote:
    >>
    >> On 17. 09. 19 14:43, Simon Goldschmidt wrote:
    >>> On Tue, Sep 17, 2019 at 1:22 PM Michal Simek
    <michal.simek at xilinx.com <mailto:[email protected]>> wrote:
    >>>>
    >>>> From: Ashok Reddy Soma <[email protected]
    <mailto:[email protected]>>
    >>>>
    >>>> When two instances of AXI QSPI with flash are added and tested
    >>>> simultaneously the spi driver operations are relocated twice.
    >>>> As a result code is accessing addresses outside of RAM when
    >>>> relocated second time which is causing a crash.
    >>>>
    >>>> Tested on Microblaze.
    >>>>
    >>>> Similar change was done in past by:
    >>>> commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation
    for watchdogs")
    >>>> commit 2588f2ddfd60 ("dm: sf: Add support for all targets which
    requires MANUAL_RELOC")
    >>>> commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for
    gpio")
    >>>>
    >>>> Signed-off-by: Ashok Reddy Soma <[email protected]
    <mailto:[email protected]>>
    >>>> Signed-off-by: Michal Simek <[email protected]
    <mailto:[email protected]>>
    >>>> ---
    >>>>
    >>>>  drivers/spi/spi-uclass.c | 34 +++++++++++++++++++---------------
    >>>>  1 file changed, 19 insertions(+), 15 deletions(-)
    >>>>
    >>>> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
    >>>> index 88cb2a126227..6d63006d186c 100644
    >>>> --- a/drivers/spi/spi-uclass.c
    >>>> +++ b/drivers/spi/spi-uclass.c
    >>>> @@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice
    *bus)
    >>>>  #endif
    >>>>  #if defined(CONFIG_NEEDS_MANUAL_RELOC)
    >>>>         struct dm_spi_ops *ops = spi_get_ops(bus);
    >>>> -
    >>>> -       if (ops->claim_bus)
    >>>> -               ops->claim_bus += gd->reloc_off;
    >>>> -       if (ops->release_bus)
    >>>> -               ops->release_bus += gd->reloc_off;
    >>>> -       if (ops->set_wordlen)
    >>>> -               ops->set_wordlen += gd->reloc_off;
    >>>> -       if (ops->xfer)
    >>>> -               ops->xfer += gd->reloc_off;
    >>>> -       if (ops->set_speed)
    >>>> -               ops->set_speed += gd->reloc_off;
    >>>> -       if (ops->set_mode)
    >>>> -               ops->set_mode += gd->reloc_off;
    >>>> -       if (ops->cs_info)
    >>>> -               ops->cs_info += gd->reloc_off;
    >>>> +       static int reloc_done;
    >>>
    >>> So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple
    >>> (differen) spi (or watchdog, sf, gpio) drivers?
    >>
    >> If you look at commits above you will see that several subsystems
    >> support multiple instances already.
    >> We can check others as well.
    >
    > I have looked at the commits above, that's why I ask. To me, this code
    > relocates the ops of the device called first. If a second device
    has different
    > ops, it won't get relocated, or am I wrong?
    >
    > Given your other similar commits that were already accepted, I
    don't want to
    > hold this one, but I still would like to understand.

    I think you are right. It should be called once per driver and after
    relocation.  That means that this should be the part variable should be
    the part of every ops and there should be also handling in connection to
    bind/unbind method.
    On microblaze which is one architecture common systems only one driver
    is in place that's why none has found any issue with it.

    Let me play with this a little bit to see if we can setup system with
    also bind/unbind to see how this is exactly working.
Quoted 2 lines

Right, that's what I came to when thinking about it again. That way, it could even be the framework that relocates all ops...

Framework is doing it already but we should do it without static variable.

Thanks,
Michal

#9 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Michal Simek <[email protected]> schrieb am Fr., 20. Sep. 2019, 10:17:

Quoted 95 lines · Simon Goldschmidt
Quoted 31 lines

Michal Simek <michal.simek at xilinx.com <mailto:[email protected]>> schrieb am Do., 19. Sep. 2019, 16:22:

On 17. 09. 19 14:53, Simon Goldschmidt wrote:
> On Tue, Sep 17, 2019 at 2:48 PM Michal Simek <michal.simek at xilinx.com <mailto:[email protected]>> wrote:
>>
>> On 17. 09. 19 14:43, Simon Goldschmidt wrote:
>>> On Tue, Sep 17, 2019 at 1:22 PM Michal Simek <michal.simek at xilinx.com <mailto:[email protected]>> wrote:
>>>>
>>>> From: Ashok Reddy Soma <[email protected] <mailto:[email protected]>>
>>>>
>>>> When two instances of AXI QSPI with flash are added and tested >>>> simultaneously the spi driver operations are relocated twice. >>>> As a result code is accessing addresses outside of RAM when >>>> relocated second time which is causing a crash. >>>>
>>>> Tested on Microblaze.
>>>>
>>>> Similar change was done in past by:
>>>> commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation for watchdogs")
>>>> commit 2588f2ddfd60 ("dm: sf: Add support for all targets which requires MANUAL_RELOC")
>>>> commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for gpio")
>>>>

Quoted 7 lines

>>>> Signed-off-by: Ashok Reddy Soma <[email protected] <mailto:[email protected]>>
>>>> Signed-off-by: Michal Simek <[email protected] <mailto:[email protected]>>
>>>> ---
>>>>
>>>> drivers/spi/spi-uclass.c | 34

+++++++++++++++++++---------------

Quoted 28 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/spi/spi-uclass.c static int spi_post_probe(struct udevice

Quoted 7 lines
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/spi/spi-uclass.c +0 -0
index 88cb2a126227..6d63006d186c 100644
@@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice
    *bus)
    >>>>  #endif
    >>>>  #if defined(CONFIG_NEEDS_MANUAL_RELOC)
    >>>>         struct dm_spi_ops *ops = spi_get_ops(bus);
    >>>> -
    >>>> -       if (ops->claim_bus)
    >>>> -               ops->claim_bus += gd->reloc_off;
    >>>> -       if (ops->release_bus)
    >>>> -               ops->release_bus += gd->reloc_off;
    >>>> -       if (ops->set_wordlen)
    >>>> -               ops->set_wordlen += gd->reloc_off;
    >>>> -       if (ops->xfer)
    >>>> -               ops->xfer += gd->reloc_off;
    >>>> -       if (ops->set_speed)
    >>>> -               ops->set_speed += gd->reloc_off;
    >>>> -       if (ops->set_mode)
    >>>> -               ops->set_mode += gd->reloc_off;
    >>>> -       if (ops->cs_info)
    >>>> -               ops->cs_info += gd->reloc_off;
    >>>> +       static int reloc_done;
    >>>
Quoted 8 lines
    >>> So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple
    >>> (differen) spi (or watchdog, sf, gpio) drivers?
    >>
    >> If you look at commits above you will see that several subsystems
    >> support multiple instances already.
    >> We can check others as well.
    >
    > I have looked at the commits above, that's why I ask. To me, this

code

Quoted 10 lines
Quoted 1 line

relocates the ops of the device called first. If a second device

has different
> ops, it won't get relocated, or am I wrong?
>
> Given your other similar commits that were already accepted, I don't want to
> hold this one, but I still would like to understand.

I think you are right. It should be called once per driver and after relocation. That means that this should be the part variable should

be

Quoted 1 line

the part of every ops and there should be also handling in

connection to

Quoted 2 lines

bind/unbind method.
On microblaze which is one architecture common systems only one

driver

Quoted 2 lines

is in place that's why none has found any issue with it.

Quoted 9 lines
Quoted 6 lines

Let me play with this a little bit to see if we can setup system with also bind/unbind to see how this is exactly working.

Right, that's what I came to when thinking about it again. That way, it could even be the framework that relocates all ops...

Framework is doing it already but we should do it without static variable.

Right, it's done in the UCLASSes. What I meant was it could already be done in the core DM framework.

Regards,
Simon

Quoted 3 lines

Thanks,
Michal

#10 lore raw

PATCH 1/1 spi: Fix manual relocation calling more times

Quoted 126 lines · Simon Goldschmidt

Michal Simek <michal.simek at xilinx.com <mailto:[email protected]>> schrieb am Fr., 20. Sep. 2019, 10:17:

On 19. 09. 19 16:35, Simon Goldschmidt wrote:
>
>
> Michal Simek <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
> schrieb am Do., 19. Sep. 2019, 16:22:
>
>     On 17. 09. 19 14:53, Simon Goldschmidt wrote:
>     > On Tue, Sep 17, 2019 at 2:48 PM Michal Simek
>     <michal.simek at xilinx.com <mailto:[email protected]> <mailto:michal.simek at xilinx.com <mailto:[email protected]>>> wrote:
>     >>
>     >> On 17. 09. 19 14:43, Simon Goldschmidt wrote:
>     >>> On Tue, Sep 17, 2019 at 1:22 PM Michal Simek
>     <michal.simek at xilinx.com <mailto:[email protected]> <mailto:michal.simek at xilinx.com <mailto:[email protected]>>> wrote:
>     >>>>
>     >>>> From: Ashok Reddy Soma <[email protected] <mailto:[email protected]>
>     <mailto:[email protected] <mailto:[email protected]>>>
>     >>>>
>     >>>> When two instances of AXI QSPI with flash are added and tested
>     >>>> simultaneously the spi driver operations are relocated twice. >     >>>> As a result code is accessing addresses outside of RAM when >     >>>> relocated second time which is causing a crash.
>     >>>>
>     >>>> Tested on Microblaze.
>     >>>>
>     >>>> Similar change was done in past by:
>     >>>> commit f238b3f0fbc9 ("watchdog: dm: Support manual relocation >     for watchdogs")
>     >>>> commit 2588f2ddfd60 ("dm: sf: Add support for all targets which
>     requires MANUAL_RELOC")
>     >>>> commit 1b4c2aa25bdf ("gpio: dm: Support manual relocation for >     gpio")
>     >>>>
>     >>>> Signed-off-by: Ashok Reddy Soma
<ashok.reddy.soma at xilinx.com <mailto:[email protected]> >     <mailto:[email protected] <mailto:[email protected]>>>
>     >>>> Signed-off-by: Michal Simek <[email protected] <mailto:[email protected]>
>     <mailto:michal.simek at xilinx.com <mailto:[email protected]>>> >     >>>> ---
>     >>>>
>     >>>>  drivers/spi/spi-uclass.c | 34
+++++++++++++++++++---------------
>     >>>>  1 file changed, 19 insertions(+), 15 deletions(-) >     >>>>
>     >>>> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
>     >>>> index 88cb2a126227..6d63006d186c 100644
>     >>>> --- a/drivers/spi/spi-uclass.c
>     >>>> +++ b/drivers/spi/spi-uclass.c
>     >>>> @@ -129,21 +129,25 @@ static int spi_post_probe(struct udevice
>     *bus)
>     >>>>  #endif
>     >>>>  #if defined(CONFIG_NEEDS_MANUAL_RELOC)
>     >>>>         struct dm_spi_ops *ops = spi_get_ops(bus); >     >>>> -
>     >>>> -       if (ops->claim_bus)
>     >>>> -               ops->claim_bus += gd->reloc_off;
>     >>>> -       if (ops->release_bus)
>     >>>> -               ops->release_bus += gd->reloc_off; >     >>>> -       if (ops->set_wordlen)
>     >>>> -               ops->set_wordlen += gd->reloc_off; >     >>>> -       if (ops->xfer)
>     >>>> -               ops->xfer += gd->reloc_off;
>     >>>> -       if (ops->set_speed)
>     >>>> -               ops->set_speed += gd->reloc_off;
>     >>>> -       if (ops->set_mode)
>     >>>> -               ops->set_mode += gd->reloc_off;
>     >>>> -       if (ops->cs_info)
>     >>>> -               ops->cs_info += gd->reloc_off;
>     >>>> +       static int reloc_done;
>     >>>
>     >>> So with CONFIG_NEEDS_MANUAL_RELOC, we don't support multiple >     >>> (differen) spi (or watchdog, sf, gpio) drivers?
>     >>
>     >> If you look at commits above you will see that several subsystems
>     >> support multiple instances already.
>     >> We can check others as well.
>     >
>     > I have looked at the commits above, that's why I ask. To me, this code
>     > relocates the ops of the device called first. If a second device >     has different
>     > ops, it won't get relocated, or am I wrong?
>     >
>     > Given your other similar commits that were already accepted, I >     don't want to
>     > hold this one, but I still would like to understand.
>
>     I think you are right. It should be called once per driver and after
>     relocation.  That means that this should be the part variable should be
>     the part of every ops and there should be also handling in connection to
>     bind/unbind method.
>     On microblaze which is one architecture common systems only one driver
>     is in place that's why none has found any issue with it. >
>     Let me play with this a little bit to see if we can setup system with
>     also bind/unbind to see how this is exactly working.
>
>
> Right, that's what I came to when thinking about it again. That way, it
> could even be the framework that relocates all ops...

Quoted 6 lines

Framework is doing it already but we should do it without static variable.

Right, it's done in the UCLASSes. What I meant was it could already be done in the core DM framework.

DM framework could call it and we can get it out of post_probe functions but still actual relocation should be likely done in uclasses because every device type has different ops.

Thanks,
Michal