1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2015, Michael Neuling, IBM Corp.
4 * Original: Michael Neuling 19/7/2013
5 * Edited: Rashmica Gupta 01/12/2015
7 * Do some transactions, see if the tar is corrupted.
8 * If the transaction is aborted, the TAR should be rolled back to the
9 * checkpointed value before the transaction began. The value written to
10 * TAR in suspended mode should only remain in TAR if the transaction
22 int num_loops
= 10000;
29 SKIP_IF(!is_ppc64le());
31 for (i
= 0; i
< num_loops
; i
++)
36 "mtspr %[tar], 7;" /* tar = 1 */
39 "li 4, 0x7000;" /* Loop lots, to use time */
40 "2:;" /* Start loop */
42 "mtspr %[tar], 7;" /* tar = 2 */
45 "mtspr %[tar], 7;" /* tar = 3 */
52 /* Transaction sucess! TAR should be 3 */
54 "ori %[res], 7, 4;" // res = 3|4 = 7
57 /* Abort handler. TAR should be rolled back to 1 */
60 "ori %[res], 7, 8;" // res = 1|8 = 9
65 : "memory", "r0", "r4", "r7");
67 /* If result is anything else other than 7 or 9, the tar
68 * value must have been corrupted. */
69 if ((result
!= 7) && (result
!= 9))
75 int main(int argc
, char *argv
[])
77 /* A low number of iterations (eg 100) can cause a false pass */
79 if (strcmp(argv
[1], "-h") == 0) {
80 printf("Syntax:\n\t%s [<num loops>]\n",
84 num_loops
= atoi(argv
[1]);
88 printf("Starting, %d loops\n", num_loops
);
90 return test_harness(test_tar
, "tm_tar");