Messages in this thread | | | Date | Wed, 16 Mar 2022 16:47:25 -0700 | From | Dave Hansen <> | Subject | Re: [PATCHv6 21/30] x86/acpi, x86/boot: Add multiprocessor wake-up support |
| |
On 3/15/22 19:08, Kirill A. Shutemov wrote: > + * The value of apic_id and wakeup_vector has to be set before updating > + * the wakeup command. To let compiler preserve order of writes, use > + * smp_store_release. > + */
Yeah, but that's not what's written:
> + smp_store_release(&acpi_mp_wake_mailbox->apic_id, apicid); > + smp_store_release(&acpi_mp_wake_mailbox->wakeup_vector, start_ip); > + smp_store_release(&acpi_mp_wake_mailbox->command, > + ACPI_MP_WAKE_COMMAND_WAKEUP);
That says that the write to ->apic_id has to happen before the write to ->wakeup_vector which has to happen before the write to ->command. What you have here *works*, but it doesn't match the comment.
If the problem were the compiler alone, I think three WRITE_ONCE()'s would also suffice. (Hint: WRITE_ONCE() is insufficient).
I _think_ this will do:
acpi_mp_wake_mailbox->apic_id = apicid; acpi_mp_wake_mailbox->wakeup_vector = start_ip; smp_wmb(); WRITE_ONCE(acpi_mp_wake_mailbox->command, ACPI_MP_WAKE_CO...);
But it's the end of the day and I'm sending this out under duress, so please double-check my logic.
Also, in all practicality, the WRITE_ONCE() isn't going to do much. ->command is 2 bytes and even the stupidest compiler isn't going to break that up. The compiler also fundamentally understands the ordering between this ->command write and the below:
READ_ONCE(acpi_mp_wake_mailbox->command).
The READ_ONCE() will also ensure that *it* goes out to memory. *But*, the WRITE_ONCE() does make it very clear what is supposed to happen.
| |