* [PATCH] dm: Fix OF_BAD_ADDR definition
@ 2021-12-23 16:09 Patrice Chotard
2021-12-24 13:17 ` Simon Glass
0 siblings, 1 reply; 3+ messages in thread
From: Patrice Chotard @ 2021-12-23 16:09 UTC (permalink / raw
To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Simon Glass
When OF_LIVE flag is enabled on a 64 bits platform, there is an
issue when dev_read_addr() is called and need to perform an address
translation using __of_translate_address().
In case of error, __of_translate_address() return value is OF_BAD_ADDR
(wich is defined in include/dm/of.h to ((u64)-1) = 0xffffffffffffffff).
The return value of dev_read_addr() is often compared to FDT_ADDR_T_NONE
which is defined as (-1U) = 0xffffffff.
In this case the comparison is always false.
To fix this issue, define OF_BAD_ADDR to FDT_ADDR_T_NONE.
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
include/dm/of.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/dm/of.h b/include/dm/of.h
index 5cb6f44a6c..0208cc234a 100644
--- a/include/dm/of.h
+++ b/include/dm/of.h
@@ -95,7 +95,7 @@ static inline bool of_live_active(void)
return gd_of_root() != NULL;
}
-#define OF_BAD_ADDR ((u64)-1)
+#define OF_BAD_ADDR FDT_ADDR_T_NONE
static inline const char *of_node_full_name(const struct device_node *np)
{
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dm: Fix OF_BAD_ADDR definition
2021-12-23 16:09 [PATCH] dm: Fix OF_BAD_ADDR definition Patrice Chotard
@ 2021-12-24 13:17 ` Simon Glass
2022-01-04 7:38 ` Patrice CHOTARD
0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2021-12-24 13:17 UTC (permalink / raw
To: Patrice Chotard; +Cc: U-Boot Mailing List, Patrick DELAUNAY, U-Boot STM32
Hi Patrice,
On Thu, 23 Dec 2021 at 09:09, Patrice Chotard
<patrice.chotard@foss.st.com> wrote:
>
> When OF_LIVE flag is enabled on a 64 bits platform, there is an
> issue when dev_read_addr() is called and need to perform an address
> translation using __of_translate_address().
>
> In case of error, __of_translate_address() return value is OF_BAD_ADDR
> (wich is defined in include/dm/of.h to ((u64)-1) = 0xffffffffffffffff).
> The return value of dev_read_addr() is often compared to FDT_ADDR_T_NONE
> which is defined as (-1U) = 0xffffffff.
> In this case the comparison is always false.
>
> To fix this issue, define OF_BAD_ADDR to FDT_ADDR_T_NONE.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
> include/dm/of.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Would it be better to define FDT_ADDR_T_NONE as something like ((ulong)(-1)) ?
>
> diff --git a/include/dm/of.h b/include/dm/of.h
> index 5cb6f44a6c..0208cc234a 100644
> --- a/include/dm/of.h
> +++ b/include/dm/of.h
> @@ -95,7 +95,7 @@ static inline bool of_live_active(void)
> return gd_of_root() != NULL;
> }
>
> -#define OF_BAD_ADDR ((u64)-1)
> +#define OF_BAD_ADDR FDT_ADDR_T_NONE
>
> static inline const char *of_node_full_name(const struct device_node *np)
> {
> --
> 2.17.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dm: Fix OF_BAD_ADDR definition
2021-12-24 13:17 ` Simon Glass
@ 2022-01-04 7:38 ` Patrice CHOTARD
0 siblings, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2022-01-04 7:38 UTC (permalink / raw
To: Simon Glass; +Cc: U-Boot Mailing List, Patrick DELAUNAY, U-Boot STM32
Hi Simon
On 12/24/21 2:17 PM, Simon Glass wrote:
> Hi Patrice,
>
> On Thu, 23 Dec 2021 at 09:09, Patrice Chotard
> <patrice.chotard@foss.st.com> wrote:
>>
>> When OF_LIVE flag is enabled on a 64 bits platform, there is an
>> issue when dev_read_addr() is called and need to perform an address
>> translation using __of_translate_address().
>>
>> In case of error, __of_translate_address() return value is OF_BAD_ADDR
>> (wich is defined in include/dm/of.h to ((u64)-1) = 0xffffffffffffffff).
>> The return value of dev_read_addr() is often compared to FDT_ADDR_T_NONE
>> which is defined as (-1U) = 0xffffffff.
>> In this case the comparison is always false.
>>
>> To fix this issue, define OF_BAD_ADDR to FDT_ADDR_T_NONE.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>> include/dm/of.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Would it be better to define FDT_ADDR_T_NONE as something like ((ulong)(-1)) ?
Agree, a v2 will be sent soon.
Thanks
Patrice
>>
>> diff --git a/include/dm/of.h b/include/dm/of.h
>> index 5cb6f44a6c..0208cc234a 100644
>> --- a/include/dm/of.h
>> +++ b/include/dm/of.h
>> @@ -95,7 +95,7 @@ static inline bool of_live_active(void)
>> return gd_of_root() != NULL;
>> }
>>
>> -#define OF_BAD_ADDR ((u64)-1)
>> +#define OF_BAD_ADDR FDT_ADDR_T_NONE
>>
>> static inline const char *of_node_full_name(const struct device_node *np)
>> {
>> --
>> 2.17.1
>>
>
> Regards,
> Simon
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-04 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-23 16:09 [PATCH] dm: Fix OF_BAD_ADDR definition Patrice Chotard
2021-12-24 13:17 ` Simon Glass
2022-01-04 7:38 ` Patrice CHOTARD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.