Skip to content

Commit fa3dcd3

Browse files
hoshinolinamarcan
authored andcommitted
payload: Add tso=1 m1n1 option to enable TSO
Signed-off-by: Asahi Lina <[email protected]>
1 parent 0a05a01 commit fa3dcd3

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/payload.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ static void *load_kernel(void *p, size_t size)
155155
static size_t chosen_cnt = 0;
156156
static char *chosen[MAX_CHOSEN_VARS];
157157

158+
static bool enable_tso = false;
159+
158160
static bool check_var(u8 **p)
159161
{
160162
char *val = memchr(*p, '=', strnlen((char *)*p, MAX_VAR_NAME + 1));
@@ -179,6 +181,8 @@ static bool check_var(u8 **p)
179181
chainload_spec = val;
180182
} else if (IS_VAR("display=")) {
181183
display_configure(val);
184+
} else if (IS_VAR("tso=")) {
185+
enable_tso = val[0] == '1';
182186
} else {
183187
printf("Unknown variable %s\n", *p);
184188
}
@@ -226,6 +230,13 @@ static void *load_one_payload(void *start, size_t size)
226230
}
227231
}
228232

233+
void do_enable_tso(void)
234+
{
235+
u64 actlr = mrs(ACTLR_EL1);
236+
actlr |= BIT(1); // Enable TSO
237+
msr(ACTLR_EL1, actlr);
238+
}
239+
229240
int payload_run(void)
230241
{
231242
const char *target = adt_getprop(adt, 0, "target-type", NULL);
@@ -255,6 +266,17 @@ int payload_run(void)
255266

256267
if (kernel && fdt) {
257268
smp_start_secondaries();
269+
if (enable_tso) {
270+
271+
do_enable_tso();
272+
for (int i = 1; i < MAX_CPUS; i++) {
273+
if (smp_is_alive(i)) {
274+
smp_call0(i, do_enable_tso);
275+
smp_wait(i);
276+
}
277+
}
278+
kboot_set_chosen("apple,tso", "");
279+
}
258280

259281
for (size_t i = 0; i < chosen_cnt; i++) {
260282
char *val = memchr(chosen[i], '=', MAX_VAR_NAME + 1);

0 commit comments

Comments
 (0)