[PATCH rtems 3/3] bsps/fdt: Make sure data is cache aligned.
Christian Mauderer
christian.mauderer at embedded-brains.de
Mon Jul 20 05:18:02 UTC 2020
Hello Gedare,
thanks for the review.
On 17/07/2020 17:53, Gedare Bloom wrote:
> The other 2 BSP-specific patches look fine. I didn't look too closely
> at the imx-specific part.
>
> On Thu, Jul 16, 2020 at 11:55 PM Christian Mauderer
> <christian.mauderer at embedded-brains.de> wrote:
>>
>> The cache of the fdt blob is flushed after copy. Therefore it should be
>> aligned.
>> ---
>> bsps/shared/start/bsp-fdt.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-fdt.c
>> index 7e8d8922a8..f55273e4ca 100644
>> --- a/bsps/shared/start/bsp-fdt.c
>> +++ b/bsps/shared/start/bsp-fdt.c
>> @@ -28,10 +28,10 @@
>> #endif
>>
>> #ifdef BSP_FDT_BLOB_READ_ONLY
>> -static const uint32_t
>> +static const uint32_t CPU_STRUCTURE_ALIGNMENT
>
> Typically seen the alignment after the variable decl. Maybe it is
> flexible, but we might consider a rule for consistency if both
> placements work.
I'll move it.
>
>> bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)] = { 0xdeadbeef };
>> #else
>> -static uint32_t
>> +static uint32_t CPU_STRUCTURE_ALIGNMENT
>> bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)];
>> #endif
>>
>> @@ -48,6 +48,7 @@ void bsp_fdt_copy(const void *src)
>>
>> if (s != d) {
>> size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(src));
>> + size_t aligned_size = ((m-1) | (CPU_CACHE_LINE_BYTES-1)) + 1;
>
> This is a little bit of magic, I guess it works with cache line bytes
> a power of 2. Do we have a macro for this?
>
I don't think that we have a macro for alignment. But I found a
"roundup2" in newlibs sys/param.h after some searching. I'll try to use
that one.
>> size_t n = (m + sizeof(*d) - 1) / sizeof(*d);
>> size_t i;
>>
>> @@ -55,7 +56,7 @@ void bsp_fdt_copy(const void *src)
>> d[i] = s[i];
>> }
>>
>> - rtems_cache_flush_multiple_data_lines(d, m);
>> + rtems_cache_flush_multiple_data_lines(d, aligned_size);
>> }
>> }
>>
>> --
>> 2.26.2
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
--
--------------------------------------------
embedded brains GmbH
Herr Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.mauderer at embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax: +49-89-18 94 741 - 08
PGP: Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list