Hi Vikram, On 07/12/2022 06:18, Vikram Garhwal wrote:
Dynamic programming ops will modify the dt_host and there might be other function which are browsing the dt_host at the same time. To avoid the race conditions, adding rwlock for browsing the dt_host. But adding rwlock in device_tree.h causes following circular dependency: device_tree.h->rwlock.h->smp.h->asm/smp.h->device_tree.hInside arch/arm/include/asm/smp.h, there is one function which needs device_tree.h, moved the cpu related function to a new file: arch/arm/include/asm/cpu.h
Given there is only one function, I don't really see the benefits of splitting smp.h and then adding #ifdef CONFIG_ARM in the common code.
Instead, it would be better if we don't include device_tree.h in the header but in the c files that need to call arch_cpu_init() and forward declare dt_device_node.
Another potential approach is to move out the percpu_rwlock helpers in a separate header. The advantage with this approach is we would reduce the number of definition included everywhere (there are not many use of the percpu rwlock).
Cheers, -- Julien Grall
