[coreboot] Fw:Re: I want to submit some code, but there aresomeproblems.

王翔 merle at tya.email
Tue Jul 3 16:34:47 CEST 2018


>```
>if (running_on_hart(active)) { ... }
>```
>Yes, these codes are clearer.
>
>/*
> * If your code needs to temporarily block multiple-threads, do this:
> *     SMP_PAUSE(active)    // `active` is hartid of working thread
> *     ... single-threaded work ...
> *     SMP_RESUME()
> *     ... multi-threaded work ...
> */
>But sometimes multi-threaded work has to wait for the single-threaded work to complete.
>
>etc:
>    single-threaded work : init ddr controller
>    multi-threaded work  : some operations related to memory
>
>It is necessary to wait for the completion of single-threaded work.
>
>Xiang Wang

There is other solution here.
```
#define HART_NUM 5

void smp_sync(unsigned long *cnt) 
{
    atomic_add(cnt,1);
    do {
        barrier();
    }while(*cnt < HART_MAX);
}

static unsigned long cnt;
if (running_on_hart(active)) { ... }
smp_sync(&cnt);
```
This solution must define HART_NUM.
I think this solution is not as flexible as SMP_PAUSE/SMP_RESUME.
Which solution do you want to use?

Xiang Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot/attachments/20180703/29bb1d18/attachment.html>


More information about the coreboot mailing list