forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/tools/testing/selftests/powerpc/tm/tm-unavailable.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2017, Gustavo Romero, Breno Leitao, Cyril Bur, IBM Corp.
3
- * Licensed under GPLv2.
44 *
55 * Force FP, VEC and VSX unavailable exception during transaction in all
66 * possible scenarios regarding the MSR.FP and MSR.VEC state, e.g. when FP
....@@ -338,16 +338,19 @@
338338
339339 int tm_unavailable_test(void)
340340 {
341
- int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
341
+ int cpu, rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
342342 pthread_t t1;
343343 pthread_attr_t attr;
344344 cpu_set_t cpuset;
345345
346346 SKIP_IF(!have_htm());
347347
348
- /* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */
348
+ cpu = pick_online_cpu();
349
+ FAIL_IF(cpu < 0);
350
+
351
+ // Set only one CPU in the mask. Both threads will be bound to that CPU.
349352 CPU_ZERO(&cpuset);
350
- CPU_SET(0, &cpuset);
353
+ CPU_SET(cpu, &cpuset);
351354
352355 /* Init pthread attribute. */
353356 rc = pthread_attr_init(&attr);