mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
* [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices
@ 2023-11-06 11:04 Ahmad Fatoum
  2023-11-06 12:03 ` Roland Hieber
  2023-11-24 11:24 ` Roland Hieber
  0 siblings, 2 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-11-06 11:04 UTC (permalink / raw)
  To: oss-tools; +Cc: Leonard Göhrs

Recent rework introduced a regression for state located in the eMMC
user area described by DT fixed partitions. Whereas before, the first
device with type "disk" was taken, dt-utils will now iterate over all
devices to try to find a matching GPT partition. If it doesn't find any,
it will instead take the last device with type "disk", which will be the
second boot partition for eMMC devices leading barebox-state to access
/dev/mmcblkXboot1 instead of /dev/mmcblkX.

Let's fix this regression by restoring the old behavior of preferring the
first disk. This may not be totally future proof, but it worked ok for
years and a better solution can always be added later with a regular
release.

Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 src/libdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libdt.c b/src/libdt.c
index 650b40467587..72e8ab41e09b 100644
--- a/src/libdt.c
+++ b/src/libdt.c
@@ -2301,7 +2301,7 @@ static int cdev_from_block_device(struct udev_device *dev,
 		devtype = udev_device_get_devtype(part);
 		if (!devtype)
 			continue;
-		if (!strcmp(devtype, "disk")) {
+		if (!strcmp(devtype, "disk") && !best_match) {
 			best_match = part;
 
 			/* Should we try to find a matching partition first? */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices
  2023-11-06 11:04 [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices Ahmad Fatoum
@ 2023-11-06 12:03 ` Roland Hieber
  2023-11-06 12:24   ` Leonard Göhrs
  2023-11-24 11:24 ` Roland Hieber
  1 sibling, 1 reply; 4+ messages in thread
From: Roland Hieber @ 2023-11-06 12:03 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Leonard Göhrs, oss-tools

On Mon, Nov 06, 2023 at 12:04:05PM +0100, Ahmad Fatoum wrote:
> Recent rework introduced a regression for state located in the eMMC
> user area described by DT fixed partitions. Whereas before, the first
> device with type "disk" was taken, dt-utils will now iterate over all
> devices to try to find a matching GPT partition. If it doesn't find any,
> it will instead take the last device with type "disk", which will be the
> second boot partition for eMMC devices leading barebox-state to access
> /dev/mmcblkXboot1 instead of /dev/mmcblkX.
> 
> Let's fix this regression by restoring the old behavior of preferring the
> first disk. This may not be totally future proof, but it worked ok for
> years and a better solution can always be added later with a regular
> release.
> 
> Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Tested-by: Roland Hieber <rhi@pengutronix.de> [riot,imx6s-riotboard]

> ---
>  src/libdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libdt.c b/src/libdt.c
> index 650b40467587..72e8ab41e09b 100644
> --- a/src/libdt.c
> +++ b/src/libdt.c
> @@ -2301,7 +2301,7 @@ static int cdev_from_block_device(struct udev_device *dev,
>  		devtype = udev_device_get_devtype(part);
>  		if (!devtype)
>  			continue;
> -		if (!strcmp(devtype, "disk")) {
> +		if (!strcmp(devtype, "disk") && !best_match) {
>  			best_match = part;
>  
>  			/* Should we try to find a matching partition first? */
> -- 
> 2.39.2
> 
> 
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices
  2023-11-06 12:03 ` Roland Hieber
@ 2023-11-06 12:24   ` Leonard Göhrs
  0 siblings, 0 replies; 4+ messages in thread
From: Leonard Göhrs @ 2023-11-06 12:24 UTC (permalink / raw)
  To: Roland Hieber, Ahmad Fatoum; +Cc: oss-tools



On 06.11.23 13:03, Roland Hieber wrote:
> On Mon, Nov 06, 2023 at 12:04:05PM +0100, Ahmad Fatoum wrote:
>> Recent rework introduced a regression for state located in the eMMC
>> user area described by DT fixed partitions. Whereas before, the first
>> device with type "disk" was taken, dt-utils will now iterate over all
>> devices to try to find a matching GPT partition. If it doesn't find any,
>> it will instead take the last device with type "disk", which will be the
>> second boot partition for eMMC devices leading barebox-state to access
>> /dev/mmcblkXboot1 instead of /dev/mmcblkX.
>>
>> Let's fix this regression by restoring the old behavior of preferring the
>> first disk. This may not be totally future proof, but it worked ok for
>> years and a better solution can always be added later with a regular
>> release.
>>
>> Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> 
> Tested-by: Roland Hieber <rhi@pengutronix.de> [riot,imx6s-riotboard]
Tested-by: Leonard Göhrs <lgo@pengutronix.de> [lxa,stm32mp157c-tac-gen1]

>> ---
>>   src/libdt.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/libdt.c b/src/libdt.c
>> index 650b40467587..72e8ab41e09b 100644
>> --- a/src/libdt.c
>> +++ b/src/libdt.c
>> @@ -2301,7 +2301,7 @@ static int cdev_from_block_device(struct udev_device *dev,
>>   		devtype = udev_device_get_devtype(part);
>>   		if (!devtype)
>>   			continue;
>> -		if (!strcmp(devtype, "disk")) {
>> +		if (!strcmp(devtype, "disk") && !best_match) {
>>   			best_match = part;
>>   
>>   			/* Should we try to find a matching partition first? */
>> -- 
>> 2.39.2
>>
>>
>>
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices
  2023-11-06 11:04 [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices Ahmad Fatoum
  2023-11-06 12:03 ` Roland Hieber
@ 2023-11-24 11:24 ` Roland Hieber
  1 sibling, 0 replies; 4+ messages in thread
From: Roland Hieber @ 2023-11-24 11:24 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Leonard Göhrs, oss-tools

On Mon, Nov 06, 2023 at 12:04:05PM +0100, Ahmad Fatoum wrote:
> Recent rework introduced a regression for state located in the eMMC
> user area described by DT fixed partitions. Whereas before, the first
> device with type "disk" was taken, dt-utils will now iterate over all
> devices to try to find a matching GPT partition. If it doesn't find any,
> it will instead take the last device with type "disk", which will be the
> second boot partition for eMMC devices leading barebox-state to access
> /dev/mmcblkXboot1 instead of /dev/mmcblkX.
> 
> Let's fix this regression by restoring the old behavior of preferring the
> first disk. This may not be totally future proof, but it worked ok for
> years and a better solution can always be added later with a regular
> release.
> 
> Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  src/libdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, this patch is now released in v2023.11.0.

 - Roland

> diff --git a/src/libdt.c b/src/libdt.c
> index 650b40467587..72e8ab41e09b 100644
> --- a/src/libdt.c
> +++ b/src/libdt.c
> @@ -2301,7 +2301,7 @@ static int cdev_from_block_device(struct udev_device *dev,
>  		devtype = udev_device_get_devtype(part);
>  		if (!devtype)
>  			continue;
> -		if (!strcmp(devtype, "disk")) {
> +		if (!strcmp(devtype, "disk") && !best_match) {
>  			best_match = part;
>  
>  			/* Should we try to find a matching partition first? */
> -- 
> 2.39.2
> 
> 
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-24 11:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 11:04 [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices Ahmad Fatoum
2023-11-06 12:03 ` Roland Hieber
2023-11-06 12:24   ` Leonard Göhrs
2023-11-24 11:24 ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox