diff mbox series

[v2,1/9] dm: core: Fix iteration over driver_info records

Message ID 20221114124243.3719037-2-paul.barker@sancloud.com
State Accepted
Delegated to: Tom Rini
Headers show
Series Fixes for SPI boot on SanCloud BBE Lite | expand

Commit Message

Paul Barker Nov. 14, 2022, 12:42 p.m. UTC
We should only perform additional iteration steps when needed to
initialize the parent of a device. Other binding errors (such as a
missing driver) should not lead to additional iteration steps.

Unnecessary iteration steps can cause issues when memory is tightly
constrained (such as in the TPL/SPL) since device_bind_by_name()
unconditionally allocates memory for a struct udevice. On the SanCloud
BBE this led to boot failure caused by memory exhaustion in the SPL
when booting from SPI flash.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
---
 drivers/core/lists.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Tom Rini Dec. 2, 2022, 3:23 p.m. UTC | #1
On Mon, Nov 14, 2022 at 12:42:35PM +0000, Paul Barker wrote:

> We should only perform additional iteration steps when needed to
> initialize the parent of a device. Other binding errors (such as a
> missing driver) should not lead to additional iteration steps.
> 
> Unnecessary iteration steps can cause issues when memory is tightly
> constrained (such as in the TPL/SPL) since device_bind_by_name()
> unconditionally allocates memory for a struct udevice. On the SanCloud
> BBE this led to boot failure caused by memory exhaustion in the SPL
> when booting from SPI flash.
> 
> Signed-off-by: Paul Barker <paul.barker@sancloud.com>

For the series, applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 3878957c9ef4..8034a8f48d99 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -120,10 +120,10 @@  int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
 		int ret;
 
 		ret = bind_drivers_pass(parent, pre_reloc_only);
-		if (!ret)
-			break;
-		if (ret != -EAGAIN && !result)
+		if (!result || result == -EAGAIN)
 			result = ret;
+		if (ret != -EAGAIN)
+			break;
 	}
 
 	return result;