aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Held <felix.held@amd.corp-partner.google.com>2021-10-19 01:03:24 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-10-20 17:28:18 +0000
commitb04e2bae7730c98d9722b6b908e1ec1e8f28853f (patch)
tree7b285539cf0e24cfda78de7ec50095db3ddb4cb5 /src
parentedc5af552a3c706f29ee6cd80d93052f61742737 (diff)
cpu/x86/mp_init: factor out send_sipi_to_aps function
Apart from the SIPI number in the debug message the two instances of the SIPI sending code in start_aps are identical, so factor it out into a new send_sipi_to_aps function. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I6a921b81fce77fbf58c7ae3b50efd8c3e6e5aef3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/58453 Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/x86/mp_init.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index 1061f81c8a..13cfd4ce3a 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -425,6 +425,29 @@ static int apic_wait_timeout(int total_delay, int delay_step)
return timeout;
}
+/* Send Startup IPI to APs */
+static enum cb_err send_sipi_to_aps(int ap_count, atomic_t *num_aps, int sipi_vector)
+{
+ if (lapic_busy()) {
+ printk(BIOS_DEBUG, "Waiting for ICR not to be busy...");
+ if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
+ printk(BIOS_ERR, "timed out. Aborting.\n");
+ return CB_ERR;
+ }
+ printk(BIOS_DEBUG, "done.\n");
+ }
+
+ lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector,
+ 0);
+ printk(BIOS_DEBUG, "Waiting for SIPI to complete...");
+ if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */)) {
+ printk(BIOS_ERR, "timed out.\n");
+ return CB_ERR;
+ }
+ printk(BIOS_DEBUG, "done.\n");
+ return CB_SUCCESS;
+}
+
static int start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_aps)
{
int sipi_vector;
@@ -466,23 +489,8 @@ static int start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_aps)
}
/* Send 1st Startup IPI (SIPI) */
- if (lapic_busy()) {
- printk(BIOS_DEBUG, "Waiting for ICR not to be busy...");
- if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
- printk(BIOS_ERR, "timed out. Aborting.\n");
- return -1;
- }
- printk(BIOS_DEBUG, "done.\n");
- }
-
- lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector,
- 0);
- printk(BIOS_DEBUG, "Waiting for 1st SIPI to complete...");
- if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */)) {
- printk(BIOS_ERR, "timed out.\n");
+ if (send_sipi_to_aps(ap_count, num_aps, sipi_vector) != CB_SUCCESS)
return -1;
- }
- printk(BIOS_DEBUG, "done.\n");
/* Wait for CPUs to check in up to 200 us. */
wait_for_aps(num_aps, ap_count, 200 /* us */, 15 /* us */);
@@ -491,23 +499,8 @@ static int start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_aps)
return 0;
/* Send 2nd SIPI */
- if (lapic_busy()) {
- printk(BIOS_DEBUG, "Waiting for ICR not to be busy...");
- if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
- printk(BIOS_ERR, "timed out. Aborting.\n");
- return -1;
- }
- printk(BIOS_DEBUG, "done.\n");
- }
-
- lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector,
- 0);
- printk(BIOS_DEBUG, "Waiting for 2nd SIPI to complete...");
- if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */)) {
- printk(BIOS_ERR, "timed out.\n");
+ if (send_sipi_to_aps(ap_count, num_aps, sipi_vector) != CB_SUCCESS)
return -1;
- }
- printk(BIOS_DEBUG, "done.\n");
/* Wait for CPUs to check in. */
if (wait_for_aps(num_aps, ap_count, 100000 /* 100 ms */, 50 /* us */)) {