Deleted Added
full compact
mp_machdep.c (236830) mp_machdep.c (236938)
1/*-
2 * Copyright (c) 1996, by Steve Passe
3 * Copyright (c) 2003, by Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996, by Steve Passe
3 * Copyright (c) 2003, by Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/amd64/amd64/mp_machdep.c 236830 2012-06-10 02:38:51Z iwasaki $");
28__FBSDID("$FreeBSD: head/sys/amd64/amd64/mp_machdep.c 236938 2012-06-12 00:14:54Z iwasaki $");
29
30#include "opt_cpu.h"
31#include "opt_kstack_pages.h"
32#include "opt_sched.h"
33#include "opt_smp.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 939 unchanged lines hidden (view full) ---

976 int cpus;
977
978 /* calculate the vector */
979 vector = (boot_address >> 12) & 0xff;
980
981 /* used as a watchpoint to signal AP startup */
982 cpus = mp_naps;
983
29
30#include "opt_cpu.h"
31#include "opt_kstack_pages.h"
32#include "opt_sched.h"
33#include "opt_smp.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 939 unchanged lines hidden (view full) ---

976 int cpus;
977
978 /* calculate the vector */
979 vector = (boot_address >> 12) & 0xff;
980
981 /* used as a watchpoint to signal AP startup */
982 cpus = mp_naps;
983
984 ipi_startup(apic_id, vector);
985
986 /* Wait up to 5 seconds for it to start. */
987 for (ms = 0; ms < 5000; ms++) {
988 if (mp_naps > cpus)
989 return 1; /* return SUCCESS */
990 DELAY(1000);
991 }
992 return 0; /* return FAILURE */
993}
994
995#ifdef COUNT_XINVLTLB_HITS
996u_int xhits_gbl[MAXCPU];
997u_int xhits_pg[MAXCPU];
998u_int xhits_rng[MAXCPU];
999static SYSCTL_NODE(_debug, OID_AUTO, xhits, CTLFLAG_RW, 0, "");
1000SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, global, CTLFLAG_RW, &xhits_gbl,
1001 sizeof(xhits_gbl), "IU", "");
1002SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, page, CTLFLAG_RW, &xhits_pg,
1003 sizeof(xhits_pg), "IU", "");
1004SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, range, CTLFLAG_RW, &xhits_rng,
1005 sizeof(xhits_rng), "IU", "");
1006
1007u_int ipi_global;
1008u_int ipi_page;
1009u_int ipi_range;
1010u_int ipi_range_size;
1011SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, &ipi_global, 0, "");
1012SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, &ipi_page, 0, "");
1013SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, &ipi_range, 0, "");
1014SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW,
1015 &ipi_range_size, 0, "");
1016
1017u_int ipi_masked_global;
1018u_int ipi_masked_page;
1019u_int ipi_masked_range;
1020u_int ipi_masked_range_size;
1021SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
1022 &ipi_masked_global, 0, "");
1023SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
1024 &ipi_masked_page, 0, "");
1025SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
1026 &ipi_masked_range, 0, "");
1027SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
1028 &ipi_masked_range_size, 0, "");
1029#endif /* COUNT_XINVLTLB_HITS */
1030
1031/*
1032 * Init and startup IPI.
1033 */
1034void
1035ipi_startup(int apic_id, int vector)
1036{
1037
984 /*
985 * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
986 * and running the target CPU. OR this INIT IPI might be latched (P5
987 * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
988 * ignored.
989 */
990
991 /* do an INIT IPI: assert RESET */

--- 34 unchanged lines hidden (view full) ---

1026 * recognized after hardware RESET or INIT IPI.
1027 */
1028
1029 lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
1030 APIC_LEVEL_DEASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_STARTUP |
1031 vector, apic_id);
1032 lapic_ipi_wait(-1);
1033 DELAY(200); /* wait ~200uS */
1038 /*
1039 * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
1040 * and running the target CPU. OR this INIT IPI might be latched (P5
1041 * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
1042 * ignored.
1043 */
1044
1045 /* do an INIT IPI: assert RESET */

--- 34 unchanged lines hidden (view full) ---

1080 * recognized after hardware RESET or INIT IPI.
1081 */
1082
1083 lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
1084 APIC_LEVEL_DEASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_STARTUP |
1085 vector, apic_id);
1086 lapic_ipi_wait(-1);
1087 DELAY(200); /* wait ~200uS */
1034
1035 /* Wait up to 5 seconds for it to start. */
1036 for (ms = 0; ms < 5000; ms++) {
1037 if (mp_naps > cpus)
1038 return 1; /* return SUCCESS */
1039 DELAY(1000);
1040 }
1041 return 0; /* return FAILURE */
1042}
1043
1088}
1089
1044#ifdef COUNT_XINVLTLB_HITS
1045u_int xhits_gbl[MAXCPU];
1046u_int xhits_pg[MAXCPU];
1047u_int xhits_rng[MAXCPU];
1048static SYSCTL_NODE(_debug, OID_AUTO, xhits, CTLFLAG_RW, 0, "");
1049SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, global, CTLFLAG_RW, &xhits_gbl,
1050 sizeof(xhits_gbl), "IU", "");
1051SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, page, CTLFLAG_RW, &xhits_pg,
1052 sizeof(xhits_pg), "IU", "");
1053SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, range, CTLFLAG_RW, &xhits_rng,
1054 sizeof(xhits_rng), "IU", "");
1055
1056u_int ipi_global;
1057u_int ipi_page;
1058u_int ipi_range;
1059u_int ipi_range_size;
1060SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, &ipi_global, 0, "");
1061SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, &ipi_page, 0, "");
1062SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, &ipi_range, 0, "");
1063SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW,
1064 &ipi_range_size, 0, "");
1065
1066u_int ipi_masked_global;
1067u_int ipi_masked_page;
1068u_int ipi_masked_range;
1069u_int ipi_masked_range_size;
1070SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
1071 &ipi_masked_global, 0, "");
1072SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
1073 &ipi_masked_page, 0, "");
1074SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
1075 &ipi_masked_range, 0, "");
1076SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
1077 &ipi_masked_range_size, 0, "");
1078#endif /* COUNT_XINVLTLB_HITS */
1079
1080/*
1081 * Send an IPI to specified CPU handling the bitmap logic.
1082 */
1083static void
1084ipi_send_cpu(int cpu, u_int ipi)
1085{
1086 u_int bitmap, old_pending, new_pending;
1087

--- 404 unchanged lines hidden ---
1090/*
1091 * Send an IPI to specified CPU handling the bitmap logic.
1092 */
1093static void
1094ipi_send_cpu(int cpu, u_int ipi)
1095{
1096 u_int bitmap, old_pending, new_pending;
1097

--- 404 unchanged lines hidden ---