Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 2 | /* bitops.S: Sparc64 atomic bit operations. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 4 | * Copyright (C) 2000, 2007 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 7 | #include <linux/linkage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <asm/asi.h> |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 9 | #include <asm/backoff.h> |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 10 | #include <asm/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 12 | .text |
| 13 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 14 | ENTRY(test_and_set_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 15 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | srlx %o0, 6, %g1 |
| 17 | mov 1, %o2 |
| 18 | sllx %g1, 3, %g3 |
| 19 | and %o0, 63, %g2 |
| 20 | sllx %o2, %g2, %o2 |
| 21 | add %o1, %g3, %o1 |
| 22 | 1: ldx [%o1], %g7 |
| 23 | or %g7, %o2, %g1 |
| 24 | casx [%o1], %g7, %g1 |
| 25 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 26 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | and %g7, %o2, %g2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | clr %o0 |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 29 | movrne %g2, 1, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | retl |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 31 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 32 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 33 | ENDPROC(test_and_set_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 34 | EXPORT_SYMBOL(test_and_set_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 36 | ENTRY(test_and_clear_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 37 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | srlx %o0, 6, %g1 |
| 39 | mov 1, %o2 |
| 40 | sllx %g1, 3, %g3 |
| 41 | and %o0, 63, %g2 |
| 42 | sllx %o2, %g2, %o2 |
| 43 | add %o1, %g3, %o1 |
| 44 | 1: ldx [%o1], %g7 |
| 45 | andn %g7, %o2, %g1 |
| 46 | casx [%o1], %g7, %g1 |
| 47 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 48 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | and %g7, %o2, %g2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | clr %o0 |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 51 | movrne %g2, 1, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | retl |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 53 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 54 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 55 | ENDPROC(test_and_clear_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 56 | EXPORT_SYMBOL(test_and_clear_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 58 | ENTRY(test_and_change_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 59 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | srlx %o0, 6, %g1 |
| 61 | mov 1, %o2 |
| 62 | sllx %g1, 3, %g3 |
| 63 | and %o0, 63, %g2 |
| 64 | sllx %o2, %g2, %o2 |
| 65 | add %o1, %g3, %o1 |
| 66 | 1: ldx [%o1], %g7 |
| 67 | xor %g7, %o2, %g1 |
| 68 | casx [%o1], %g7, %g1 |
| 69 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 70 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | and %g7, %o2, %g2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | clr %o0 |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 73 | movrne %g2, 1, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | retl |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 75 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 76 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 77 | ENDPROC(test_and_change_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 78 | EXPORT_SYMBOL(test_and_change_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 80 | ENTRY(set_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 81 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | srlx %o0, 6, %g1 |
| 83 | mov 1, %o2 |
| 84 | sllx %g1, 3, %g3 |
| 85 | and %o0, 63, %g2 |
| 86 | sllx %o2, %g2, %o2 |
| 87 | add %o1, %g3, %o1 |
| 88 | 1: ldx [%o1], %g7 |
| 89 | or %g7, %o2, %g1 |
| 90 | casx [%o1], %g7, %g1 |
| 91 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 92 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | nop |
| 94 | retl |
| 95 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 96 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 97 | ENDPROC(set_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 98 | EXPORT_SYMBOL(set_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 100 | ENTRY(clear_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 101 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | srlx %o0, 6, %g1 |
| 103 | mov 1, %o2 |
| 104 | sllx %g1, 3, %g3 |
| 105 | and %o0, 63, %g2 |
| 106 | sllx %o2, %g2, %o2 |
| 107 | add %o1, %g3, %o1 |
| 108 | 1: ldx [%o1], %g7 |
| 109 | andn %g7, %o2, %g1 |
| 110 | casx [%o1], %g7, %g1 |
| 111 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 112 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | nop |
| 114 | retl |
| 115 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 116 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 117 | ENDPROC(clear_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 118 | EXPORT_SYMBOL(clear_bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 120 | ENTRY(change_bit) /* %o0=nr, %o1=addr */ |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 121 | BACKOFF_SETUP(%o3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | srlx %o0, 6, %g1 |
| 123 | mov 1, %o2 |
| 124 | sllx %g1, 3, %g3 |
| 125 | and %o0, 63, %g2 |
| 126 | sllx %o2, %g2, %o2 |
| 127 | add %o1, %g3, %o1 |
| 128 | 1: ldx [%o1], %g7 |
| 129 | xor %g7, %o2, %g1 |
| 130 | casx [%o1], %g7, %g1 |
| 131 | cmp %g7, %g1 |
David S. Miller | 0f58189 | 2010-08-18 22:53:26 -0700 | [diff] [blame] | 132 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | nop |
| 134 | retl |
| 135 | nop |
David S. Miller | 24f287e | 2007-10-15 16:41:44 -0700 | [diff] [blame] | 136 | 2: BACKOFF_SPIN(%o3, %o4, 1b) |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 137 | ENDPROC(change_bit) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 138 | EXPORT_SYMBOL(change_bit) |