This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2634-Q1: AM263x Spinlock Question

Part Number: AM2634-Q1

Hi,

    Customer has some questions regarding to spinlock HW.  In the TRM, we suggest when use the spinlock, the maximum hold time should be less than 200 CPU cycles. So we suggest using for share memory access protect only.

What happens if this time is larger than 200cycles? Will spinlock be unlocked?   

Basically, they want to use spinlock to protect contention if multi cores want to use the peripheral. For example: several cores want to use the same FSI/UART to exchange information to external device.

1. Core1 takes spinlock.  ( the take time should be less than 200cycles).

2. Core1 start transmission by using  FSI/UART, this take more than 200 cycles.

3. Core2 to try to take spinlock during Core1 using FSI/UART.  When happens?  Since spinlock is locked more than 200 cycles, can core2 take spinlock? 

If HW spinlock is not good for this purpose, what is our recommendation? 

Regards

Andre 

  • Hi Andre,

    I am checking with the appropriate owner about this. It seems weird to me because for such a smaller  timing constraint, I am not aware what could be the use-case requirement behind this. Will get back before EOD.

    Thanks,
    G Kowshik

  • G Kowshik,

        According to test,  HW spinlock will not automatically unlock after 200cycles. If you review TRM descriptions across all AM24,AM26,AM27,  they all emphasizes 200cycles limitation. it's really weird. Can you please check why TRM emphasizes this limitation so much. Thanks.

    Regards

    Andre 

  • Hi Andre,

    I have received some reply on this case. It’s a guiding principle in software design to keep critical section small ( it’s even more important if you are implementing critical section by disabling interrupts globally - current SDK way). Advantage with spinlock is that it is not disabling interrupts, hw spinlock is the only way to implement multi core critical section and you can always yield a lower priority task if critical section is already taken by other core.

    So, it is not exactly a requirement to use splin lock, however if user wishes to use these then it's a recommendation to keep the critical section access locked by the spinlock for smaller times.

    I'll update here if I hear anything more.

  • G Kowshik,

        May I get your confirmation regarding HW behavior?

    Once one core get and put this spinlock into taken state, what will happen after 200 cycles? Will this spinlock keep in taken state until some one unlock it?

     

    Regards

    Andre

  • Hi Andre,

    I have checked the experts more deep here. They are saying no such restriction on timing is required because no such use-case has been validated til now or come across. I am checking with HW apps team to handle the behaviour of hardware. I will update you once I hear back.

    Thanks