Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 IBM Corp. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version |
| 7 | * 2 of the License, or (at your option) any later version. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/spinlock.h> |
| 11 | #include <linux/sched.h> |
Ingo Molnar | e601757 | 2017-02-01 16:36:40 +0100 | [diff] [blame] | 12 | #include <linux/sched/clock.h> |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 13 | #include <linux/slab.h> |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 14 | #include <linux/mutex.h> |
| 15 | #include <linux/mm.h> |
| 16 | #include <linux/uaccess.h> |
Michael Neuling | 2bc79ff | 2016-04-22 14:57:49 +1000 | [diff] [blame] | 17 | #include <linux/delay.h> |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 18 | #include <asm/synch.h> |
Michael Neuling | ec249dd | 2015-05-27 16:07:16 +1000 | [diff] [blame] | 19 | #include <misc/cxl-base.h> |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 20 | |
| 21 | #include "cxl.h" |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 22 | #include "trace.h" |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 23 | |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 24 | static int afu_control(struct cxl_afu *afu, u64 command, u64 clear, |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 25 | u64 result, u64 mask, bool enabled) |
| 26 | { |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 27 | u64 AFU_Cntl; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 28 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 29 | int rc = 0; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 30 | |
| 31 | spin_lock(&afu->afu_cntl_lock); |
| 32 | pr_devel("AFU command starting: %llx\n", command); |
| 33 | |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 34 | trace_cxl_afu_ctrl(afu, command); |
| 35 | |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 36 | AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); |
| 37 | cxl_p2n_write(afu, CXL_AFU_Cntl_An, (AFU_Cntl & ~clear) | command); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 38 | |
| 39 | AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); |
| 40 | while ((AFU_Cntl & mask) != result) { |
| 41 | if (time_after_eq(jiffies, timeout)) { |
| 42 | dev_warn(&afu->dev, "WARNING: AFU control timed out!\n"); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 43 | rc = -EBUSY; |
| 44 | goto out; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 45 | } |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 46 | |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 47 | if (!cxl_ops->link_ok(afu->adapter, afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 48 | afu->enabled = enabled; |
| 49 | rc = -EIO; |
| 50 | goto out; |
| 51 | } |
| 52 | |
Rasmus Villemoes | de36953 | 2015-06-11 13:27:52 +0200 | [diff] [blame] | 53 | pr_devel_ratelimited("AFU control... (0x%016llx)\n", |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 54 | AFU_Cntl | command); |
| 55 | cpu_relax(); |
| 56 | AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); |
Andrew Donnellan | 3382a62 | 2016-11-22 21:13:27 +1100 | [diff] [blame] | 57 | } |
Ian Munsie | 2a4f667 | 2016-06-30 04:51:26 +1000 | [diff] [blame] | 58 | |
| 59 | if (AFU_Cntl & CXL_AFU_Cntl_An_RA) { |
| 60 | /* |
| 61 | * Workaround for a bug in the XSL used in the Mellanox CX4 |
| 62 | * that fails to clear the RA bit after an AFU reset, |
| 63 | * preventing subsequent AFU resets from working. |
| 64 | */ |
| 65 | cxl_p2n_write(afu, CXL_AFU_Cntl_An, AFU_Cntl & ~CXL_AFU_Cntl_An_RA); |
| 66 | } |
| 67 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 68 | pr_devel("AFU command complete: %llx\n", command); |
| 69 | afu->enabled = enabled; |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 70 | out: |
| 71 | trace_cxl_afu_ctrl_done(afu, command, rc); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 72 | spin_unlock(&afu->afu_cntl_lock); |
| 73 | |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 74 | return rc; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static int afu_enable(struct cxl_afu *afu) |
| 78 | { |
| 79 | pr_devel("AFU enable request\n"); |
| 80 | |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 81 | return afu_control(afu, CXL_AFU_Cntl_An_E, 0, |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 82 | CXL_AFU_Cntl_An_ES_Enabled, |
| 83 | CXL_AFU_Cntl_An_ES_MASK, true); |
| 84 | } |
| 85 | |
| 86 | int cxl_afu_disable(struct cxl_afu *afu) |
| 87 | { |
| 88 | pr_devel("AFU disable request\n"); |
| 89 | |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 90 | return afu_control(afu, 0, CXL_AFU_Cntl_An_E, |
| 91 | CXL_AFU_Cntl_An_ES_Disabled, |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 92 | CXL_AFU_Cntl_An_ES_MASK, false); |
| 93 | } |
| 94 | |
| 95 | /* This will disable as well as reset */ |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 96 | static int native_afu_reset(struct cxl_afu *afu) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 97 | { |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 98 | int rc; |
| 99 | u64 serr; |
| 100 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 101 | pr_devel("AFU reset request\n"); |
| 102 | |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 103 | rc = afu_control(afu, CXL_AFU_Cntl_An_RA, 0, |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 104 | CXL_AFU_Cntl_An_RS_Complete | CXL_AFU_Cntl_An_ES_Disabled, |
| 105 | CXL_AFU_Cntl_An_RS_MASK | CXL_AFU_Cntl_An_ES_MASK, |
| 106 | false); |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 107 | |
| 108 | /* Re-enable any masked interrupts */ |
| 109 | serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); |
| 110 | serr &= ~CXL_PSL_SERR_An_IRQ_MASKS; |
| 111 | cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); |
| 112 | |
| 113 | |
| 114 | return rc; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 115 | } |
| 116 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 117 | static int native_afu_check_and_enable(struct cxl_afu *afu) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 118 | { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 119 | if (!cxl_ops->link_ok(afu->adapter, afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 120 | WARN(1, "Refusing to enable afu while link down!\n"); |
| 121 | return -EIO; |
| 122 | } |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 123 | if (afu->enabled) |
| 124 | return 0; |
| 125 | return afu_enable(afu); |
| 126 | } |
| 127 | |
| 128 | int cxl_psl_purge(struct cxl_afu *afu) |
| 129 | { |
| 130 | u64 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); |
| 131 | u64 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); |
| 132 | u64 dsisr, dar; |
| 133 | u64 start, end; |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 134 | u64 trans_fault = 0x0ULL; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 135 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 136 | int rc = 0; |
| 137 | |
| 138 | trace_cxl_psl_ctrl(afu, CXL_PSL_SCNTL_An_Pc); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 139 | |
| 140 | pr_devel("PSL purge request\n"); |
| 141 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 142 | if (cxl_is_psl8(afu)) |
| 143 | trans_fault = CXL_PSL_DSISR_TRANS; |
| 144 | if (cxl_is_psl9(afu)) |
| 145 | trans_fault = CXL_PSL9_DSISR_An_TF; |
| 146 | |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 147 | if (!cxl_ops->link_ok(afu->adapter, afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 148 | dev_warn(&afu->dev, "PSL Purge called with link down, ignoring\n"); |
| 149 | rc = -EIO; |
| 150 | goto out; |
| 151 | } |
| 152 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 153 | if ((AFU_Cntl & CXL_AFU_Cntl_An_ES_MASK) != CXL_AFU_Cntl_An_ES_Disabled) { |
| 154 | WARN(1, "psl_purge request while AFU not disabled!\n"); |
| 155 | cxl_afu_disable(afu); |
| 156 | } |
| 157 | |
| 158 | cxl_p1n_write(afu, CXL_PSL_SCNTL_An, |
| 159 | PSL_CNTL | CXL_PSL_SCNTL_An_Pc); |
| 160 | start = local_clock(); |
| 161 | PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); |
| 162 | while ((PSL_CNTL & CXL_PSL_SCNTL_An_Ps_MASK) |
| 163 | == CXL_PSL_SCNTL_An_Ps_Pending) { |
| 164 | if (time_after_eq(jiffies, timeout)) { |
| 165 | dev_warn(&afu->dev, "WARNING: PSL Purge timed out!\n"); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 166 | rc = -EBUSY; |
| 167 | goto out; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 168 | } |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 169 | if (!cxl_ops->link_ok(afu->adapter, afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 170 | rc = -EIO; |
| 171 | goto out; |
| 172 | } |
| 173 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 174 | dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 175 | pr_devel_ratelimited("PSL purging... PSL_CNTL: 0x%016llx PSL_DSISR: 0x%016llx\n", |
| 176 | PSL_CNTL, dsisr); |
| 177 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 178 | if (dsisr & trans_fault) { |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 179 | dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 180 | dev_notice(&afu->dev, "PSL purge terminating pending translation, DSISR: 0x%016llx, DAR: 0x%016llx\n", |
| 181 | dsisr, dar); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 182 | cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); |
| 183 | } else if (dsisr) { |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 184 | dev_notice(&afu->dev, "PSL purge acknowledging pending non-translation fault, DSISR: 0x%016llx\n", |
| 185 | dsisr); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 186 | cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); |
| 187 | } else { |
| 188 | cpu_relax(); |
| 189 | } |
| 190 | PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); |
Andrew Donnellan | 3382a62 | 2016-11-22 21:13:27 +1100 | [diff] [blame] | 191 | } |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 192 | end = local_clock(); |
| 193 | pr_devel("PSL purged in %lld ns\n", end - start); |
| 194 | |
| 195 | cxl_p1n_write(afu, CXL_PSL_SCNTL_An, |
| 196 | PSL_CNTL & ~CXL_PSL_SCNTL_An_Pc); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 197 | out: |
| 198 | trace_cxl_psl_ctrl_done(afu, CXL_PSL_SCNTL_An_Pc, rc); |
| 199 | return rc; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | static int spa_max_procs(int spa_size) |
| 203 | { |
| 204 | /* |
| 205 | * From the CAIA: |
| 206 | * end_of_SPA_area = SPA_Base + ((n+4) * 128) + (( ((n*8) + 127) >> 7) * 128) + 255 |
| 207 | * Most of that junk is really just an overly-complicated way of saying |
| 208 | * the last 256 bytes are __aligned(128), so it's really: |
| 209 | * end_of_SPA_area = end_of_PSL_queue_area + __aligned(128) 255 |
| 210 | * and |
| 211 | * end_of_PSL_queue_area = SPA_Base + ((n+4) * 128) + (n*8) - 1 |
| 212 | * so |
| 213 | * sizeof(SPA) = ((n+4) * 128) + (n*8) + __aligned(128) 256 |
| 214 | * Ignore the alignment (which is safe in this case as long as we are |
| 215 | * careful with our rounding) and solve for n: |
| 216 | */ |
| 217 | return ((spa_size / 8) - 96) / 17; |
| 218 | } |
| 219 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 220 | static int cxl_alloc_spa(struct cxl_afu *afu, int mode) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 221 | { |
Ian Munsie | 895a798 | 2016-05-04 14:46:30 +1000 | [diff] [blame] | 222 | unsigned spa_size; |
| 223 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 224 | /* Work out how many pages to allocate */ |
Ian Munsie | 2224b67 | 2016-06-29 22:16:26 +1000 | [diff] [blame] | 225 | afu->native->spa_order = -1; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 226 | do { |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 227 | afu->native->spa_order++; |
Ian Munsie | 895a798 | 2016-05-04 14:46:30 +1000 | [diff] [blame] | 228 | spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; |
| 229 | |
| 230 | if (spa_size > 0x100000) { |
| 231 | dev_warn(&afu->dev, "num_of_processes too large for the SPA, limiting to %i (0x%x)\n", |
| 232 | afu->native->spa_max_procs, afu->native->spa_size); |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 233 | if (mode != CXL_MODE_DEDICATED) |
| 234 | afu->num_procs = afu->native->spa_max_procs; |
Ian Munsie | 895a798 | 2016-05-04 14:46:30 +1000 | [diff] [blame] | 235 | break; |
| 236 | } |
| 237 | |
| 238 | afu->native->spa_size = spa_size; |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 239 | afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size); |
| 240 | } while (afu->native->spa_max_procs < afu->num_procs); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 241 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 242 | if (!(afu->native->spa = (struct cxl_process_element *) |
| 243 | __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) { |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 244 | pr_err("cxl_alloc_spa: Unable to allocate scheduled process area\n"); |
| 245 | return -ENOMEM; |
| 246 | } |
| 247 | pr_devel("spa pages: %i afu->spa_max_procs: %i afu->num_procs: %i\n", |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 248 | 1<<afu->native->spa_order, afu->native->spa_max_procs, afu->num_procs); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 249 | |
Daniel Axtens | 05155772 | 2015-08-14 17:41:19 +1000 | [diff] [blame] | 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | static void attach_spa(struct cxl_afu *afu) |
| 254 | { |
| 255 | u64 spap; |
| 256 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 257 | afu->native->sw_command_status = (__be64 *)((char *)afu->native->spa + |
| 258 | ((afu->native->spa_max_procs + 3) * 128)); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 259 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 260 | spap = virt_to_phys(afu->native->spa) & CXL_PSL_SPAP_Addr; |
| 261 | spap |= ((afu->native->spa_size >> (12 - CXL_PSL_SPAP_Size_Shift)) - 1) & CXL_PSL_SPAP_Size; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 262 | spap |= CXL_PSL_SPAP_V; |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 263 | pr_devel("cxl: SPA allocated at 0x%p. Max processes: %i, sw_command_status: 0x%p CXL_PSL_SPAP_An=0x%016llx\n", |
| 264 | afu->native->spa, afu->native->spa_max_procs, |
| 265 | afu->native->sw_command_status, spap); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 266 | cxl_p1n_write(afu, CXL_PSL_SPAP_An, spap); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 267 | } |
| 268 | |
Daniel Axtens | 05155772 | 2015-08-14 17:41:19 +1000 | [diff] [blame] | 269 | static inline void detach_spa(struct cxl_afu *afu) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 270 | { |
Ian Munsie | db7933f | 2014-12-08 19:18:00 +1100 | [diff] [blame] | 271 | cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0); |
Daniel Axtens | 05155772 | 2015-08-14 17:41:19 +1000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void cxl_release_spa(struct cxl_afu *afu) |
| 275 | { |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 276 | if (afu->native->spa) { |
| 277 | free_pages((unsigned long) afu->native->spa, |
| 278 | afu->native->spa_order); |
| 279 | afu->native->spa = NULL; |
Daniel Axtens | 05155772 | 2015-08-14 17:41:19 +1000 | [diff] [blame] | 280 | } |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 281 | } |
| 282 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 283 | /* |
| 284 | * Invalidation of all ERAT entries is no longer required by CAIA2. Use |
| 285 | * only for debug. |
| 286 | */ |
| 287 | int cxl_invalidate_all_psl9(struct cxl *adapter) |
| 288 | { |
| 289 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
| 290 | u64 ierat; |
| 291 | |
| 292 | pr_devel("CXL adapter - invalidation of all ERAT entries\n"); |
| 293 | |
| 294 | /* Invalidates all ERAT entries for Radix or HPT */ |
| 295 | ierat = CXL_XSL9_IERAT_IALL; |
| 296 | if (radix_enabled()) |
| 297 | ierat |= CXL_XSL9_IERAT_INVR; |
| 298 | cxl_p1_write(adapter, CXL_XSL9_IERAT, ierat); |
| 299 | |
| 300 | while (cxl_p1_read(adapter, CXL_XSL9_IERAT) & CXL_XSL9_IERAT_IINPROG) { |
| 301 | if (time_after_eq(jiffies, timeout)) { |
| 302 | dev_warn(&adapter->dev, |
| 303 | "WARNING: CXL adapter invalidation of all ERAT entries timed out!\n"); |
| 304 | return -EBUSY; |
| 305 | } |
| 306 | if (!cxl_ops->link_ok(adapter, NULL)) |
| 307 | return -EIO; |
| 308 | cpu_relax(); |
| 309 | } |
| 310 | return 0; |
| 311 | } |
| 312 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 313 | int cxl_invalidate_all_psl8(struct cxl *adapter) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 314 | { |
| 315 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
| 316 | |
| 317 | pr_devel("CXL adapter wide TLBIA & SLBIA\n"); |
| 318 | |
| 319 | cxl_p1_write(adapter, CXL_PSL_AFUSEL, CXL_PSL_AFUSEL_A); |
| 320 | |
| 321 | cxl_p1_write(adapter, CXL_PSL_TLBIA, CXL_TLB_SLB_IQ_ALL); |
| 322 | while (cxl_p1_read(adapter, CXL_PSL_TLBIA) & CXL_TLB_SLB_P) { |
| 323 | if (time_after_eq(jiffies, timeout)) { |
| 324 | dev_warn(&adapter->dev, "WARNING: CXL adapter wide TLBIA timed out!\n"); |
| 325 | return -EBUSY; |
| 326 | } |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 327 | if (!cxl_ops->link_ok(adapter, NULL)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 328 | return -EIO; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 329 | cpu_relax(); |
| 330 | } |
| 331 | |
| 332 | cxl_p1_write(adapter, CXL_PSL_SLBIA, CXL_TLB_SLB_IQ_ALL); |
| 333 | while (cxl_p1_read(adapter, CXL_PSL_SLBIA) & CXL_TLB_SLB_P) { |
| 334 | if (time_after_eq(jiffies, timeout)) { |
| 335 | dev_warn(&adapter->dev, "WARNING: CXL adapter wide SLBIA timed out!\n"); |
| 336 | return -EBUSY; |
| 337 | } |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 338 | if (!cxl_ops->link_ok(adapter, NULL)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 339 | return -EIO; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 340 | cpu_relax(); |
| 341 | } |
| 342 | return 0; |
| 343 | } |
| 344 | |
Frederic Barrat | aaa2245 | 2016-10-03 21:36:02 +0200 | [diff] [blame] | 345 | int cxl_data_cache_flush(struct cxl *adapter) |
| 346 | { |
| 347 | u64 reg; |
| 348 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
| 349 | |
| 350 | pr_devel("Flushing data cache\n"); |
| 351 | |
| 352 | reg = cxl_p1_read(adapter, CXL_PSL_Control); |
| 353 | reg |= CXL_PSL_Control_Fr; |
| 354 | cxl_p1_write(adapter, CXL_PSL_Control, reg); |
| 355 | |
| 356 | reg = cxl_p1_read(adapter, CXL_PSL_Control); |
| 357 | while ((reg & CXL_PSL_Control_Fs_MASK) != CXL_PSL_Control_Fs_Complete) { |
| 358 | if (time_after_eq(jiffies, timeout)) { |
| 359 | dev_warn(&adapter->dev, "WARNING: cache flush timed out!\n"); |
| 360 | return -EBUSY; |
| 361 | } |
| 362 | |
| 363 | if (!cxl_ops->link_ok(adapter, NULL)) { |
| 364 | dev_warn(&adapter->dev, "WARNING: link down when flushing cache\n"); |
| 365 | return -EIO; |
| 366 | } |
| 367 | cpu_relax(); |
| 368 | reg = cxl_p1_read(adapter, CXL_PSL_Control); |
| 369 | } |
| 370 | |
| 371 | reg &= ~CXL_PSL_Control_Fr; |
| 372 | cxl_p1_write(adapter, CXL_PSL_Control, reg); |
| 373 | return 0; |
| 374 | } |
| 375 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 376 | static int cxl_write_sstp(struct cxl_afu *afu, u64 sstp0, u64 sstp1) |
| 377 | { |
| 378 | int rc; |
| 379 | |
| 380 | /* 1. Disable SSTP by writing 0 to SSTP1[V] */ |
| 381 | cxl_p2n_write(afu, CXL_SSTP1_An, 0); |
| 382 | |
| 383 | /* 2. Invalidate all SLB entries */ |
| 384 | if ((rc = cxl_afu_slbia(afu))) |
| 385 | return rc; |
| 386 | |
| 387 | /* 3. Set SSTP0_An */ |
| 388 | cxl_p2n_write(afu, CXL_SSTP0_An, sstp0); |
| 389 | |
| 390 | /* 4. Set SSTP1_An */ |
| 391 | cxl_p2n_write(afu, CXL_SSTP1_An, sstp1); |
| 392 | |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | /* Using per slice version may improve performance here. (ie. SLBIA_An) */ |
| 397 | static void slb_invalid(struct cxl_context *ctx) |
| 398 | { |
| 399 | struct cxl *adapter = ctx->afu->adapter; |
| 400 | u64 slbia; |
| 401 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 402 | WARN_ON(!mutex_is_locked(&ctx->afu->native->spa_mutex)); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 403 | |
| 404 | cxl_p1_write(adapter, CXL_PSL_LBISEL, |
| 405 | ((u64)be32_to_cpu(ctx->elem->common.pid) << 32) | |
| 406 | be32_to_cpu(ctx->elem->lpid)); |
| 407 | cxl_p1_write(adapter, CXL_PSL_SLBIA, CXL_TLB_SLB_IQ_LPIDPID); |
| 408 | |
| 409 | while (1) { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 410 | if (!cxl_ops->link_ok(adapter, NULL)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 411 | break; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 412 | slbia = cxl_p1_read(adapter, CXL_PSL_SLBIA); |
| 413 | if (!(slbia & CXL_TLB_SLB_P)) |
| 414 | break; |
| 415 | cpu_relax(); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | static int do_process_element_cmd(struct cxl_context *ctx, |
| 420 | u64 cmd, u64 pe_state) |
| 421 | { |
| 422 | u64 state; |
Ian Munsie | a98e6e9 | 2014-12-08 19:17:56 +1100 | [diff] [blame] | 423 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 424 | int rc = 0; |
| 425 | |
| 426 | trace_cxl_llcmd(ctx, cmd); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 427 | |
| 428 | WARN_ON(!ctx->afu->enabled); |
| 429 | |
| 430 | ctx->elem->software_state = cpu_to_be32(pe_state); |
| 431 | smp_wmb(); |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 432 | *(ctx->afu->native->sw_command_status) = cpu_to_be64(cmd | 0 | ctx->pe); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 433 | smp_mb(); |
| 434 | cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); |
| 435 | while (1) { |
Ian Munsie | a98e6e9 | 2014-12-08 19:17:56 +1100 | [diff] [blame] | 436 | if (time_after_eq(jiffies, timeout)) { |
| 437 | dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n"); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 438 | rc = -EBUSY; |
| 439 | goto out; |
Ian Munsie | a98e6e9 | 2014-12-08 19:17:56 +1100 | [diff] [blame] | 440 | } |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 441 | if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 442 | dev_warn(&ctx->afu->dev, "WARNING: Device link down, aborting Process Element Command!\n"); |
| 443 | rc = -EIO; |
| 444 | goto out; |
| 445 | } |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 446 | state = be64_to_cpup(ctx->afu->native->sw_command_status); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 447 | if (state == ~0ULL) { |
| 448 | pr_err("cxl: Error adding process element to AFU\n"); |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 449 | rc = -1; |
| 450 | goto out; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 451 | } |
| 452 | if ((state & (CXL_SPA_SW_CMD_MASK | CXL_SPA_SW_STATE_MASK | CXL_SPA_SW_LINK_MASK)) == |
| 453 | (cmd | (cmd >> 16) | ctx->pe)) |
| 454 | break; |
| 455 | /* |
| 456 | * The command won't finish in the PSL if there are |
| 457 | * outstanding DSIs. Hence we need to yield here in |
| 458 | * case there are outstanding DSIs that we need to |
| 459 | * service. Tuning possiblity: we could wait for a |
| 460 | * while before sched |
| 461 | */ |
| 462 | schedule(); |
| 463 | |
| 464 | } |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 465 | out: |
| 466 | trace_cxl_llcmd_done(ctx, cmd, rc); |
| 467 | return rc; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | static int add_process_element(struct cxl_context *ctx) |
| 471 | { |
| 472 | int rc = 0; |
| 473 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 474 | mutex_lock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 475 | pr_devel("%s Adding pe: %i started\n", __func__, ctx->pe); |
| 476 | if (!(rc = do_process_element_cmd(ctx, CXL_SPA_SW_CMD_ADD, CXL_PE_SOFTWARE_STATE_V))) |
| 477 | ctx->pe_inserted = true; |
| 478 | pr_devel("%s Adding pe: %i finished\n", __func__, ctx->pe); |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 479 | mutex_unlock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 480 | return rc; |
| 481 | } |
| 482 | |
| 483 | static int terminate_process_element(struct cxl_context *ctx) |
| 484 | { |
| 485 | int rc = 0; |
| 486 | |
| 487 | /* fast path terminate if it's already invalid */ |
| 488 | if (!(ctx->elem->software_state & cpu_to_be32(CXL_PE_SOFTWARE_STATE_V))) |
| 489 | return rc; |
| 490 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 491 | mutex_lock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 492 | pr_devel("%s Terminate pe: %i started\n", __func__, ctx->pe); |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 493 | /* We could be asked to terminate when the hw is down. That |
| 494 | * should always succeed: it's not running if the hw has gone |
| 495 | * away and is being reset. |
| 496 | */ |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 497 | if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 498 | rc = do_process_element_cmd(ctx, CXL_SPA_SW_CMD_TERMINATE, |
| 499 | CXL_PE_SOFTWARE_STATE_V | CXL_PE_SOFTWARE_STATE_T); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 500 | ctx->elem->software_state = 0; /* Remove Valid bit */ |
| 501 | pr_devel("%s Terminate pe: %i finished\n", __func__, ctx->pe); |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 502 | mutex_unlock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 503 | return rc; |
| 504 | } |
| 505 | |
| 506 | static int remove_process_element(struct cxl_context *ctx) |
| 507 | { |
| 508 | int rc = 0; |
| 509 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 510 | mutex_lock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 511 | pr_devel("%s Remove pe: %i started\n", __func__, ctx->pe); |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 512 | |
| 513 | /* We could be asked to remove when the hw is down. Again, if |
| 514 | * the hw is down, the PE is gone, so we succeed. |
| 515 | */ |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 516 | if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 517 | rc = do_process_element_cmd(ctx, CXL_SPA_SW_CMD_REMOVE, 0); |
| 518 | |
| 519 | if (!rc) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 520 | ctx->pe_inserted = false; |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 521 | if (cxl_is_power8()) |
| 522 | slb_invalid(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 523 | pr_devel("%s Remove pe: %i finished\n", __func__, ctx->pe); |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 524 | mutex_unlock(&ctx->afu->native->spa_mutex); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 525 | |
| 526 | return rc; |
| 527 | } |
| 528 | |
Michael Neuling | 1a1a94b | 2015-05-27 16:07:10 +1000 | [diff] [blame] | 529 | void cxl_assign_psn_space(struct cxl_context *ctx) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 530 | { |
| 531 | if (!ctx->afu->pp_size || ctx->master) { |
| 532 | ctx->psn_phys = ctx->afu->psn_phys; |
| 533 | ctx->psn_size = ctx->afu->adapter->ps_size; |
| 534 | } else { |
| 535 | ctx->psn_phys = ctx->afu->psn_phys + |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 536 | (ctx->afu->native->pp_offset + ctx->afu->pp_size * ctx->pe); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 537 | ctx->psn_size = ctx->afu->pp_size; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | static int activate_afu_directed(struct cxl_afu *afu) |
| 542 | { |
| 543 | int rc; |
| 544 | |
| 545 | dev_info(&afu->dev, "Activating AFU directed mode\n"); |
| 546 | |
Christophe Lombard | 4108efb | 2015-10-07 16:07:40 +1100 | [diff] [blame] | 547 | afu->num_procs = afu->max_procs_virtualised; |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 548 | if (afu->native->spa == NULL) { |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 549 | if (cxl_alloc_spa(afu, CXL_MODE_DIRECTED)) |
Daniel Axtens | 05155772 | 2015-08-14 17:41:19 +1000 | [diff] [blame] | 550 | return -ENOMEM; |
| 551 | } |
| 552 | attach_spa(afu); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 553 | |
| 554 | cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_AFU); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 555 | if (cxl_is_power8()) |
| 556 | cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 557 | cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); |
| 558 | |
| 559 | afu->current_mode = CXL_MODE_DIRECTED; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 560 | |
| 561 | if ((rc = cxl_chardev_m_afu_add(afu))) |
| 562 | return rc; |
| 563 | |
| 564 | if ((rc = cxl_sysfs_afu_m_add(afu))) |
| 565 | goto err; |
| 566 | |
| 567 | if ((rc = cxl_chardev_s_afu_add(afu))) |
| 568 | goto err1; |
| 569 | |
| 570 | return 0; |
| 571 | err1: |
| 572 | cxl_sysfs_afu_m_remove(afu); |
| 573 | err: |
| 574 | cxl_chardev_afu_remove(afu); |
| 575 | return rc; |
| 576 | } |
| 577 | |
| 578 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 579 | #define set_endian(sr) ((sr) |= CXL_PSL_SR_An_LE) |
| 580 | #else |
| 581 | #define set_endian(sr) ((sr) &= ~(CXL_PSL_SR_An_LE)) |
| 582 | #endif |
| 583 | |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 584 | static u64 calculate_sr(struct cxl_context *ctx) |
| 585 | { |
| 586 | u64 sr = 0; |
| 587 | |
Frederic Barrat | e606e03 | 2015-12-07 14:34:40 +0100 | [diff] [blame] | 588 | set_endian(sr); |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 589 | if (ctx->master) |
| 590 | sr |= CXL_PSL_SR_An_MP; |
| 591 | if (mfspr(SPRN_LPCR) & LPCR_TC) |
| 592 | sr |= CXL_PSL_SR_An_TC; |
| 593 | if (ctx->kernel) { |
Ian Munsie | 7a0d85d | 2016-05-06 17:46:36 +1000 | [diff] [blame] | 594 | if (!ctx->real_mode) |
| 595 | sr |= CXL_PSL_SR_An_R; |
| 596 | sr |= (mfmsr() & MSR_SF) | CXL_PSL_SR_An_HV; |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 597 | } else { |
| 598 | sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R; |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 599 | if (radix_enabled()) |
| 600 | sr |= CXL_PSL_SR_An_HV; |
| 601 | else |
| 602 | sr &= ~(CXL_PSL_SR_An_HV); |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 603 | if (!test_tsk_thread_flag(current, TIF_32BIT)) |
| 604 | sr |= CXL_PSL_SR_An_SF; |
| 605 | } |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 606 | if (cxl_is_psl9(ctx->afu)) { |
| 607 | if (radix_enabled()) |
| 608 | sr |= CXL_PSL_SR_An_XLAT_ror; |
| 609 | else |
| 610 | sr |= CXL_PSL_SR_An_XLAT_hpt; |
| 611 | } |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 612 | return sr; |
| 613 | } |
| 614 | |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 615 | static void update_ivtes_directed(struct cxl_context *ctx) |
| 616 | { |
| 617 | bool need_update = (ctx->status == STARTED); |
| 618 | int r; |
| 619 | |
| 620 | if (need_update) { |
| 621 | WARN_ON(terminate_process_element(ctx)); |
| 622 | WARN_ON(remove_process_element(ctx)); |
| 623 | } |
| 624 | |
| 625 | for (r = 0; r < CXL_IRQ_RANGES; r++) { |
| 626 | ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); |
| 627 | ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); |
| 628 | } |
| 629 | |
| 630 | /* |
| 631 | * Theoretically we could use the update llcmd, instead of a |
| 632 | * terminate/remove/add (or if an atomic update was required we could |
| 633 | * do a suspend/update/resume), however it seems there might be issues |
| 634 | * with the update llcmd on some cards (including those using an XSL on |
| 635 | * an ASIC) so for now it's safest to go with the commands that are |
| 636 | * known to work. In the future if we come across a situation where the |
| 637 | * card may be performing transactions using the same PE while we are |
| 638 | * doing this update we might need to revisit this. |
| 639 | */ |
| 640 | if (need_update) |
| 641 | WARN_ON(add_process_element(ctx)); |
| 642 | } |
| 643 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 644 | static int process_element_entry_psl9(struct cxl_context *ctx, u64 wed, u64 amr) |
| 645 | { |
| 646 | u32 pid; |
| 647 | |
| 648 | cxl_assign_psn_space(ctx); |
| 649 | |
| 650 | ctx->elem->ctxtime = 0; /* disable */ |
| 651 | ctx->elem->lpid = cpu_to_be32(mfspr(SPRN_LPID)); |
| 652 | ctx->elem->haurp = 0; /* disable */ |
| 653 | |
| 654 | if (ctx->kernel) |
| 655 | pid = 0; |
| 656 | else { |
| 657 | if (ctx->mm == NULL) { |
| 658 | pr_devel("%s: unable to get mm for pe=%d pid=%i\n", |
| 659 | __func__, ctx->pe, pid_nr(ctx->pid)); |
| 660 | return -EINVAL; |
| 661 | } |
| 662 | pid = ctx->mm->context.id; |
| 663 | } |
| 664 | |
| 665 | ctx->elem->common.tid = 0; |
| 666 | ctx->elem->common.pid = cpu_to_be32(pid); |
| 667 | |
| 668 | ctx->elem->sr = cpu_to_be64(calculate_sr(ctx)); |
| 669 | |
| 670 | ctx->elem->common.csrp = 0; /* disable */ |
| 671 | |
| 672 | cxl_prefault(ctx, wed); |
| 673 | |
| 674 | /* |
| 675 | * Ensure we have the multiplexed PSL interrupt set up to take faults |
| 676 | * for kernel contexts that may not have allocated any AFU IRQs at all: |
| 677 | */ |
| 678 | if (ctx->irqs.range[0] == 0) { |
| 679 | ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; |
| 680 | ctx->irqs.range[0] = 1; |
| 681 | } |
| 682 | |
| 683 | ctx->elem->common.amr = cpu_to_be64(amr); |
| 684 | ctx->elem->common.wed = cpu_to_be64(wed); |
| 685 | |
| 686 | return 0; |
| 687 | } |
| 688 | |
| 689 | int cxl_attach_afu_directed_psl9(struct cxl_context *ctx, u64 wed, u64 amr) |
| 690 | { |
| 691 | int result; |
| 692 | |
| 693 | /* fill the process element entry */ |
| 694 | result = process_element_entry_psl9(ctx, wed, amr); |
| 695 | if (result) |
| 696 | return result; |
| 697 | |
| 698 | update_ivtes_directed(ctx); |
| 699 | |
| 700 | /* first guy needs to enable */ |
| 701 | result = cxl_ops->afu_check_and_enable(ctx->afu); |
| 702 | if (result) |
| 703 | return result; |
| 704 | |
| 705 | return add_process_element(ctx); |
| 706 | } |
| 707 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 708 | int cxl_attach_afu_directed_psl8(struct cxl_context *ctx, u64 wed, u64 amr) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 709 | { |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 710 | u32 pid; |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 711 | int result; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 712 | |
Michael Neuling | 1a1a94b | 2015-05-27 16:07:10 +1000 | [diff] [blame] | 713 | cxl_assign_psn_space(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 714 | |
| 715 | ctx->elem->ctxtime = 0; /* disable */ |
| 716 | ctx->elem->lpid = cpu_to_be32(mfspr(SPRN_LPID)); |
| 717 | ctx->elem->haurp = 0; /* disable */ |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 718 | ctx->elem->u.sdr = cpu_to_be64(mfspr(SPRN_SDR1)); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 719 | |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 720 | pid = current->pid; |
| 721 | if (ctx->kernel) |
| 722 | pid = 0; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 723 | ctx->elem->common.tid = 0; |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 724 | ctx->elem->common.pid = cpu_to_be32(pid); |
| 725 | |
| 726 | ctx->elem->sr = cpu_to_be64(calculate_sr(ctx)); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 727 | |
| 728 | ctx->elem->common.csrp = 0; /* disable */ |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 729 | ctx->elem->common.u.psl8.aurp0 = 0; /* disable */ |
| 730 | ctx->elem->common.u.psl8.aurp1 = 0; /* disable */ |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 731 | |
| 732 | cxl_prefault(ctx, wed); |
| 733 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 734 | ctx->elem->common.u.psl8.sstp0 = cpu_to_be64(ctx->sstp0); |
| 735 | ctx->elem->common.u.psl8.sstp1 = cpu_to_be64(ctx->sstp1); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 736 | |
Ian Munsie | 3c206fa | 2016-05-04 14:52:58 +1000 | [diff] [blame] | 737 | /* |
| 738 | * Ensure we have the multiplexed PSL interrupt set up to take faults |
| 739 | * for kernel contexts that may not have allocated any AFU IRQs at all: |
| 740 | */ |
| 741 | if (ctx->irqs.range[0] == 0) { |
| 742 | ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; |
| 743 | ctx->irqs.range[0] = 1; |
| 744 | } |
| 745 | |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 746 | update_ivtes_directed(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 747 | |
| 748 | ctx->elem->common.amr = cpu_to_be64(amr); |
| 749 | ctx->elem->common.wed = cpu_to_be64(wed); |
| 750 | |
| 751 | /* first guy needs to enable */ |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 752 | if ((result = cxl_ops->afu_check_and_enable(ctx->afu))) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 753 | return result; |
| 754 | |
Daniel Axtens | 368857c | 2015-07-29 14:07:22 +1000 | [diff] [blame] | 755 | return add_process_element(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | static int deactivate_afu_directed(struct cxl_afu *afu) |
| 759 | { |
| 760 | dev_info(&afu->dev, "Deactivating AFU directed mode\n"); |
| 761 | |
| 762 | afu->current_mode = 0; |
| 763 | afu->num_procs = 0; |
| 764 | |
| 765 | cxl_sysfs_afu_m_remove(afu); |
| 766 | cxl_chardev_afu_remove(afu); |
| 767 | |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 768 | /* |
| 769 | * The CAIA section 2.2.1 indicates that the procedure for starting and |
| 770 | * stopping an AFU in AFU directed mode is AFU specific, which is not |
| 771 | * ideal since this code is generic and with one exception has no |
| 772 | * knowledge of the AFU. This is in contrast to the procedure for |
| 773 | * disabling a dedicated process AFU, which is documented to just |
| 774 | * require a reset. The architecture does indicate that both an AFU |
| 775 | * reset and an AFU disable should result in the AFU being disabled and |
| 776 | * we do both followed by a PSL purge for safety. |
| 777 | * |
| 778 | * Notably we used to have some issues with the disable sequence on PSL |
| 779 | * cards, which is why we ended up using this heavy weight procedure in |
| 780 | * the first place, however a bug was discovered that had rendered the |
| 781 | * disable operation ineffective, so it is conceivable that was the |
| 782 | * sole explanation for those difficulties. Careful regression testing |
| 783 | * is recommended if anyone attempts to remove or reorder these |
| 784 | * operations. |
| 785 | * |
| 786 | * The XSL on the Mellanox CX4 behaves a little differently from the |
| 787 | * PSL based cards and will time out an AFU reset if the AFU is still |
| 788 | * enabled. That card is special in that we do have a means to identify |
| 789 | * it from this code, so in that case we skip the reset and just use a |
| 790 | * disable/purge to avoid the timeout and corresponding noise in the |
| 791 | * kernel log. |
| 792 | */ |
| 793 | if (afu->adapter->native->sl_ops->needs_reset_before_disable) |
| 794 | cxl_ops->afu_reset(afu); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 795 | cxl_afu_disable(afu); |
| 796 | cxl_psl_purge(afu); |
| 797 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 798 | return 0; |
| 799 | } |
| 800 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 801 | int cxl_activate_dedicated_process_psl9(struct cxl_afu *afu) |
| 802 | { |
| 803 | dev_info(&afu->dev, "Activating dedicated process mode\n"); |
| 804 | |
| 805 | /* |
| 806 | * If XSL is set to dedicated mode (Set in PSL_SCNTL reg), the |
| 807 | * XSL and AFU are programmed to work with a single context. |
| 808 | * The context information should be configured in the SPA area |
| 809 | * index 0 (so PSL_SPAP must be configured before enabling the |
| 810 | * AFU). |
| 811 | */ |
| 812 | afu->num_procs = 1; |
| 813 | if (afu->native->spa == NULL) { |
| 814 | if (cxl_alloc_spa(afu, CXL_MODE_DEDICATED)) |
| 815 | return -ENOMEM; |
| 816 | } |
| 817 | attach_spa(afu); |
| 818 | |
| 819 | cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); |
| 820 | cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); |
| 821 | |
| 822 | afu->current_mode = CXL_MODE_DEDICATED; |
| 823 | |
| 824 | return cxl_chardev_d_afu_add(afu); |
| 825 | } |
| 826 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 827 | int cxl_activate_dedicated_process_psl8(struct cxl_afu *afu) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 828 | { |
| 829 | dev_info(&afu->dev, "Activating dedicated process mode\n"); |
| 830 | |
| 831 | cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); |
| 832 | |
| 833 | cxl_p1n_write(afu, CXL_PSL_CtxTime_An, 0); /* disable */ |
| 834 | cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0); /* disable */ |
| 835 | cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); |
| 836 | cxl_p1n_write(afu, CXL_PSL_LPID_An, mfspr(SPRN_LPID)); |
| 837 | cxl_p1n_write(afu, CXL_HAURP_An, 0); /* disable */ |
| 838 | cxl_p1n_write(afu, CXL_PSL_SDR_An, mfspr(SPRN_SDR1)); |
| 839 | |
| 840 | cxl_p2n_write(afu, CXL_CSRP_An, 0); /* disable */ |
| 841 | cxl_p2n_write(afu, CXL_AURP0_An, 0); /* disable */ |
| 842 | cxl_p2n_write(afu, CXL_AURP1_An, 0); /* disable */ |
| 843 | |
| 844 | afu->current_mode = CXL_MODE_DEDICATED; |
| 845 | afu->num_procs = 1; |
| 846 | |
| 847 | return cxl_chardev_d_afu_add(afu); |
| 848 | } |
| 849 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 850 | void cxl_update_dedicated_ivtes_psl9(struct cxl_context *ctx) |
| 851 | { |
| 852 | int r; |
| 853 | |
| 854 | for (r = 0; r < CXL_IRQ_RANGES; r++) { |
| 855 | ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); |
| 856 | ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); |
| 857 | } |
| 858 | } |
| 859 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 860 | void cxl_update_dedicated_ivtes_psl8(struct cxl_context *ctx) |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 861 | { |
| 862 | struct cxl_afu *afu = ctx->afu; |
| 863 | |
| 864 | cxl_p1n_write(afu, CXL_PSL_IVTE_Offset_An, |
| 865 | (((u64)ctx->irqs.offset[0] & 0xffff) << 48) | |
| 866 | (((u64)ctx->irqs.offset[1] & 0xffff) << 32) | |
| 867 | (((u64)ctx->irqs.offset[2] & 0xffff) << 16) | |
| 868 | ((u64)ctx->irqs.offset[3] & 0xffff)); |
| 869 | cxl_p1n_write(afu, CXL_PSL_IVTE_Limit_An, (u64) |
| 870 | (((u64)ctx->irqs.range[0] & 0xffff) << 48) | |
| 871 | (((u64)ctx->irqs.range[1] & 0xffff) << 32) | |
| 872 | (((u64)ctx->irqs.range[2] & 0xffff) << 16) | |
| 873 | ((u64)ctx->irqs.range[3] & 0xffff)); |
| 874 | } |
| 875 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 876 | int cxl_attach_dedicated_process_psl9(struct cxl_context *ctx, u64 wed, u64 amr) |
| 877 | { |
| 878 | struct cxl_afu *afu = ctx->afu; |
| 879 | int result; |
| 880 | |
| 881 | /* fill the process element entry */ |
| 882 | result = process_element_entry_psl9(ctx, wed, amr); |
| 883 | if (result) |
| 884 | return result; |
| 885 | |
| 886 | if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) |
| 887 | afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); |
| 888 | |
| 889 | result = cxl_ops->afu_reset(afu); |
| 890 | if (result) |
| 891 | return result; |
| 892 | |
| 893 | return afu_enable(afu); |
| 894 | } |
| 895 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 896 | int cxl_attach_dedicated_process_psl8(struct cxl_context *ctx, u64 wed, u64 amr) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 897 | { |
| 898 | struct cxl_afu *afu = ctx->afu; |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 899 | u64 pid; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 900 | int rc; |
| 901 | |
Michael Neuling | 2f66352 | 2015-05-27 16:07:13 +1000 | [diff] [blame] | 902 | pid = (u64)current->pid << 32; |
| 903 | if (ctx->kernel) |
| 904 | pid = 0; |
| 905 | cxl_p2n_write(afu, CXL_PSL_PID_TID_An, pid); |
| 906 | |
| 907 | cxl_p1n_write(afu, CXL_PSL_SR_An, calculate_sr(ctx)); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 908 | |
| 909 | if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1))) |
| 910 | return rc; |
| 911 | |
| 912 | cxl_prefault(ctx, wed); |
| 913 | |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 914 | if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) |
| 915 | afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 916 | |
| 917 | cxl_p2n_write(afu, CXL_PSL_AMR_An, amr); |
| 918 | |
| 919 | /* master only context for dedicated */ |
Michael Neuling | 1a1a94b | 2015-05-27 16:07:10 +1000 | [diff] [blame] | 920 | cxl_assign_psn_space(ctx); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 921 | |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 922 | if ((rc = cxl_ops->afu_reset(afu))) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 923 | return rc; |
| 924 | |
| 925 | cxl_p2n_write(afu, CXL_PSL_WED_An, wed); |
| 926 | |
| 927 | return afu_enable(afu); |
| 928 | } |
| 929 | |
| 930 | static int deactivate_dedicated_process(struct cxl_afu *afu) |
| 931 | { |
| 932 | dev_info(&afu->dev, "Deactivating dedicated process mode\n"); |
| 933 | |
| 934 | afu->current_mode = 0; |
| 935 | afu->num_procs = 0; |
| 936 | |
| 937 | cxl_chardev_afu_remove(afu); |
| 938 | |
| 939 | return 0; |
| 940 | } |
| 941 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 942 | static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 943 | { |
| 944 | if (mode == CXL_MODE_DIRECTED) |
| 945 | return deactivate_afu_directed(afu); |
| 946 | if (mode == CXL_MODE_DEDICATED) |
| 947 | return deactivate_dedicated_process(afu); |
| 948 | return 0; |
| 949 | } |
| 950 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 951 | static int native_afu_activate_mode(struct cxl_afu *afu, int mode) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 952 | { |
| 953 | if (!mode) |
| 954 | return 0; |
| 955 | if (!(mode & afu->modes_supported)) |
| 956 | return -EINVAL; |
| 957 | |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 958 | if (!cxl_ops->link_ok(afu->adapter, afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 959 | WARN(1, "Device link is down, refusing to activate!\n"); |
| 960 | return -EIO; |
| 961 | } |
| 962 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 963 | if (mode == CXL_MODE_DIRECTED) |
| 964 | return activate_afu_directed(afu); |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 965 | if ((mode == CXL_MODE_DEDICATED) && |
| 966 | (afu->adapter->native->sl_ops->activate_dedicated_process)) |
| 967 | return afu->adapter->native->sl_ops->activate_dedicated_process(afu); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 968 | |
| 969 | return -EINVAL; |
| 970 | } |
| 971 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 972 | static int native_attach_process(struct cxl_context *ctx, bool kernel, |
| 973 | u64 wed, u64 amr) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 974 | { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 975 | if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 976 | WARN(1, "Device link is down, refusing to attach process!\n"); |
| 977 | return -EIO; |
| 978 | } |
| 979 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 980 | ctx->kernel = kernel; |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 981 | if ((ctx->afu->current_mode == CXL_MODE_DIRECTED) && |
| 982 | (ctx->afu->adapter->native->sl_ops->attach_afu_directed)) |
| 983 | return ctx->afu->adapter->native->sl_ops->attach_afu_directed(ctx, wed, amr); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 984 | |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 985 | if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && |
| 986 | (ctx->afu->adapter->native->sl_ops->attach_dedicated_process)) |
| 987 | return ctx->afu->adapter->native->sl_ops->attach_dedicated_process(ctx, wed, amr); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 988 | |
| 989 | return -EINVAL; |
| 990 | } |
| 991 | |
| 992 | static inline int detach_process_native_dedicated(struct cxl_context *ctx) |
| 993 | { |
Ian Munsie | 5e7823c | 2016-07-01 02:50:40 +1000 | [diff] [blame] | 994 | /* |
| 995 | * The CAIA section 2.1.1 indicates that we need to do an AFU reset to |
| 996 | * stop the AFU in dedicated mode (we therefore do not make that |
| 997 | * optional like we do in the afu directed path). It does not indicate |
| 998 | * that we need to do an explicit disable (which should occur |
| 999 | * implicitly as part of the reset) or purge, but we do these as well |
| 1000 | * to be on the safe side. |
| 1001 | * |
| 1002 | * Notably we used to have some issues with the disable sequence |
| 1003 | * (before the sequence was spelled out in the architecture) which is |
| 1004 | * why we were so heavy weight in the first place, however a bug was |
| 1005 | * discovered that had rendered the disable operation ineffective, so |
| 1006 | * it is conceivable that was the sole explanation for those |
| 1007 | * difficulties. Point is, we should be careful and do some regression |
| 1008 | * testing if we ever attempt to remove any part of this procedure. |
| 1009 | */ |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1010 | cxl_ops->afu_reset(ctx->afu); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1011 | cxl_afu_disable(ctx->afu); |
| 1012 | cxl_psl_purge(ctx->afu); |
| 1013 | return 0; |
| 1014 | } |
| 1015 | |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 1016 | static void native_update_ivtes(struct cxl_context *ctx) |
| 1017 | { |
| 1018 | if (ctx->afu->current_mode == CXL_MODE_DIRECTED) |
| 1019 | return update_ivtes_directed(ctx); |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1020 | if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && |
| 1021 | (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)) |
| 1022 | return ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 1023 | WARN(1, "native_update_ivtes: Bad mode\n"); |
| 1024 | } |
| 1025 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1026 | static inline int detach_process_native_afu_directed(struct cxl_context *ctx) |
| 1027 | { |
| 1028 | if (!ctx->pe_inserted) |
| 1029 | return 0; |
| 1030 | if (terminate_process_element(ctx)) |
| 1031 | return -1; |
| 1032 | if (remove_process_element(ctx)) |
| 1033 | return -1; |
| 1034 | |
| 1035 | return 0; |
| 1036 | } |
| 1037 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1038 | static int native_detach_process(struct cxl_context *ctx) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1039 | { |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 1040 | trace_cxl_detach(ctx); |
| 1041 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1042 | if (ctx->afu->current_mode == CXL_MODE_DEDICATED) |
| 1043 | return detach_process_native_dedicated(ctx); |
| 1044 | |
| 1045 | return detach_process_native_afu_directed(ctx); |
| 1046 | } |
| 1047 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1048 | static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1049 | { |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 1050 | /* If the adapter has gone away, we can't get any meaningful |
| 1051 | * information. |
| 1052 | */ |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 1053 | if (!cxl_ops->link_ok(afu->adapter, afu)) |
Daniel Axtens | 0b3f9c7 | 2015-08-14 17:41:18 +1000 | [diff] [blame] | 1054 | return -EIO; |
| 1055 | |
Ian Munsie | bc78b05 | 2014-11-14 17:37:50 +1100 | [diff] [blame] | 1056 | info->dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); |
| 1057 | info->dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 1058 | if (cxl_is_power8()) |
| 1059 | info->dsr = cxl_p2n_read(afu, CXL_PSL_DSR_An); |
Ian Munsie | bc78b05 | 2014-11-14 17:37:50 +1100 | [diff] [blame] | 1060 | info->afu_err = cxl_p2n_read(afu, CXL_AFU_ERR_An); |
| 1061 | info->errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); |
Christophe Lombard | 444c4ba | 2016-03-04 12:26:34 +0100 | [diff] [blame] | 1062 | info->proc_handle = 0; |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1063 | |
| 1064 | return 0; |
| 1065 | } |
| 1066 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 1067 | void cxl_native_irq_dump_regs_psl9(struct cxl_context *ctx) |
| 1068 | { |
| 1069 | u64 fir1, fir2, serr; |
| 1070 | |
| 1071 | fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR1); |
| 1072 | fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR2); |
| 1073 | |
| 1074 | dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); |
| 1075 | dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); |
| 1076 | if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { |
| 1077 | serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); |
| 1078 | cxl_afu_decode_psl_serr(ctx->afu, serr); |
| 1079 | } |
| 1080 | } |
| 1081 | |
Christophe Lombard | 64663f3 | 2017-04-07 16:11:57 +0200 | [diff] [blame] | 1082 | void cxl_native_irq_dump_regs_psl8(struct cxl_context *ctx) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1083 | { |
| 1084 | u64 fir1, fir2, fir_slice, serr, afu_debug; |
| 1085 | |
| 1086 | fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); |
| 1087 | fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); |
| 1088 | fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1089 | afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); |
| 1090 | |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1091 | dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); |
| 1092 | dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1093 | if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { |
| 1094 | serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); |
Philippe Bergheaud | 6e0c50f | 2016-07-05 13:08:06 +0200 | [diff] [blame] | 1095 | cxl_afu_decode_psl_serr(ctx->afu, serr); |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1096 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1097 | dev_crit(&ctx->afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); |
| 1098 | dev_crit(&ctx->afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1099 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1100 | |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1101 | static irqreturn_t native_handle_psl_slice_error(struct cxl_context *ctx, |
| 1102 | u64 dsisr, u64 errstat) |
| 1103 | { |
| 1104 | |
| 1105 | dev_crit(&ctx->afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); |
| 1106 | |
| 1107 | if (ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers) |
| 1108 | ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers(ctx); |
| 1109 | |
| 1110 | if (ctx->afu->adapter->native->sl_ops->debugfs_stop_trace) { |
| 1111 | dev_crit(&ctx->afu->dev, "STOPPING CXL TRACE\n"); |
| 1112 | ctx->afu->adapter->native->sl_ops->debugfs_stop_trace(ctx->afu->adapter); |
| 1113 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1114 | |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1115 | return cxl_ops->ack_irq(ctx, 0, errstat); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1116 | } |
| 1117 | |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 1118 | static bool cxl_is_translation_fault(struct cxl_afu *afu, u64 dsisr) |
| 1119 | { |
| 1120 | if ((cxl_is_psl8(afu)) && (dsisr & CXL_PSL_DSISR_TRANS)) |
| 1121 | return true; |
| 1122 | |
| 1123 | if ((cxl_is_psl9(afu)) && (dsisr & CXL_PSL9_DSISR_An_TF)) |
| 1124 | return true; |
| 1125 | |
| 1126 | return false; |
| 1127 | } |
| 1128 | |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1129 | irqreturn_t cxl_fail_irq_psl(struct cxl_afu *afu, struct cxl_irq_info *irq_info) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1130 | { |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 1131 | if (cxl_is_translation_fault(afu, irq_info->dsisr)) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1132 | cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); |
| 1133 | else |
| 1134 | cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); |
| 1135 | |
| 1136 | return IRQ_HANDLED; |
| 1137 | } |
| 1138 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1139 | static irqreturn_t native_irq_multiplexed(int irq, void *data) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1140 | { |
| 1141 | struct cxl_afu *afu = data; |
| 1142 | struct cxl_context *ctx; |
| 1143 | struct cxl_irq_info irq_info; |
Vaibhav Jain | abf051b | 2016-11-16 19:39:33 +0530 | [diff] [blame] | 1144 | u64 phreg = cxl_p2n_read(afu, CXL_PSL_PEHandle_An); |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1145 | int ph, ret = IRQ_HANDLED, res; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1146 | |
Vaibhav Jain | abf051b | 2016-11-16 19:39:33 +0530 | [diff] [blame] | 1147 | /* check if eeh kicked in while the interrupt was in flight */ |
| 1148 | if (unlikely(phreg == ~0ULL)) { |
| 1149 | dev_warn(&afu->dev, |
| 1150 | "Ignoring slice interrupt(%d) due to fenced card", |
| 1151 | irq); |
| 1152 | return IRQ_HANDLED; |
| 1153 | } |
| 1154 | /* Mask the pe-handle from register value */ |
| 1155 | ph = phreg & 0xffff; |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1156 | if ((res = native_get_irq_info(afu, &irq_info))) { |
| 1157 | WARN(1, "Unable to get CXL IRQ Info: %i\n", res); |
| 1158 | if (afu->adapter->native->sl_ops->fail_irq) |
| 1159 | return afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); |
| 1160 | return ret; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | rcu_read_lock(); |
| 1164 | ctx = idr_find(&afu->contexts_idr, ph); |
| 1165 | if (ctx) { |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1166 | if (afu->adapter->native->sl_ops->handle_interrupt) |
| 1167 | ret = afu->adapter->native->sl_ops->handle_interrupt(irq, ctx, &irq_info); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1168 | rcu_read_unlock(); |
| 1169 | return ret; |
| 1170 | } |
| 1171 | rcu_read_unlock(); |
| 1172 | |
| 1173 | WARN(1, "Unable to demultiplex CXL PSL IRQ for PE %i DSISR %016llx DAR" |
| 1174 | " %016llx\n(Possible AFU HW issue - was a term/remove acked" |
| 1175 | " with outstanding transactions?)\n", ph, irq_info.dsisr, |
| 1176 | irq_info.dar); |
Christophe Lombard | bdd2e71 | 2017-04-07 16:11:56 +0200 | [diff] [blame] | 1177 | if (afu->adapter->native->sl_ops->fail_irq) |
| 1178 | ret = afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); |
| 1179 | return ret; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1180 | } |
| 1181 | |
Andrew Donnellan | 6fd40f1 | 2016-07-22 19:01:36 +1000 | [diff] [blame] | 1182 | static void native_irq_wait(struct cxl_context *ctx) |
Michael Neuling | 2bc79ff | 2016-04-22 14:57:49 +1000 | [diff] [blame] | 1183 | { |
| 1184 | u64 dsisr; |
| 1185 | int timeout = 1000; |
| 1186 | int ph; |
| 1187 | |
| 1188 | /* |
| 1189 | * Wait until no further interrupts are presented by the PSL |
| 1190 | * for this context. |
| 1191 | */ |
| 1192 | while (timeout--) { |
| 1193 | ph = cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) & 0xffff; |
| 1194 | if (ph != ctx->pe) |
| 1195 | return; |
| 1196 | dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 1197 | if (cxl_is_psl8(ctx->afu) && |
| 1198 | ((dsisr & CXL_PSL_DSISR_PENDING) == 0)) |
Michael Neuling | 2bc79ff | 2016-04-22 14:57:49 +1000 | [diff] [blame] | 1199 | return; |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 1200 | if (cxl_is_psl9(ctx->afu) && |
| 1201 | ((dsisr & CXL_PSL9_DSISR_PENDING) == 0)) |
| 1202 | return; |
Michael Neuling | 2bc79ff | 2016-04-22 14:57:49 +1000 | [diff] [blame] | 1203 | /* |
| 1204 | * We are waiting for the workqueue to process our |
| 1205 | * irq, so need to let that run here. |
| 1206 | */ |
| 1207 | msleep(1); |
| 1208 | } |
| 1209 | |
| 1210 | dev_warn(&ctx->afu->dev, "WARNING: waiting on DSI for PE %i" |
| 1211 | " DSISR %016llx!\n", ph, dsisr); |
| 1212 | return; |
| 1213 | } |
| 1214 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1215 | static irqreturn_t native_slice_irq_err(int irq, void *data) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1216 | { |
| 1217 | struct cxl_afu *afu = data; |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 1218 | u64 errstat, serr, afu_error, dsisr; |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 1219 | u64 fir_slice, afu_debug, irq_mask; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1220 | |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1221 | /* |
| 1222 | * slice err interrupt is only used with full PSL (no XSL) |
| 1223 | */ |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1224 | serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1225 | errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); |
Philippe Bergheaud | 6e0c50f | 2016-07-05 13:08:06 +0200 | [diff] [blame] | 1226 | afu_error = cxl_p2n_read(afu, CXL_AFU_ERR_An); |
| 1227 | dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); |
| 1228 | cxl_afu_decode_psl_serr(afu, serr); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 1229 | |
| 1230 | if (cxl_is_power8()) { |
| 1231 | fir_slice = cxl_p1n_read(afu, CXL_PSL_FIR_SLICE_An); |
| 1232 | afu_debug = cxl_p1n_read(afu, CXL_AFU_DEBUG_An); |
| 1233 | dev_crit(&afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); |
| 1234 | dev_crit(&afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); |
| 1235 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1236 | dev_crit(&afu->dev, "CXL_PSL_ErrStat_An: 0x%016llx\n", errstat); |
Philippe Bergheaud | 6e0c50f | 2016-07-05 13:08:06 +0200 | [diff] [blame] | 1237 | dev_crit(&afu->dev, "AFU_ERR_An: 0x%.16llx\n", afu_error); |
| 1238 | dev_crit(&afu->dev, "PSL_DSISR_An: 0x%.16llx\n", dsisr); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1239 | |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 1240 | /* mask off the IRQ so it won't retrigger until the AFU is reset */ |
| 1241 | irq_mask = (serr & CXL_PSL_SERR_An_IRQS) >> 32; |
| 1242 | serr |= irq_mask; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1243 | cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); |
Alastair D'Silva | a715626 | 2017-05-01 10:53:31 +1000 | [diff] [blame] | 1244 | dev_info(&afu->dev, "Further such interrupts will be masked until the AFU is reset\n"); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1245 | |
| 1246 | return IRQ_HANDLED; |
| 1247 | } |
| 1248 | |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1249 | void cxl_native_err_irq_dump_regs(struct cxl *adapter) |
| 1250 | { |
| 1251 | u64 fir1, fir2; |
| 1252 | |
| 1253 | fir1 = cxl_p1_read(adapter, CXL_PSL_FIR1); |
| 1254 | fir2 = cxl_p1_read(adapter, CXL_PSL_FIR2); |
| 1255 | |
| 1256 | dev_crit(&adapter->dev, "PSL_FIR1: 0x%016llx\nPSL_FIR2: 0x%016llx\n", fir1, fir2); |
| 1257 | } |
| 1258 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1259 | static irqreturn_t native_irq_err(int irq, void *data) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1260 | { |
| 1261 | struct cxl *adapter = data; |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1262 | u64 err_ivte; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1263 | |
| 1264 | WARN(1, "CXL ERROR interrupt %i\n", irq); |
| 1265 | |
| 1266 | err_ivte = cxl_p1_read(adapter, CXL_PSL_ErrIVTE); |
| 1267 | dev_crit(&adapter->dev, "PSL_ErrIVTE: 0x%016llx\n", err_ivte); |
| 1268 | |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1269 | if (adapter->native->sl_ops->debugfs_stop_trace) { |
| 1270 | dev_crit(&adapter->dev, "STOPPING CXL TRACE\n"); |
| 1271 | adapter->native->sl_ops->debugfs_stop_trace(adapter); |
| 1272 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1273 | |
Frederic Barrat | 6d38261 | 2016-05-24 03:39:18 +1000 | [diff] [blame] | 1274 | if (adapter->native->sl_ops->err_irq_dump_registers) |
| 1275 | adapter->native->sl_ops->err_irq_dump_registers(adapter); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1276 | |
| 1277 | return IRQ_HANDLED; |
| 1278 | } |
| 1279 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1280 | int cxl_native_register_psl_err_irq(struct cxl *adapter) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1281 | { |
| 1282 | int rc; |
| 1283 | |
| 1284 | adapter->irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", |
| 1285 | dev_name(&adapter->dev)); |
| 1286 | if (!adapter->irq_name) |
| 1287 | return -ENOMEM; |
| 1288 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1289 | if ((rc = cxl_register_one_irq(adapter, native_irq_err, adapter, |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1290 | &adapter->native->err_hwirq, |
| 1291 | &adapter->native->err_virq, |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1292 | adapter->irq_name))) { |
| 1293 | kfree(adapter->irq_name); |
| 1294 | adapter->irq_name = NULL; |
| 1295 | return rc; |
| 1296 | } |
| 1297 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1298 | cxl_p1_write(adapter, CXL_PSL_ErrIVTE, adapter->native->err_hwirq & 0xffff); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1299 | |
| 1300 | return 0; |
| 1301 | } |
| 1302 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1303 | void cxl_native_release_psl_err_irq(struct cxl *adapter) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1304 | { |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1305 | if (adapter->native->err_virq != irq_find_mapping(NULL, adapter->native->err_hwirq)) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1306 | return; |
| 1307 | |
| 1308 | cxl_p1_write(adapter, CXL_PSL_ErrIVTE, 0x0000000000000000); |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1309 | cxl_unmap_irq(adapter->native->err_virq, adapter); |
| 1310 | cxl_ops->release_one_irq(adapter, adapter->native->err_hwirq); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1311 | kfree(adapter->irq_name); |
| 1312 | } |
| 1313 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1314 | int cxl_native_register_serr_irq(struct cxl_afu *afu) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1315 | { |
| 1316 | u64 serr; |
| 1317 | int rc; |
| 1318 | |
| 1319 | afu->err_irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", |
| 1320 | dev_name(&afu->dev)); |
| 1321 | if (!afu->err_irq_name) |
| 1322 | return -ENOMEM; |
| 1323 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1324 | if ((rc = cxl_register_one_irq(afu->adapter, native_slice_irq_err, afu, |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1325 | &afu->serr_hwirq, |
| 1326 | &afu->serr_virq, afu->err_irq_name))) { |
| 1327 | kfree(afu->err_irq_name); |
| 1328 | afu->err_irq_name = NULL; |
| 1329 | return rc; |
| 1330 | } |
| 1331 | |
| 1332 | serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); |
Christophe Lombard | abd1d99 | 2017-04-07 16:11:58 +0200 | [diff] [blame] | 1333 | if (cxl_is_power8()) |
| 1334 | serr = (serr & 0x00ffffffffff0000ULL) | (afu->serr_hwirq & 0xffff); |
Christophe Lombard | f24be42 | 2017-04-12 16:34:07 +0200 | [diff] [blame] | 1335 | if (cxl_is_power9()) { |
| 1336 | /* |
| 1337 | * By default, all errors are masked. So don't set all masks. |
| 1338 | * Slice errors will be transfered. |
| 1339 | */ |
| 1340 | serr = (serr & ~0xff0000007fffffffULL) | (afu->serr_hwirq & 0xffff); |
| 1341 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1342 | cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); |
| 1343 | |
| 1344 | return 0; |
| 1345 | } |
| 1346 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1347 | void cxl_native_release_serr_irq(struct cxl_afu *afu) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1348 | { |
| 1349 | if (afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) |
| 1350 | return; |
| 1351 | |
| 1352 | cxl_p1n_write(afu, CXL_PSL_SERR_An, 0x0000000000000000); |
| 1353 | cxl_unmap_irq(afu->serr_virq, afu); |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1354 | cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1355 | kfree(afu->err_irq_name); |
| 1356 | } |
| 1357 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1358 | int cxl_native_register_psl_irq(struct cxl_afu *afu) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1359 | { |
| 1360 | int rc; |
| 1361 | |
| 1362 | afu->psl_irq_name = kasprintf(GFP_KERNEL, "cxl-%s", |
| 1363 | dev_name(&afu->dev)); |
| 1364 | if (!afu->psl_irq_name) |
| 1365 | return -ENOMEM; |
| 1366 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1367 | if ((rc = cxl_register_one_irq(afu->adapter, native_irq_multiplexed, |
| 1368 | afu, &afu->native->psl_hwirq, &afu->native->psl_virq, |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1369 | afu->psl_irq_name))) { |
| 1370 | kfree(afu->psl_irq_name); |
| 1371 | afu->psl_irq_name = NULL; |
| 1372 | } |
| 1373 | return rc; |
| 1374 | } |
| 1375 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1376 | void cxl_native_release_psl_irq(struct cxl_afu *afu) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1377 | { |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1378 | if (afu->native->psl_virq != irq_find_mapping(NULL, afu->native->psl_hwirq)) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1379 | return; |
| 1380 | |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1381 | cxl_unmap_irq(afu->native->psl_virq, afu); |
| 1382 | cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1383 | kfree(afu->psl_irq_name); |
| 1384 | } |
| 1385 | |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1386 | static void recover_psl_err(struct cxl_afu *afu, u64 errstat) |
| 1387 | { |
| 1388 | u64 dsisr; |
| 1389 | |
Rasmus Villemoes | de36953 | 2015-06-11 13:27:52 +0200 | [diff] [blame] | 1390 | pr_devel("RECOVERING FROM PSL ERROR... (0x%016llx)\n", errstat); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1391 | |
| 1392 | /* Clear PSL_DSISR[PE] */ |
| 1393 | dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); |
| 1394 | cxl_p2n_write(afu, CXL_PSL_DSISR_An, dsisr & ~CXL_PSL_DSISR_An_PE); |
| 1395 | |
| 1396 | /* Write 1s to clear error status bits */ |
| 1397 | cxl_p2n_write(afu, CXL_PSL_ErrStat_An, errstat); |
| 1398 | } |
| 1399 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1400 | static int native_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask) |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1401 | { |
Ian Munsie | 9bcf28c | 2015-01-09 20:34:36 +1100 | [diff] [blame] | 1402 | trace_cxl_psl_irq_ack(ctx, tfc); |
Ian Munsie | f204e0b | 2014-10-08 19:55:02 +1100 | [diff] [blame] | 1403 | if (tfc) |
| 1404 | cxl_p2n_write(ctx->afu, CXL_PSL_TFC_An, tfc); |
| 1405 | if (psl_reset_mask) |
| 1406 | recover_psl_err(ctx->afu, psl_reset_mask); |
| 1407 | |
| 1408 | return 0; |
| 1409 | } |
| 1410 | |
| 1411 | int cxl_check_error(struct cxl_afu *afu) |
| 1412 | { |
| 1413 | return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL); |
| 1414 | } |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1415 | |
Christophe Lombard | 4752876 | 2016-03-04 12:26:37 +0100 | [diff] [blame] | 1416 | static bool native_support_attributes(const char *attr_name, |
| 1417 | enum cxl_attrs type) |
| 1418 | { |
| 1419 | return true; |
| 1420 | } |
| 1421 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1422 | static int native_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1423 | { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 1424 | if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1425 | return -EIO; |
| 1426 | if (unlikely(off >= afu->crs_len)) |
| 1427 | return -ERANGE; |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1428 | *out = in_le64(afu->native->afu_desc_mmio + afu->crs_offset + |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1429 | (cr * afu->crs_len) + off); |
| 1430 | return 0; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1431 | } |
| 1432 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1433 | static int native_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1434 | { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 1435 | if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1436 | return -EIO; |
| 1437 | if (unlikely(off >= afu->crs_len)) |
| 1438 | return -ERANGE; |
Christophe Lombard | cbffa3a | 2016-03-04 12:26:35 +0100 | [diff] [blame] | 1439 | *out = in_le32(afu->native->afu_desc_mmio + afu->crs_offset + |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1440 | (cr * afu->crs_len) + off); |
| 1441 | return 0; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1442 | } |
| 1443 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1444 | static int native_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off, u16 *out) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1445 | { |
| 1446 | u64 aligned_off = off & ~0x3L; |
| 1447 | u32 val; |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1448 | int rc; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1449 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1450 | rc = native_afu_cr_read32(afu, cr, aligned_off, &val); |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1451 | if (!rc) |
| 1452 | *out = (val >> ((off & 0x3) * 8)) & 0xffff; |
| 1453 | return rc; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1454 | } |
| 1455 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1456 | static int native_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out) |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1457 | { |
| 1458 | u64 aligned_off = off & ~0x3L; |
| 1459 | u32 val; |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1460 | int rc; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1461 | |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1462 | rc = native_afu_cr_read32(afu, cr, aligned_off, &val); |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1463 | if (!rc) |
| 1464 | *out = (val >> ((off & 0x3) * 8)) & 0xff; |
| 1465 | return rc; |
Frederic Barrat | d56d301 | 2016-03-04 12:26:26 +0100 | [diff] [blame] | 1466 | } |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1467 | |
Frederic Barrat | d601ea9 | 2016-03-04 12:26:40 +0100 | [diff] [blame] | 1468 | static int native_afu_cr_write32(struct cxl_afu *afu, int cr, u64 off, u32 in) |
| 1469 | { |
Christophe Lombard | 0d400f7 | 2016-03-04 12:26:41 +0100 | [diff] [blame] | 1470 | if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) |
Frederic Barrat | d601ea9 | 2016-03-04 12:26:40 +0100 | [diff] [blame] | 1471 | return -EIO; |
| 1472 | if (unlikely(off >= afu->crs_len)) |
| 1473 | return -ERANGE; |
| 1474 | out_le32(afu->native->afu_desc_mmio + afu->crs_offset + |
| 1475 | (cr * afu->crs_len) + off, in); |
| 1476 | return 0; |
| 1477 | } |
| 1478 | |
| 1479 | static int native_afu_cr_write16(struct cxl_afu *afu, int cr, u64 off, u16 in) |
| 1480 | { |
| 1481 | u64 aligned_off = off & ~0x3L; |
| 1482 | u32 val32, mask, shift; |
| 1483 | int rc; |
| 1484 | |
| 1485 | rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); |
| 1486 | if (rc) |
| 1487 | return rc; |
| 1488 | shift = (off & 0x3) * 8; |
| 1489 | WARN_ON(shift == 24); |
| 1490 | mask = 0xffff << shift; |
| 1491 | val32 = (val32 & ~mask) | (in << shift); |
| 1492 | |
| 1493 | rc = native_afu_cr_write32(afu, cr, aligned_off, val32); |
| 1494 | return rc; |
| 1495 | } |
| 1496 | |
| 1497 | static int native_afu_cr_write8(struct cxl_afu *afu, int cr, u64 off, u8 in) |
| 1498 | { |
| 1499 | u64 aligned_off = off & ~0x3L; |
| 1500 | u32 val32, mask, shift; |
| 1501 | int rc; |
| 1502 | |
| 1503 | rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); |
| 1504 | if (rc) |
| 1505 | return rc; |
| 1506 | shift = (off & 0x3) * 8; |
| 1507 | mask = 0xff << shift; |
| 1508 | val32 = (val32 & ~mask) | (in << shift); |
| 1509 | |
| 1510 | rc = native_afu_cr_write32(afu, cr, aligned_off, val32); |
| 1511 | return rc; |
| 1512 | } |
| 1513 | |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1514 | const struct cxl_backend_ops cxl_native_ops = { |
| 1515 | .module = THIS_MODULE, |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1516 | .adapter_reset = cxl_pci_reset, |
| 1517 | .alloc_one_irq = cxl_pci_alloc_one_irq, |
| 1518 | .release_one_irq = cxl_pci_release_one_irq, |
| 1519 | .alloc_irq_ranges = cxl_pci_alloc_irq_ranges, |
| 1520 | .release_irq_ranges = cxl_pci_release_irq_ranges, |
| 1521 | .setup_irq = cxl_pci_setup_irq, |
| 1522 | .handle_psl_slice_error = native_handle_psl_slice_error, |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1523 | .psl_interrupt = NULL, |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1524 | .ack_irq = native_ack_irq, |
Michael Neuling | 2bc79ff | 2016-04-22 14:57:49 +1000 | [diff] [blame] | 1525 | .irq_wait = native_irq_wait, |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1526 | .attach_process = native_attach_process, |
| 1527 | .detach_process = native_detach_process, |
Ian Munsie | 292841b | 2016-05-24 02:14:05 +1000 | [diff] [blame] | 1528 | .update_ivtes = native_update_ivtes, |
Christophe Lombard | 4752876 | 2016-03-04 12:26:37 +0100 | [diff] [blame] | 1529 | .support_attributes = native_support_attributes, |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1530 | .link_ok = cxl_adapter_link_ok, |
Frederic Barrat | 2b04cf3 | 2016-03-04 12:26:29 +0100 | [diff] [blame] | 1531 | .release_afu = cxl_pci_release_afu, |
| 1532 | .afu_read_err_buffer = cxl_pci_afu_read_err_buffer, |
| 1533 | .afu_check_and_enable = native_afu_check_and_enable, |
| 1534 | .afu_activate_mode = native_afu_activate_mode, |
| 1535 | .afu_deactivate_mode = native_afu_deactivate_mode, |
| 1536 | .afu_reset = native_afu_reset, |
| 1537 | .afu_cr_read8 = native_afu_cr_read8, |
| 1538 | .afu_cr_read16 = native_afu_cr_read16, |
| 1539 | .afu_cr_read32 = native_afu_cr_read32, |
| 1540 | .afu_cr_read64 = native_afu_cr_read64, |
Frederic Barrat | d601ea9 | 2016-03-04 12:26:40 +0100 | [diff] [blame] | 1541 | .afu_cr_write8 = native_afu_cr_write8, |
| 1542 | .afu_cr_write16 = native_afu_cr_write16, |
| 1543 | .afu_cr_write32 = native_afu_cr_write32, |
| 1544 | .read_adapter_vpd = cxl_pci_read_adapter_vpd, |
Frederic Barrat | 5be587b | 2016-03-04 12:26:28 +0100 | [diff] [blame] | 1545 | }; |