Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1 | /* |
| 2 | * PMC-Sierra SPCv/ve 8088/8089 SAS/SATA based host adapters driver |
| 3 | * |
| 4 | * Copyright (c) 2008-2009 PMC-Sierra, Inc., |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions, and the following disclaimer, |
| 12 | * without modification. |
| 13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 14 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 15 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 16 | * including a substantially similar Disclaimer requirement for further |
| 17 | * binary redistribution. |
| 18 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 19 | * of any contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * |
| 22 | * Alternatively, this software may be distributed under the terms of the |
| 23 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 24 | * Software Foundation. |
| 25 | * |
| 26 | * NO WARRANTY |
| 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 31 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 35 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 36 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 37 | * POSSIBILITY OF SUCH DAMAGES. |
| 38 | * |
| 39 | */ |
| 40 | #include <linux/slab.h> |
| 41 | #include "pm8001_sas.h" |
| 42 | #include "pm80xx_hwi.h" |
| 43 | #include "pm8001_chips.h" |
| 44 | #include "pm8001_ctl.h" |
| 45 | |
| 46 | #define SMP_DIRECT 1 |
| 47 | #define SMP_INDIRECT 2 |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 48 | |
| 49 | |
| 50 | int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shift_value) |
| 51 | { |
| 52 | u32 reg_val; |
| 53 | unsigned long start; |
| 54 | pm8001_cw32(pm8001_ha, 0, MEMBASE_II_SHIFT_REGISTER, shift_value); |
| 55 | /* confirm the setting is written */ |
| 56 | start = jiffies + HZ; /* 1 sec */ |
| 57 | do { |
| 58 | reg_val = pm8001_cr32(pm8001_ha, 0, MEMBASE_II_SHIFT_REGISTER); |
| 59 | } while ((reg_val != shift_value) && time_before(jiffies, start)); |
| 60 | if (reg_val != shift_value) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 61 | pm8001_dbg(pm8001_ha, FAIL, "TIMEOUT:MEMBASE_II_SHIFT_REGISTER = 0x%x\n", |
| 62 | reg_val); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 63 | return -1; |
| 64 | } |
| 65 | return 0; |
| 66 | } |
| 67 | |
Lee Jones | ea310f5 | 2020-07-21 17:41:33 +0100 | [diff] [blame] | 68 | static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 69 | const void *destination, |
| 70 | u32 dw_count, u32 bus_base_number) |
| 71 | { |
| 72 | u32 index, value, offset; |
| 73 | u32 *destination1; |
| 74 | destination1 = (u32 *)destination; |
| 75 | |
| 76 | for (index = 0; index < dw_count; index += 4, destination1++) { |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 77 | offset = (soffset + index); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 78 | if (offset < (64 * 1024)) { |
| 79 | value = pm8001_cr32(pm8001_ha, bus_base_number, offset); |
| 80 | *destination1 = cpu_to_le32(value); |
| 81 | } |
| 82 | } |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | ssize_t pm80xx_get_fatal_dump(struct device *cdev, |
| 87 | struct device_attribute *attr, char *buf) |
| 88 | { |
| 89 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 90 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 91 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 92 | void __iomem *fatal_table_address = pm8001_ha->fatal_tbl_addr; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 93 | u32 accum_len , reg_val, index, *temp; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 94 | u32 status = 1; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 95 | unsigned long start; |
| 96 | u8 *direct_data; |
| 97 | char *fatal_error_data = buf; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 98 | u32 length_to_read; |
| 99 | u32 offset; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 100 | |
| 101 | pm8001_ha->forensic_info.data_buf.direct_data = buf; |
| 102 | if (pm8001_ha->chip_id == chip_8001) { |
| 103 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 104 | sprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
| 105 | "Not supported for SPC controller"); |
| 106 | return (char *)pm8001_ha->forensic_info.data_buf.direct_data - |
| 107 | (char *)buf; |
| 108 | } |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 109 | /* initialize variables for very first call from host application */ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 110 | if (pm8001_ha->forensic_info.data_buf.direct_offset == 0) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 111 | pm8001_dbg(pm8001_ha, IO, |
| 112 | "forensic_info TYPE_NON_FATAL..............\n"); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 113 | direct_data = (u8 *)fatal_error_data; |
| 114 | pm8001_ha->forensic_info.data_type = TYPE_NON_FATAL; |
| 115 | pm8001_ha->forensic_info.data_buf.direct_len = SYSFS_OFFSET; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 116 | pm8001_ha->forensic_info.data_buf.direct_offset = 0; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 117 | pm8001_ha->forensic_info.data_buf.read_len = 0; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 118 | pm8001_ha->forensic_preserved_accumulated_transfer = 0; |
| 119 | |
| 120 | /* Write signature to fatal dump table */ |
| 121 | pm8001_mw32(fatal_table_address, |
| 122 | MPI_FATAL_EDUMP_TABLE_SIGNATURE, 0x1234abcd); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 123 | |
| 124 | pm8001_ha->forensic_info.data_buf.direct_data = direct_data; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 125 | pm8001_dbg(pm8001_ha, IO, "ossaHwCB: status1 %d\n", status); |
| 126 | pm8001_dbg(pm8001_ha, IO, "ossaHwCB: read_len 0x%x\n", |
| 127 | pm8001_ha->forensic_info.data_buf.read_len); |
| 128 | pm8001_dbg(pm8001_ha, IO, "ossaHwCB: direct_len 0x%x\n", |
| 129 | pm8001_ha->forensic_info.data_buf.direct_len); |
| 130 | pm8001_dbg(pm8001_ha, IO, "ossaHwCB: direct_offset 0x%x\n", |
| 131 | pm8001_ha->forensic_info.data_buf.direct_offset); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 132 | } |
| 133 | if (pm8001_ha->forensic_info.data_buf.direct_offset == 0) { |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 134 | /* start to get data */ |
| 135 | /* Program the MEMBASE II Shifting Register with 0x00.*/ |
| 136 | pm8001_cw32(pm8001_ha, 0, MEMBASE_II_SHIFT_REGISTER, |
| 137 | pm8001_ha->fatal_forensic_shift_offset); |
| 138 | pm8001_ha->forensic_last_offset = 0; |
| 139 | pm8001_ha->forensic_fatal_step = 0; |
| 140 | pm8001_ha->fatal_bar_loc = 0; |
| 141 | } |
Viswas G | cf37006 | 2013-12-10 10:31:38 +0530 | [diff] [blame] | 142 | |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 143 | /* Read until accum_len is retrived */ |
| 144 | accum_len = pm8001_mr32(fatal_table_address, |
| 145 | MPI_FATAL_EDUMP_TABLE_ACCUM_LEN); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 146 | /* Determine length of data between previously stored transfer length |
| 147 | * and current accumulated transfer length |
| 148 | */ |
| 149 | length_to_read = |
| 150 | accum_len - pm8001_ha->forensic_preserved_accumulated_transfer; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 151 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: accum_len 0x%x\n", |
| 152 | accum_len); |
| 153 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: length_to_read 0x%x\n", |
| 154 | length_to_read); |
| 155 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: last_offset 0x%x\n", |
| 156 | pm8001_ha->forensic_last_offset); |
| 157 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: read_len 0x%x\n", |
| 158 | pm8001_ha->forensic_info.data_buf.read_len); |
| 159 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv:: direct_len 0x%x\n", |
| 160 | pm8001_ha->forensic_info.data_buf.direct_len); |
| 161 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv:: direct_offset 0x%x\n", |
| 162 | pm8001_ha->forensic_info.data_buf.direct_offset); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 163 | |
| 164 | /* If accumulated length failed to read correctly fail the attempt.*/ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 165 | if (accum_len == 0xFFFFFFFF) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 166 | pm8001_dbg(pm8001_ha, IO, |
| 167 | "Possible PCI issue 0x%x not expected\n", |
| 168 | accum_len); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 169 | return status; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 170 | } |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 171 | /* If accumulated length is zero fail the attempt */ |
| 172 | if (accum_len == 0) { |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 173 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 174 | sprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 175 | "%08x ", 0xFFFFFFFF); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 176 | return (char *)pm8001_ha->forensic_info.data_buf.direct_data - |
| 177 | (char *)buf; |
| 178 | } |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 179 | /* Accumulated length is good so start capturing the first data */ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 180 | temp = (u32 *)pm8001_ha->memoryMap.region[FORENSIC_MEM].virt_ptr; |
| 181 | if (pm8001_ha->forensic_fatal_step == 0) { |
| 182 | moreData: |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 183 | /* If data to read is less than SYSFS_OFFSET then reduce the |
| 184 | * length of dataLen |
| 185 | */ |
| 186 | if (pm8001_ha->forensic_last_offset + SYSFS_OFFSET |
| 187 | > length_to_read) { |
| 188 | pm8001_ha->forensic_info.data_buf.direct_len = |
| 189 | length_to_read - |
| 190 | pm8001_ha->forensic_last_offset; |
| 191 | } else { |
| 192 | pm8001_ha->forensic_info.data_buf.direct_len = |
| 193 | SYSFS_OFFSET; |
| 194 | } |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 195 | if (pm8001_ha->forensic_info.data_buf.direct_data) { |
| 196 | /* Data is in bar, copy to host memory */ |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 197 | pm80xx_pci_mem_copy(pm8001_ha, |
| 198 | pm8001_ha->fatal_bar_loc, |
| 199 | pm8001_ha->memoryMap.region[FORENSIC_MEM].virt_ptr, |
| 200 | pm8001_ha->forensic_info.data_buf.direct_len, 1); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 201 | } |
| 202 | pm8001_ha->fatal_bar_loc += |
| 203 | pm8001_ha->forensic_info.data_buf.direct_len; |
| 204 | pm8001_ha->forensic_info.data_buf.direct_offset += |
| 205 | pm8001_ha->forensic_info.data_buf.direct_len; |
| 206 | pm8001_ha->forensic_last_offset += |
| 207 | pm8001_ha->forensic_info.data_buf.direct_len; |
| 208 | pm8001_ha->forensic_info.data_buf.read_len = |
| 209 | pm8001_ha->forensic_info.data_buf.direct_len; |
| 210 | |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 211 | if (pm8001_ha->forensic_last_offset >= length_to_read) { |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 212 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 213 | sprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
| 214 | "%08x ", 3); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 215 | for (index = 0; index < |
| 216 | (pm8001_ha->forensic_info.data_buf.direct_len |
| 217 | / 4); index++) { |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 218 | pm8001_ha->forensic_info.data_buf.direct_data += |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 219 | sprintf( |
| 220 | pm8001_ha->forensic_info.data_buf.direct_data, |
| 221 | "%08x ", *(temp + index)); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | pm8001_ha->fatal_bar_loc = 0; |
| 225 | pm8001_ha->forensic_fatal_step = 1; |
| 226 | pm8001_ha->fatal_forensic_shift_offset = 0; |
| 227 | pm8001_ha->forensic_last_offset = 0; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 228 | status = 0; |
| 229 | offset = (int) |
| 230 | ((char *)pm8001_ha->forensic_info.data_buf.direct_data |
| 231 | - (char *)buf); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 232 | pm8001_dbg(pm8001_ha, IO, |
| 233 | "get_fatal_spcv:return1 0x%x\n", offset); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 234 | return (char *)pm8001_ha-> |
| 235 | forensic_info.data_buf.direct_data - |
| 236 | (char *)buf; |
| 237 | } |
| 238 | if (pm8001_ha->fatal_bar_loc < (64 * 1024)) { |
| 239 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 240 | sprintf(pm8001_ha-> |
| 241 | forensic_info.data_buf.direct_data, |
| 242 | "%08x ", 2); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 243 | for (index = 0; index < |
| 244 | (pm8001_ha->forensic_info.data_buf.direct_len |
| 245 | / 4); index++) { |
| 246 | pm8001_ha->forensic_info.data_buf.direct_data |
| 247 | += sprintf(pm8001_ha-> |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 248 | forensic_info.data_buf.direct_data, |
| 249 | "%08x ", *(temp + index)); |
| 250 | } |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 251 | status = 0; |
| 252 | offset = (int) |
| 253 | ((char *)pm8001_ha->forensic_info.data_buf.direct_data |
| 254 | - (char *)buf); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 255 | pm8001_dbg(pm8001_ha, IO, |
| 256 | "get_fatal_spcv:return2 0x%x\n", offset); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 257 | return (char *)pm8001_ha-> |
| 258 | forensic_info.data_buf.direct_data - |
| 259 | (char *)buf; |
| 260 | } |
| 261 | |
| 262 | /* Increment the MEMBASE II Shifting Register value by 0x100.*/ |
| 263 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 264 | sprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
| 265 | "%08x ", 2); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 266 | for (index = 0; index < |
| 267 | (pm8001_ha->forensic_info.data_buf.direct_len |
| 268 | / 4) ; index++) { |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 269 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 270 | sprintf(pm8001_ha-> |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 271 | forensic_info.data_buf.direct_data, |
| 272 | "%08x ", *(temp + index)); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 273 | } |
| 274 | pm8001_ha->fatal_forensic_shift_offset += 0x100; |
| 275 | pm8001_cw32(pm8001_ha, 0, MEMBASE_II_SHIFT_REGISTER, |
| 276 | pm8001_ha->fatal_forensic_shift_offset); |
| 277 | pm8001_ha->fatal_bar_loc = 0; |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 278 | status = 0; |
| 279 | offset = (int) |
| 280 | ((char *)pm8001_ha->forensic_info.data_buf.direct_data |
| 281 | - (char *)buf); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 282 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: return3 0x%x\n", |
| 283 | offset); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 284 | return (char *)pm8001_ha->forensic_info.data_buf.direct_data - |
| 285 | (char *)buf; |
| 286 | } |
| 287 | if (pm8001_ha->forensic_fatal_step == 1) { |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 288 | /* store previous accumulated length before triggering next |
| 289 | * accumulated length update |
| 290 | */ |
| 291 | pm8001_ha->forensic_preserved_accumulated_transfer = |
| 292 | pm8001_mr32(fatal_table_address, |
| 293 | MPI_FATAL_EDUMP_TABLE_ACCUM_LEN); |
| 294 | |
| 295 | /* continue capturing the fatal log until Dump status is 0x3 */ |
| 296 | if (pm8001_mr32(fatal_table_address, |
| 297 | MPI_FATAL_EDUMP_TABLE_STATUS) < |
| 298 | MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE) { |
| 299 | |
| 300 | /* reset fddstat bit by writing to zero*/ |
| 301 | pm8001_mw32(fatal_table_address, |
| 302 | MPI_FATAL_EDUMP_TABLE_STATUS, 0x0); |
| 303 | |
| 304 | /* set dump control value to '1' so that new data will |
| 305 | * be transferred to shared memory |
| 306 | */ |
| 307 | pm8001_mw32(fatal_table_address, |
| 308 | MPI_FATAL_EDUMP_TABLE_HANDSHAKE, |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 309 | MPI_FATAL_EDUMP_HANDSHAKE_RDY); |
| 310 | |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 311 | /*Poll FDDHSHK until clear */ |
| 312 | start = jiffies + (2 * HZ); /* 2 sec */ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 313 | |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 314 | do { |
| 315 | reg_val = pm8001_mr32(fatal_table_address, |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 316 | MPI_FATAL_EDUMP_TABLE_HANDSHAKE); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 317 | } while ((reg_val) && time_before(jiffies, start)); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 318 | |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 319 | if (reg_val != 0) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 320 | pm8001_dbg(pm8001_ha, FAIL, |
| 321 | "TIMEOUT:MPI_FATAL_EDUMP_TABLE_HDSHAKE 0x%x\n", |
| 322 | reg_val); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 323 | /* Fail the dump if a timeout occurs */ |
| 324 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 325 | sprintf( |
| 326 | pm8001_ha->forensic_info.data_buf.direct_data, |
| 327 | "%08x ", 0xFFFFFFFF); |
| 328 | return((char *) |
| 329 | pm8001_ha->forensic_info.data_buf.direct_data |
| 330 | - (char *)buf); |
| 331 | } |
| 332 | /* Poll status register until set to 2 or |
| 333 | * 3 for up to 2 seconds |
| 334 | */ |
| 335 | start = jiffies + (2 * HZ); /* 2 sec */ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 336 | |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 337 | do { |
| 338 | reg_val = pm8001_mr32(fatal_table_address, |
| 339 | MPI_FATAL_EDUMP_TABLE_STATUS); |
Colin Ian King | 0e7c353 | 2019-11-20 13:50:31 +0000 | [diff] [blame] | 340 | } while (((reg_val != 2) && (reg_val != 3)) && |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 341 | time_before(jiffies, start)); |
| 342 | |
| 343 | if (reg_val < 2) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 344 | pm8001_dbg(pm8001_ha, FAIL, |
| 345 | "TIMEOUT:MPI_FATAL_EDUMP_TABLE_STATUS = 0x%x\n", |
| 346 | reg_val); |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 347 | /* Fail the dump if a timeout occurs */ |
| 348 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 349 | sprintf( |
| 350 | pm8001_ha->forensic_info.data_buf.direct_data, |
| 351 | "%08x ", 0xFFFFFFFF); |
Viswas G | ec2e7e1 | 2021-01-09 18:08:46 +0530 | [diff] [blame] | 352 | return((char *)pm8001_ha->forensic_info.data_buf.direct_data - |
| 353 | (char *)buf); |
| 354 | } |
| 355 | /* reset fatal_forensic_shift_offset back to zero and reset MEMBASE 2 register to zero */ |
| 356 | pm8001_ha->fatal_forensic_shift_offset = 0; /* location in 64k region */ |
| 357 | pm8001_cw32(pm8001_ha, 0, |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 358 | MEMBASE_II_SHIFT_REGISTER, |
| 359 | pm8001_ha->fatal_forensic_shift_offset); |
Viswas G | ec2e7e1 | 2021-01-09 18:08:46 +0530 | [diff] [blame] | 360 | } |
Colin Ian King | 7b38212 | 2021-01-15 09:58:24 +0000 | [diff] [blame] | 361 | /* Read the next block of the debug data.*/ |
| 362 | length_to_read = pm8001_mr32(fatal_table_address, |
| 363 | MPI_FATAL_EDUMP_TABLE_ACCUM_LEN) - |
| 364 | pm8001_ha->forensic_preserved_accumulated_transfer; |
| 365 | if (length_to_read != 0x0) { |
| 366 | pm8001_ha->forensic_fatal_step = 0; |
| 367 | goto moreData; |
| 368 | } else { |
| 369 | pm8001_ha->forensic_info.data_buf.direct_data += |
| 370 | sprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 371 | "%08x ", 4); |
Colin Ian King | 7b38212 | 2021-01-15 09:58:24 +0000 | [diff] [blame] | 372 | pm8001_ha->forensic_info.data_buf.read_len = 0xFFFFFFFF; |
| 373 | pm8001_ha->forensic_info.data_buf.direct_len = 0; |
| 374 | pm8001_ha->forensic_info.data_buf.direct_offset = 0; |
| 375 | pm8001_ha->forensic_info.data_buf.read_len = 0; |
| 376 | } |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 377 | } |
Deepak Ukey | 044f59d | 2019-11-14 15:39:10 +0530 | [diff] [blame] | 378 | offset = (int)((char *)pm8001_ha->forensic_info.data_buf.direct_data |
| 379 | - (char *)buf); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 380 | pm8001_dbg(pm8001_ha, IO, "get_fatal_spcv: return4 0x%x\n", offset); |
Viswas G | ec2e7e1 | 2021-01-09 18:08:46 +0530 | [diff] [blame] | 381 | return ((char *)pm8001_ha->forensic_info.data_buf.direct_data - |
| 382 | (char *)buf); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 383 | } |
| 384 | |
Deepak Ukey | dba2cc0 | 2020-03-16 13:19:05 +0530 | [diff] [blame] | 385 | /* pm80xx_get_non_fatal_dump - dump the nonfatal data from the dma |
| 386 | * location by the firmware. |
| 387 | */ |
| 388 | ssize_t pm80xx_get_non_fatal_dump(struct device *cdev, |
| 389 | struct device_attribute *attr, char *buf) |
| 390 | { |
| 391 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 392 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 393 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 394 | void __iomem *nonfatal_table_address = pm8001_ha->fatal_tbl_addr; |
| 395 | u32 accum_len = 0; |
| 396 | u32 total_len = 0; |
| 397 | u32 reg_val = 0; |
| 398 | u32 *temp = NULL; |
| 399 | u32 index = 0; |
| 400 | u32 output_length; |
| 401 | unsigned long start = 0; |
| 402 | char *buf_copy = buf; |
| 403 | |
| 404 | temp = (u32 *)pm8001_ha->memoryMap.region[FORENSIC_MEM].virt_ptr; |
| 405 | if (++pm8001_ha->non_fatal_count == 1) { |
| 406 | if (pm8001_ha->chip_id == chip_8001) { |
| 407 | snprintf(pm8001_ha->forensic_info.data_buf.direct_data, |
| 408 | PAGE_SIZE, "Not supported for SPC controller"); |
| 409 | return 0; |
| 410 | } |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 411 | pm8001_dbg(pm8001_ha, IO, "forensic_info TYPE_NON_FATAL...\n"); |
Deepak Ukey | dba2cc0 | 2020-03-16 13:19:05 +0530 | [diff] [blame] | 412 | /* |
| 413 | * Step 1: Write the host buffer parameters in the MPI Fatal and |
| 414 | * Non-Fatal Error Dump Capture Table.This is the buffer |
| 415 | * where debug data will be DMAed to. |
| 416 | */ |
| 417 | pm8001_mw32(nonfatal_table_address, |
| 418 | MPI_FATAL_EDUMP_TABLE_LO_OFFSET, |
| 419 | pm8001_ha->memoryMap.region[FORENSIC_MEM].phys_addr_lo); |
| 420 | |
| 421 | pm8001_mw32(nonfatal_table_address, |
| 422 | MPI_FATAL_EDUMP_TABLE_HI_OFFSET, |
| 423 | pm8001_ha->memoryMap.region[FORENSIC_MEM].phys_addr_hi); |
| 424 | |
| 425 | pm8001_mw32(nonfatal_table_address, |
| 426 | MPI_FATAL_EDUMP_TABLE_LENGTH, SYSFS_OFFSET); |
| 427 | |
| 428 | /* Optionally, set the DUMPCTRL bit to 1 if the host |
| 429 | * keeps sending active I/Os while capturing the non-fatal |
| 430 | * debug data. Otherwise, leave this bit set to zero |
| 431 | */ |
| 432 | pm8001_mw32(nonfatal_table_address, |
| 433 | MPI_FATAL_EDUMP_TABLE_HANDSHAKE, MPI_FATAL_EDUMP_HANDSHAKE_RDY); |
| 434 | |
| 435 | /* |
| 436 | * Step 2: Clear Accumulative Length of Debug Data Transferred |
| 437 | * [ACCDDLEN] field in the MPI Fatal and Non-Fatal Error Dump |
| 438 | * Capture Table to zero. |
| 439 | */ |
| 440 | pm8001_mw32(nonfatal_table_address, |
| 441 | MPI_FATAL_EDUMP_TABLE_ACCUM_LEN, 0); |
| 442 | |
| 443 | /* initiallize previous accumulated length to 0 */ |
| 444 | pm8001_ha->forensic_preserved_accumulated_transfer = 0; |
| 445 | pm8001_ha->non_fatal_read_length = 0; |
| 446 | } |
| 447 | |
| 448 | total_len = pm8001_mr32(nonfatal_table_address, |
| 449 | MPI_FATAL_EDUMP_TABLE_TOTAL_LEN); |
| 450 | /* |
| 451 | * Step 3:Clear Fatal/Non-Fatal Debug Data Transfer Status [FDDTSTAT] |
| 452 | * field and then request that the SPCv controller transfer the debug |
| 453 | * data by setting bit 7 of the Inbound Doorbell Set Register. |
| 454 | */ |
| 455 | pm8001_mw32(nonfatal_table_address, MPI_FATAL_EDUMP_TABLE_STATUS, 0); |
| 456 | pm8001_cw32(pm8001_ha, 0, MSGU_IBDB_SET, |
| 457 | SPCv_MSGU_CFG_TABLE_NONFATAL_DUMP); |
| 458 | |
| 459 | /* |
| 460 | * Step 4.1: Read back the Inbound Doorbell Set Register (by polling for |
| 461 | * 2 seconds) until register bit 7 is cleared. |
| 462 | * This step only indicates the request is accepted by the controller. |
| 463 | */ |
| 464 | start = jiffies + (2 * HZ); /* 2 sec */ |
| 465 | do { |
| 466 | reg_val = pm8001_cr32(pm8001_ha, 0, MSGU_IBDB_SET) & |
| 467 | SPCv_MSGU_CFG_TABLE_NONFATAL_DUMP; |
| 468 | } while ((reg_val != 0) && time_before(jiffies, start)); |
| 469 | |
| 470 | /* Step 4.2: To check the completion of the transfer, poll the Fatal/Non |
| 471 | * Fatal Debug Data Transfer Status [FDDTSTAT] field for 2 seconds in |
| 472 | * the MPI Fatal and Non-Fatal Error Dump Capture Table. |
| 473 | */ |
| 474 | start = jiffies + (2 * HZ); /* 2 sec */ |
| 475 | do { |
| 476 | reg_val = pm8001_mr32(nonfatal_table_address, |
| 477 | MPI_FATAL_EDUMP_TABLE_STATUS); |
| 478 | } while ((!reg_val) && time_before(jiffies, start)); |
| 479 | |
| 480 | if ((reg_val == 0x00) || |
| 481 | (reg_val == MPI_FATAL_EDUMP_TABLE_STAT_DMA_FAILED) || |
| 482 | (reg_val > MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE)) { |
| 483 | pm8001_ha->non_fatal_read_length = 0; |
| 484 | buf_copy += snprintf(buf_copy, PAGE_SIZE, "%08x ", 0xFFFFFFFF); |
| 485 | pm8001_ha->non_fatal_count = 0; |
| 486 | return (buf_copy - buf); |
| 487 | } else if (reg_val == |
| 488 | MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_MORE_DATA) { |
| 489 | buf_copy += snprintf(buf_copy, PAGE_SIZE, "%08x ", 2); |
| 490 | } else if ((reg_val == MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE) || |
| 491 | (pm8001_ha->non_fatal_read_length >= total_len)) { |
| 492 | pm8001_ha->non_fatal_read_length = 0; |
| 493 | buf_copy += snprintf(buf_copy, PAGE_SIZE, "%08x ", 4); |
| 494 | pm8001_ha->non_fatal_count = 0; |
| 495 | } |
| 496 | accum_len = pm8001_mr32(nonfatal_table_address, |
| 497 | MPI_FATAL_EDUMP_TABLE_ACCUM_LEN); |
| 498 | output_length = accum_len - |
| 499 | pm8001_ha->forensic_preserved_accumulated_transfer; |
| 500 | |
| 501 | for (index = 0; index < output_length/4; index++) |
| 502 | buf_copy += snprintf(buf_copy, PAGE_SIZE, |
| 503 | "%08x ", *(temp+index)); |
| 504 | |
| 505 | pm8001_ha->non_fatal_read_length += output_length; |
| 506 | |
| 507 | /* store current accumulated length to use in next iteration as |
| 508 | * the previous accumulated length |
| 509 | */ |
| 510 | pm8001_ha->forensic_preserved_accumulated_transfer = accum_len; |
| 511 | return (buf_copy - buf); |
| 512 | } |
| 513 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 514 | /** |
| 515 | * read_main_config_table - read the configure table and save it. |
| 516 | * @pm8001_ha: our hba card information |
| 517 | */ |
| 518 | static void read_main_config_table(struct pm8001_hba_info *pm8001_ha) |
| 519 | { |
| 520 | void __iomem *address = pm8001_ha->main_cfg_tbl_addr; |
| 521 | |
| 522 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.signature = |
| 523 | pm8001_mr32(address, MAIN_SIGNATURE_OFFSET); |
| 524 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev = |
| 525 | pm8001_mr32(address, MAIN_INTERFACE_REVISION); |
| 526 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev = |
| 527 | pm8001_mr32(address, MAIN_FW_REVISION); |
| 528 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io = |
| 529 | pm8001_mr32(address, MAIN_MAX_OUTSTANDING_IO_OFFSET); |
| 530 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl = |
| 531 | pm8001_mr32(address, MAIN_MAX_SGL_OFFSET); |
| 532 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.ctrl_cap_flag = |
| 533 | pm8001_mr32(address, MAIN_CNTRL_CAP_OFFSET); |
| 534 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gst_offset = |
| 535 | pm8001_mr32(address, MAIN_GST_OFFSET); |
| 536 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.inbound_queue_offset = |
| 537 | pm8001_mr32(address, MAIN_IBQ_OFFSET); |
| 538 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.outbound_queue_offset = |
| 539 | pm8001_mr32(address, MAIN_OBQ_OFFSET); |
| 540 | |
| 541 | /* read Error Dump Offset and Length */ |
| 542 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_offset0 = |
| 543 | pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP0_OFFSET); |
| 544 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_length0 = |
| 545 | pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP0_LENGTH); |
| 546 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_offset1 = |
| 547 | pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP1_OFFSET); |
| 548 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_length1 = |
| 549 | pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP1_LENGTH); |
| 550 | |
| 551 | /* read GPIO LED settings from the configuration table */ |
| 552 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping = |
| 553 | pm8001_mr32(address, MAIN_GPIO_LED_FLAGS_OFFSET); |
| 554 | |
| 555 | /* read analog Setting offset from the configuration table */ |
| 556 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.analog_setup_table_offset = |
| 557 | pm8001_mr32(address, MAIN_ANALOG_SETUP_OFFSET); |
| 558 | |
| 559 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.int_vec_table_offset = |
| 560 | pm8001_mr32(address, MAIN_INT_VECTOR_TABLE_OFFSET); |
| 561 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.phy_attr_table_offset = |
| 562 | pm8001_mr32(address, MAIN_SAS_PHY_ATTR_TABLE_OFFSET); |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 563 | /* read port recover and reset timeout */ |
| 564 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer = |
| 565 | pm8001_mr32(address, MAIN_PORT_RECOVERY_TIMER); |
Viswas G | 24fff01 | 2017-10-18 11:39:08 +0530 | [diff] [blame] | 566 | /* read ILA and inactive firmware version */ |
| 567 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version = |
| 568 | pm8001_mr32(address, MAIN_MPI_ILA_RELEASE_TYPE); |
| 569 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version = |
| 570 | pm8001_mr32(address, MAIN_MPI_INACTIVE_FW_VERSION); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 571 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 572 | pm8001_dbg(pm8001_ha, DEV, |
| 573 | "Main cfg table: sign:%x interface rev:%x fw_rev:%x\n", |
| 574 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.signature, |
| 575 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev, |
| 576 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 577 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 578 | pm8001_dbg(pm8001_ha, DEV, |
| 579 | "table offset: gst:%x iq:%x oq:%x int vec:%x phy attr:%x\n", |
| 580 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gst_offset, |
| 581 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.inbound_queue_offset, |
| 582 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.outbound_queue_offset, |
| 583 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.int_vec_table_offset, |
| 584 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.phy_attr_table_offset); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 585 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 586 | pm8001_dbg(pm8001_ha, DEV, |
| 587 | "Main cfg table; ila rev:%x Inactive fw rev:%x\n", |
| 588 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version, |
| 589 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /** |
| 593 | * read_general_status_table - read the general status table and save it. |
| 594 | * @pm8001_ha: our hba card information |
| 595 | */ |
| 596 | static void read_general_status_table(struct pm8001_hba_info *pm8001_ha) |
| 597 | { |
| 598 | void __iomem *address = pm8001_ha->general_stat_tbl_addr; |
| 599 | pm8001_ha->gs_tbl.pm80xx_tbl.gst_len_mpistate = |
| 600 | pm8001_mr32(address, GST_GSTLEN_MPIS_OFFSET); |
| 601 | pm8001_ha->gs_tbl.pm80xx_tbl.iq_freeze_state0 = |
| 602 | pm8001_mr32(address, GST_IQ_FREEZE_STATE0_OFFSET); |
| 603 | pm8001_ha->gs_tbl.pm80xx_tbl.iq_freeze_state1 = |
| 604 | pm8001_mr32(address, GST_IQ_FREEZE_STATE1_OFFSET); |
| 605 | pm8001_ha->gs_tbl.pm80xx_tbl.msgu_tcnt = |
| 606 | pm8001_mr32(address, GST_MSGUTCNT_OFFSET); |
| 607 | pm8001_ha->gs_tbl.pm80xx_tbl.iop_tcnt = |
| 608 | pm8001_mr32(address, GST_IOPTCNT_OFFSET); |
| 609 | pm8001_ha->gs_tbl.pm80xx_tbl.gpio_input_val = |
| 610 | pm8001_mr32(address, GST_GPIO_INPUT_VAL); |
| 611 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[0] = |
| 612 | pm8001_mr32(address, GST_RERRINFO_OFFSET0); |
| 613 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[1] = |
| 614 | pm8001_mr32(address, GST_RERRINFO_OFFSET1); |
| 615 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[2] = |
| 616 | pm8001_mr32(address, GST_RERRINFO_OFFSET2); |
| 617 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[3] = |
| 618 | pm8001_mr32(address, GST_RERRINFO_OFFSET3); |
| 619 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[4] = |
| 620 | pm8001_mr32(address, GST_RERRINFO_OFFSET4); |
| 621 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[5] = |
| 622 | pm8001_mr32(address, GST_RERRINFO_OFFSET5); |
| 623 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[6] = |
| 624 | pm8001_mr32(address, GST_RERRINFO_OFFSET6); |
| 625 | pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[7] = |
| 626 | pm8001_mr32(address, GST_RERRINFO_OFFSET7); |
| 627 | } |
| 628 | /** |
| 629 | * read_phy_attr_table - read the phy attribute table and save it. |
| 630 | * @pm8001_ha: our hba card information |
| 631 | */ |
| 632 | static void read_phy_attr_table(struct pm8001_hba_info *pm8001_ha) |
| 633 | { |
| 634 | void __iomem *address = pm8001_ha->pspa_q_tbl_addr; |
| 635 | pm8001_ha->phy_attr_table.phystart1_16[0] = |
| 636 | pm8001_mr32(address, PSPA_PHYSTATE0_OFFSET); |
| 637 | pm8001_ha->phy_attr_table.phystart1_16[1] = |
| 638 | pm8001_mr32(address, PSPA_PHYSTATE1_OFFSET); |
| 639 | pm8001_ha->phy_attr_table.phystart1_16[2] = |
| 640 | pm8001_mr32(address, PSPA_PHYSTATE2_OFFSET); |
| 641 | pm8001_ha->phy_attr_table.phystart1_16[3] = |
| 642 | pm8001_mr32(address, PSPA_PHYSTATE3_OFFSET); |
| 643 | pm8001_ha->phy_attr_table.phystart1_16[4] = |
| 644 | pm8001_mr32(address, PSPA_PHYSTATE4_OFFSET); |
| 645 | pm8001_ha->phy_attr_table.phystart1_16[5] = |
| 646 | pm8001_mr32(address, PSPA_PHYSTATE5_OFFSET); |
| 647 | pm8001_ha->phy_attr_table.phystart1_16[6] = |
| 648 | pm8001_mr32(address, PSPA_PHYSTATE6_OFFSET); |
| 649 | pm8001_ha->phy_attr_table.phystart1_16[7] = |
| 650 | pm8001_mr32(address, PSPA_PHYSTATE7_OFFSET); |
| 651 | pm8001_ha->phy_attr_table.phystart1_16[8] = |
| 652 | pm8001_mr32(address, PSPA_PHYSTATE8_OFFSET); |
| 653 | pm8001_ha->phy_attr_table.phystart1_16[9] = |
| 654 | pm8001_mr32(address, PSPA_PHYSTATE9_OFFSET); |
| 655 | pm8001_ha->phy_attr_table.phystart1_16[10] = |
| 656 | pm8001_mr32(address, PSPA_PHYSTATE10_OFFSET); |
| 657 | pm8001_ha->phy_attr_table.phystart1_16[11] = |
| 658 | pm8001_mr32(address, PSPA_PHYSTATE11_OFFSET); |
| 659 | pm8001_ha->phy_attr_table.phystart1_16[12] = |
| 660 | pm8001_mr32(address, PSPA_PHYSTATE12_OFFSET); |
| 661 | pm8001_ha->phy_attr_table.phystart1_16[13] = |
| 662 | pm8001_mr32(address, PSPA_PHYSTATE13_OFFSET); |
| 663 | pm8001_ha->phy_attr_table.phystart1_16[14] = |
| 664 | pm8001_mr32(address, PSPA_PHYSTATE14_OFFSET); |
| 665 | pm8001_ha->phy_attr_table.phystart1_16[15] = |
| 666 | pm8001_mr32(address, PSPA_PHYSTATE15_OFFSET); |
| 667 | |
| 668 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[0] = |
| 669 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID0_OFFSET); |
| 670 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[1] = |
| 671 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID1_OFFSET); |
| 672 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[2] = |
| 673 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID2_OFFSET); |
| 674 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[3] = |
| 675 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID3_OFFSET); |
| 676 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[4] = |
| 677 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID4_OFFSET); |
| 678 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[5] = |
| 679 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID5_OFFSET); |
| 680 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[6] = |
| 681 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID6_OFFSET); |
| 682 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[7] = |
| 683 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID7_OFFSET); |
| 684 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[8] = |
| 685 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID8_OFFSET); |
| 686 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[9] = |
| 687 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID9_OFFSET); |
| 688 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[10] = |
| 689 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID10_OFFSET); |
| 690 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[11] = |
| 691 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID11_OFFSET); |
| 692 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[12] = |
| 693 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID12_OFFSET); |
| 694 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[13] = |
| 695 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID13_OFFSET); |
| 696 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[14] = |
| 697 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID14_OFFSET); |
| 698 | pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[15] = |
| 699 | pm8001_mr32(address, PSPA_OB_HW_EVENT_PID15_OFFSET); |
| 700 | |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * read_inbnd_queue_table - read the inbound queue table and save it. |
| 705 | * @pm8001_ha: our hba card information |
| 706 | */ |
| 707 | static void read_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha) |
| 708 | { |
| 709 | int i; |
| 710 | void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 711 | for (i = 0; i < PM8001_MAX_INB_NUM; i++) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 712 | u32 offset = i * 0x20; |
| 713 | pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = |
| 714 | get_pci_bar_index(pm8001_mr32(address, |
| 715 | (offset + IB_PIPCI_BAR))); |
| 716 | pm8001_ha->inbnd_q_tbl[i].pi_offset = |
| 717 | pm8001_mr32(address, (offset + IB_PIPCI_BAR_OFFSET)); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * read_outbnd_queue_table - read the outbound queue table and save it. |
| 723 | * @pm8001_ha: our hba card information |
| 724 | */ |
| 725 | static void read_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha) |
| 726 | { |
| 727 | int i; |
| 728 | void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 729 | for (i = 0; i < PM8001_MAX_OUTB_NUM; i++) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 730 | u32 offset = i * 0x24; |
| 731 | pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = |
| 732 | get_pci_bar_index(pm8001_mr32(address, |
| 733 | (offset + OB_CIPCI_BAR))); |
| 734 | pm8001_ha->outbnd_q_tbl[i].ci_offset = |
| 735 | pm8001_mr32(address, (offset + OB_CIPCI_BAR_OFFSET)); |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * init_default_table_values - init the default table. |
| 741 | * @pm8001_ha: our hba card information |
| 742 | */ |
| 743 | static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) |
| 744 | { |
| 745 | int i; |
| 746 | u32 offsetib, offsetob; |
| 747 | void __iomem *addressib = pm8001_ha->inbnd_q_tbl_addr; |
| 748 | void __iomem *addressob = pm8001_ha->outbnd_q_tbl_addr; |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 749 | u32 ib_offset = pm8001_ha->ib_offset; |
| 750 | u32 ob_offset = pm8001_ha->ob_offset; |
| 751 | u32 ci_offset = pm8001_ha->ci_offset; |
| 752 | u32 pi_offset = pm8001_ha->pi_offset; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 753 | |
| 754 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_event_log_addr = |
| 755 | pm8001_ha->memoryMap.region[AAP1].phys_addr_hi; |
| 756 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_event_log_addr = |
| 757 | pm8001_ha->memoryMap.region[AAP1].phys_addr_lo; |
| 758 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size = |
| 759 | PM8001_EVENT_LOG_SIZE; |
| 760 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_severity = 0x01; |
| 761 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_pcs_event_log_addr = |
| 762 | pm8001_ha->memoryMap.region[IOP].phys_addr_hi; |
| 763 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_pcs_event_log_addr = |
| 764 | pm8001_ha->memoryMap.region[IOP].phys_addr_lo; |
| 765 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_size = |
| 766 | PM8001_EVENT_LOG_SIZE; |
| 767 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_severity = 0x01; |
| 768 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt = 0x01; |
| 769 | |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 770 | /* Disable end to end CRC checking */ |
| 771 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.crc_core_dump = (0x1 << 16); |
| 772 | |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 773 | for (i = 0; i < pm8001_ha->max_q_num; i++) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 774 | pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt = |
Hans Verkuil | 9504a92 | 2013-07-26 18:43:45 +0200 | [diff] [blame] | 775 | PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x00<<30); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 776 | pm8001_ha->inbnd_q_tbl[i].upper_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 777 | pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_hi; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 778 | pm8001_ha->inbnd_q_tbl[i].lower_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 779 | pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_lo; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 780 | pm8001_ha->inbnd_q_tbl[i].base_virt = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 781 | (u8 *)pm8001_ha->memoryMap.region[ib_offset + i].virt_ptr; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 782 | pm8001_ha->inbnd_q_tbl[i].total_length = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 783 | pm8001_ha->memoryMap.region[ib_offset + i].total_len; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 784 | pm8001_ha->inbnd_q_tbl[i].ci_upper_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 785 | pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_hi; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 786 | pm8001_ha->inbnd_q_tbl[i].ci_lower_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 787 | pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 788 | pm8001_ha->inbnd_q_tbl[i].ci_virt = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 789 | pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 790 | offsetib = i * 0x20; |
| 791 | pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = |
| 792 | get_pci_bar_index(pm8001_mr32(addressib, |
| 793 | (offsetib + 0x14))); |
| 794 | pm8001_ha->inbnd_q_tbl[i].pi_offset = |
| 795 | pm8001_mr32(addressib, (offsetib + 0x18)); |
| 796 | pm8001_ha->inbnd_q_tbl[i].producer_idx = 0; |
| 797 | pm8001_ha->inbnd_q_tbl[i].consumer_index = 0; |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 798 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 799 | pm8001_dbg(pm8001_ha, DEV, |
| 800 | "IQ %d pi_bar 0x%x pi_offset 0x%x\n", i, |
| 801 | pm8001_ha->inbnd_q_tbl[i].pi_pci_bar, |
| 802 | pm8001_ha->inbnd_q_tbl[i].pi_offset); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 803 | } |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 804 | for (i = 0; i < pm8001_ha->max_q_num; i++) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 805 | pm8001_ha->outbnd_q_tbl[i].element_size_cnt = |
Hans Verkuil | 9504a92 | 2013-07-26 18:43:45 +0200 | [diff] [blame] | 806 | PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x01<<30); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 807 | pm8001_ha->outbnd_q_tbl[i].upper_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 808 | pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_hi; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 809 | pm8001_ha->outbnd_q_tbl[i].lower_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 810 | pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_lo; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 811 | pm8001_ha->outbnd_q_tbl[i].base_virt = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 812 | (u8 *)pm8001_ha->memoryMap.region[ob_offset + i].virt_ptr; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 813 | pm8001_ha->outbnd_q_tbl[i].total_length = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 814 | pm8001_ha->memoryMap.region[ob_offset + i].total_len; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 815 | pm8001_ha->outbnd_q_tbl[i].pi_upper_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 816 | pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_hi; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 817 | pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 818 | pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_lo; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 819 | /* interrupt vector based on oq */ |
| 820 | pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24); |
| 821 | pm8001_ha->outbnd_q_tbl[i].pi_virt = |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 822 | pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 823 | offsetob = i * 0x24; |
| 824 | pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = |
| 825 | get_pci_bar_index(pm8001_mr32(addressob, |
| 826 | offsetob + 0x14)); |
| 827 | pm8001_ha->outbnd_q_tbl[i].ci_offset = |
| 828 | pm8001_mr32(addressob, (offsetob + 0x18)); |
| 829 | pm8001_ha->outbnd_q_tbl[i].consumer_idx = 0; |
| 830 | pm8001_ha->outbnd_q_tbl[i].producer_index = 0; |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 831 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 832 | pm8001_dbg(pm8001_ha, DEV, |
| 833 | "OQ %d ci_bar 0x%x ci_offset 0x%x\n", i, |
| 834 | pm8001_ha->outbnd_q_tbl[i].ci_pci_bar, |
| 835 | pm8001_ha->outbnd_q_tbl[i].ci_offset); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 836 | } |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * update_main_config_table - update the main default table to the HBA. |
| 841 | * @pm8001_ha: our hba card information |
| 842 | */ |
| 843 | static void update_main_config_table(struct pm8001_hba_info *pm8001_ha) |
| 844 | { |
| 845 | void __iomem *address = pm8001_ha->main_cfg_tbl_addr; |
| 846 | pm8001_mw32(address, MAIN_IQNPPD_HPPD_OFFSET, |
| 847 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.inbound_q_nppd_hppd); |
| 848 | pm8001_mw32(address, MAIN_EVENT_LOG_ADDR_HI, |
| 849 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_event_log_addr); |
| 850 | pm8001_mw32(address, MAIN_EVENT_LOG_ADDR_LO, |
| 851 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_event_log_addr); |
| 852 | pm8001_mw32(address, MAIN_EVENT_LOG_BUFF_SIZE, |
| 853 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size); |
| 854 | pm8001_mw32(address, MAIN_EVENT_LOG_OPTION, |
| 855 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_severity); |
| 856 | pm8001_mw32(address, MAIN_PCS_EVENT_LOG_ADDR_HI, |
| 857 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_pcs_event_log_addr); |
| 858 | pm8001_mw32(address, MAIN_PCS_EVENT_LOG_ADDR_LO, |
| 859 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_pcs_event_log_addr); |
| 860 | pm8001_mw32(address, MAIN_PCS_EVENT_LOG_BUFF_SIZE, |
| 861 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_size); |
| 862 | pm8001_mw32(address, MAIN_PCS_EVENT_LOG_OPTION, |
| 863 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_severity); |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 864 | /* Update Fatal error interrupt vector */ |
| 865 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt |= |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 866 | ((pm8001_ha->max_q_num - 1) << 8); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 867 | pm8001_mw32(address, MAIN_FATAL_ERROR_INTERRUPT, |
| 868 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 869 | pm8001_dbg(pm8001_ha, DEV, |
| 870 | "Updated Fatal error interrupt vector 0x%x\n", |
| 871 | pm8001_mr32(address, MAIN_FATAL_ERROR_INTERRUPT)); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 872 | |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 873 | pm8001_mw32(address, MAIN_EVENT_CRC_CHECK, |
| 874 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.crc_core_dump); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 875 | |
| 876 | /* SPCv specific */ |
| 877 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping &= 0xCFFFFFFF; |
| 878 | /* Set GPIOLED to 0x2 for LED indicator */ |
| 879 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping |= 0x20000000; |
| 880 | pm8001_mw32(address, MAIN_GPIO_LED_FLAGS_OFFSET, |
| 881 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 882 | pm8001_dbg(pm8001_ha, DEV, |
| 883 | "Programming DW 0x21 in main cfg table with 0x%x\n", |
| 884 | pm8001_mr32(address, MAIN_GPIO_LED_FLAGS_OFFSET)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 885 | |
| 886 | pm8001_mw32(address, MAIN_PORT_RECOVERY_TIMER, |
| 887 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer); |
| 888 | pm8001_mw32(address, MAIN_INT_REASSERTION_DELAY, |
| 889 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.interrupt_reassertion_delay); |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 890 | |
| 891 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &= 0xffff0000; |
| 892 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |= |
| 893 | PORT_RECOVERY_TIMEOUT; |
Viswas G | 61daffd | 2017-10-18 11:39:12 +0530 | [diff] [blame] | 894 | if (pm8001_ha->chip_id == chip_8006) { |
| 895 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &= |
| 896 | 0x0000ffff; |
| 897 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |= |
Deepak Ukey | 196ba66 | 2019-07-09 15:30:48 +0530 | [diff] [blame] | 898 | CHIP_8006_PORT_RECOVERY_TIMEOUT; |
Viswas G | 61daffd | 2017-10-18 11:39:12 +0530 | [diff] [blame] | 899 | } |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 900 | pm8001_mw32(address, MAIN_PORT_RECOVERY_TIMER, |
| 901 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | /** |
| 905 | * update_inbnd_queue_table - update the inbound queue table to the HBA. |
| 906 | * @pm8001_ha: our hba card information |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 907 | * @number: entry in the queue |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 908 | */ |
| 909 | static void update_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha, |
| 910 | int number) |
| 911 | { |
| 912 | void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; |
| 913 | u16 offset = number * 0x20; |
| 914 | pm8001_mw32(address, offset + IB_PROPERITY_OFFSET, |
| 915 | pm8001_ha->inbnd_q_tbl[number].element_pri_size_cnt); |
| 916 | pm8001_mw32(address, offset + IB_BASE_ADDR_HI_OFFSET, |
| 917 | pm8001_ha->inbnd_q_tbl[number].upper_base_addr); |
| 918 | pm8001_mw32(address, offset + IB_BASE_ADDR_LO_OFFSET, |
| 919 | pm8001_ha->inbnd_q_tbl[number].lower_base_addr); |
| 920 | pm8001_mw32(address, offset + IB_CI_BASE_ADDR_HI_OFFSET, |
| 921 | pm8001_ha->inbnd_q_tbl[number].ci_upper_base_addr); |
| 922 | pm8001_mw32(address, offset + IB_CI_BASE_ADDR_LO_OFFSET, |
| 923 | pm8001_ha->inbnd_q_tbl[number].ci_lower_base_addr); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 924 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 925 | pm8001_dbg(pm8001_ha, DEV, |
| 926 | "IQ %d: Element pri size 0x%x\n", |
| 927 | number, |
| 928 | pm8001_ha->inbnd_q_tbl[number].element_pri_size_cnt); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 929 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 930 | pm8001_dbg(pm8001_ha, DEV, |
| 931 | "IQ upr base addr 0x%x IQ lwr base addr 0x%x\n", |
| 932 | pm8001_ha->inbnd_q_tbl[number].upper_base_addr, |
| 933 | pm8001_ha->inbnd_q_tbl[number].lower_base_addr); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 934 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 935 | pm8001_dbg(pm8001_ha, DEV, |
| 936 | "CI upper base addr 0x%x CI lower base addr 0x%x\n", |
| 937 | pm8001_ha->inbnd_q_tbl[number].ci_upper_base_addr, |
| 938 | pm8001_ha->inbnd_q_tbl[number].ci_lower_base_addr); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | /** |
| 942 | * update_outbnd_queue_table - update the outbound queue table to the HBA. |
| 943 | * @pm8001_ha: our hba card information |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 944 | * @number: entry in the queue |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 945 | */ |
| 946 | static void update_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha, |
| 947 | int number) |
| 948 | { |
| 949 | void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; |
| 950 | u16 offset = number * 0x24; |
| 951 | pm8001_mw32(address, offset + OB_PROPERITY_OFFSET, |
| 952 | pm8001_ha->outbnd_q_tbl[number].element_size_cnt); |
| 953 | pm8001_mw32(address, offset + OB_BASE_ADDR_HI_OFFSET, |
| 954 | pm8001_ha->outbnd_q_tbl[number].upper_base_addr); |
| 955 | pm8001_mw32(address, offset + OB_BASE_ADDR_LO_OFFSET, |
| 956 | pm8001_ha->outbnd_q_tbl[number].lower_base_addr); |
| 957 | pm8001_mw32(address, offset + OB_PI_BASE_ADDR_HI_OFFSET, |
| 958 | pm8001_ha->outbnd_q_tbl[number].pi_upper_base_addr); |
| 959 | pm8001_mw32(address, offset + OB_PI_BASE_ADDR_LO_OFFSET, |
| 960 | pm8001_ha->outbnd_q_tbl[number].pi_lower_base_addr); |
| 961 | pm8001_mw32(address, offset + OB_INTERRUPT_COALES_OFFSET, |
| 962 | pm8001_ha->outbnd_q_tbl[number].interrup_vec_cnt_delay); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 963 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 964 | pm8001_dbg(pm8001_ha, DEV, |
| 965 | "OQ %d: Element pri size 0x%x\n", |
| 966 | number, |
| 967 | pm8001_ha->outbnd_q_tbl[number].element_size_cnt); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 968 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 969 | pm8001_dbg(pm8001_ha, DEV, |
| 970 | "OQ upr base addr 0x%x OQ lwr base addr 0x%x\n", |
| 971 | pm8001_ha->outbnd_q_tbl[number].upper_base_addr, |
| 972 | pm8001_ha->outbnd_q_tbl[number].lower_base_addr); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 973 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 974 | pm8001_dbg(pm8001_ha, DEV, |
| 975 | "PI upper base addr 0x%x PI lower base addr 0x%x\n", |
| 976 | pm8001_ha->outbnd_q_tbl[number].pi_upper_base_addr, |
| 977 | pm8001_ha->outbnd_q_tbl[number].pi_lower_base_addr); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | /** |
| 981 | * mpi_init_check - check firmware initialization status. |
| 982 | * @pm8001_ha: our hba card information |
| 983 | */ |
| 984 | static int mpi_init_check(struct pm8001_hba_info *pm8001_ha) |
| 985 | { |
| 986 | u32 max_wait_count; |
| 987 | u32 value; |
| 988 | u32 gst_len_mpistate; |
| 989 | |
| 990 | /* Write bit0=1 to Inbound DoorBell Register to tell the SPC FW the |
| 991 | table is updated */ |
| 992 | pm8001_cw32(pm8001_ha, 0, MSGU_IBDB_SET, SPCv_MSGU_CFG_TABLE_UPDATE); |
| 993 | /* wait until Inbound DoorBell Clear Register toggled */ |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 994 | if (IS_SPCV_12G(pm8001_ha->pdev)) { |
ianyar | e90e2362 | 2019-11-14 15:39:03 +0530 | [diff] [blame] | 995 | max_wait_count = SPCV_DOORBELL_CLEAR_TIMEOUT; |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 996 | } else { |
ianyar | e90e2362 | 2019-11-14 15:39:03 +0530 | [diff] [blame] | 997 | max_wait_count = SPC_DOORBELL_CLEAR_TIMEOUT; |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 998 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 999 | do { |
akshatzen | d71023a | 2021-01-09 18:08:42 +0530 | [diff] [blame] | 1000 | msleep(FW_READY_INTERVAL); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1001 | value = pm8001_cr32(pm8001_ha, 0, MSGU_IBDB_SET); |
| 1002 | value &= SPCv_MSGU_CFG_TABLE_UPDATE; |
| 1003 | } while ((value != 0) && (--max_wait_count)); |
| 1004 | |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1005 | if (!max_wait_count) { |
| 1006 | /* additional check */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1007 | pm8001_dbg(pm8001_ha, FAIL, |
| 1008 | "Inb doorbell clear not toggled[value:%x]\n", |
| 1009 | value); |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1010 | return -EBUSY; |
| 1011 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1012 | /* check the MPI-State for initialization upto 100ms*/ |
akshatzen | d71023a | 2021-01-09 18:08:42 +0530 | [diff] [blame] | 1013 | max_wait_count = 5;/* 100 msec */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1014 | do { |
akshatzen | d71023a | 2021-01-09 18:08:42 +0530 | [diff] [blame] | 1015 | msleep(FW_READY_INTERVAL); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1016 | gst_len_mpistate = |
| 1017 | pm8001_mr32(pm8001_ha->general_stat_tbl_addr, |
| 1018 | GST_GSTLEN_MPIS_OFFSET); |
| 1019 | } while ((GST_MPI_STATE_INIT != |
| 1020 | (gst_len_mpistate & GST_MPI_STATE_MASK)) && (--max_wait_count)); |
| 1021 | if (!max_wait_count) |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1022 | return -EBUSY; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1023 | |
| 1024 | /* check MPI Initialization error */ |
| 1025 | gst_len_mpistate = gst_len_mpistate >> 16; |
| 1026 | if (0x0000 != gst_len_mpistate) |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1027 | return -EBUSY; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1028 | |
| 1029 | return 0; |
| 1030 | } |
| 1031 | |
| 1032 | /** |
| 1033 | * check_fw_ready - The LLDD check if the FW is ready, if not, return error. |
akshatzen | 48cd6b3 | 2020-11-02 22:25:27 +0530 | [diff] [blame] | 1034 | * This function sleeps hence it must not be used in atomic context. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1035 | * @pm8001_ha: our hba card information |
| 1036 | */ |
| 1037 | static int check_fw_ready(struct pm8001_hba_info *pm8001_ha) |
| 1038 | { |
| 1039 | u32 value; |
| 1040 | u32 max_wait_count; |
| 1041 | u32 max_wait_time; |
Bhavesh Jashnani | 6b2f2d0 | 2021-01-09 18:08:47 +0530 | [diff] [blame] | 1042 | u32 expected_mask; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1043 | int ret = 0; |
| 1044 | |
| 1045 | /* reset / PCIe ready */ |
akshatzen | 48cd6b3 | 2020-11-02 22:25:27 +0530 | [diff] [blame] | 1046 | max_wait_time = max_wait_count = 5; /* 100 milli sec */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1047 | do { |
akshatzen | 48cd6b3 | 2020-11-02 22:25:27 +0530 | [diff] [blame] | 1048 | msleep(FW_READY_INTERVAL); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1049 | value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); |
| 1050 | } while ((value == 0xFFFFFFFF) && (--max_wait_count)); |
| 1051 | |
Bhavesh Jashnani | 6b2f2d0 | 2021-01-09 18:08:47 +0530 | [diff] [blame] | 1052 | /* check ila, RAAE and iops status */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1053 | if ((pm8001_ha->chip_id != chip_8008) && |
| 1054 | (pm8001_ha->chip_id != chip_8009)) { |
Bhavesh Jashnani | 6b2f2d0 | 2021-01-09 18:08:47 +0530 | [diff] [blame] | 1055 | max_wait_time = max_wait_count = 180; /* 3600 milli sec */ |
| 1056 | expected_mask = SCRATCH_PAD_ILA_READY | |
| 1057 | SCRATCH_PAD_RAAE_READY | |
| 1058 | SCRATCH_PAD_IOP0_READY | |
| 1059 | SCRATCH_PAD_IOP1_READY; |
| 1060 | } else { |
| 1061 | max_wait_time = max_wait_count = 170; /* 3400 milli sec */ |
| 1062 | expected_mask = SCRATCH_PAD_ILA_READY | |
| 1063 | SCRATCH_PAD_RAAE_READY | |
| 1064 | SCRATCH_PAD_IOP0_READY; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1065 | } |
Bhavesh Jashnani | 6b2f2d0 | 2021-01-09 18:08:47 +0530 | [diff] [blame] | 1066 | do { |
| 1067 | msleep(FW_READY_INTERVAL); |
| 1068 | value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); |
| 1069 | } while (((value & expected_mask) != |
| 1070 | expected_mask) && (--max_wait_count)); |
| 1071 | if (!max_wait_count) { |
| 1072 | pm8001_dbg(pm8001_ha, INIT, |
| 1073 | "At least one FW component failed to load within %d millisec: Scratchpad1: 0x%x\n", |
| 1074 | max_wait_time * FW_READY_INTERVAL, value); |
| 1075 | ret = -1; |
| 1076 | } else { |
| 1077 | pm8001_dbg(pm8001_ha, MSG, |
| 1078 | "All FW components ready by %d ms\n", |
| 1079 | (max_wait_time - max_wait_count) * FW_READY_INTERVAL); |
| 1080 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1081 | return ret; |
| 1082 | } |
| 1083 | |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1084 | static int init_pci_device_addresses(struct pm8001_hba_info *pm8001_ha) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1085 | { |
| 1086 | void __iomem *base_addr; |
| 1087 | u32 value; |
| 1088 | u32 offset; |
| 1089 | u32 pcibar; |
| 1090 | u32 pcilogic; |
| 1091 | |
| 1092 | value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_0); |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1093 | |
| 1094 | /** |
| 1095 | * lower 26 bits of SCRATCHPAD0 register describes offset within the |
| 1096 | * PCIe BAR where the MPI configuration table is present |
| 1097 | */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1098 | offset = value & 0x03FFFFFF; /* scratch pad 0 TBL address */ |
| 1099 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1100 | pm8001_dbg(pm8001_ha, DEV, "Scratchpad 0 Offset: 0x%x value 0x%x\n", |
| 1101 | offset, value); |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1102 | /** |
| 1103 | * Upper 6 bits describe the offset within PCI config space where BAR |
| 1104 | * is located. |
| 1105 | */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1106 | pcilogic = (value & 0xFC000000) >> 26; |
| 1107 | pcibar = get_pci_bar_index(pcilogic); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1108 | pm8001_dbg(pm8001_ha, INIT, "Scratchpad 0 PCI BAR: %d\n", pcibar); |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1109 | |
| 1110 | /** |
| 1111 | * Make sure the offset falls inside the ioremapped PCI BAR |
| 1112 | */ |
| 1113 | if (offset > pm8001_ha->io_mem[pcibar].memsize) { |
| 1114 | pm8001_dbg(pm8001_ha, FAIL, |
| 1115 | "Main cfg tbl offset outside %u > %u\n", |
| 1116 | offset, pm8001_ha->io_mem[pcibar].memsize); |
| 1117 | return -EBUSY; |
| 1118 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1119 | pm8001_ha->main_cfg_tbl_addr = base_addr = |
| 1120 | pm8001_ha->io_mem[pcibar].memvirtaddr + offset; |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1121 | |
| 1122 | /** |
| 1123 | * Validate main configuration table address: first DWord should read |
| 1124 | * "PMCS" |
| 1125 | */ |
| 1126 | value = pm8001_mr32(pm8001_ha->main_cfg_tbl_addr, 0); |
| 1127 | if (memcmp(&value, "PMCS", 4) != 0) { |
| 1128 | pm8001_dbg(pm8001_ha, FAIL, |
| 1129 | "BAD main config signature 0x%x\n", |
| 1130 | value); |
| 1131 | return -EBUSY; |
| 1132 | } |
| 1133 | pm8001_dbg(pm8001_ha, INIT, |
| 1134 | "VALID main config signature 0x%x\n", value); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1135 | pm8001_ha->general_stat_tbl_addr = |
| 1136 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x18) & |
| 1137 | 0xFFFFFF); |
| 1138 | pm8001_ha->inbnd_q_tbl_addr = |
| 1139 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x1C) & |
| 1140 | 0xFFFFFF); |
| 1141 | pm8001_ha->outbnd_q_tbl_addr = |
| 1142 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x20) & |
| 1143 | 0xFFFFFF); |
| 1144 | pm8001_ha->ivt_tbl_addr = |
| 1145 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x8C) & |
| 1146 | 0xFFFFFF); |
| 1147 | pm8001_ha->pspa_q_tbl_addr = |
| 1148 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x90) & |
| 1149 | 0xFFFFFF); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 1150 | pm8001_ha->fatal_tbl_addr = |
| 1151 | base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0xA0) & |
| 1152 | 0xFFFFFF); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1153 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1154 | pm8001_dbg(pm8001_ha, INIT, "GST OFFSET 0x%x\n", |
| 1155 | pm8001_cr32(pm8001_ha, pcibar, offset + 0x18)); |
| 1156 | pm8001_dbg(pm8001_ha, INIT, "INBND OFFSET 0x%x\n", |
| 1157 | pm8001_cr32(pm8001_ha, pcibar, offset + 0x1C)); |
| 1158 | pm8001_dbg(pm8001_ha, INIT, "OBND OFFSET 0x%x\n", |
| 1159 | pm8001_cr32(pm8001_ha, pcibar, offset + 0x20)); |
| 1160 | pm8001_dbg(pm8001_ha, INIT, "IVT OFFSET 0x%x\n", |
| 1161 | pm8001_cr32(pm8001_ha, pcibar, offset + 0x8C)); |
| 1162 | pm8001_dbg(pm8001_ha, INIT, "PSPA OFFSET 0x%x\n", |
| 1163 | pm8001_cr32(pm8001_ha, pcibar, offset + 0x90)); |
| 1164 | pm8001_dbg(pm8001_ha, INIT, "addr - main cfg %p general status %p\n", |
| 1165 | pm8001_ha->main_cfg_tbl_addr, |
| 1166 | pm8001_ha->general_stat_tbl_addr); |
| 1167 | pm8001_dbg(pm8001_ha, INIT, "addr - inbnd %p obnd %p\n", |
| 1168 | pm8001_ha->inbnd_q_tbl_addr, |
| 1169 | pm8001_ha->outbnd_q_tbl_addr); |
| 1170 | pm8001_dbg(pm8001_ha, INIT, "addr - pspa %p ivt %p\n", |
| 1171 | pm8001_ha->pspa_q_tbl_addr, |
| 1172 | pm8001_ha->ivt_tbl_addr); |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1173 | return 0; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | /** |
| 1177 | * pm80xx_set_thermal_config - support the thermal configuration |
| 1178 | * @pm8001_ha: our hba card information. |
| 1179 | */ |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 1180 | int |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1181 | pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) |
| 1182 | { |
| 1183 | struct set_ctrl_cfg_req payload; |
| 1184 | struct inbound_queue_table *circularQ; |
| 1185 | int rc; |
| 1186 | u32 tag; |
| 1187 | u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; |
Viswas G | 842784e | 2015-08-11 15:06:27 +0530 | [diff] [blame] | 1188 | u32 page_code; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1189 | |
| 1190 | memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); |
| 1191 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 1192 | if (rc) |
| 1193 | return -1; |
| 1194 | |
| 1195 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 1196 | payload.tag = cpu_to_le32(tag); |
Viswas G | 842784e | 2015-08-11 15:06:27 +0530 | [diff] [blame] | 1197 | |
| 1198 | if (IS_SPCV_12G(pm8001_ha->pdev)) |
| 1199 | page_code = THERMAL_PAGE_CODE_7H; |
| 1200 | else |
| 1201 | page_code = THERMAL_PAGE_CODE_8H; |
| 1202 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1203 | payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) | |
Viswas G | 842784e | 2015-08-11 15:06:27 +0530 | [diff] [blame] | 1204 | (THERMAL_ENABLE << 8) | page_code; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1205 | payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8); |
| 1206 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1207 | pm8001_dbg(pm8001_ha, DEV, |
| 1208 | "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", |
| 1209 | payload.cfg_pg[0], payload.cfg_pg[1]); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 1210 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 1211 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 1212 | sizeof(payload), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1213 | if (rc) |
| 1214 | pm8001_tag_free(pm8001_ha, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1215 | return rc; |
| 1216 | |
| 1217 | } |
| 1218 | |
| 1219 | /** |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 1220 | * pm80xx_set_sas_protocol_timer_config - support the SAS Protocol |
| 1221 | * Timer configuration page |
| 1222 | * @pm8001_ha: our hba card information. |
| 1223 | */ |
| 1224 | static int |
| 1225 | pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) |
| 1226 | { |
| 1227 | struct set_ctrl_cfg_req payload; |
| 1228 | struct inbound_queue_table *circularQ; |
| 1229 | SASProtocolTimerConfig_t SASConfigPage; |
| 1230 | int rc; |
| 1231 | u32 tag; |
| 1232 | u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; |
| 1233 | |
| 1234 | memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); |
| 1235 | memset(&SASConfigPage, 0, sizeof(SASProtocolTimerConfig_t)); |
| 1236 | |
| 1237 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 1238 | |
| 1239 | if (rc) |
| 1240 | return -1; |
| 1241 | |
| 1242 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 1243 | payload.tag = cpu_to_le32(tag); |
| 1244 | |
| 1245 | SASConfigPage.pageCode = SAS_PROTOCOL_TIMER_CONFIG_PAGE; |
| 1246 | SASConfigPage.MST_MSI = 3 << 15; |
| 1247 | SASConfigPage.STP_SSP_MCT_TMO = (STP_MCT_TMO << 16) | SSP_MCT_TMO; |
| 1248 | SASConfigPage.STP_FRM_TMO = (SAS_MAX_OPEN_TIME << 24) | |
| 1249 | (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER; |
| 1250 | SASConfigPage.STP_IDLE_TMO = STP_IDLE_TIME; |
| 1251 | |
| 1252 | if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF) |
| 1253 | SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF; |
| 1254 | |
| 1255 | |
| 1256 | SASConfigPage.OPNRJT_RTRY_INTVL = (SAS_MFD << 16) | |
| 1257 | SAS_OPNRJT_RTRY_INTVL; |
| 1258 | SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (SAS_DOPNRJT_RTRY_TMO << 16) |
| 1259 | | SAS_COPNRJT_RTRY_TMO; |
| 1260 | SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (SAS_DOPNRJT_RTRY_THR << 16) |
| 1261 | | SAS_COPNRJT_RTRY_THR; |
| 1262 | SASConfigPage.MAX_AIP = SAS_MAX_AIP; |
| 1263 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1264 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.pageCode 0x%08x\n", |
| 1265 | SASConfigPage.pageCode); |
| 1266 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MST_MSI 0x%08x\n", |
| 1267 | SASConfigPage.MST_MSI); |
| 1268 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n", |
| 1269 | SASConfigPage.STP_SSP_MCT_TMO); |
| 1270 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_FRM_TMO 0x%08x\n", |
| 1271 | SASConfigPage.STP_FRM_TMO); |
| 1272 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_IDLE_TMO 0x%08x\n", |
| 1273 | SASConfigPage.STP_IDLE_TMO); |
| 1274 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n", |
| 1275 | SASConfigPage.OPNRJT_RTRY_INTVL); |
| 1276 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n", |
| 1277 | SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO); |
| 1278 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n", |
| 1279 | SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR); |
| 1280 | pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MAX_AIP 0x%08x\n", |
| 1281 | SASConfigPage.MAX_AIP); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 1282 | |
| 1283 | memcpy(&payload.cfg_pg, &SASConfigPage, |
| 1284 | sizeof(SASProtocolTimerConfig_t)); |
| 1285 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 1286 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 1287 | sizeof(payload), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1288 | if (rc) |
| 1289 | pm8001_tag_free(pm8001_ha, tag); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 1290 | |
| 1291 | return rc; |
| 1292 | } |
| 1293 | |
| 1294 | /** |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1295 | * pm80xx_get_encrypt_info - Check for encryption |
| 1296 | * @pm8001_ha: our hba card information. |
| 1297 | */ |
| 1298 | static int |
| 1299 | pm80xx_get_encrypt_info(struct pm8001_hba_info *pm8001_ha) |
| 1300 | { |
| 1301 | u32 scratch3_value; |
Rickard Strandqvist | da22549 | 2014-07-09 17:20:10 +0530 | [diff] [blame] | 1302 | int ret = -1; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1303 | |
| 1304 | /* Read encryption status from SCRATCH PAD 3 */ |
| 1305 | scratch3_value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_3); |
| 1306 | |
| 1307 | if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == |
| 1308 | SCRATCH_PAD3_ENC_READY) { |
| 1309 | if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) |
| 1310 | pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; |
| 1311 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1312 | SCRATCH_PAD3_SMF_ENABLED) |
| 1313 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; |
| 1314 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1315 | SCRATCH_PAD3_SMA_ENABLED) |
| 1316 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; |
| 1317 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1318 | SCRATCH_PAD3_SMB_ENABLED) |
| 1319 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; |
| 1320 | pm8001_ha->encrypt_info.status = 0; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1321 | pm8001_dbg(pm8001_ha, INIT, |
| 1322 | "Encryption: SCRATCH_PAD3_ENC_READY 0x%08X.Cipher mode 0x%x Sec mode 0x%x status 0x%x\n", |
| 1323 | scratch3_value, |
| 1324 | pm8001_ha->encrypt_info.cipher_mode, |
| 1325 | pm8001_ha->encrypt_info.sec_mode, |
| 1326 | pm8001_ha->encrypt_info.status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1327 | ret = 0; |
| 1328 | } else if ((scratch3_value & SCRATCH_PAD3_ENC_READY) == |
| 1329 | SCRATCH_PAD3_ENC_DISABLED) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1330 | pm8001_dbg(pm8001_ha, INIT, |
| 1331 | "Encryption: SCRATCH_PAD3_ENC_DISABLED 0x%08X\n", |
| 1332 | scratch3_value); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1333 | pm8001_ha->encrypt_info.status = 0xFFFFFFFF; |
| 1334 | pm8001_ha->encrypt_info.cipher_mode = 0; |
| 1335 | pm8001_ha->encrypt_info.sec_mode = 0; |
Rickard Strandqvist | da22549 | 2014-07-09 17:20:10 +0530 | [diff] [blame] | 1336 | ret = 0; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1337 | } else if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == |
| 1338 | SCRATCH_PAD3_ENC_DIS_ERR) { |
| 1339 | pm8001_ha->encrypt_info.status = |
| 1340 | (scratch3_value & SCRATCH_PAD3_ERR_CODE) >> 16; |
| 1341 | if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) |
| 1342 | pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; |
| 1343 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1344 | SCRATCH_PAD3_SMF_ENABLED) |
| 1345 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; |
| 1346 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1347 | SCRATCH_PAD3_SMA_ENABLED) |
| 1348 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; |
| 1349 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1350 | SCRATCH_PAD3_SMB_ENABLED) |
| 1351 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1352 | pm8001_dbg(pm8001_ha, INIT, |
| 1353 | "Encryption: SCRATCH_PAD3_DIS_ERR 0x%08X.Cipher mode 0x%x sec mode 0x%x status 0x%x\n", |
| 1354 | scratch3_value, |
| 1355 | pm8001_ha->encrypt_info.cipher_mode, |
| 1356 | pm8001_ha->encrypt_info.sec_mode, |
| 1357 | pm8001_ha->encrypt_info.status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1358 | } else if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == |
| 1359 | SCRATCH_PAD3_ENC_ENA_ERR) { |
| 1360 | |
| 1361 | pm8001_ha->encrypt_info.status = |
| 1362 | (scratch3_value & SCRATCH_PAD3_ERR_CODE) >> 16; |
| 1363 | if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) |
| 1364 | pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; |
| 1365 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1366 | SCRATCH_PAD3_SMF_ENABLED) |
| 1367 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; |
| 1368 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1369 | SCRATCH_PAD3_SMA_ENABLED) |
| 1370 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; |
| 1371 | if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == |
| 1372 | SCRATCH_PAD3_SMB_ENABLED) |
| 1373 | pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; |
| 1374 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1375 | pm8001_dbg(pm8001_ha, INIT, |
| 1376 | "Encryption: SCRATCH_PAD3_ENA_ERR 0x%08X.Cipher mode 0x%x sec mode 0x%x status 0x%x\n", |
| 1377 | scratch3_value, |
| 1378 | pm8001_ha->encrypt_info.cipher_mode, |
| 1379 | pm8001_ha->encrypt_info.sec_mode, |
| 1380 | pm8001_ha->encrypt_info.status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1381 | } |
| 1382 | return ret; |
| 1383 | } |
| 1384 | |
| 1385 | /** |
| 1386 | * pm80xx_encrypt_update - update flash with encryption informtion |
| 1387 | * @pm8001_ha: our hba card information. |
| 1388 | */ |
| 1389 | static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) |
| 1390 | { |
| 1391 | struct kek_mgmt_req payload; |
| 1392 | struct inbound_queue_table *circularQ; |
| 1393 | int rc; |
| 1394 | u32 tag; |
| 1395 | u32 opc = OPC_INB_KEK_MANAGEMENT; |
| 1396 | |
| 1397 | memset(&payload, 0, sizeof(struct kek_mgmt_req)); |
| 1398 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 1399 | if (rc) |
| 1400 | return -1; |
| 1401 | |
| 1402 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 1403 | payload.tag = cpu_to_le32(tag); |
| 1404 | /* Currently only one key is used. New KEK index is 1. |
| 1405 | * Current KEK index is 1. Store KEK to NVRAM is 1. |
| 1406 | */ |
| 1407 | payload.new_curidx_ksop = ((1 << 24) | (1 << 16) | (1 << 8) | |
| 1408 | KEK_MGMT_SUBOP_KEYCARDUPDATE); |
| 1409 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1410 | pm8001_dbg(pm8001_ha, DEV, |
| 1411 | "Saving Encryption info to flash. payload 0x%x\n", |
| 1412 | payload.new_curidx_ksop); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 1413 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 1414 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 1415 | sizeof(payload), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1416 | if (rc) |
| 1417 | pm8001_tag_free(pm8001_ha, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1418 | |
| 1419 | return rc; |
| 1420 | } |
| 1421 | |
| 1422 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1423 | * pm80xx_chip_init - the main init function that initialize whole PM8001 chip. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1424 | * @pm8001_ha: our hba card information |
| 1425 | */ |
| 1426 | static int pm80xx_chip_init(struct pm8001_hba_info *pm8001_ha) |
| 1427 | { |
| 1428 | int ret; |
| 1429 | u8 i = 0; |
| 1430 | |
| 1431 | /* check the firmware status */ |
| 1432 | if (-1 == check_fw_ready(pm8001_ha)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1433 | pm8001_dbg(pm8001_ha, FAIL, "Firmware is not ready!\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1434 | return -EBUSY; |
| 1435 | } |
| 1436 | |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 1437 | /* Initialize the controller fatal error flag */ |
| 1438 | pm8001_ha->controller_fatal_error = false; |
| 1439 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1440 | /* Initialize pci space address eg: mpi offset */ |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1441 | ret = init_pci_device_addresses(pm8001_ha); |
| 1442 | if (ret) { |
| 1443 | pm8001_dbg(pm8001_ha, FAIL, |
| 1444 | "Failed to init pci addresses"); |
| 1445 | return ret; |
| 1446 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1447 | init_default_table_values(pm8001_ha); |
| 1448 | read_main_config_table(pm8001_ha); |
| 1449 | read_general_status_table(pm8001_ha); |
| 1450 | read_inbnd_queue_table(pm8001_ha); |
| 1451 | read_outbnd_queue_table(pm8001_ha); |
| 1452 | read_phy_attr_table(pm8001_ha); |
| 1453 | |
| 1454 | /* update main config table ,inbound table and outbound table */ |
| 1455 | update_main_config_table(pm8001_ha); |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1456 | for (i = 0; i < pm8001_ha->max_q_num; i++) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1457 | update_inbnd_queue_table(pm8001_ha, i); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1458 | update_outbnd_queue_table(pm8001_ha, i); |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 1459 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1460 | /* notify firmware update finished and check initialization status */ |
| 1461 | if (0 == mpi_init_check(pm8001_ha)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1462 | pm8001_dbg(pm8001_ha, INIT, "MPI initialize successful!\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1463 | } else |
| 1464 | return -EBUSY; |
| 1465 | |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 1466 | /* send SAS protocol timer configuration page to FW */ |
| 1467 | ret = pm80xx_set_sas_protocol_timer_config(pm8001_ha); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1468 | |
| 1469 | /* Check for encryption */ |
| 1470 | if (pm8001_ha->chip->encrypt) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1471 | pm8001_dbg(pm8001_ha, INIT, "Checking for encryption\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1472 | ret = pm80xx_get_encrypt_info(pm8001_ha); |
| 1473 | if (ret == -1) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1474 | pm8001_dbg(pm8001_ha, INIT, "Encryption error !!\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1475 | if (pm8001_ha->encrypt_info.status == 0x81) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1476 | pm8001_dbg(pm8001_ha, INIT, |
| 1477 | "Encryption enabled with error.Saving encryption key to flash\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1478 | pm80xx_encrypt_update(pm8001_ha); |
| 1479 | } |
| 1480 | } |
| 1481 | } |
| 1482 | return 0; |
| 1483 | } |
| 1484 | |
| 1485 | static int mpi_uninit_check(struct pm8001_hba_info *pm8001_ha) |
| 1486 | { |
| 1487 | u32 max_wait_count; |
| 1488 | u32 value; |
| 1489 | u32 gst_len_mpistate; |
akshatzen | 95652f9 | 2021-01-09 18:08:44 +0530 | [diff] [blame] | 1490 | int ret; |
| 1491 | |
| 1492 | ret = init_pci_device_addresses(pm8001_ha); |
| 1493 | if (ret) { |
| 1494 | pm8001_dbg(pm8001_ha, FAIL, |
| 1495 | "Failed to init pci addresses"); |
| 1496 | return ret; |
| 1497 | } |
| 1498 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1499 | /* Write bit1=1 to Inbound DoorBell Register to tell the SPC FW the |
| 1500 | table is stop */ |
| 1501 | pm8001_cw32(pm8001_ha, 0, MSGU_IBDB_SET, SPCv_MSGU_CFG_TABLE_RESET); |
| 1502 | |
| 1503 | /* wait until Inbound DoorBell Clear Register toggled */ |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 1504 | if (IS_SPCV_12G(pm8001_ha->pdev)) { |
Igor Pylypiv | 6f305bf | 2021-04-06 11:05:34 -0700 | [diff] [blame^] | 1505 | max_wait_count = SPCV_DOORBELL_CLEAR_TIMEOUT; |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 1506 | } else { |
Igor Pylypiv | 6f305bf | 2021-04-06 11:05:34 -0700 | [diff] [blame^] | 1507 | max_wait_count = SPC_DOORBELL_CLEAR_TIMEOUT; |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 1508 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1509 | do { |
Igor Pylypiv | 6f305bf | 2021-04-06 11:05:34 -0700 | [diff] [blame^] | 1510 | msleep(FW_READY_INTERVAL); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1511 | value = pm8001_cr32(pm8001_ha, 0, MSGU_IBDB_SET); |
| 1512 | value &= SPCv_MSGU_CFG_TABLE_RESET; |
| 1513 | } while ((value != 0) && (--max_wait_count)); |
| 1514 | |
| 1515 | if (!max_wait_count) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1516 | pm8001_dbg(pm8001_ha, FAIL, "TIMEOUT:IBDB value/=%x\n", value); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1517 | return -1; |
| 1518 | } |
| 1519 | |
| 1520 | /* check the MPI-State for termination in progress */ |
| 1521 | /* wait until Inbound DoorBell Clear Register toggled */ |
Igor Pylypiv | 6f305bf | 2021-04-06 11:05:34 -0700 | [diff] [blame^] | 1522 | max_wait_count = 100; /* 2 sec for spcv/ve */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1523 | do { |
Igor Pylypiv | 6f305bf | 2021-04-06 11:05:34 -0700 | [diff] [blame^] | 1524 | msleep(FW_READY_INTERVAL); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1525 | gst_len_mpistate = |
| 1526 | pm8001_mr32(pm8001_ha->general_stat_tbl_addr, |
| 1527 | GST_GSTLEN_MPIS_OFFSET); |
| 1528 | if (GST_MPI_STATE_UNINIT == |
| 1529 | (gst_len_mpistate & GST_MPI_STATE_MASK)) |
| 1530 | break; |
| 1531 | } while (--max_wait_count); |
| 1532 | if (!max_wait_count) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1533 | pm8001_dbg(pm8001_ha, FAIL, " TIME OUT MPI State = 0x%x\n", |
| 1534 | gst_len_mpistate & GST_MPI_STATE_MASK); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1535 | return -1; |
| 1536 | } |
| 1537 | |
| 1538 | return 0; |
| 1539 | } |
| 1540 | |
| 1541 | /** |
akshatzen | a961ea0 | 2021-01-09 18:08:43 +0530 | [diff] [blame] | 1542 | * pm80xx_fatal_errors - returns non zero *ONLY* when fatal errors |
| 1543 | * @pm8001_ha: our hba card information |
| 1544 | * |
| 1545 | * Fatal errors are recoverable only after a host reboot. |
| 1546 | */ |
| 1547 | int |
| 1548 | pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha) |
| 1549 | { |
| 1550 | int ret = 0; |
| 1551 | u32 scratch_pad_rsvd0 = pm8001_cr32(pm8001_ha, 0, |
| 1552 | MSGU_HOST_SCRATCH_PAD_6); |
| 1553 | u32 scratch_pad_rsvd1 = pm8001_cr32(pm8001_ha, 0, |
| 1554 | MSGU_HOST_SCRATCH_PAD_7); |
| 1555 | u32 scratch_pad1 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); |
| 1556 | u32 scratch_pad2 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_2); |
| 1557 | u32 scratch_pad3 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_3); |
| 1558 | |
| 1559 | if (pm8001_ha->chip_id != chip_8006 && |
| 1560 | pm8001_ha->chip_id != chip_8074 && |
| 1561 | pm8001_ha->chip_id != chip_8076) { |
| 1562 | return 0; |
| 1563 | } |
| 1564 | |
| 1565 | if (MSGU_SCRATCHPAD1_STATE_FATAL_ERROR(scratch_pad1)) { |
| 1566 | pm8001_dbg(pm8001_ha, FAIL, |
| 1567 | "Fatal error SCRATCHPAD1 = 0x%x SCRATCHPAD2 = 0x%x SCRATCHPAD3 = 0x%x SCRATCHPAD_RSVD0 = 0x%x SCRATCHPAD_RSVD1 = 0x%x\n", |
| 1568 | scratch_pad1, scratch_pad2, scratch_pad3, |
| 1569 | scratch_pad_rsvd0, scratch_pad_rsvd1); |
| 1570 | ret = 1; |
| 1571 | } |
| 1572 | |
| 1573 | return ret; |
| 1574 | } |
| 1575 | |
| 1576 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1577 | * pm80xx_chip_soft_rst - soft reset the PM8001 chip, so that the clear all |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1578 | * the FW register status to the originated status. |
| 1579 | * @pm8001_ha: our hba card information |
| 1580 | */ |
| 1581 | |
| 1582 | static int |
| 1583 | pm80xx_chip_soft_rst(struct pm8001_hba_info *pm8001_ha) |
| 1584 | { |
| 1585 | u32 regval; |
| 1586 | u32 bootloader_state; |
Anand Kumar Santhanam | 06f12f22 | 2013-09-17 14:32:20 +0530 | [diff] [blame] | 1587 | u32 ibutton0, ibutton1; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1588 | |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 1589 | /* Process MPI table uninitialization only if FW is ready */ |
| 1590 | if (!pm8001_ha->controller_fatal_error) { |
| 1591 | /* Check if MPI is in ready state to reset */ |
| 1592 | if (mpi_uninit_check(pm8001_ha) != 0) { |
Vikram Auradkar | d384be6 | 2020-03-16 13:19:02 +0530 | [diff] [blame] | 1593 | u32 r0 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_0); |
| 1594 | u32 r1 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); |
| 1595 | u32 r2 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_2); |
| 1596 | u32 r3 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_3); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1597 | pm8001_dbg(pm8001_ha, FAIL, |
| 1598 | "MPI state is not ready scratch: %x:%x:%x:%x\n", |
| 1599 | r0, r1, r2, r3); |
Vikram Auradkar | d384be6 | 2020-03-16 13:19:02 +0530 | [diff] [blame] | 1600 | /* if things aren't ready but the bootloader is ok then |
| 1601 | * try the reset anyway. |
| 1602 | */ |
| 1603 | if (r1 & SCRATCH_PAD1_BOOTSTATE_MASK) |
| 1604 | return -1; |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 1605 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1606 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1607 | /* checked for reset register normal state; 0x0 */ |
| 1608 | regval = pm8001_cr32(pm8001_ha, 0, SPC_REG_SOFT_RESET); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1609 | pm8001_dbg(pm8001_ha, INIT, "reset register before write : 0x%x\n", |
| 1610 | regval); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1611 | |
| 1612 | pm8001_cw32(pm8001_ha, 0, SPC_REG_SOFT_RESET, SPCv_NORMAL_RESET_VALUE); |
Vikram Auradkar | 4daf1ef | 2019-11-14 15:39:01 +0530 | [diff] [blame] | 1613 | msleep(500); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1614 | |
| 1615 | regval = pm8001_cr32(pm8001_ha, 0, SPC_REG_SOFT_RESET); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1616 | pm8001_dbg(pm8001_ha, INIT, "reset register after write 0x%x\n", |
| 1617 | regval); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1618 | |
| 1619 | if ((regval & SPCv_SOFT_RESET_READ_MASK) == |
| 1620 | SPCv_SOFT_RESET_NORMAL_RESET_OCCURED) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1621 | pm8001_dbg(pm8001_ha, MSG, |
| 1622 | " soft reset successful [regval: 0x%x]\n", |
| 1623 | regval); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1624 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1625 | pm8001_dbg(pm8001_ha, MSG, |
| 1626 | " soft reset failed [regval: 0x%x]\n", |
| 1627 | regval); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1628 | |
| 1629 | /* check bootloader is successfully executed or in HDA mode */ |
| 1630 | bootloader_state = |
| 1631 | pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1) & |
| 1632 | SCRATCH_PAD1_BOOTSTATE_MASK; |
| 1633 | |
| 1634 | if (bootloader_state == SCRATCH_PAD1_BOOTSTATE_HDA_SEEPROM) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1635 | pm8001_dbg(pm8001_ha, MSG, |
| 1636 | "Bootloader state - HDA mode SEEPROM\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1637 | } else if (bootloader_state == |
| 1638 | SCRATCH_PAD1_BOOTSTATE_HDA_BOOTSTRAP) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1639 | pm8001_dbg(pm8001_ha, MSG, |
| 1640 | "Bootloader state - HDA mode Bootstrap Pin\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1641 | } else if (bootloader_state == |
| 1642 | SCRATCH_PAD1_BOOTSTATE_HDA_SOFTRESET) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1643 | pm8001_dbg(pm8001_ha, MSG, |
| 1644 | "Bootloader state - HDA mode soft reset\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1645 | } else if (bootloader_state == |
| 1646 | SCRATCH_PAD1_BOOTSTATE_CRIT_ERROR) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1647 | pm8001_dbg(pm8001_ha, MSG, |
| 1648 | "Bootloader state-HDA mode critical error\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1649 | } |
| 1650 | return -EBUSY; |
| 1651 | } |
| 1652 | |
| 1653 | /* check the firmware status after reset */ |
| 1654 | if (-1 == check_fw_ready(pm8001_ha)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1655 | pm8001_dbg(pm8001_ha, FAIL, "Firmware is not ready!\n"); |
Anand Kumar Santhanam | 06f12f22 | 2013-09-17 14:32:20 +0530 | [diff] [blame] | 1656 | /* check iButton feature support for motherboard controller */ |
| 1657 | if (pm8001_ha->pdev->subsystem_vendor != |
| 1658 | PCI_VENDOR_ID_ADAPTEC2 && |
Benjamin Rood | faf321b | 2015-10-30 10:53:29 -0400 | [diff] [blame] | 1659 | pm8001_ha->pdev->subsystem_vendor != |
| 1660 | PCI_VENDOR_ID_ATTO && |
Anand Kumar Santhanam | 06f12f22 | 2013-09-17 14:32:20 +0530 | [diff] [blame] | 1661 | pm8001_ha->pdev->subsystem_vendor != 0) { |
| 1662 | ibutton0 = pm8001_cr32(pm8001_ha, 0, |
| 1663 | MSGU_HOST_SCRATCH_PAD_6); |
| 1664 | ibutton1 = pm8001_cr32(pm8001_ha, 0, |
| 1665 | MSGU_HOST_SCRATCH_PAD_7); |
| 1666 | if (!ibutton0 && !ibutton1) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1667 | pm8001_dbg(pm8001_ha, FAIL, |
| 1668 | "iButton Feature is not Available!!!\n"); |
Anand Kumar Santhanam | 06f12f22 | 2013-09-17 14:32:20 +0530 | [diff] [blame] | 1669 | return -EBUSY; |
| 1670 | } |
| 1671 | if (ibutton0 == 0xdeadbeef && ibutton1 == 0xdeadbeef) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1672 | pm8001_dbg(pm8001_ha, FAIL, |
| 1673 | "CRC Check for iButton Feature Failed!!!\n"); |
Anand Kumar Santhanam | 06f12f22 | 2013-09-17 14:32:20 +0530 | [diff] [blame] | 1674 | return -EBUSY; |
| 1675 | } |
| 1676 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1677 | } |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1678 | pm8001_dbg(pm8001_ha, INIT, "SPCv soft reset Complete\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1679 | return 0; |
| 1680 | } |
| 1681 | |
| 1682 | static void pm80xx_hw_chip_rst(struct pm8001_hba_info *pm8001_ha) |
| 1683 | { |
Colin Ian King | 9e2a07e | 2019-03-17 18:15:32 +0000 | [diff] [blame] | 1684 | u32 i; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1685 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1686 | pm8001_dbg(pm8001_ha, INIT, "chip reset start\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1687 | |
| 1688 | /* do SPCv chip reset. */ |
| 1689 | pm8001_cw32(pm8001_ha, 0, SPC_REG_SOFT_RESET, 0x11); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1690 | pm8001_dbg(pm8001_ha, INIT, "SPC soft reset Complete\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1691 | |
| 1692 | /* Check this ..whether delay is required or no */ |
| 1693 | /* delay 10 usec */ |
| 1694 | udelay(10); |
| 1695 | |
| 1696 | /* wait for 20 msec until the firmware gets reloaded */ |
| 1697 | i = 20; |
| 1698 | do { |
| 1699 | mdelay(1); |
| 1700 | } while ((--i) != 0); |
| 1701 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1702 | pm8001_dbg(pm8001_ha, INIT, "chip reset finished\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1706 | * pm80xx_chip_intx_interrupt_enable - enable PM8001 chip interrupt |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1707 | * @pm8001_ha: our hba card information |
| 1708 | */ |
| 1709 | static void |
| 1710 | pm80xx_chip_intx_interrupt_enable(struct pm8001_hba_info *pm8001_ha) |
| 1711 | { |
| 1712 | pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL); |
| 1713 | pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL); |
| 1714 | } |
| 1715 | |
| 1716 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1717 | * pm80xx_chip_intx_interrupt_disable - disable PM8001 chip interrupt |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1718 | * @pm8001_ha: our hba card information |
| 1719 | */ |
| 1720 | static void |
| 1721 | pm80xx_chip_intx_interrupt_disable(struct pm8001_hba_info *pm8001_ha) |
| 1722 | { |
| 1723 | pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, ODMR_MASK_ALL); |
| 1724 | } |
| 1725 | |
| 1726 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1727 | * pm80xx_chip_interrupt_enable - enable PM8001 chip interrupt |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1728 | * @pm8001_ha: our hba card information |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 1729 | * @vec: interrupt number to enable |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1730 | */ |
| 1731 | static void |
| 1732 | pm80xx_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec) |
| 1733 | { |
| 1734 | #ifdef PM8001_USE_MSIX |
| 1735 | u32 mask; |
| 1736 | mask = (u32)(1 << vec); |
| 1737 | |
| 1738 | pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, (u32)(mask & 0xFFFFFFFF)); |
| 1739 | return; |
| 1740 | #endif |
| 1741 | pm80xx_chip_intx_interrupt_enable(pm8001_ha); |
| 1742 | |
| 1743 | } |
| 1744 | |
| 1745 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 1746 | * pm80xx_chip_interrupt_disable - disable PM8001 chip interrupt |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1747 | * @pm8001_ha: our hba card information |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 1748 | * @vec: interrupt number to disable |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1749 | */ |
| 1750 | static void |
| 1751 | pm80xx_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec) |
| 1752 | { |
| 1753 | #ifdef PM8001_USE_MSIX |
| 1754 | u32 mask; |
| 1755 | if (vec == 0xFF) |
| 1756 | mask = 0xFFFFFFFF; |
| 1757 | else |
| 1758 | mask = (u32)(1 << vec); |
| 1759 | pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, (u32)(mask & 0xFFFFFFFF)); |
| 1760 | return; |
| 1761 | #endif |
| 1762 | pm80xx_chip_intx_interrupt_disable(pm8001_ha); |
| 1763 | } |
| 1764 | |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1765 | static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, |
| 1766 | struct pm8001_device *pm8001_ha_dev) |
| 1767 | { |
| 1768 | int res; |
| 1769 | u32 ccb_tag; |
| 1770 | struct pm8001_ccb_info *ccb; |
| 1771 | struct sas_task *task = NULL; |
| 1772 | struct task_abort_req task_abort; |
| 1773 | struct inbound_queue_table *circularQ; |
| 1774 | u32 opc = OPC_INB_SATA_ABORT; |
| 1775 | int ret; |
| 1776 | |
| 1777 | if (!pm8001_ha_dev) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1778 | pm8001_dbg(pm8001_ha, FAIL, "dev is null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1779 | return; |
| 1780 | } |
| 1781 | |
| 1782 | task = sas_alloc_slow_task(GFP_ATOMIC); |
| 1783 | |
| 1784 | if (!task) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1785 | pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1786 | return; |
| 1787 | } |
| 1788 | |
| 1789 | task->task_done = pm8001_task_done; |
| 1790 | |
| 1791 | res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1792 | if (res) { |
| 1793 | sas_free_task(task); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1794 | return; |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1795 | } |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1796 | |
| 1797 | ccb = &pm8001_ha->ccb_info[ccb_tag]; |
| 1798 | ccb->device = pm8001_ha_dev; |
| 1799 | ccb->ccb_tag = ccb_tag; |
| 1800 | ccb->task = task; |
| 1801 | |
| 1802 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 1803 | |
| 1804 | memset(&task_abort, 0, sizeof(task_abort)); |
| 1805 | task_abort.abort_all = cpu_to_le32(1); |
| 1806 | task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); |
| 1807 | task_abort.tag = cpu_to_le32(ccb_tag); |
| 1808 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 1809 | ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, |
| 1810 | sizeof(task_abort), 0); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1811 | pm8001_dbg(pm8001_ha, FAIL, "Executing abort task end\n"); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1812 | if (ret) { |
| 1813 | sas_free_task(task); |
| 1814 | pm8001_tag_free(pm8001_ha, ccb_tag); |
| 1815 | } |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1816 | } |
| 1817 | |
| 1818 | static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, |
| 1819 | struct pm8001_device *pm8001_ha_dev) |
| 1820 | { |
| 1821 | struct sata_start_req sata_cmd; |
| 1822 | int res; |
| 1823 | u32 ccb_tag; |
| 1824 | struct pm8001_ccb_info *ccb; |
| 1825 | struct sas_task *task = NULL; |
| 1826 | struct host_to_dev_fis fis; |
| 1827 | struct domain_device *dev; |
| 1828 | struct inbound_queue_table *circularQ; |
| 1829 | u32 opc = OPC_INB_SATA_HOST_OPSTART; |
| 1830 | |
| 1831 | task = sas_alloc_slow_task(GFP_ATOMIC); |
| 1832 | |
| 1833 | if (!task) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1834 | pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task !!!\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1835 | return; |
| 1836 | } |
| 1837 | task->task_done = pm8001_task_done; |
| 1838 | |
| 1839 | res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); |
| 1840 | if (res) { |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1841 | sas_free_task(task); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1842 | pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1843 | return; |
| 1844 | } |
| 1845 | |
| 1846 | /* allocate domain device by ourselves as libsas |
| 1847 | * is not going to provide any |
| 1848 | */ |
| 1849 | dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); |
| 1850 | if (!dev) { |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1851 | sas_free_task(task); |
| 1852 | pm8001_tag_free(pm8001_ha, ccb_tag); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1853 | pm8001_dbg(pm8001_ha, FAIL, |
| 1854 | "Domain device cannot be allocated\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1855 | return; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1856 | } |
| 1857 | |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1858 | task->dev = dev; |
| 1859 | task->dev->lldd_dev = pm8001_ha_dev; |
| 1860 | |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1861 | ccb = &pm8001_ha->ccb_info[ccb_tag]; |
| 1862 | ccb->device = pm8001_ha_dev; |
| 1863 | ccb->ccb_tag = ccb_tag; |
| 1864 | ccb->task = task; |
Viswas G | 0b6df11 | 2017-10-18 11:39:14 +0530 | [diff] [blame] | 1865 | ccb->n_elem = 0; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1866 | pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; |
| 1867 | pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; |
| 1868 | |
| 1869 | memset(&sata_cmd, 0, sizeof(sata_cmd)); |
| 1870 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 1871 | |
| 1872 | /* construct read log FIS */ |
| 1873 | memset(&fis, 0, sizeof(struct host_to_dev_fis)); |
| 1874 | fis.fis_type = 0x27; |
| 1875 | fis.flags = 0x80; |
| 1876 | fis.command = ATA_CMD_READ_LOG_EXT; |
| 1877 | fis.lbal = 0x10; |
| 1878 | fis.sector_count = 0x1; |
| 1879 | |
| 1880 | sata_cmd.tag = cpu_to_le32(ccb_tag); |
| 1881 | sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); |
| 1882 | sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9)); |
| 1883 | memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); |
| 1884 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 1885 | res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, |
| 1886 | sizeof(sata_cmd), 0); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1887 | pm8001_dbg(pm8001_ha, FAIL, "Executing read log end\n"); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 1888 | if (res) { |
| 1889 | sas_free_task(task); |
| 1890 | pm8001_tag_free(pm8001_ha, ccb_tag); |
| 1891 | kfree(dev); |
| 1892 | } |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 1893 | } |
| 1894 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1895 | /** |
| 1896 | * mpi_ssp_completion- process the event that FW response to the SSP request. |
| 1897 | * @pm8001_ha: our hba card information |
| 1898 | * @piomb: the message contents of this outbound message. |
| 1899 | * |
| 1900 | * When FW has completed a ssp request for example a IO request, after it has |
| 1901 | * filled the SG data with the data, it will trigger this event represent |
| 1902 | * that he has finished the job,please check the coresponding buffer. |
| 1903 | * So we will tell the caller who maybe waiting the result to tell upper layer |
| 1904 | * that the task has been finished. |
| 1905 | */ |
| 1906 | static void |
| 1907 | mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb) |
| 1908 | { |
| 1909 | struct sas_task *t; |
| 1910 | struct pm8001_ccb_info *ccb; |
| 1911 | unsigned long flags; |
| 1912 | u32 status; |
| 1913 | u32 param; |
| 1914 | u32 tag; |
| 1915 | struct ssp_completion_resp *psspPayload; |
| 1916 | struct task_status_struct *ts; |
| 1917 | struct ssp_response_iu *iu; |
| 1918 | struct pm8001_device *pm8001_dev; |
| 1919 | psspPayload = (struct ssp_completion_resp *)(piomb + 4); |
| 1920 | status = le32_to_cpu(psspPayload->status); |
| 1921 | tag = le32_to_cpu(psspPayload->tag); |
| 1922 | ccb = &pm8001_ha->ccb_info[tag]; |
| 1923 | if ((status == IO_ABORTED) && ccb->open_retry) { |
| 1924 | /* Being completed by another */ |
| 1925 | ccb->open_retry = 0; |
| 1926 | return; |
| 1927 | } |
| 1928 | pm8001_dev = ccb->device; |
| 1929 | param = le32_to_cpu(psspPayload->param); |
| 1930 | t = ccb->task; |
| 1931 | |
| 1932 | if (status && status != IO_UNDERFLOW) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1933 | pm8001_dbg(pm8001_ha, FAIL, "sas IO status 0x%x\n", status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1934 | if (unlikely(!t || !t->lldd_task || !t->dev)) |
| 1935 | return; |
| 1936 | ts = &t->task_status; |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 1937 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1938 | pm8001_dbg(pm8001_ha, DEV, |
| 1939 | "tag::0x%x, status::0x%x task::0x%p\n", tag, status, t); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 1940 | |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 1941 | /* Print sas address of IO failed device */ |
| 1942 | if ((status != IO_SUCCESS) && (status != IO_OVERFLOW) && |
| 1943 | (status != IO_UNDERFLOW)) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1944 | pm8001_dbg(pm8001_ha, FAIL, "SAS Address of IO Failure Drive:%016llx\n", |
| 1945 | SAS_ADDR(t->dev->sas_addr)); |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 1946 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1947 | switch (status) { |
| 1948 | case IO_SUCCESS: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1949 | pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS ,param = 0x%x\n", |
| 1950 | param); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1951 | if (param == 0) { |
| 1952 | ts->resp = SAS_TASK_COMPLETE; |
| 1953 | ts->stat = SAM_STAT_GOOD; |
| 1954 | } else { |
| 1955 | ts->resp = SAS_TASK_COMPLETE; |
| 1956 | ts->stat = SAS_PROTO_RESPONSE; |
| 1957 | ts->residual = param; |
| 1958 | iu = &psspPayload->ssp_resp_iu; |
| 1959 | sas_ssp_task_response(pm8001_ha->dev, t, iu); |
| 1960 | } |
| 1961 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 1962 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1963 | break; |
| 1964 | case IO_ABORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1965 | pm8001_dbg(pm8001_ha, IO, "IO_ABORTED IOMB Tag\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1966 | ts->resp = SAS_TASK_COMPLETE; |
| 1967 | ts->stat = SAS_ABORTED_TASK; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 1968 | if (pm8001_dev) |
| 1969 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1970 | break; |
| 1971 | case IO_UNDERFLOW: |
| 1972 | /* SSP Completion with error */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1973 | pm8001_dbg(pm8001_ha, IO, "IO_UNDERFLOW ,param = 0x%x\n", |
| 1974 | param); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1975 | ts->resp = SAS_TASK_COMPLETE; |
| 1976 | ts->stat = SAS_DATA_UNDERRUN; |
| 1977 | ts->residual = param; |
| 1978 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 1979 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1980 | break; |
| 1981 | case IO_NO_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1982 | pm8001_dbg(pm8001_ha, IO, "IO_NO_DEVICE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1983 | ts->resp = SAS_TASK_UNDELIVERED; |
| 1984 | ts->stat = SAS_PHY_DOWN; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 1985 | if (pm8001_dev) |
| 1986 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1987 | break; |
| 1988 | case IO_XFER_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1989 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1990 | ts->resp = SAS_TASK_COMPLETE; |
| 1991 | ts->stat = SAS_OPEN_REJECT; |
| 1992 | /* Force the midlayer to retry */ |
| 1993 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 1994 | if (pm8001_dev) |
| 1995 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1996 | break; |
| 1997 | case IO_XFER_ERROR_PHY_NOT_READY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 1998 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 1999 | ts->resp = SAS_TASK_COMPLETE; |
| 2000 | ts->stat = SAS_OPEN_REJECT; |
| 2001 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2002 | if (pm8001_dev) |
| 2003 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2004 | break; |
Viswas G | 27ecfa5 | 2015-08-11 15:06:31 +0530 | [diff] [blame] | 2005 | case IO_XFER_ERROR_INVALID_SSP_RSP_FRAME: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2006 | pm8001_dbg(pm8001_ha, IO, |
| 2007 | "IO_XFER_ERROR_INVALID_SSP_RSP_FRAME\n"); |
Viswas G | 27ecfa5 | 2015-08-11 15:06:31 +0530 | [diff] [blame] | 2008 | ts->resp = SAS_TASK_COMPLETE; |
| 2009 | ts->stat = SAS_OPEN_REJECT; |
| 2010 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2011 | if (pm8001_dev) |
| 2012 | atomic_dec(&pm8001_dev->running_req); |
Viswas G | 27ecfa5 | 2015-08-11 15:06:31 +0530 | [diff] [blame] | 2013 | break; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2014 | case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2015 | pm8001_dbg(pm8001_ha, IO, |
| 2016 | "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2017 | ts->resp = SAS_TASK_COMPLETE; |
| 2018 | ts->stat = SAS_OPEN_REJECT; |
| 2019 | ts->open_rej_reason = SAS_OREJ_EPROTO; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2020 | if (pm8001_dev) |
| 2021 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2022 | break; |
| 2023 | case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2024 | pm8001_dbg(pm8001_ha, IO, |
| 2025 | "IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2026 | ts->resp = SAS_TASK_COMPLETE; |
| 2027 | ts->stat = SAS_OPEN_REJECT; |
| 2028 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2029 | if (pm8001_dev) |
| 2030 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2031 | break; |
| 2032 | case IO_OPEN_CNX_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2033 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2034 | ts->resp = SAS_TASK_COMPLETE; |
| 2035 | ts->stat = SAS_OPEN_REJECT; |
| 2036 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2037 | if (pm8001_dev) |
| 2038 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2039 | break; |
| 2040 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2041 | case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: |
| 2042 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: |
| 2043 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: |
| 2044 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: |
| 2045 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2046 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2047 | ts->resp = SAS_TASK_COMPLETE; |
| 2048 | ts->stat = SAS_OPEN_REJECT; |
| 2049 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 2050 | if (!t->uldd_task) |
| 2051 | pm8001_handle_event(pm8001_ha, |
| 2052 | pm8001_dev, |
| 2053 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 2054 | break; |
| 2055 | case IO_OPEN_CNX_ERROR_BAD_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2056 | pm8001_dbg(pm8001_ha, IO, |
| 2057 | "IO_OPEN_CNX_ERROR_BAD_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2058 | ts->resp = SAS_TASK_COMPLETE; |
| 2059 | ts->stat = SAS_OPEN_REJECT; |
| 2060 | ts->open_rej_reason = SAS_OREJ_BAD_DEST; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2061 | if (pm8001_dev) |
| 2062 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2063 | break; |
| 2064 | case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2065 | pm8001_dbg(pm8001_ha, IO, |
| 2066 | "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2067 | ts->resp = SAS_TASK_COMPLETE; |
| 2068 | ts->stat = SAS_OPEN_REJECT; |
| 2069 | ts->open_rej_reason = SAS_OREJ_CONN_RATE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2070 | if (pm8001_dev) |
| 2071 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2072 | break; |
| 2073 | case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2074 | pm8001_dbg(pm8001_ha, IO, |
| 2075 | "IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2076 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2077 | ts->stat = SAS_OPEN_REJECT; |
| 2078 | ts->open_rej_reason = SAS_OREJ_WRONG_DEST; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2079 | if (pm8001_dev) |
| 2080 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2081 | break; |
| 2082 | case IO_XFER_ERROR_NAK_RECEIVED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2083 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_NAK_RECEIVED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2084 | ts->resp = SAS_TASK_COMPLETE; |
| 2085 | ts->stat = SAS_OPEN_REJECT; |
| 2086 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2087 | if (pm8001_dev) |
| 2088 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2089 | break; |
| 2090 | case IO_XFER_ERROR_ACK_NAK_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2091 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_ACK_NAK_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2092 | ts->resp = SAS_TASK_COMPLETE; |
| 2093 | ts->stat = SAS_NAK_R_ERR; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2094 | if (pm8001_dev) |
| 2095 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2096 | break; |
| 2097 | case IO_XFER_ERROR_DMA: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2098 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_DMA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2099 | ts->resp = SAS_TASK_COMPLETE; |
| 2100 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2101 | if (pm8001_dev) |
| 2102 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2103 | break; |
| 2104 | case IO_XFER_OPEN_RETRY_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2105 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_OPEN_RETRY_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2106 | ts->resp = SAS_TASK_COMPLETE; |
| 2107 | ts->stat = SAS_OPEN_REJECT; |
| 2108 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2109 | if (pm8001_dev) |
| 2110 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2111 | break; |
| 2112 | case IO_XFER_ERROR_OFFSET_MISMATCH: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2113 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_OFFSET_MISMATCH\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2114 | ts->resp = SAS_TASK_COMPLETE; |
| 2115 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2116 | if (pm8001_dev) |
| 2117 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2118 | break; |
| 2119 | case IO_PORT_IN_RESET: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2120 | pm8001_dbg(pm8001_ha, IO, "IO_PORT_IN_RESET\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2121 | ts->resp = SAS_TASK_COMPLETE; |
| 2122 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2123 | if (pm8001_dev) |
| 2124 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2125 | break; |
| 2126 | case IO_DS_NON_OPERATIONAL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2127 | pm8001_dbg(pm8001_ha, IO, "IO_DS_NON_OPERATIONAL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2128 | ts->resp = SAS_TASK_COMPLETE; |
| 2129 | ts->stat = SAS_OPEN_REJECT; |
| 2130 | if (!t->uldd_task) |
| 2131 | pm8001_handle_event(pm8001_ha, |
| 2132 | pm8001_dev, |
| 2133 | IO_DS_NON_OPERATIONAL); |
| 2134 | break; |
| 2135 | case IO_DS_IN_RECOVERY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2136 | pm8001_dbg(pm8001_ha, IO, "IO_DS_IN_RECOVERY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2137 | ts->resp = SAS_TASK_COMPLETE; |
| 2138 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2139 | if (pm8001_dev) |
| 2140 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2141 | break; |
| 2142 | case IO_TM_TAG_NOT_FOUND: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2143 | pm8001_dbg(pm8001_ha, IO, "IO_TM_TAG_NOT_FOUND\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2144 | ts->resp = SAS_TASK_COMPLETE; |
| 2145 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2146 | if (pm8001_dev) |
| 2147 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2148 | break; |
| 2149 | case IO_SSP_EXT_IU_ZERO_LEN_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2150 | pm8001_dbg(pm8001_ha, IO, "IO_SSP_EXT_IU_ZERO_LEN_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2151 | ts->resp = SAS_TASK_COMPLETE; |
| 2152 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2153 | if (pm8001_dev) |
| 2154 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2155 | break; |
| 2156 | case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2157 | pm8001_dbg(pm8001_ha, IO, |
| 2158 | "IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2159 | ts->resp = SAS_TASK_COMPLETE; |
| 2160 | ts->stat = SAS_OPEN_REJECT; |
| 2161 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2162 | if (pm8001_dev) |
| 2163 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2164 | break; |
| 2165 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2166 | pm8001_dbg(pm8001_ha, DEVIO, "Unknown status 0x%x\n", status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2167 | /* not allowed case. Therefore, return failed status */ |
| 2168 | ts->resp = SAS_TASK_COMPLETE; |
| 2169 | ts->stat = SAS_OPEN_REJECT; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2170 | if (pm8001_dev) |
| 2171 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2172 | break; |
| 2173 | } |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2174 | pm8001_dbg(pm8001_ha, IO, "scsi_status = 0x%x\n ", |
| 2175 | psspPayload->ssp_resp_iu.status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2176 | spin_lock_irqsave(&t->task_state_lock, flags); |
| 2177 | t->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 2178 | t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 2179 | t->task_state_flags |= SAS_TASK_STATE_DONE; |
| 2180 | if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { |
| 2181 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2182 | pm8001_dbg(pm8001_ha, FAIL, |
| 2183 | "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", |
| 2184 | t, status, ts->resp, ts->stat); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 2185 | if (t->slow_task) |
| 2186 | complete(&t->slow_task->completion); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2187 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 2188 | } else { |
| 2189 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
| 2190 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 2191 | mb();/* in order to force CPU ordering */ |
| 2192 | t->task_done(t); |
| 2193 | } |
| 2194 | } |
| 2195 | |
| 2196 | /*See the comments for mpi_ssp_completion */ |
| 2197 | static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb) |
| 2198 | { |
| 2199 | struct sas_task *t; |
| 2200 | unsigned long flags; |
| 2201 | struct task_status_struct *ts; |
| 2202 | struct pm8001_ccb_info *ccb; |
| 2203 | struct pm8001_device *pm8001_dev; |
| 2204 | struct ssp_event_resp *psspPayload = |
| 2205 | (struct ssp_event_resp *)(piomb + 4); |
| 2206 | u32 event = le32_to_cpu(psspPayload->event); |
| 2207 | u32 tag = le32_to_cpu(psspPayload->tag); |
| 2208 | u32 port_id = le32_to_cpu(psspPayload->port_id); |
| 2209 | |
| 2210 | ccb = &pm8001_ha->ccb_info[tag]; |
| 2211 | t = ccb->task; |
| 2212 | pm8001_dev = ccb->device; |
| 2213 | if (event) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2214 | pm8001_dbg(pm8001_ha, FAIL, "sas IO status 0x%x\n", event); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2215 | if (unlikely(!t || !t->lldd_task || !t->dev)) |
| 2216 | return; |
| 2217 | ts = &t->task_status; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2218 | pm8001_dbg(pm8001_ha, IOERR, "port_id:0x%x, tag:0x%x, event:0x%x\n", |
| 2219 | port_id, tag, event); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2220 | switch (event) { |
| 2221 | case IO_OVERFLOW: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2222 | pm8001_dbg(pm8001_ha, IO, "IO_UNDERFLOW\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2223 | ts->resp = SAS_TASK_COMPLETE; |
| 2224 | ts->stat = SAS_DATA_OVERRUN; |
| 2225 | ts->residual = 0; |
| 2226 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2227 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2228 | break; |
| 2229 | case IO_XFER_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2230 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2231 | pm8001_handle_event(pm8001_ha, t, IO_XFER_ERROR_BREAK); |
| 2232 | return; |
| 2233 | case IO_XFER_ERROR_PHY_NOT_READY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2234 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2235 | ts->resp = SAS_TASK_COMPLETE; |
| 2236 | ts->stat = SAS_OPEN_REJECT; |
| 2237 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 2238 | break; |
| 2239 | case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2240 | pm8001_dbg(pm8001_ha, IO, |
| 2241 | "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2242 | ts->resp = SAS_TASK_COMPLETE; |
| 2243 | ts->stat = SAS_OPEN_REJECT; |
| 2244 | ts->open_rej_reason = SAS_OREJ_EPROTO; |
| 2245 | break; |
| 2246 | case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2247 | pm8001_dbg(pm8001_ha, IO, |
| 2248 | "IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2249 | ts->resp = SAS_TASK_COMPLETE; |
| 2250 | ts->stat = SAS_OPEN_REJECT; |
| 2251 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 2252 | break; |
| 2253 | case IO_OPEN_CNX_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2254 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2255 | ts->resp = SAS_TASK_COMPLETE; |
| 2256 | ts->stat = SAS_OPEN_REJECT; |
| 2257 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 2258 | break; |
| 2259 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2260 | case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: |
| 2261 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: |
| 2262 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: |
| 2263 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: |
| 2264 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2265 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2266 | ts->resp = SAS_TASK_COMPLETE; |
| 2267 | ts->stat = SAS_OPEN_REJECT; |
| 2268 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 2269 | if (!t->uldd_task) |
| 2270 | pm8001_handle_event(pm8001_ha, |
| 2271 | pm8001_dev, |
| 2272 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 2273 | break; |
| 2274 | case IO_OPEN_CNX_ERROR_BAD_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2275 | pm8001_dbg(pm8001_ha, IO, |
| 2276 | "IO_OPEN_CNX_ERROR_BAD_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2277 | ts->resp = SAS_TASK_COMPLETE; |
| 2278 | ts->stat = SAS_OPEN_REJECT; |
| 2279 | ts->open_rej_reason = SAS_OREJ_BAD_DEST; |
| 2280 | break; |
| 2281 | case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2282 | pm8001_dbg(pm8001_ha, IO, |
| 2283 | "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2284 | ts->resp = SAS_TASK_COMPLETE; |
| 2285 | ts->stat = SAS_OPEN_REJECT; |
| 2286 | ts->open_rej_reason = SAS_OREJ_CONN_RATE; |
| 2287 | break; |
| 2288 | case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2289 | pm8001_dbg(pm8001_ha, IO, |
| 2290 | "IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2291 | ts->resp = SAS_TASK_COMPLETE; |
| 2292 | ts->stat = SAS_OPEN_REJECT; |
| 2293 | ts->open_rej_reason = SAS_OREJ_WRONG_DEST; |
| 2294 | break; |
| 2295 | case IO_XFER_ERROR_NAK_RECEIVED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2296 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_NAK_RECEIVED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2297 | ts->resp = SAS_TASK_COMPLETE; |
| 2298 | ts->stat = SAS_OPEN_REJECT; |
| 2299 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 2300 | break; |
| 2301 | case IO_XFER_ERROR_ACK_NAK_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2302 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_ACK_NAK_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2303 | ts->resp = SAS_TASK_COMPLETE; |
| 2304 | ts->stat = SAS_NAK_R_ERR; |
| 2305 | break; |
| 2306 | case IO_XFER_OPEN_RETRY_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2307 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_OPEN_RETRY_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2308 | pm8001_handle_event(pm8001_ha, t, IO_XFER_OPEN_RETRY_TIMEOUT); |
| 2309 | return; |
| 2310 | case IO_XFER_ERROR_UNEXPECTED_PHASE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2311 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_UNEXPECTED_PHASE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2312 | ts->resp = SAS_TASK_COMPLETE; |
| 2313 | ts->stat = SAS_DATA_OVERRUN; |
| 2314 | break; |
| 2315 | case IO_XFER_ERROR_XFER_RDY_OVERRUN: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2316 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_XFER_RDY_OVERRUN\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2317 | ts->resp = SAS_TASK_COMPLETE; |
| 2318 | ts->stat = SAS_DATA_OVERRUN; |
| 2319 | break; |
| 2320 | case IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2321 | pm8001_dbg(pm8001_ha, IO, |
| 2322 | "IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2323 | ts->resp = SAS_TASK_COMPLETE; |
| 2324 | ts->stat = SAS_DATA_OVERRUN; |
| 2325 | break; |
| 2326 | case IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2327 | pm8001_dbg(pm8001_ha, IO, |
| 2328 | "IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2329 | ts->resp = SAS_TASK_COMPLETE; |
| 2330 | ts->stat = SAS_DATA_OVERRUN; |
| 2331 | break; |
| 2332 | case IO_XFER_ERROR_OFFSET_MISMATCH: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2333 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_OFFSET_MISMATCH\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2334 | ts->resp = SAS_TASK_COMPLETE; |
| 2335 | ts->stat = SAS_DATA_OVERRUN; |
| 2336 | break; |
| 2337 | case IO_XFER_ERROR_XFER_ZERO_DATA_LEN: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2338 | pm8001_dbg(pm8001_ha, IO, |
| 2339 | "IO_XFER_ERROR_XFER_ZERO_DATA_LEN\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2340 | ts->resp = SAS_TASK_COMPLETE; |
| 2341 | ts->stat = SAS_DATA_OVERRUN; |
| 2342 | break; |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2343 | case IO_XFER_ERROR_INTERNAL_CRC_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2344 | pm8001_dbg(pm8001_ha, IOERR, |
| 2345 | "IO_XFR_ERROR_INTERNAL_CRC_ERROR\n"); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2346 | /* TBC: used default set values */ |
| 2347 | ts->resp = SAS_TASK_COMPLETE; |
| 2348 | ts->stat = SAS_DATA_OVERRUN; |
| 2349 | break; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2350 | case IO_XFER_CMD_FRAME_ISSUED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2351 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_CMD_FRAME_ISSUED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2352 | return; |
| 2353 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2354 | pm8001_dbg(pm8001_ha, DEVIO, "Unknown status 0x%x\n", event); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2355 | /* not allowed case. Therefore, return failed status */ |
| 2356 | ts->resp = SAS_TASK_COMPLETE; |
| 2357 | ts->stat = SAS_DATA_OVERRUN; |
| 2358 | break; |
| 2359 | } |
| 2360 | spin_lock_irqsave(&t->task_state_lock, flags); |
| 2361 | t->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 2362 | t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 2363 | t->task_state_flags |= SAS_TASK_STATE_DONE; |
| 2364 | if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { |
| 2365 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2366 | pm8001_dbg(pm8001_ha, FAIL, |
| 2367 | "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", |
| 2368 | t, event, ts->resp, ts->stat); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2369 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 2370 | } else { |
| 2371 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
| 2372 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 2373 | mb();/* in order to force CPU ordering */ |
| 2374 | t->task_done(t); |
| 2375 | } |
| 2376 | } |
| 2377 | |
| 2378 | /*See the comments for mpi_ssp_completion */ |
| 2379 | static void |
| 2380 | mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 2381 | { |
| 2382 | struct sas_task *t; |
| 2383 | struct pm8001_ccb_info *ccb; |
| 2384 | u32 param; |
| 2385 | u32 status; |
| 2386 | u32 tag; |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 2387 | int i, j; |
| 2388 | u8 sata_addr_low[4]; |
| 2389 | u32 temp_sata_addr_low, temp_sata_addr_hi; |
| 2390 | u8 sata_addr_hi[4]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2391 | struct sata_completion_resp *psataPayload; |
| 2392 | struct task_status_struct *ts; |
| 2393 | struct ata_task_resp *resp ; |
| 2394 | u32 *sata_resp; |
| 2395 | struct pm8001_device *pm8001_dev; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2396 | unsigned long flags; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2397 | |
| 2398 | psataPayload = (struct sata_completion_resp *)(piomb + 4); |
| 2399 | status = le32_to_cpu(psataPayload->status); |
| 2400 | tag = le32_to_cpu(psataPayload->tag); |
| 2401 | |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2402 | if (!tag) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2403 | pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2404 | return; |
| 2405 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2406 | ccb = &pm8001_ha->ccb_info[tag]; |
| 2407 | param = le32_to_cpu(psataPayload->param); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2408 | if (ccb) { |
| 2409 | t = ccb->task; |
| 2410 | pm8001_dev = ccb->device; |
| 2411 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2412 | pm8001_dbg(pm8001_ha, FAIL, "ccb null\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2413 | return; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2414 | } |
| 2415 | |
| 2416 | if (t) { |
| 2417 | if (t->dev && (t->dev->lldd_dev)) |
| 2418 | pm8001_dev = t->dev->lldd_dev; |
| 2419 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2420 | pm8001_dbg(pm8001_ha, FAIL, "task null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2421 | return; |
| 2422 | } |
| 2423 | |
| 2424 | if ((pm8001_dev && !(pm8001_dev->id & NCQ_READ_LOG_FLAG)) |
| 2425 | && unlikely(!t || !t->lldd_task || !t->dev)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2426 | pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2427 | return; |
| 2428 | } |
| 2429 | |
| 2430 | ts = &t->task_status; |
| 2431 | if (!ts) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2432 | pm8001_dbg(pm8001_ha, FAIL, "ts null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2433 | return; |
| 2434 | } |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 2435 | |
Vishakha Channapattan | 4f608fb | 2021-01-09 18:08:48 +0530 | [diff] [blame] | 2436 | if (status != IO_SUCCESS) { |
| 2437 | pm8001_dbg(pm8001_ha, FAIL, |
| 2438 | "IO failed device_id %u status 0x%x tag %d\n", |
| 2439 | pm8001_dev->device_id, status, tag); |
| 2440 | } |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 2441 | |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 2442 | /* Print sas address of IO failed device */ |
| 2443 | if ((status != IO_SUCCESS) && (status != IO_OVERFLOW) && |
| 2444 | (status != IO_UNDERFLOW)) { |
| 2445 | if (!((t->dev->parent) && |
John Garry | 924a354 | 2019-06-10 20:41:41 +0800 | [diff] [blame] | 2446 | (dev_is_expander(t->dev->parent->dev_type)))) { |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 2447 | for (i = 0 , j = 4; i <= 3 && j <= 7; i++ , j++) |
| 2448 | sata_addr_low[i] = pm8001_ha->sas_addr[j]; |
| 2449 | for (i = 0 , j = 0; i <= 3 && j <= 3; i++ , j++) |
| 2450 | sata_addr_hi[i] = pm8001_ha->sas_addr[j]; |
| 2451 | memcpy(&temp_sata_addr_low, sata_addr_low, |
| 2452 | sizeof(sata_addr_low)); |
| 2453 | memcpy(&temp_sata_addr_hi, sata_addr_hi, |
| 2454 | sizeof(sata_addr_hi)); |
| 2455 | temp_sata_addr_hi = (((temp_sata_addr_hi >> 24) & 0xff) |
| 2456 | |((temp_sata_addr_hi << 8) & |
| 2457 | 0xff0000) | |
| 2458 | ((temp_sata_addr_hi >> 8) |
| 2459 | & 0xff00) | |
| 2460 | ((temp_sata_addr_hi << 24) & |
| 2461 | 0xff000000)); |
| 2462 | temp_sata_addr_low = ((((temp_sata_addr_low >> 24) |
| 2463 | & 0xff) | |
| 2464 | ((temp_sata_addr_low << 8) |
| 2465 | & 0xff0000) | |
| 2466 | ((temp_sata_addr_low >> 8) |
| 2467 | & 0xff00) | |
| 2468 | ((temp_sata_addr_low << 24) |
| 2469 | & 0xff000000)) + |
| 2470 | pm8001_dev->attached_phy + |
| 2471 | 0x10); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2472 | pm8001_dbg(pm8001_ha, FAIL, |
| 2473 | "SAS Address of IO Failure Drive:%08x%08x\n", |
| 2474 | temp_sata_addr_hi, |
| 2475 | temp_sata_addr_low); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2476 | |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 2477 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2478 | pm8001_dbg(pm8001_ha, FAIL, |
| 2479 | "SAS Address of IO Failure Drive:%016llx\n", |
| 2480 | SAS_ADDR(t->dev->sas_addr)); |
Anand Kumar Santhanam | cb269c2 | 2013-09-17 16:47:21 +0530 | [diff] [blame] | 2481 | } |
| 2482 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2483 | switch (status) { |
| 2484 | case IO_SUCCESS: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2485 | pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2486 | if (param == 0) { |
| 2487 | ts->resp = SAS_TASK_COMPLETE; |
| 2488 | ts->stat = SAM_STAT_GOOD; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2489 | /* check if response is for SEND READ LOG */ |
| 2490 | if (pm8001_dev && |
| 2491 | (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { |
| 2492 | /* set new bit for abort_all */ |
| 2493 | pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; |
| 2494 | /* clear bit for read log */ |
| 2495 | pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; |
| 2496 | pm80xx_send_abort_all(pm8001_ha, pm8001_dev); |
| 2497 | /* Free the tag */ |
| 2498 | pm8001_tag_free(pm8001_ha, tag); |
| 2499 | sas_free_task(t); |
| 2500 | return; |
| 2501 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2502 | } else { |
| 2503 | u8 len; |
| 2504 | ts->resp = SAS_TASK_COMPLETE; |
| 2505 | ts->stat = SAS_PROTO_RESPONSE; |
| 2506 | ts->residual = param; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2507 | pm8001_dbg(pm8001_ha, IO, |
| 2508 | "SAS_PROTO_RESPONSE len = %d\n", |
| 2509 | param); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2510 | sata_resp = &psataPayload->sata_resp[0]; |
| 2511 | resp = (struct ata_task_resp *)ts->buf; |
| 2512 | if (t->ata_task.dma_xfer == 0 && |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 2513 | t->data_dir == DMA_FROM_DEVICE) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2514 | len = sizeof(struct pio_setup_fis); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2515 | pm8001_dbg(pm8001_ha, IO, |
| 2516 | "PIO read len = %d\n", len); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2517 | } else if (t->ata_task.use_ncq) { |
| 2518 | len = sizeof(struct set_dev_bits_fis); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2519 | pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", |
| 2520 | len); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2521 | } else { |
| 2522 | len = sizeof(struct dev_to_host_fis); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2523 | pm8001_dbg(pm8001_ha, IO, "other len = %d\n", |
| 2524 | len); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2525 | } |
| 2526 | if (SAS_STATUS_BUF_SIZE >= sizeof(*resp)) { |
| 2527 | resp->frame_len = len; |
| 2528 | memcpy(&resp->ending_fis[0], sata_resp, len); |
| 2529 | ts->buf_valid_size = sizeof(*resp); |
| 2530 | } else |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2531 | pm8001_dbg(pm8001_ha, IO, |
| 2532 | "response too large\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2533 | } |
| 2534 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2535 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2536 | break; |
| 2537 | case IO_ABORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2538 | pm8001_dbg(pm8001_ha, IO, "IO_ABORTED IOMB Tag\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2539 | ts->resp = SAS_TASK_COMPLETE; |
| 2540 | ts->stat = SAS_ABORTED_TASK; |
| 2541 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2542 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2543 | break; |
| 2544 | /* following cases are to do cases */ |
| 2545 | case IO_UNDERFLOW: |
| 2546 | /* SATA Completion with error */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2547 | pm8001_dbg(pm8001_ha, IO, "IO_UNDERFLOW param = %d\n", param); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2548 | ts->resp = SAS_TASK_COMPLETE; |
| 2549 | ts->stat = SAS_DATA_UNDERRUN; |
| 2550 | ts->residual = param; |
| 2551 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2552 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2553 | break; |
| 2554 | case IO_NO_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2555 | pm8001_dbg(pm8001_ha, IO, "IO_NO_DEVICE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2556 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2557 | ts->stat = SAS_PHY_DOWN; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2558 | if (pm8001_dev) |
| 2559 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2560 | break; |
| 2561 | case IO_XFER_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2562 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2563 | ts->resp = SAS_TASK_COMPLETE; |
| 2564 | ts->stat = SAS_INTERRUPTED; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2565 | if (pm8001_dev) |
| 2566 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2567 | break; |
| 2568 | case IO_XFER_ERROR_PHY_NOT_READY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2569 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2570 | ts->resp = SAS_TASK_COMPLETE; |
| 2571 | ts->stat = SAS_OPEN_REJECT; |
| 2572 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2573 | if (pm8001_dev) |
| 2574 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2575 | break; |
| 2576 | case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2577 | pm8001_dbg(pm8001_ha, IO, |
| 2578 | "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2579 | ts->resp = SAS_TASK_COMPLETE; |
| 2580 | ts->stat = SAS_OPEN_REJECT; |
| 2581 | ts->open_rej_reason = SAS_OREJ_EPROTO; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2582 | if (pm8001_dev) |
| 2583 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2584 | break; |
| 2585 | case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2586 | pm8001_dbg(pm8001_ha, IO, |
| 2587 | "IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2588 | ts->resp = SAS_TASK_COMPLETE; |
| 2589 | ts->stat = SAS_OPEN_REJECT; |
| 2590 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2591 | if (pm8001_dev) |
| 2592 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2593 | break; |
| 2594 | case IO_OPEN_CNX_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2595 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2596 | ts->resp = SAS_TASK_COMPLETE; |
| 2597 | ts->stat = SAS_OPEN_REJECT; |
| 2598 | ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2599 | if (pm8001_dev) |
| 2600 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2601 | break; |
| 2602 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2603 | case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: |
| 2604 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: |
| 2605 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: |
| 2606 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: |
| 2607 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2608 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2609 | ts->resp = SAS_TASK_COMPLETE; |
| 2610 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 2611 | if (!t->uldd_task) { |
| 2612 | pm8001_handle_event(pm8001_ha, |
| 2613 | pm8001_dev, |
| 2614 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 2615 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2616 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2617 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2618 | return; |
| 2619 | } |
| 2620 | break; |
| 2621 | case IO_OPEN_CNX_ERROR_BAD_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2622 | pm8001_dbg(pm8001_ha, IO, |
| 2623 | "IO_OPEN_CNX_ERROR_BAD_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2624 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2625 | ts->stat = SAS_OPEN_REJECT; |
| 2626 | ts->open_rej_reason = SAS_OREJ_BAD_DEST; |
| 2627 | if (!t->uldd_task) { |
| 2628 | pm8001_handle_event(pm8001_ha, |
| 2629 | pm8001_dev, |
| 2630 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 2631 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2632 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2633 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2634 | return; |
| 2635 | } |
| 2636 | break; |
| 2637 | case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2638 | pm8001_dbg(pm8001_ha, IO, |
| 2639 | "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2640 | ts->resp = SAS_TASK_COMPLETE; |
| 2641 | ts->stat = SAS_OPEN_REJECT; |
| 2642 | ts->open_rej_reason = SAS_OREJ_CONN_RATE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2643 | if (pm8001_dev) |
| 2644 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2645 | break; |
| 2646 | case IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2647 | pm8001_dbg(pm8001_ha, IO, |
| 2648 | "IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2649 | ts->resp = SAS_TASK_COMPLETE; |
| 2650 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 2651 | if (!t->uldd_task) { |
| 2652 | pm8001_handle_event(pm8001_ha, |
| 2653 | pm8001_dev, |
| 2654 | IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY); |
| 2655 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2656 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2657 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2658 | return; |
| 2659 | } |
| 2660 | break; |
| 2661 | case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2662 | pm8001_dbg(pm8001_ha, IO, |
| 2663 | "IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2664 | ts->resp = SAS_TASK_COMPLETE; |
| 2665 | ts->stat = SAS_OPEN_REJECT; |
| 2666 | ts->open_rej_reason = SAS_OREJ_WRONG_DEST; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2667 | if (pm8001_dev) |
| 2668 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2669 | break; |
| 2670 | case IO_XFER_ERROR_NAK_RECEIVED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2671 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_NAK_RECEIVED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2672 | ts->resp = SAS_TASK_COMPLETE; |
| 2673 | ts->stat = SAS_NAK_R_ERR; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2674 | if (pm8001_dev) |
| 2675 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2676 | break; |
| 2677 | case IO_XFER_ERROR_ACK_NAK_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2678 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_ACK_NAK_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2679 | ts->resp = SAS_TASK_COMPLETE; |
| 2680 | ts->stat = SAS_NAK_R_ERR; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2681 | if (pm8001_dev) |
| 2682 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2683 | break; |
| 2684 | case IO_XFER_ERROR_DMA: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2685 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_DMA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2686 | ts->resp = SAS_TASK_COMPLETE; |
| 2687 | ts->stat = SAS_ABORTED_TASK; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2688 | if (pm8001_dev) |
| 2689 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2690 | break; |
| 2691 | case IO_XFER_ERROR_SATA_LINK_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2692 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_SATA_LINK_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2693 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2694 | ts->stat = SAS_DEV_NO_RESPONSE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2695 | if (pm8001_dev) |
| 2696 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2697 | break; |
| 2698 | case IO_XFER_ERROR_REJECTED_NCQ_MODE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2699 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_REJECTED_NCQ_MODE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2700 | ts->resp = SAS_TASK_COMPLETE; |
| 2701 | ts->stat = SAS_DATA_UNDERRUN; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2702 | if (pm8001_dev) |
| 2703 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2704 | break; |
| 2705 | case IO_XFER_OPEN_RETRY_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2706 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_OPEN_RETRY_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2707 | ts->resp = SAS_TASK_COMPLETE; |
| 2708 | ts->stat = SAS_OPEN_TO; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2709 | if (pm8001_dev) |
| 2710 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2711 | break; |
| 2712 | case IO_PORT_IN_RESET: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2713 | pm8001_dbg(pm8001_ha, IO, "IO_PORT_IN_RESET\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2714 | ts->resp = SAS_TASK_COMPLETE; |
| 2715 | ts->stat = SAS_DEV_NO_RESPONSE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2716 | if (pm8001_dev) |
| 2717 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2718 | break; |
| 2719 | case IO_DS_NON_OPERATIONAL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2720 | pm8001_dbg(pm8001_ha, IO, "IO_DS_NON_OPERATIONAL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2721 | ts->resp = SAS_TASK_COMPLETE; |
| 2722 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 2723 | if (!t->uldd_task) { |
| 2724 | pm8001_handle_event(pm8001_ha, pm8001_dev, |
| 2725 | IO_DS_NON_OPERATIONAL); |
| 2726 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2727 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2728 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2729 | return; |
| 2730 | } |
| 2731 | break; |
| 2732 | case IO_DS_IN_RECOVERY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2733 | pm8001_dbg(pm8001_ha, IO, "IO_DS_IN_RECOVERY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2734 | ts->resp = SAS_TASK_COMPLETE; |
| 2735 | ts->stat = SAS_DEV_NO_RESPONSE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2736 | if (pm8001_dev) |
| 2737 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2738 | break; |
| 2739 | case IO_DS_IN_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2740 | pm8001_dbg(pm8001_ha, IO, "IO_DS_IN_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2741 | ts->resp = SAS_TASK_COMPLETE; |
| 2742 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 2743 | if (!t->uldd_task) { |
| 2744 | pm8001_handle_event(pm8001_ha, pm8001_dev, |
| 2745 | IO_DS_IN_ERROR); |
| 2746 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2747 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2748 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2749 | return; |
| 2750 | } |
| 2751 | break; |
| 2752 | case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2753 | pm8001_dbg(pm8001_ha, IO, |
| 2754 | "IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2755 | ts->resp = SAS_TASK_COMPLETE; |
| 2756 | ts->stat = SAS_OPEN_REJECT; |
| 2757 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2758 | if (pm8001_dev) |
| 2759 | atomic_dec(&pm8001_dev->running_req); |
Johannes Thumshirn | 50acde8 | 2015-08-17 15:52:32 +0200 | [diff] [blame] | 2760 | break; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2761 | default: |
Vishakha Channapattan | 4f608fb | 2021-01-09 18:08:48 +0530 | [diff] [blame] | 2762 | pm8001_dbg(pm8001_ha, DEVIO, |
| 2763 | "Unknown status device_id %u status 0x%x tag %d\n", |
| 2764 | pm8001_dev->device_id, status, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2765 | /* not allowed case. Therefore, return failed status */ |
| 2766 | ts->resp = SAS_TASK_COMPLETE; |
| 2767 | ts->stat = SAS_DEV_NO_RESPONSE; |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2768 | if (pm8001_dev) |
| 2769 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2770 | break; |
| 2771 | } |
| 2772 | spin_lock_irqsave(&t->task_state_lock, flags); |
| 2773 | t->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 2774 | t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 2775 | t->task_state_flags |= SAS_TASK_STATE_DONE; |
| 2776 | if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { |
| 2777 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2778 | pm8001_dbg(pm8001_ha, FAIL, |
| 2779 | "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", |
| 2780 | t, status, ts->resp, ts->stat); |
peter chang | ce21c63 | 2019-11-14 15:38:58 +0530 | [diff] [blame] | 2781 | if (t->slow_task) |
| 2782 | complete(&t->slow_task->completion); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2783 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2784 | } else { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2785 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2786 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2787 | } |
| 2788 | } |
| 2789 | |
| 2790 | /*See the comments for mpi_ssp_completion */ |
| 2791 | static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb) |
| 2792 | { |
| 2793 | struct sas_task *t; |
| 2794 | struct task_status_struct *ts; |
| 2795 | struct pm8001_ccb_info *ccb; |
| 2796 | struct pm8001_device *pm8001_dev; |
| 2797 | struct sata_event_resp *psataPayload = |
| 2798 | (struct sata_event_resp *)(piomb + 4); |
| 2799 | u32 event = le32_to_cpu(psataPayload->event); |
| 2800 | u32 tag = le32_to_cpu(psataPayload->tag); |
| 2801 | u32 port_id = le32_to_cpu(psataPayload->port_id); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2802 | u32 dev_id = le32_to_cpu(psataPayload->device_id); |
| 2803 | unsigned long flags; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2804 | |
| 2805 | ccb = &pm8001_ha->ccb_info[tag]; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2806 | |
| 2807 | if (ccb) { |
| 2808 | t = ccb->task; |
| 2809 | pm8001_dev = ccb->device; |
| 2810 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2811 | pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2812 | return; |
| 2813 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2814 | if (event) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2815 | pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2816 | |
| 2817 | /* Check if this is NCQ error */ |
| 2818 | if (event == IO_XFER_ERROR_ABORTED_NCQ_MODE) { |
| 2819 | /* find device using device id */ |
| 2820 | pm8001_dev = pm8001_find_dev(pm8001_ha, dev_id); |
| 2821 | /* send read log extension */ |
| 2822 | if (pm8001_dev) |
| 2823 | pm80xx_send_read_log(pm8001_ha, pm8001_dev); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2824 | return; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2825 | } |
| 2826 | |
| 2827 | if (unlikely(!t || !t->lldd_task || !t->dev)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2828 | pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n"); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 2829 | return; |
| 2830 | } |
| 2831 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2832 | ts = &t->task_status; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2833 | pm8001_dbg(pm8001_ha, IOERR, "port_id:0x%x, tag:0x%x, event:0x%x\n", |
| 2834 | port_id, tag, event); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2835 | switch (event) { |
| 2836 | case IO_OVERFLOW: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2837 | pm8001_dbg(pm8001_ha, IO, "IO_UNDERFLOW\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2838 | ts->resp = SAS_TASK_COMPLETE; |
| 2839 | ts->stat = SAS_DATA_OVERRUN; |
| 2840 | ts->residual = 0; |
| 2841 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 2842 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2843 | break; |
| 2844 | case IO_XFER_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2845 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2846 | ts->resp = SAS_TASK_COMPLETE; |
| 2847 | ts->stat = SAS_INTERRUPTED; |
| 2848 | break; |
| 2849 | case IO_XFER_ERROR_PHY_NOT_READY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2850 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2851 | ts->resp = SAS_TASK_COMPLETE; |
| 2852 | ts->stat = SAS_OPEN_REJECT; |
| 2853 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 2854 | break; |
| 2855 | case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2856 | pm8001_dbg(pm8001_ha, IO, |
| 2857 | "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2858 | ts->resp = SAS_TASK_COMPLETE; |
| 2859 | ts->stat = SAS_OPEN_REJECT; |
| 2860 | ts->open_rej_reason = SAS_OREJ_EPROTO; |
| 2861 | break; |
| 2862 | case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2863 | pm8001_dbg(pm8001_ha, IO, |
| 2864 | "IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2865 | ts->resp = SAS_TASK_COMPLETE; |
| 2866 | ts->stat = SAS_OPEN_REJECT; |
| 2867 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 2868 | break; |
| 2869 | case IO_OPEN_CNX_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2870 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2871 | ts->resp = SAS_TASK_COMPLETE; |
| 2872 | ts->stat = SAS_OPEN_REJECT; |
| 2873 | ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; |
| 2874 | break; |
| 2875 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2876 | case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: |
| 2877 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: |
| 2878 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: |
| 2879 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: |
| 2880 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2881 | pm8001_dbg(pm8001_ha, FAIL, |
| 2882 | "IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2883 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2884 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 2885 | if (!t->uldd_task) { |
| 2886 | pm8001_handle_event(pm8001_ha, |
| 2887 | pm8001_dev, |
| 2888 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 2889 | ts->resp = SAS_TASK_COMPLETE; |
| 2890 | ts->stat = SAS_QUEUE_FULL; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 2891 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2892 | return; |
| 2893 | } |
| 2894 | break; |
| 2895 | case IO_OPEN_CNX_ERROR_BAD_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2896 | pm8001_dbg(pm8001_ha, IO, |
| 2897 | "IO_OPEN_CNX_ERROR_BAD_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2898 | ts->resp = SAS_TASK_UNDELIVERED; |
| 2899 | ts->stat = SAS_OPEN_REJECT; |
| 2900 | ts->open_rej_reason = SAS_OREJ_BAD_DEST; |
| 2901 | break; |
| 2902 | case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2903 | pm8001_dbg(pm8001_ha, IO, |
| 2904 | "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2905 | ts->resp = SAS_TASK_COMPLETE; |
| 2906 | ts->stat = SAS_OPEN_REJECT; |
| 2907 | ts->open_rej_reason = SAS_OREJ_CONN_RATE; |
| 2908 | break; |
| 2909 | case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2910 | pm8001_dbg(pm8001_ha, IO, |
| 2911 | "IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2912 | ts->resp = SAS_TASK_COMPLETE; |
| 2913 | ts->stat = SAS_OPEN_REJECT; |
| 2914 | ts->open_rej_reason = SAS_OREJ_WRONG_DEST; |
| 2915 | break; |
| 2916 | case IO_XFER_ERROR_NAK_RECEIVED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2917 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_NAK_RECEIVED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2918 | ts->resp = SAS_TASK_COMPLETE; |
| 2919 | ts->stat = SAS_NAK_R_ERR; |
| 2920 | break; |
| 2921 | case IO_XFER_ERROR_PEER_ABORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2922 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PEER_ABORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2923 | ts->resp = SAS_TASK_COMPLETE; |
| 2924 | ts->stat = SAS_NAK_R_ERR; |
| 2925 | break; |
| 2926 | case IO_XFER_ERROR_REJECTED_NCQ_MODE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2927 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_REJECTED_NCQ_MODE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2928 | ts->resp = SAS_TASK_COMPLETE; |
| 2929 | ts->stat = SAS_DATA_UNDERRUN; |
| 2930 | break; |
| 2931 | case IO_XFER_OPEN_RETRY_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2932 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_OPEN_RETRY_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2933 | ts->resp = SAS_TASK_COMPLETE; |
| 2934 | ts->stat = SAS_OPEN_TO; |
| 2935 | break; |
| 2936 | case IO_XFER_ERROR_UNEXPECTED_PHASE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2937 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_UNEXPECTED_PHASE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2938 | ts->resp = SAS_TASK_COMPLETE; |
| 2939 | ts->stat = SAS_OPEN_TO; |
| 2940 | break; |
| 2941 | case IO_XFER_ERROR_XFER_RDY_OVERRUN: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2942 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_XFER_RDY_OVERRUN\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2943 | ts->resp = SAS_TASK_COMPLETE; |
| 2944 | ts->stat = SAS_OPEN_TO; |
| 2945 | break; |
| 2946 | case IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2947 | pm8001_dbg(pm8001_ha, IO, |
| 2948 | "IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2949 | ts->resp = SAS_TASK_COMPLETE; |
| 2950 | ts->stat = SAS_OPEN_TO; |
| 2951 | break; |
| 2952 | case IO_XFER_ERROR_OFFSET_MISMATCH: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2953 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_OFFSET_MISMATCH\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2954 | ts->resp = SAS_TASK_COMPLETE; |
| 2955 | ts->stat = SAS_OPEN_TO; |
| 2956 | break; |
| 2957 | case IO_XFER_ERROR_XFER_ZERO_DATA_LEN: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2958 | pm8001_dbg(pm8001_ha, IO, |
| 2959 | "IO_XFER_ERROR_XFER_ZERO_DATA_LEN\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2960 | ts->resp = SAS_TASK_COMPLETE; |
| 2961 | ts->stat = SAS_OPEN_TO; |
| 2962 | break; |
| 2963 | case IO_XFER_CMD_FRAME_ISSUED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2964 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_CMD_FRAME_ISSUED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2965 | break; |
| 2966 | case IO_XFER_PIO_SETUP_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2967 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_PIO_SETUP_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2968 | ts->resp = SAS_TASK_COMPLETE; |
| 2969 | ts->stat = SAS_OPEN_TO; |
| 2970 | break; |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2971 | case IO_XFER_ERROR_INTERNAL_CRC_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2972 | pm8001_dbg(pm8001_ha, FAIL, |
| 2973 | "IO_XFR_ERROR_INTERNAL_CRC_ERROR\n"); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2974 | /* TBC: used default set values */ |
| 2975 | ts->resp = SAS_TASK_COMPLETE; |
| 2976 | ts->stat = SAS_OPEN_TO; |
| 2977 | break; |
| 2978 | case IO_XFER_DMA_ACTIVATE_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2979 | pm8001_dbg(pm8001_ha, FAIL, "IO_XFR_DMA_ACTIVATE_TIMEOUT\n"); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 2980 | /* TBC: used default set values */ |
| 2981 | ts->resp = SAS_TASK_COMPLETE; |
| 2982 | ts->stat = SAS_OPEN_TO; |
| 2983 | break; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2984 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2985 | pm8001_dbg(pm8001_ha, IO, "Unknown status 0x%x\n", event); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 2986 | /* not allowed case. Therefore, return failed status */ |
| 2987 | ts->resp = SAS_TASK_COMPLETE; |
| 2988 | ts->stat = SAS_OPEN_TO; |
| 2989 | break; |
| 2990 | } |
| 2991 | spin_lock_irqsave(&t->task_state_lock, flags); |
| 2992 | t->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 2993 | t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 2994 | t->task_state_flags |= SAS_TASK_STATE_DONE; |
| 2995 | if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { |
| 2996 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 2997 | pm8001_dbg(pm8001_ha, FAIL, |
| 2998 | "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", |
| 2999 | t, event, ts->resp, ts->stat); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3000 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 3001 | } else { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3002 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 3003 | pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3004 | } |
| 3005 | } |
| 3006 | |
| 3007 | /*See the comments for mpi_ssp_completion */ |
| 3008 | static void |
| 3009 | mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3010 | { |
| 3011 | u32 param, i; |
| 3012 | struct sas_task *t; |
| 3013 | struct pm8001_ccb_info *ccb; |
| 3014 | unsigned long flags; |
| 3015 | u32 status; |
| 3016 | u32 tag; |
| 3017 | struct smp_completion_resp *psmpPayload; |
| 3018 | struct task_status_struct *ts; |
| 3019 | struct pm8001_device *pm8001_dev; |
| 3020 | char *pdma_respaddr = NULL; |
| 3021 | |
| 3022 | psmpPayload = (struct smp_completion_resp *)(piomb + 4); |
| 3023 | status = le32_to_cpu(psmpPayload->status); |
| 3024 | tag = le32_to_cpu(psmpPayload->tag); |
| 3025 | |
| 3026 | ccb = &pm8001_ha->ccb_info[tag]; |
| 3027 | param = le32_to_cpu(psmpPayload->param); |
| 3028 | t = ccb->task; |
| 3029 | ts = &t->task_status; |
| 3030 | pm8001_dev = ccb->device; |
| 3031 | if (status) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3032 | pm8001_dbg(pm8001_ha, FAIL, "smp IO status 0x%x\n", status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3033 | if (unlikely(!t || !t->lldd_task || !t->dev)) |
| 3034 | return; |
| 3035 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3036 | pm8001_dbg(pm8001_ha, DEV, "tag::0x%x status::0x%x\n", tag, status); |
peter chang | 7370672 | 2019-11-14 15:39:02 +0530 | [diff] [blame] | 3037 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3038 | switch (status) { |
| 3039 | |
| 3040 | case IO_SUCCESS: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3041 | pm8001_dbg(pm8001_ha, IO, "IO_SUCCESS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3042 | ts->resp = SAS_TASK_COMPLETE; |
| 3043 | ts->stat = SAM_STAT_GOOD; |
| 3044 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 3045 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3046 | if (pm8001_ha->smp_exp_mode == SMP_DIRECT) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3047 | pm8001_dbg(pm8001_ha, IO, |
| 3048 | "DIRECT RESPONSE Length:%d\n", |
| 3049 | param); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3050 | pdma_respaddr = (char *)(phys_to_virt(cpu_to_le64 |
| 3051 | ((u64)sg_dma_address |
| 3052 | (&t->smp_task.smp_resp)))); |
| 3053 | for (i = 0; i < param; i++) { |
| 3054 | *(pdma_respaddr+i) = psmpPayload->_r_a[i]; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3055 | pm8001_dbg(pm8001_ha, IO, |
| 3056 | "SMP Byte%d DMA data 0x%x psmp 0x%x\n", |
| 3057 | i, *(pdma_respaddr + i), |
| 3058 | psmpPayload->_r_a[i]); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3059 | } |
| 3060 | } |
| 3061 | break; |
| 3062 | case IO_ABORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3063 | pm8001_dbg(pm8001_ha, IO, "IO_ABORTED IOMB\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3064 | ts->resp = SAS_TASK_COMPLETE; |
| 3065 | ts->stat = SAS_ABORTED_TASK; |
| 3066 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 3067 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3068 | break; |
| 3069 | case IO_OVERFLOW: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3070 | pm8001_dbg(pm8001_ha, IO, "IO_UNDERFLOW\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3071 | ts->resp = SAS_TASK_COMPLETE; |
| 3072 | ts->stat = SAS_DATA_OVERRUN; |
| 3073 | ts->residual = 0; |
| 3074 | if (pm8001_dev) |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 3075 | atomic_dec(&pm8001_dev->running_req); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3076 | break; |
| 3077 | case IO_NO_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3078 | pm8001_dbg(pm8001_ha, IO, "IO_NO_DEVICE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3079 | ts->resp = SAS_TASK_COMPLETE; |
| 3080 | ts->stat = SAS_PHY_DOWN; |
| 3081 | break; |
| 3082 | case IO_ERROR_HW_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3083 | pm8001_dbg(pm8001_ha, IO, "IO_ERROR_HW_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3084 | ts->resp = SAS_TASK_COMPLETE; |
| 3085 | ts->stat = SAM_STAT_BUSY; |
| 3086 | break; |
| 3087 | case IO_XFER_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3088 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3089 | ts->resp = SAS_TASK_COMPLETE; |
| 3090 | ts->stat = SAM_STAT_BUSY; |
| 3091 | break; |
| 3092 | case IO_XFER_ERROR_PHY_NOT_READY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3093 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_PHY_NOT_READY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3094 | ts->resp = SAS_TASK_COMPLETE; |
| 3095 | ts->stat = SAM_STAT_BUSY; |
| 3096 | break; |
| 3097 | case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3098 | pm8001_dbg(pm8001_ha, IO, |
| 3099 | "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3100 | ts->resp = SAS_TASK_COMPLETE; |
| 3101 | ts->stat = SAS_OPEN_REJECT; |
| 3102 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 3103 | break; |
| 3104 | case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3105 | pm8001_dbg(pm8001_ha, IO, |
| 3106 | "IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3107 | ts->resp = SAS_TASK_COMPLETE; |
| 3108 | ts->stat = SAS_OPEN_REJECT; |
| 3109 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 3110 | break; |
| 3111 | case IO_OPEN_CNX_ERROR_BREAK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3112 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_BREAK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3113 | ts->resp = SAS_TASK_COMPLETE; |
| 3114 | ts->stat = SAS_OPEN_REJECT; |
| 3115 | ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; |
| 3116 | break; |
| 3117 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 3118 | case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: |
| 3119 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: |
| 3120 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: |
| 3121 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: |
| 3122 | case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3123 | pm8001_dbg(pm8001_ha, IO, "IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3124 | ts->resp = SAS_TASK_COMPLETE; |
| 3125 | ts->stat = SAS_OPEN_REJECT; |
| 3126 | ts->open_rej_reason = SAS_OREJ_UNKNOWN; |
| 3127 | pm8001_handle_event(pm8001_ha, |
| 3128 | pm8001_dev, |
| 3129 | IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); |
| 3130 | break; |
| 3131 | case IO_OPEN_CNX_ERROR_BAD_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3132 | pm8001_dbg(pm8001_ha, IO, |
| 3133 | "IO_OPEN_CNX_ERROR_BAD_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3134 | ts->resp = SAS_TASK_COMPLETE; |
| 3135 | ts->stat = SAS_OPEN_REJECT; |
| 3136 | ts->open_rej_reason = SAS_OREJ_BAD_DEST; |
| 3137 | break; |
| 3138 | case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3139 | pm8001_dbg(pm8001_ha, IO, |
| 3140 | "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3141 | ts->resp = SAS_TASK_COMPLETE; |
| 3142 | ts->stat = SAS_OPEN_REJECT; |
| 3143 | ts->open_rej_reason = SAS_OREJ_CONN_RATE; |
| 3144 | break; |
| 3145 | case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3146 | pm8001_dbg(pm8001_ha, IO, |
| 3147 | "IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3148 | ts->resp = SAS_TASK_COMPLETE; |
| 3149 | ts->stat = SAS_OPEN_REJECT; |
| 3150 | ts->open_rej_reason = SAS_OREJ_WRONG_DEST; |
| 3151 | break; |
| 3152 | case IO_XFER_ERROR_RX_FRAME: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3153 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_RX_FRAME\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3154 | ts->resp = SAS_TASK_COMPLETE; |
| 3155 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 3156 | break; |
| 3157 | case IO_XFER_OPEN_RETRY_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3158 | pm8001_dbg(pm8001_ha, IO, "IO_XFER_OPEN_RETRY_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3159 | ts->resp = SAS_TASK_COMPLETE; |
| 3160 | ts->stat = SAS_OPEN_REJECT; |
| 3161 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 3162 | break; |
| 3163 | case IO_ERROR_INTERNAL_SMP_RESOURCE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3164 | pm8001_dbg(pm8001_ha, IO, "IO_ERROR_INTERNAL_SMP_RESOURCE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3165 | ts->resp = SAS_TASK_COMPLETE; |
| 3166 | ts->stat = SAS_QUEUE_FULL; |
| 3167 | break; |
| 3168 | case IO_PORT_IN_RESET: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3169 | pm8001_dbg(pm8001_ha, IO, "IO_PORT_IN_RESET\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3170 | ts->resp = SAS_TASK_COMPLETE; |
| 3171 | ts->stat = SAS_OPEN_REJECT; |
| 3172 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 3173 | break; |
| 3174 | case IO_DS_NON_OPERATIONAL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3175 | pm8001_dbg(pm8001_ha, IO, "IO_DS_NON_OPERATIONAL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3176 | ts->resp = SAS_TASK_COMPLETE; |
| 3177 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 3178 | break; |
| 3179 | case IO_DS_IN_RECOVERY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3180 | pm8001_dbg(pm8001_ha, IO, "IO_DS_IN_RECOVERY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3181 | ts->resp = SAS_TASK_COMPLETE; |
| 3182 | ts->stat = SAS_OPEN_REJECT; |
| 3183 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 3184 | break; |
| 3185 | case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3186 | pm8001_dbg(pm8001_ha, IO, |
| 3187 | "IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3188 | ts->resp = SAS_TASK_COMPLETE; |
| 3189 | ts->stat = SAS_OPEN_REJECT; |
| 3190 | ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; |
| 3191 | break; |
| 3192 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3193 | pm8001_dbg(pm8001_ha, DEVIO, "Unknown status 0x%x\n", status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3194 | ts->resp = SAS_TASK_COMPLETE; |
| 3195 | ts->stat = SAS_DEV_NO_RESPONSE; |
| 3196 | /* not allowed case. Therefore, return failed status */ |
| 3197 | break; |
| 3198 | } |
| 3199 | spin_lock_irqsave(&t->task_state_lock, flags); |
| 3200 | t->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 3201 | t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 3202 | t->task_state_flags |= SAS_TASK_STATE_DONE; |
| 3203 | if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { |
| 3204 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3205 | pm8001_dbg(pm8001_ha, FAIL, |
| 3206 | "task 0x%p done with io_status 0x%x resp 0x%xstat 0x%x but aborted by upper layer!\n", |
| 3207 | t, status, ts->resp, ts->stat); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3208 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 3209 | } else { |
| 3210 | spin_unlock_irqrestore(&t->task_state_lock, flags); |
| 3211 | pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); |
| 3212 | mb();/* in order to force CPU ordering */ |
| 3213 | t->task_done(t); |
| 3214 | } |
| 3215 | } |
| 3216 | |
| 3217 | /** |
| 3218 | * pm80xx_hw_event_ack_req- For PM8001,some events need to acknowage to FW. |
| 3219 | * @pm8001_ha: our hba card information |
| 3220 | * @Qnum: the outbound queue message number. |
| 3221 | * @SEA: source of event to ack |
| 3222 | * @port_id: port id. |
| 3223 | * @phyId: phy id. |
| 3224 | * @param0: parameter 0. |
| 3225 | * @param1: parameter 1. |
| 3226 | */ |
| 3227 | static void pm80xx_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, |
| 3228 | u32 Qnum, u32 SEA, u32 port_id, u32 phyId, u32 param0, u32 param1) |
| 3229 | { |
| 3230 | struct hw_event_ack_req payload; |
| 3231 | u32 opc = OPC_INB_SAS_HW_EVENT_ACK; |
| 3232 | |
| 3233 | struct inbound_queue_table *circularQ; |
| 3234 | |
| 3235 | memset((u8 *)&payload, 0, sizeof(payload)); |
| 3236 | circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; |
| 3237 | payload.tag = cpu_to_le32(1); |
| 3238 | payload.phyid_sea_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | |
| 3239 | ((phyId & 0xFF) << 24) | (port_id & 0xFF)); |
| 3240 | payload.param0 = cpu_to_le32(param0); |
| 3241 | payload.param1 = cpu_to_le32(param1); |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 3242 | pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 3243 | sizeof(payload), 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3244 | } |
| 3245 | |
| 3246 | static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, |
| 3247 | u32 phyId, u32 phy_op); |
| 3248 | |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3249 | static void hw_event_port_recover(struct pm8001_hba_info *pm8001_ha, |
| 3250 | void *piomb) |
| 3251 | { |
| 3252 | struct hw_event_resp *pPayload = (struct hw_event_resp *)(piomb + 4); |
| 3253 | u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); |
| 3254 | u8 phy_id = (u8)((phyid_npip_portstate & 0xFF0000) >> 16); |
| 3255 | u32 lr_status_evt_portid = |
| 3256 | le32_to_cpu(pPayload->lr_status_evt_portid); |
| 3257 | u8 deviceType = pPayload->sas_identify.dev_type; |
| 3258 | u8 link_rate = (u8)((lr_status_evt_portid & 0xF0000000) >> 28); |
| 3259 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
| 3260 | u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); |
| 3261 | struct pm8001_port *port = &pm8001_ha->port[port_id]; |
| 3262 | |
| 3263 | if (deviceType == SAS_END_DEVICE) { |
| 3264 | pm80xx_chip_phy_ctl_req(pm8001_ha, phy_id, |
| 3265 | PHY_NOTIFY_ENABLE_SPINUP); |
| 3266 | } |
| 3267 | |
| 3268 | port->wide_port_phymap |= (1U << phy_id); |
| 3269 | pm8001_get_lrate_mode(phy, link_rate); |
| 3270 | phy->sas_phy.oob_mode = SAS_OOB_MODE; |
| 3271 | phy->phy_state = PHY_STATE_LINK_UP_SPCV; |
| 3272 | phy->phy_attached = 1; |
| 3273 | } |
| 3274 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3275 | /** |
| 3276 | * hw_event_sas_phy_up -FW tells me a SAS phy up event. |
| 3277 | * @pm8001_ha: our hba card information |
| 3278 | * @piomb: IO message buffer |
| 3279 | */ |
| 3280 | static void |
| 3281 | hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3282 | { |
| 3283 | struct hw_event_resp *pPayload = |
| 3284 | (struct hw_event_resp *)(piomb + 4); |
| 3285 | u32 lr_status_evt_portid = |
| 3286 | le32_to_cpu(pPayload->lr_status_evt_portid); |
| 3287 | u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); |
| 3288 | |
| 3289 | u8 link_rate = |
| 3290 | (u8)((lr_status_evt_portid & 0xF0000000) >> 28); |
| 3291 | u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); |
| 3292 | u8 phy_id = |
| 3293 | (u8)((phyid_npip_portstate & 0xFF0000) >> 16); |
| 3294 | u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); |
| 3295 | |
| 3296 | struct pm8001_port *port = &pm8001_ha->port[port_id]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3297 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
| 3298 | unsigned long flags; |
| 3299 | u8 deviceType = pPayload->sas_identify.dev_type; |
| 3300 | port->port_state = portstate; |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3301 | port->wide_port_phymap |= (1U << phy_id); |
Nikith Ganigarakoppal | 7d02900 | 2013-10-30 16:23:47 +0530 | [diff] [blame] | 3302 | phy->phy_state = PHY_STATE_LINK_UP_SPCV; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3303 | pm8001_dbg(pm8001_ha, MSG, |
| 3304 | "portid:%d; phyid:%d; linkrate:%d; portstate:%x; devicetype:%x\n", |
| 3305 | port_id, phy_id, link_rate, portstate, deviceType); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3306 | |
| 3307 | switch (deviceType) { |
| 3308 | case SAS_PHY_UNUSED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3309 | pm8001_dbg(pm8001_ha, MSG, "device type no device.\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3310 | break; |
| 3311 | case SAS_END_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3312 | pm8001_dbg(pm8001_ha, MSG, "end device.\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3313 | pm80xx_chip_phy_ctl_req(pm8001_ha, phy_id, |
| 3314 | PHY_NOTIFY_ENABLE_SPINUP); |
| 3315 | port->port_attached = 1; |
| 3316 | pm8001_get_lrate_mode(phy, link_rate); |
| 3317 | break; |
| 3318 | case SAS_EDGE_EXPANDER_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3319 | pm8001_dbg(pm8001_ha, MSG, "expander device.\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3320 | port->port_attached = 1; |
| 3321 | pm8001_get_lrate_mode(phy, link_rate); |
| 3322 | break; |
| 3323 | case SAS_FANOUT_EXPANDER_DEVICE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3324 | pm8001_dbg(pm8001_ha, MSG, "fanout expander device.\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3325 | port->port_attached = 1; |
| 3326 | pm8001_get_lrate_mode(phy, link_rate); |
| 3327 | break; |
| 3328 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3329 | pm8001_dbg(pm8001_ha, DEVIO, "unknown device type(%x)\n", |
| 3330 | deviceType); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3331 | break; |
| 3332 | } |
| 3333 | phy->phy_type |= PORT_TYPE_SAS; |
| 3334 | phy->identify.device_type = deviceType; |
| 3335 | phy->phy_attached = 1; |
| 3336 | if (phy->identify.device_type == SAS_END_DEVICE) |
| 3337 | phy->identify.target_port_protocols = SAS_PROTOCOL_SSP; |
| 3338 | else if (phy->identify.device_type != SAS_PHY_UNUSED) |
| 3339 | phy->identify.target_port_protocols = SAS_PROTOCOL_SMP; |
| 3340 | phy->sas_phy.oob_mode = SAS_OOB_MODE; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3341 | sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE, GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3342 | spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); |
| 3343 | memcpy(phy->frame_rcvd, &pPayload->sas_identify, |
| 3344 | sizeof(struct sas_identify_frame)-4); |
| 3345 | phy->frame_rcvd_size = sizeof(struct sas_identify_frame) - 4; |
| 3346 | pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); |
| 3347 | spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); |
| 3348 | if (pm8001_ha->flags == PM8001F_RUN_TIME) |
Ahmed S. Darwish | 4ba9e51 | 2020-11-26 14:29:39 +0100 | [diff] [blame] | 3349 | mdelay(200); /* delay a moment to wait for disk to spin up */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3350 | pm8001_bytes_dmaed(pm8001_ha, phy_id); |
| 3351 | } |
| 3352 | |
| 3353 | /** |
| 3354 | * hw_event_sata_phy_up -FW tells me a SATA phy up event. |
| 3355 | * @pm8001_ha: our hba card information |
| 3356 | * @piomb: IO message buffer |
| 3357 | */ |
| 3358 | static void |
| 3359 | hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3360 | { |
| 3361 | struct hw_event_resp *pPayload = |
| 3362 | (struct hw_event_resp *)(piomb + 4); |
| 3363 | u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); |
| 3364 | u32 lr_status_evt_portid = |
| 3365 | le32_to_cpu(pPayload->lr_status_evt_portid); |
| 3366 | u8 link_rate = |
| 3367 | (u8)((lr_status_evt_portid & 0xF0000000) >> 28); |
| 3368 | u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); |
| 3369 | u8 phy_id = |
| 3370 | (u8)((phyid_npip_portstate & 0xFF0000) >> 16); |
| 3371 | |
| 3372 | u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); |
| 3373 | |
| 3374 | struct pm8001_port *port = &pm8001_ha->port[port_id]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3375 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
| 3376 | unsigned long flags; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3377 | pm8001_dbg(pm8001_ha, DEVIO, |
| 3378 | "port id %d, phy id %d link_rate %d portstate 0x%x\n", |
| 3379 | port_id, phy_id, link_rate, portstate); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3380 | |
| 3381 | port->port_state = portstate; |
Nikith Ganigarakoppal | 7d02900 | 2013-10-30 16:23:47 +0530 | [diff] [blame] | 3382 | phy->phy_state = PHY_STATE_LINK_UP_SPCV; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3383 | port->port_attached = 1; |
| 3384 | pm8001_get_lrate_mode(phy, link_rate); |
| 3385 | phy->phy_type |= PORT_TYPE_SATA; |
| 3386 | phy->phy_attached = 1; |
| 3387 | phy->sas_phy.oob_mode = SATA_OOB_MODE; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3388 | sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE, GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3389 | spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); |
| 3390 | memcpy(phy->frame_rcvd, ((u8 *)&pPayload->sata_fis - 4), |
| 3391 | sizeof(struct dev_to_host_fis)); |
| 3392 | phy->frame_rcvd_size = sizeof(struct dev_to_host_fis); |
| 3393 | phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; |
James Bottomley | aa9f832 | 2013-05-07 14:44:06 -0700 | [diff] [blame] | 3394 | phy->identify.device_type = SAS_SATA_DEV; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3395 | pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); |
| 3396 | spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); |
| 3397 | pm8001_bytes_dmaed(pm8001_ha, phy_id); |
| 3398 | } |
| 3399 | |
| 3400 | /** |
| 3401 | * hw_event_phy_down -we should notify the libsas the phy is down. |
| 3402 | * @pm8001_ha: our hba card information |
| 3403 | * @piomb: IO message buffer |
| 3404 | */ |
| 3405 | static void |
| 3406 | hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3407 | { |
| 3408 | struct hw_event_resp *pPayload = |
| 3409 | (struct hw_event_resp *)(piomb + 4); |
| 3410 | |
| 3411 | u32 lr_status_evt_portid = |
| 3412 | le32_to_cpu(pPayload->lr_status_evt_portid); |
| 3413 | u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); |
| 3414 | u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); |
| 3415 | u8 phy_id = |
| 3416 | (u8)((phyid_npip_portstate & 0xFF0000) >> 16); |
| 3417 | u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); |
| 3418 | |
| 3419 | struct pm8001_port *port = &pm8001_ha->port[port_id]; |
| 3420 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3421 | u32 port_sata = (phy->phy_type & PORT_TYPE_SATA); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3422 | port->port_state = portstate; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3423 | phy->identify.device_type = 0; |
| 3424 | phy->phy_attached = 0; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3425 | switch (portstate) { |
| 3426 | case PORT_VALID: |
| 3427 | break; |
| 3428 | case PORT_INVALID: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3429 | pm8001_dbg(pm8001_ha, MSG, " PortInvalid portID %d\n", |
| 3430 | port_id); |
| 3431 | pm8001_dbg(pm8001_ha, MSG, |
| 3432 | " Last phy Down and port invalid\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3433 | if (port_sata) { |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3434 | phy->phy_type = 0; |
| 3435 | port->port_attached = 0; |
| 3436 | pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, |
| 3437 | port_id, phy_id, 0, 0); |
| 3438 | } |
| 3439 | sas_phy_disconnected(&phy->sas_phy); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3440 | break; |
| 3441 | case PORT_IN_RESET: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3442 | pm8001_dbg(pm8001_ha, MSG, " Port In Reset portID %d\n", |
| 3443 | port_id); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3444 | break; |
| 3445 | case PORT_NOT_ESTABLISHED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3446 | pm8001_dbg(pm8001_ha, MSG, |
| 3447 | " Phy Down and PORT_NOT_ESTABLISHED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3448 | port->port_attached = 0; |
| 3449 | break; |
| 3450 | case PORT_LOSTCOMM: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3451 | pm8001_dbg(pm8001_ha, MSG, " Phy Down and PORT_LOSTCOMM\n"); |
| 3452 | pm8001_dbg(pm8001_ha, MSG, |
| 3453 | " Last phy Down and port invalid\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3454 | if (port_sata) { |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3455 | port->port_attached = 0; |
| 3456 | phy->phy_type = 0; |
| 3457 | pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, |
| 3458 | port_id, phy_id, 0, 0); |
| 3459 | } |
| 3460 | sas_phy_disconnected(&phy->sas_phy); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3461 | break; |
| 3462 | default: |
| 3463 | port->port_attached = 0; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3464 | pm8001_dbg(pm8001_ha, DEVIO, |
| 3465 | " Phy Down and(default) = 0x%x\n", |
| 3466 | portstate); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3467 | break; |
| 3468 | |
| 3469 | } |
John Garry | 121181f | 2021-01-18 11:09:38 +0100 | [diff] [blame] | 3470 | if (port_sata && (portstate != PORT_IN_RESET)) |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3471 | sas_notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL, |
| 3472 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3473 | } |
| 3474 | |
| 3475 | static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3476 | { |
| 3477 | struct phy_start_resp *pPayload = |
| 3478 | (struct phy_start_resp *)(piomb + 4); |
| 3479 | u32 status = |
| 3480 | le32_to_cpu(pPayload->status); |
| 3481 | u32 phy_id = |
| 3482 | le32_to_cpu(pPayload->phyid); |
| 3483 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
| 3484 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3485 | pm8001_dbg(pm8001_ha, INIT, |
| 3486 | "phy start resp status:0x%x, phyid:0x%x\n", |
| 3487 | status, phy_id); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3488 | if (status == 0) { |
Deepak Ukey | cd13575 | 2018-09-11 14:18:02 +0530 | [diff] [blame] | 3489 | phy->phy_state = PHY_LINK_DOWN; |
| 3490 | if (pm8001_ha->flags == PM8001F_RUN_TIME && |
peter chang | e703977 | 2019-11-14 15:38:59 +0530 | [diff] [blame] | 3491 | phy->enable_completion != NULL) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3492 | complete(phy->enable_completion); |
peter chang | e703977 | 2019-11-14 15:38:59 +0530 | [diff] [blame] | 3493 | phy->enable_completion = NULL; |
| 3494 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3495 | } |
| 3496 | return 0; |
| 3497 | |
| 3498 | } |
| 3499 | |
| 3500 | /** |
| 3501 | * mpi_thermal_hw_event -The hw event has come. |
| 3502 | * @pm8001_ha: our hba card information |
| 3503 | * @piomb: IO message buffer |
| 3504 | */ |
| 3505 | static int mpi_thermal_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3506 | { |
| 3507 | struct thermal_hw_event *pPayload = |
| 3508 | (struct thermal_hw_event *)(piomb + 4); |
| 3509 | |
| 3510 | u32 thermal_event = le32_to_cpu(pPayload->thermal_event); |
| 3511 | u32 rht_lht = le32_to_cpu(pPayload->rht_lht); |
| 3512 | |
| 3513 | if (thermal_event & 0x40) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3514 | pm8001_dbg(pm8001_ha, IO, |
| 3515 | "Thermal Event: Local high temperature violated!\n"); |
| 3516 | pm8001_dbg(pm8001_ha, IO, |
| 3517 | "Thermal Event: Measured local high temperature %d\n", |
| 3518 | ((rht_lht & 0xFF00) >> 8)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3519 | } |
| 3520 | if (thermal_event & 0x10) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3521 | pm8001_dbg(pm8001_ha, IO, |
| 3522 | "Thermal Event: Remote high temperature violated!\n"); |
| 3523 | pm8001_dbg(pm8001_ha, IO, |
| 3524 | "Thermal Event: Measured remote high temperature %d\n", |
| 3525 | ((rht_lht & 0xFF000000) >> 24)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3526 | } |
| 3527 | return 0; |
| 3528 | } |
| 3529 | |
| 3530 | /** |
| 3531 | * mpi_hw_event -The hw event has come. |
| 3532 | * @pm8001_ha: our hba card information |
| 3533 | * @piomb: IO message buffer |
| 3534 | */ |
| 3535 | static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3536 | { |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3537 | unsigned long flags, i; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3538 | struct hw_event_resp *pPayload = |
| 3539 | (struct hw_event_resp *)(piomb + 4); |
| 3540 | u32 lr_status_evt_portid = |
| 3541 | le32_to_cpu(pPayload->lr_status_evt_portid); |
| 3542 | u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); |
| 3543 | u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); |
| 3544 | u8 phy_id = |
| 3545 | (u8)((phyid_npip_portstate & 0xFF0000) >> 16); |
| 3546 | u16 eventType = |
| 3547 | (u16)((lr_status_evt_portid & 0x00FFFF00) >> 8); |
| 3548 | u8 status = |
| 3549 | (u8)((lr_status_evt_portid & 0x0F000000) >> 24); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3550 | struct sas_ha_struct *sas_ha = pm8001_ha->sas; |
| 3551 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3552 | struct pm8001_port *port = &pm8001_ha->port[port_id]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3553 | struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3554 | pm8001_dbg(pm8001_ha, DEV, |
| 3555 | "portid:%d phyid:%d event:0x%x status:0x%x\n", |
| 3556 | port_id, phy_id, eventType, status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3557 | |
| 3558 | switch (eventType) { |
| 3559 | |
| 3560 | case HW_EVENT_SAS_PHY_UP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3561 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PHY_START_STATUS\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3562 | hw_event_sas_phy_up(pm8001_ha, piomb); |
| 3563 | break; |
| 3564 | case HW_EVENT_SATA_PHY_UP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3565 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_SATA_PHY_UP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3566 | hw_event_sata_phy_up(pm8001_ha, piomb); |
| 3567 | break; |
| 3568 | case HW_EVENT_SATA_SPINUP_HOLD: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3569 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_SATA_SPINUP_HOLD\n"); |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3570 | sas_notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3571 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3572 | break; |
| 3573 | case HW_EVENT_PHY_DOWN: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3574 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PHY_DOWN\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3575 | hw_event_phy_down(pm8001_ha, piomb); |
| 3576 | if (pm8001_ha->reset_in_progress) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3577 | pm8001_dbg(pm8001_ha, MSG, "Reset in progress\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3578 | return 0; |
| 3579 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3580 | phy->phy_attached = 0; |
Deepak Ukey | cd13575 | 2018-09-11 14:18:02 +0530 | [diff] [blame] | 3581 | phy->phy_state = PHY_LINK_DISABLE; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3582 | break; |
| 3583 | case HW_EVENT_PORT_INVALID: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3584 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PORT_INVALID\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3585 | sas_phy_disconnected(sas_phy); |
| 3586 | phy->phy_attached = 0; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3587 | sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3588 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3589 | break; |
| 3590 | /* the broadcast change primitive received, tell the LIBSAS this event |
| 3591 | to revalidate the sas domain*/ |
| 3592 | case HW_EVENT_BROADCAST_CHANGE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3593 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_BROADCAST_CHANGE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3594 | pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_BROADCAST_CHANGE, |
| 3595 | port_id, phy_id, 1, 0); |
| 3596 | spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); |
| 3597 | sas_phy->sas_prim = HW_EVENT_BROADCAST_CHANGE; |
| 3598 | spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3599 | sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3600 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3601 | break; |
| 3602 | case HW_EVENT_PHY_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3603 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PHY_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3604 | sas_phy_disconnected(&phy->sas_phy); |
| 3605 | phy->phy_attached = 0; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3606 | sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR, GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3607 | break; |
| 3608 | case HW_EVENT_BROADCAST_EXP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3609 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_BROADCAST_EXP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3610 | spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); |
| 3611 | sas_phy->sas_prim = HW_EVENT_BROADCAST_EXP; |
| 3612 | spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3613 | sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3614 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3615 | break; |
| 3616 | case HW_EVENT_LINK_ERR_INVALID_DWORD: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3617 | pm8001_dbg(pm8001_ha, MSG, |
| 3618 | "HW_EVENT_LINK_ERR_INVALID_DWORD\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3619 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3620 | HW_EVENT_LINK_ERR_INVALID_DWORD, port_id, phy_id, 0, 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3621 | break; |
| 3622 | case HW_EVENT_LINK_ERR_DISPARITY_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3623 | pm8001_dbg(pm8001_ha, MSG, |
| 3624 | "HW_EVENT_LINK_ERR_DISPARITY_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3625 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3626 | HW_EVENT_LINK_ERR_DISPARITY_ERROR, |
| 3627 | port_id, phy_id, 0, 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3628 | break; |
| 3629 | case HW_EVENT_LINK_ERR_CODE_VIOLATION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3630 | pm8001_dbg(pm8001_ha, MSG, |
| 3631 | "HW_EVENT_LINK_ERR_CODE_VIOLATION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3632 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3633 | HW_EVENT_LINK_ERR_CODE_VIOLATION, |
| 3634 | port_id, phy_id, 0, 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3635 | break; |
| 3636 | case HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3637 | pm8001_dbg(pm8001_ha, MSG, |
| 3638 | "HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3639 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3640 | HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH, |
| 3641 | port_id, phy_id, 0, 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3642 | break; |
| 3643 | case HW_EVENT_MALFUNCTION: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3644 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_MALFUNCTION\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3645 | break; |
| 3646 | case HW_EVENT_BROADCAST_SES: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3647 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_BROADCAST_SES\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3648 | spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); |
| 3649 | sas_phy->sas_prim = HW_EVENT_BROADCAST_SES; |
| 3650 | spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3651 | sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3652 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3653 | break; |
| 3654 | case HW_EVENT_INBOUND_CRC_ERROR: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3655 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_INBOUND_CRC_ERROR\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3656 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3657 | HW_EVENT_INBOUND_CRC_ERROR, |
| 3658 | port_id, phy_id, 0, 0); |
| 3659 | break; |
| 3660 | case HW_EVENT_HARD_RESET_RECEIVED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3661 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_HARD_RESET_RECEIVED\n"); |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3662 | sas_notify_port_event(sas_phy, PORTE_HARD_RESET, GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3663 | break; |
| 3664 | case HW_EVENT_ID_FRAME_TIMEOUT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3665 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_ID_FRAME_TIMEOUT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3666 | sas_phy_disconnected(sas_phy); |
| 3667 | phy->phy_attached = 0; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3668 | sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3669 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3670 | break; |
| 3671 | case HW_EVENT_LINK_ERR_PHY_RESET_FAILED: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3672 | pm8001_dbg(pm8001_ha, MSG, |
| 3673 | "HW_EVENT_LINK_ERR_PHY_RESET_FAILED\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3674 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3675 | HW_EVENT_LINK_ERR_PHY_RESET_FAILED, |
| 3676 | port_id, phy_id, 0, 0); |
| 3677 | sas_phy_disconnected(sas_phy); |
| 3678 | phy->phy_attached = 0; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3679 | sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3680 | GFP_ATOMIC); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3681 | break; |
| 3682 | case HW_EVENT_PORT_RESET_TIMER_TMO: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3683 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PORT_RESET_TIMER_TMO\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3684 | pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, |
| 3685 | port_id, phy_id, 0, 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3686 | sas_phy_disconnected(sas_phy); |
| 3687 | phy->phy_attached = 0; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3688 | sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3689 | GFP_ATOMIC); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3690 | if (pm8001_ha->phy[phy_id].reset_completion) { |
| 3691 | pm8001_ha->phy[phy_id].port_reset_status = |
| 3692 | PORT_RESET_TMO; |
| 3693 | complete(pm8001_ha->phy[phy_id].reset_completion); |
| 3694 | pm8001_ha->phy[phy_id].reset_completion = NULL; |
| 3695 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3696 | break; |
| 3697 | case HW_EVENT_PORT_RECOVERY_TIMER_TMO: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3698 | pm8001_dbg(pm8001_ha, MSG, |
| 3699 | "HW_EVENT_PORT_RECOVERY_TIMER_TMO\n"); |
Sakthivel K | a6cb3d0 | 2013-03-19 18:08:40 +0530 | [diff] [blame] | 3700 | pm80xx_hw_event_ack_req(pm8001_ha, 0, |
| 3701 | HW_EVENT_PORT_RECOVERY_TIMER_TMO, |
| 3702 | port_id, phy_id, 0, 0); |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3703 | for (i = 0; i < pm8001_ha->chip->n_phy; i++) { |
| 3704 | if (port->wide_port_phymap & (1 << i)) { |
| 3705 | phy = &pm8001_ha->phy[i]; |
Ahmed S. Darwish | de6d754 | 2021-01-18 11:09:51 +0100 | [diff] [blame] | 3706 | sas_notify_phy_event(&phy->sas_phy, |
Ahmed S. Darwish | cd4e817 | 2021-01-18 11:09:45 +0100 | [diff] [blame] | 3707 | PHYE_LOSS_OF_SIGNAL, GFP_ATOMIC); |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3708 | port->wide_port_phymap &= ~(1 << i); |
| 3709 | } |
| 3710 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3711 | break; |
| 3712 | case HW_EVENT_PORT_RECOVER: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3713 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PORT_RECOVER\n"); |
Viswas G | 8414cd8 | 2015-08-11 15:06:30 +0530 | [diff] [blame] | 3714 | hw_event_port_recover(pm8001_ha, piomb); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3715 | break; |
| 3716 | case HW_EVENT_PORT_RESET_COMPLETE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3717 | pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PORT_RESET_COMPLETE\n"); |
Viswas G | 869ddbd | 2017-10-18 11:39:13 +0530 | [diff] [blame] | 3718 | if (pm8001_ha->phy[phy_id].reset_completion) { |
| 3719 | pm8001_ha->phy[phy_id].port_reset_status = |
| 3720 | PORT_RESET_SUCCESS; |
| 3721 | complete(pm8001_ha->phy[phy_id].reset_completion); |
| 3722 | pm8001_ha->phy[phy_id].reset_completion = NULL; |
| 3723 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3724 | break; |
| 3725 | case EVENT_BROADCAST_ASYNCH_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3726 | pm8001_dbg(pm8001_ha, MSG, "EVENT_BROADCAST_ASYNCH_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3727 | break; |
| 3728 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3729 | pm8001_dbg(pm8001_ha, DEVIO, "Unknown event type 0x%x\n", |
| 3730 | eventType); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3731 | break; |
| 3732 | } |
| 3733 | return 0; |
| 3734 | } |
| 3735 | |
| 3736 | /** |
| 3737 | * mpi_phy_stop_resp - SPCv specific |
| 3738 | * @pm8001_ha: our hba card information |
| 3739 | * @piomb: IO message buffer |
| 3740 | */ |
| 3741 | static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3742 | { |
| 3743 | struct phy_stop_resp *pPayload = |
| 3744 | (struct phy_stop_resp *)(piomb + 4); |
| 3745 | u32 status = |
| 3746 | le32_to_cpu(pPayload->status); |
| 3747 | u32 phyid = |
Deepak Ukey | cd13575 | 2018-09-11 14:18:02 +0530 | [diff] [blame] | 3748 | le32_to_cpu(pPayload->phyid) & 0xFF; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3749 | struct pm8001_phy *phy = &pm8001_ha->phy[phyid]; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3750 | pm8001_dbg(pm8001_ha, MSG, "phy:0x%x status:0x%x\n", |
| 3751 | phyid, status); |
Deepak Ukey | cd13575 | 2018-09-11 14:18:02 +0530 | [diff] [blame] | 3752 | if (status == PHY_STOP_SUCCESS || |
| 3753 | status == PHY_STOP_ERR_DEVICE_ATTACHED) |
| 3754 | phy->phy_state = PHY_LINK_DISABLE; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3755 | return 0; |
| 3756 | } |
| 3757 | |
| 3758 | /** |
| 3759 | * mpi_set_controller_config_resp - SPCv specific |
| 3760 | * @pm8001_ha: our hba card information |
| 3761 | * @piomb: IO message buffer |
| 3762 | */ |
| 3763 | static int mpi_set_controller_config_resp(struct pm8001_hba_info *pm8001_ha, |
| 3764 | void *piomb) |
| 3765 | { |
| 3766 | struct set_ctrl_cfg_resp *pPayload = |
| 3767 | (struct set_ctrl_cfg_resp *)(piomb + 4); |
| 3768 | u32 status = le32_to_cpu(pPayload->status); |
| 3769 | u32 err_qlfr_pgcd = le32_to_cpu(pPayload->err_qlfr_pgcd); |
| 3770 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3771 | pm8001_dbg(pm8001_ha, MSG, |
| 3772 | "SET CONTROLLER RESP: status 0x%x qlfr_pgcd 0x%x\n", |
| 3773 | status, err_qlfr_pgcd); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3774 | |
| 3775 | return 0; |
| 3776 | } |
| 3777 | |
| 3778 | /** |
| 3779 | * mpi_get_controller_config_resp - SPCv specific |
| 3780 | * @pm8001_ha: our hba card information |
| 3781 | * @piomb: IO message buffer |
| 3782 | */ |
| 3783 | static int mpi_get_controller_config_resp(struct pm8001_hba_info *pm8001_ha, |
| 3784 | void *piomb) |
| 3785 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3786 | pm8001_dbg(pm8001_ha, MSG, " pm80xx_addition_functionality\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3787 | |
| 3788 | return 0; |
| 3789 | } |
| 3790 | |
| 3791 | /** |
| 3792 | * mpi_get_phy_profile_resp - SPCv specific |
| 3793 | * @pm8001_ha: our hba card information |
| 3794 | * @piomb: IO message buffer |
| 3795 | */ |
| 3796 | static int mpi_get_phy_profile_resp(struct pm8001_hba_info *pm8001_ha, |
| 3797 | void *piomb) |
| 3798 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3799 | pm8001_dbg(pm8001_ha, MSG, " pm80xx_addition_functionality\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3800 | |
| 3801 | return 0; |
| 3802 | } |
| 3803 | |
| 3804 | /** |
| 3805 | * mpi_flash_op_ext_resp - SPCv specific |
| 3806 | * @pm8001_ha: our hba card information |
| 3807 | * @piomb: IO message buffer |
| 3808 | */ |
| 3809 | static int mpi_flash_op_ext_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3810 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3811 | pm8001_dbg(pm8001_ha, MSG, " pm80xx_addition_functionality\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3812 | |
| 3813 | return 0; |
| 3814 | } |
| 3815 | |
| 3816 | /** |
| 3817 | * mpi_set_phy_profile_resp - SPCv specific |
| 3818 | * @pm8001_ha: our hba card information |
| 3819 | * @piomb: IO message buffer |
| 3820 | */ |
| 3821 | static int mpi_set_phy_profile_resp(struct pm8001_hba_info *pm8001_ha, |
| 3822 | void *piomb) |
| 3823 | { |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3824 | u32 tag; |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 3825 | u8 page_code; |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3826 | int rc = 0; |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 3827 | struct set_phy_profile_resp *pPayload = |
| 3828 | (struct set_phy_profile_resp *)(piomb + 4); |
| 3829 | u32 ppc_phyid = le32_to_cpu(pPayload->ppc_phyid); |
| 3830 | u32 status = le32_to_cpu(pPayload->status); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3831 | |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3832 | tag = le32_to_cpu(pPayload->tag); |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 3833 | page_code = (u8)((ppc_phyid & 0xFF00) >> 8); |
| 3834 | if (status) { |
| 3835 | /* status is FAILED */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3836 | pm8001_dbg(pm8001_ha, FAIL, |
| 3837 | "PhyProfile command failed with status 0x%08X\n", |
| 3838 | status); |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3839 | rc = -1; |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 3840 | } else { |
| 3841 | if (page_code != SAS_PHY_ANALOG_SETTINGS_PAGE) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3842 | pm8001_dbg(pm8001_ha, FAIL, "Invalid page code 0x%X\n", |
| 3843 | page_code); |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3844 | rc = -1; |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 3845 | } |
| 3846 | } |
yuuzheng | 9d9c7c2 | 2020-03-16 13:19:03 +0530 | [diff] [blame] | 3847 | pm8001_tag_free(pm8001_ha, tag); |
| 3848 | return rc; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3849 | } |
| 3850 | |
| 3851 | /** |
| 3852 | * mpi_kek_management_resp - SPCv specific |
| 3853 | * @pm8001_ha: our hba card information |
| 3854 | * @piomb: IO message buffer |
| 3855 | */ |
| 3856 | static int mpi_kek_management_resp(struct pm8001_hba_info *pm8001_ha, |
| 3857 | void *piomb) |
| 3858 | { |
| 3859 | struct kek_mgmt_resp *pPayload = (struct kek_mgmt_resp *)(piomb + 4); |
| 3860 | |
| 3861 | u32 status = le32_to_cpu(pPayload->status); |
| 3862 | u32 kidx_new_curr_ksop = le32_to_cpu(pPayload->kidx_new_curr_ksop); |
| 3863 | u32 err_qlfr = le32_to_cpu(pPayload->err_qlfr); |
| 3864 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3865 | pm8001_dbg(pm8001_ha, MSG, |
| 3866 | "KEK MGMT RESP. Status 0x%x idx_ksop 0x%x err_qlfr 0x%x\n", |
| 3867 | status, kidx_new_curr_ksop, err_qlfr); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3868 | |
| 3869 | return 0; |
| 3870 | } |
| 3871 | |
| 3872 | /** |
| 3873 | * mpi_dek_management_resp - SPCv specific |
| 3874 | * @pm8001_ha: our hba card information |
| 3875 | * @piomb: IO message buffer |
| 3876 | */ |
| 3877 | static int mpi_dek_management_resp(struct pm8001_hba_info *pm8001_ha, |
| 3878 | void *piomb) |
| 3879 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3880 | pm8001_dbg(pm8001_ha, MSG, " pm80xx_addition_functionality\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3881 | |
| 3882 | return 0; |
| 3883 | } |
| 3884 | |
| 3885 | /** |
| 3886 | * ssp_coalesced_comp_resp - SPCv specific |
| 3887 | * @pm8001_ha: our hba card information |
| 3888 | * @piomb: IO message buffer |
| 3889 | */ |
| 3890 | static int ssp_coalesced_comp_resp(struct pm8001_hba_info *pm8001_ha, |
| 3891 | void *piomb) |
| 3892 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3893 | pm8001_dbg(pm8001_ha, MSG, " pm80xx_addition_functionality\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3894 | |
| 3895 | return 0; |
| 3896 | } |
| 3897 | |
| 3898 | /** |
| 3899 | * process_one_iomb - process one outbound Queue memory block |
| 3900 | * @pm8001_ha: our hba card information |
| 3901 | * @piomb: IO message buffer |
| 3902 | */ |
| 3903 | static void process_one_iomb(struct pm8001_hba_info *pm8001_ha, void *piomb) |
| 3904 | { |
| 3905 | __le32 pHeader = *(__le32 *)piomb; |
| 3906 | u32 opc = (u32)((le32_to_cpu(pHeader)) & 0xFFF); |
| 3907 | |
| 3908 | switch (opc) { |
| 3909 | case OPC_OUB_ECHO: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3910 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_ECHO\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3911 | break; |
| 3912 | case OPC_OUB_HW_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3913 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_HW_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3914 | mpi_hw_event(pm8001_ha, piomb); |
| 3915 | break; |
| 3916 | case OPC_OUB_THERM_HW_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3917 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_THERMAL_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3918 | mpi_thermal_hw_event(pm8001_ha, piomb); |
| 3919 | break; |
| 3920 | case OPC_OUB_SSP_COMP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3921 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SSP_COMP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3922 | mpi_ssp_completion(pm8001_ha, piomb); |
| 3923 | break; |
| 3924 | case OPC_OUB_SMP_COMP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3925 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SMP_COMP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3926 | mpi_smp_completion(pm8001_ha, piomb); |
| 3927 | break; |
| 3928 | case OPC_OUB_LOCAL_PHY_CNTRL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3929 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_LOCAL_PHY_CNTRL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3930 | pm8001_mpi_local_phy_ctl(pm8001_ha, piomb); |
| 3931 | break; |
| 3932 | case OPC_OUB_DEV_REGIST: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3933 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_DEV_REGIST\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3934 | pm8001_mpi_reg_resp(pm8001_ha, piomb); |
| 3935 | break; |
| 3936 | case OPC_OUB_DEREG_DEV: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3937 | pm8001_dbg(pm8001_ha, MSG, "unregister the device\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3938 | pm8001_mpi_dereg_resp(pm8001_ha, piomb); |
| 3939 | break; |
| 3940 | case OPC_OUB_GET_DEV_HANDLE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3941 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GET_DEV_HANDLE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3942 | break; |
| 3943 | case OPC_OUB_SATA_COMP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3944 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SATA_COMP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3945 | mpi_sata_completion(pm8001_ha, piomb); |
| 3946 | break; |
| 3947 | case OPC_OUB_SATA_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3948 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SATA_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3949 | mpi_sata_event(pm8001_ha, piomb); |
| 3950 | break; |
| 3951 | case OPC_OUB_SSP_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3952 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SSP_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3953 | mpi_ssp_event(pm8001_ha, piomb); |
| 3954 | break; |
| 3955 | case OPC_OUB_DEV_HANDLE_ARRIV: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3956 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_DEV_HANDLE_ARRIV\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3957 | /*This is for target*/ |
| 3958 | break; |
| 3959 | case OPC_OUB_SSP_RECV_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3960 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SSP_RECV_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3961 | /*This is for target*/ |
| 3962 | break; |
| 3963 | case OPC_OUB_FW_FLASH_UPDATE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3964 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_FW_FLASH_UPDATE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3965 | pm8001_mpi_fw_flash_update_resp(pm8001_ha, piomb); |
| 3966 | break; |
| 3967 | case OPC_OUB_GPIO_RESPONSE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3968 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GPIO_RESPONSE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3969 | break; |
| 3970 | case OPC_OUB_GPIO_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3971 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GPIO_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3972 | break; |
| 3973 | case OPC_OUB_GENERAL_EVENT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3974 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GENERAL_EVENT\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3975 | pm8001_mpi_general_event(pm8001_ha, piomb); |
| 3976 | break; |
| 3977 | case OPC_OUB_SSP_ABORT_RSP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3978 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SSP_ABORT_RSP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3979 | pm8001_mpi_task_abort_resp(pm8001_ha, piomb); |
| 3980 | break; |
| 3981 | case OPC_OUB_SATA_ABORT_RSP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3982 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SATA_ABORT_RSP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3983 | pm8001_mpi_task_abort_resp(pm8001_ha, piomb); |
| 3984 | break; |
| 3985 | case OPC_OUB_SAS_DIAG_MODE_START_END: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3986 | pm8001_dbg(pm8001_ha, MSG, |
| 3987 | "OPC_OUB_SAS_DIAG_MODE_START_END\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3988 | break; |
| 3989 | case OPC_OUB_SAS_DIAG_EXECUTE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3990 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SAS_DIAG_EXECUTE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3991 | break; |
| 3992 | case OPC_OUB_GET_TIME_STAMP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3993 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GET_TIME_STAMP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3994 | break; |
| 3995 | case OPC_OUB_SAS_HW_EVENT_ACK: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3996 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SAS_HW_EVENT_ACK\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 3997 | break; |
| 3998 | case OPC_OUB_PORT_CONTROL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 3999 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_PORT_CONTROL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4000 | break; |
| 4001 | case OPC_OUB_SMP_ABORT_RSP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4002 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SMP_ABORT_RSP\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4003 | pm8001_mpi_task_abort_resp(pm8001_ha, piomb); |
| 4004 | break; |
| 4005 | case OPC_OUB_GET_NVMD_DATA: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4006 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GET_NVMD_DATA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4007 | pm8001_mpi_get_nvmd_resp(pm8001_ha, piomb); |
| 4008 | break; |
| 4009 | case OPC_OUB_SET_NVMD_DATA: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4010 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SET_NVMD_DATA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4011 | pm8001_mpi_set_nvmd_resp(pm8001_ha, piomb); |
| 4012 | break; |
| 4013 | case OPC_OUB_DEVICE_HANDLE_REMOVAL: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4014 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_DEVICE_HANDLE_REMOVAL\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4015 | break; |
| 4016 | case OPC_OUB_SET_DEVICE_STATE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4017 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SET_DEVICE_STATE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4018 | pm8001_mpi_set_dev_state_resp(pm8001_ha, piomb); |
| 4019 | break; |
| 4020 | case OPC_OUB_GET_DEVICE_STATE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4021 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_GET_DEVICE_STATE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4022 | break; |
| 4023 | case OPC_OUB_SET_DEV_INFO: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4024 | pm8001_dbg(pm8001_ha, MSG, "OPC_OUB_SET_DEV_INFO\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4025 | break; |
| 4026 | /* spcv specifc commands */ |
| 4027 | case OPC_OUB_PHY_START_RESP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4028 | pm8001_dbg(pm8001_ha, MSG, |
| 4029 | "OPC_OUB_PHY_START_RESP opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4030 | mpi_phy_start_resp(pm8001_ha, piomb); |
| 4031 | break; |
| 4032 | case OPC_OUB_PHY_STOP_RESP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4033 | pm8001_dbg(pm8001_ha, MSG, |
| 4034 | "OPC_OUB_PHY_STOP_RESP opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4035 | mpi_phy_stop_resp(pm8001_ha, piomb); |
| 4036 | break; |
| 4037 | case OPC_OUB_SET_CONTROLLER_CONFIG: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4038 | pm8001_dbg(pm8001_ha, MSG, |
| 4039 | "OPC_OUB_SET_CONTROLLER_CONFIG opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4040 | mpi_set_controller_config_resp(pm8001_ha, piomb); |
| 4041 | break; |
| 4042 | case OPC_OUB_GET_CONTROLLER_CONFIG: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4043 | pm8001_dbg(pm8001_ha, MSG, |
| 4044 | "OPC_OUB_GET_CONTROLLER_CONFIG opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4045 | mpi_get_controller_config_resp(pm8001_ha, piomb); |
| 4046 | break; |
| 4047 | case OPC_OUB_GET_PHY_PROFILE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4048 | pm8001_dbg(pm8001_ha, MSG, |
| 4049 | "OPC_OUB_GET_PHY_PROFILE opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4050 | mpi_get_phy_profile_resp(pm8001_ha, piomb); |
| 4051 | break; |
| 4052 | case OPC_OUB_FLASH_OP_EXT: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4053 | pm8001_dbg(pm8001_ha, MSG, |
| 4054 | "OPC_OUB_FLASH_OP_EXT opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4055 | mpi_flash_op_ext_resp(pm8001_ha, piomb); |
| 4056 | break; |
| 4057 | case OPC_OUB_SET_PHY_PROFILE: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4058 | pm8001_dbg(pm8001_ha, MSG, |
| 4059 | "OPC_OUB_SET_PHY_PROFILE opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4060 | mpi_set_phy_profile_resp(pm8001_ha, piomb); |
| 4061 | break; |
| 4062 | case OPC_OUB_KEK_MANAGEMENT_RESP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4063 | pm8001_dbg(pm8001_ha, MSG, |
| 4064 | "OPC_OUB_KEK_MANAGEMENT_RESP opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4065 | mpi_kek_management_resp(pm8001_ha, piomb); |
| 4066 | break; |
| 4067 | case OPC_OUB_DEK_MANAGEMENT_RESP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4068 | pm8001_dbg(pm8001_ha, MSG, |
| 4069 | "OPC_OUB_DEK_MANAGEMENT_RESP opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4070 | mpi_dek_management_resp(pm8001_ha, piomb); |
| 4071 | break; |
| 4072 | case OPC_OUB_SSP_COALESCED_COMP_RESP: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4073 | pm8001_dbg(pm8001_ha, MSG, |
| 4074 | "OPC_OUB_SSP_COALESCED_COMP_RESP opcode:%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4075 | ssp_coalesced_comp_resp(pm8001_ha, piomb); |
| 4076 | break; |
| 4077 | default: |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4078 | pm8001_dbg(pm8001_ha, DEVIO, |
| 4079 | "Unknown outbound Queue IOMB OPC = 0x%x\n", opc); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4080 | break; |
| 4081 | } |
| 4082 | } |
| 4083 | |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4084 | static void print_scratchpad_registers(struct pm8001_hba_info *pm8001_ha) |
| 4085 | { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4086 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_SCRATCH_PAD_0: 0x%x\n", |
| 4087 | pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_0)); |
| 4088 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_SCRATCH_PAD_1:0x%x\n", |
| 4089 | pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1)); |
| 4090 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_SCRATCH_PAD_2: 0x%x\n", |
| 4091 | pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_2)); |
| 4092 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_SCRATCH_PAD_3: 0x%x\n", |
| 4093 | pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_3)); |
| 4094 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_0: 0x%x\n", |
| 4095 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_0)); |
| 4096 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_1: 0x%x\n", |
| 4097 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_1)); |
| 4098 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_2: 0x%x\n", |
| 4099 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_2)); |
| 4100 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_3: 0x%x\n", |
| 4101 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_3)); |
| 4102 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_4: 0x%x\n", |
| 4103 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_4)); |
| 4104 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_HOST_SCRATCH_PAD_5: 0x%x\n", |
| 4105 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_5)); |
| 4106 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_RSVD_SCRATCH_PAD_0: 0x%x\n", |
| 4107 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_6)); |
| 4108 | pm8001_dbg(pm8001_ha, FAIL, "MSGU_RSVD_SCRATCH_PAD_1: 0x%x\n", |
| 4109 | pm8001_cr32(pm8001_ha, 0, MSGU_HOST_SCRATCH_PAD_7)); |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4110 | } |
| 4111 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4112 | static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) |
| 4113 | { |
| 4114 | struct outbound_queue_table *circularQ; |
| 4115 | void *pMsg1 = NULL; |
Kees Cook | 3f649ab | 2020-06-03 13:09:38 -0700 | [diff] [blame] | 4116 | u8 bc; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4117 | u32 ret = MPI_IO_STATUS_FAIL; |
| 4118 | unsigned long flags; |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4119 | u32 regval; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4120 | |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 4121 | if (vec == (pm8001_ha->max_q_num - 1)) { |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4122 | regval = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); |
| 4123 | if ((regval & SCRATCH_PAD_MIPSALL_READY) != |
| 4124 | SCRATCH_PAD_MIPSALL_READY) { |
| 4125 | pm8001_ha->controller_fatal_error = true; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4126 | pm8001_dbg(pm8001_ha, FAIL, |
| 4127 | "Firmware Fatal error! Regval:0x%x\n", |
| 4128 | regval); |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4129 | print_scratchpad_registers(pm8001_ha); |
| 4130 | return ret; |
| 4131 | } |
| 4132 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4133 | spin_lock_irqsave(&pm8001_ha->lock, flags); |
| 4134 | circularQ = &pm8001_ha->outbnd_q_tbl[vec]; |
| 4135 | do { |
Deepak Ukey | 72349b6 | 2018-09-11 14:18:04 +0530 | [diff] [blame] | 4136 | /* spurious interrupt during setup if kexec-ing and |
| 4137 | * driver doing a doorbell access w/ the pre-kexec oq |
| 4138 | * interrupt setup. |
| 4139 | */ |
| 4140 | if (!circularQ->pi_virt) |
| 4141 | break; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4142 | ret = pm8001_mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc); |
| 4143 | if (MPI_IO_STATUS_SUCCESS == ret) { |
| 4144 | /* process the outbound message */ |
| 4145 | process_one_iomb(pm8001_ha, (void *)(pMsg1 - 4)); |
| 4146 | /* free the message from the outbound circular buffer */ |
| 4147 | pm8001_mpi_msg_free_set(pm8001_ha, pMsg1, |
| 4148 | circularQ, bc); |
| 4149 | } |
| 4150 | if (MPI_IO_STATUS_BUSY == ret) { |
| 4151 | /* Update the producer index from SPC */ |
| 4152 | circularQ->producer_index = |
| 4153 | cpu_to_le32(pm8001_read_32(circularQ->pi_virt)); |
| 4154 | if (le32_to_cpu(circularQ->producer_index) == |
| 4155 | circularQ->consumer_idx) |
| 4156 | /* OQ is empty */ |
| 4157 | break; |
| 4158 | } |
| 4159 | } while (1); |
| 4160 | spin_unlock_irqrestore(&pm8001_ha->lock, flags); |
| 4161 | return ret; |
| 4162 | } |
| 4163 | |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4164 | /* DMA_... to our direction translation. */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4165 | static const u8 data_dir_flags[] = { |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4166 | [DMA_BIDIRECTIONAL] = DATA_DIR_BYRECIPIENT, /* UNSPECIFIED */ |
| 4167 | [DMA_TO_DEVICE] = DATA_DIR_OUT, /* OUTBOUND */ |
| 4168 | [DMA_FROM_DEVICE] = DATA_DIR_IN, /* INBOUND */ |
| 4169 | [DMA_NONE] = DATA_DIR_NONE, /* NO TRANSFER */ |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4170 | }; |
| 4171 | |
| 4172 | static void build_smp_cmd(u32 deviceID, __le32 hTag, |
| 4173 | struct smp_req *psmp_cmd, int mode, int length) |
| 4174 | { |
| 4175 | psmp_cmd->tag = hTag; |
| 4176 | psmp_cmd->device_id = cpu_to_le32(deviceID); |
| 4177 | if (mode == SMP_DIRECT) { |
| 4178 | length = length - 4; /* subtract crc */ |
| 4179 | psmp_cmd->len_ip_ir = cpu_to_le32(length << 16); |
| 4180 | } else { |
| 4181 | psmp_cmd->len_ip_ir = cpu_to_le32(1|(1 << 1)); |
| 4182 | } |
| 4183 | } |
| 4184 | |
| 4185 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 4186 | * pm80xx_chip_smp_req - send a SMP task to FW |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4187 | * @pm8001_ha: our hba card information. |
| 4188 | * @ccb: the ccb information this request used. |
| 4189 | */ |
| 4190 | static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, |
| 4191 | struct pm8001_ccb_info *ccb) |
| 4192 | { |
| 4193 | int elem, rc; |
| 4194 | struct sas_task *task = ccb->task; |
| 4195 | struct domain_device *dev = task->dev; |
| 4196 | struct pm8001_device *pm8001_dev = dev->lldd_dev; |
| 4197 | struct scatterlist *sg_req, *sg_resp; |
| 4198 | u32 req_len, resp_len; |
| 4199 | struct smp_req smp_cmd; |
| 4200 | u32 opc; |
| 4201 | struct inbound_queue_table *circularQ; |
| 4202 | char *preq_dma_addr = NULL; |
| 4203 | __le64 tmp_addr; |
| 4204 | u32 i, length; |
| 4205 | |
| 4206 | memset(&smp_cmd, 0, sizeof(smp_cmd)); |
| 4207 | /* |
| 4208 | * DMA-map SMP request, response buffers |
| 4209 | */ |
| 4210 | sg_req = &task->smp_task.smp_req; |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4211 | elem = dma_map_sg(pm8001_ha->dev, sg_req, 1, DMA_TO_DEVICE); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4212 | if (!elem) |
| 4213 | return -ENOMEM; |
| 4214 | req_len = sg_dma_len(sg_req); |
| 4215 | |
| 4216 | sg_resp = &task->smp_task.smp_resp; |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4217 | elem = dma_map_sg(pm8001_ha->dev, sg_resp, 1, DMA_FROM_DEVICE); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4218 | if (!elem) { |
| 4219 | rc = -ENOMEM; |
| 4220 | goto err_out; |
| 4221 | } |
| 4222 | resp_len = sg_dma_len(sg_resp); |
| 4223 | /* must be in dwords */ |
| 4224 | if ((req_len & 0x3) || (resp_len & 0x3)) { |
| 4225 | rc = -EINVAL; |
| 4226 | goto err_out_2; |
| 4227 | } |
| 4228 | |
| 4229 | opc = OPC_INB_SMP_REQUEST; |
| 4230 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4231 | smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); |
| 4232 | |
| 4233 | length = sg_req->length; |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4234 | pm8001_dbg(pm8001_ha, IO, "SMP Frame Length %d\n", sg_req->length); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4235 | if (!(length - 8)) |
| 4236 | pm8001_ha->smp_exp_mode = SMP_DIRECT; |
| 4237 | else |
| 4238 | pm8001_ha->smp_exp_mode = SMP_INDIRECT; |
| 4239 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4240 | |
| 4241 | tmp_addr = cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req)); |
| 4242 | preq_dma_addr = (char *)phys_to_virt(tmp_addr); |
| 4243 | |
| 4244 | /* INDIRECT MODE command settings. Use DMA */ |
| 4245 | if (pm8001_ha->smp_exp_mode == SMP_INDIRECT) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4246 | pm8001_dbg(pm8001_ha, IO, "SMP REQUEST INDIRECT MODE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4247 | /* for SPCv indirect mode. Place the top 4 bytes of |
| 4248 | * SMP Request header here. */ |
| 4249 | for (i = 0; i < 4; i++) |
| 4250 | smp_cmd.smp_req16[i] = *(preq_dma_addr + i); |
| 4251 | /* exclude top 4 bytes for SMP req header */ |
| 4252 | smp_cmd.long_smp_req.long_req_addr = |
| 4253 | cpu_to_le64((u64)sg_dma_address |
Anand Kumar Santhanam | cb993e5 | 2013-09-17 14:37:14 +0530 | [diff] [blame] | 4254 | (&task->smp_task.smp_req) + 4); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4255 | /* exclude 4 bytes for SMP req header and CRC */ |
| 4256 | smp_cmd.long_smp_req.long_req_size = |
| 4257 | cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-8); |
| 4258 | smp_cmd.long_smp_req.long_resp_addr = |
| 4259 | cpu_to_le64((u64)sg_dma_address |
| 4260 | (&task->smp_task.smp_resp)); |
| 4261 | smp_cmd.long_smp_req.long_resp_size = |
| 4262 | cpu_to_le32((u32)sg_dma_len |
| 4263 | (&task->smp_task.smp_resp)-4); |
| 4264 | } else { /* DIRECT MODE */ |
| 4265 | smp_cmd.long_smp_req.long_req_addr = |
| 4266 | cpu_to_le64((u64)sg_dma_address |
| 4267 | (&task->smp_task.smp_req)); |
| 4268 | smp_cmd.long_smp_req.long_req_size = |
| 4269 | cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-4); |
| 4270 | smp_cmd.long_smp_req.long_resp_addr = |
| 4271 | cpu_to_le64((u64)sg_dma_address |
| 4272 | (&task->smp_task.smp_resp)); |
| 4273 | smp_cmd.long_smp_req.long_resp_size = |
| 4274 | cpu_to_le32 |
| 4275 | ((u32)sg_dma_len(&task->smp_task.smp_resp)-4); |
| 4276 | } |
| 4277 | if (pm8001_ha->smp_exp_mode == SMP_DIRECT) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4278 | pm8001_dbg(pm8001_ha, IO, "SMP REQUEST DIRECT MODE\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4279 | for (i = 0; i < length; i++) |
| 4280 | if (i < 16) { |
| 4281 | smp_cmd.smp_req16[i] = *(preq_dma_addr+i); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4282 | pm8001_dbg(pm8001_ha, IO, |
| 4283 | "Byte[%d]:%x (DMA data:%x)\n", |
| 4284 | i, smp_cmd.smp_req16[i], |
| 4285 | *(preq_dma_addr)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4286 | } else { |
| 4287 | smp_cmd.smp_req[i] = *(preq_dma_addr+i); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4288 | pm8001_dbg(pm8001_ha, IO, |
| 4289 | "Byte[%d]:%x (DMA data:%x)\n", |
| 4290 | i, smp_cmd.smp_req[i], |
| 4291 | *(preq_dma_addr)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4292 | } |
| 4293 | } |
| 4294 | |
| 4295 | build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, |
| 4296 | &smp_cmd, pm8001_ha->smp_exp_mode, length); |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4297 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &smp_cmd, |
| 4298 | sizeof(smp_cmd), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 4299 | if (rc) |
| 4300 | goto err_out_2; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4301 | return 0; |
| 4302 | |
| 4303 | err_out_2: |
| 4304 | dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_resp, 1, |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4305 | DMA_FROM_DEVICE); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4306 | err_out: |
| 4307 | dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_req, 1, |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4308 | DMA_TO_DEVICE); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4309 | return rc; |
| 4310 | } |
| 4311 | |
| 4312 | static int check_enc_sas_cmd(struct sas_task *task) |
| 4313 | { |
James Bottomley | e73823f | 2013-05-07 15:38:18 -0700 | [diff] [blame] | 4314 | u8 cmd = task->ssp_task.cmd->cmnd[0]; |
| 4315 | |
| 4316 | if (cmd == READ_10 || cmd == WRITE_10 || cmd == WRITE_VERIFY) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4317 | return 1; |
| 4318 | else |
| 4319 | return 0; |
| 4320 | } |
| 4321 | |
| 4322 | static int check_enc_sat_cmd(struct sas_task *task) |
| 4323 | { |
| 4324 | int ret = 0; |
| 4325 | switch (task->ata_task.fis.command) { |
| 4326 | case ATA_CMD_FPDMA_READ: |
| 4327 | case ATA_CMD_READ_EXT: |
| 4328 | case ATA_CMD_READ: |
| 4329 | case ATA_CMD_FPDMA_WRITE: |
| 4330 | case ATA_CMD_WRITE_EXT: |
| 4331 | case ATA_CMD_WRITE: |
| 4332 | case ATA_CMD_PIO_READ: |
| 4333 | case ATA_CMD_PIO_READ_EXT: |
| 4334 | case ATA_CMD_PIO_WRITE: |
| 4335 | case ATA_CMD_PIO_WRITE_EXT: |
| 4336 | ret = 1; |
| 4337 | break; |
| 4338 | default: |
| 4339 | ret = 0; |
| 4340 | break; |
| 4341 | } |
| 4342 | return ret; |
| 4343 | } |
| 4344 | |
| 4345 | /** |
| 4346 | * pm80xx_chip_ssp_io_req - send a SSP task to FW |
| 4347 | * @pm8001_ha: our hba card information. |
| 4348 | * @ccb: the ccb information this request used. |
| 4349 | */ |
| 4350 | static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, |
| 4351 | struct pm8001_ccb_info *ccb) |
| 4352 | { |
| 4353 | struct sas_task *task = ccb->task; |
| 4354 | struct domain_device *dev = task->dev; |
| 4355 | struct pm8001_device *pm8001_dev = dev->lldd_dev; |
| 4356 | struct ssp_ini_io_start_req ssp_cmd; |
| 4357 | u32 tag = ccb->ccb_tag; |
| 4358 | int ret; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4359 | u64 phys_addr, start_addr, end_addr; |
| 4360 | u32 end_addr_high, end_addr_low; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4361 | struct inbound_queue_table *circularQ; |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 4362 | u32 q_index, cpu_id; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4363 | u32 opc = OPC_INB_SSPINIIOSTART; |
| 4364 | memset(&ssp_cmd, 0, sizeof(ssp_cmd)); |
| 4365 | memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); |
| 4366 | /* data address domain added for spcv; set to 0 by host, |
| 4367 | * used internally by controller |
| 4368 | * 0 for SAS 1.1 and SAS 2.0 compatible TLR |
| 4369 | */ |
| 4370 | ssp_cmd.dad_dir_m_tlr = |
| 4371 | cpu_to_le32(data_dir_flags[task->data_dir] << 8 | 0x0); |
| 4372 | ssp_cmd.data_len = cpu_to_le32(task->total_xfer_len); |
| 4373 | ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id); |
| 4374 | ssp_cmd.tag = cpu_to_le32(tag); |
| 4375 | if (task->ssp_task.enable_first_burst) |
| 4376 | ssp_cmd.ssp_iu.efb_prio_attr |= 0x80; |
| 4377 | ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_prio << 3); |
| 4378 | ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); |
James Bottomley | e73823f | 2013-05-07 15:38:18 -0700 | [diff] [blame] | 4379 | memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, |
| 4380 | task->ssp_task.cmd->cmd_len); |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 4381 | cpu_id = smp_processor_id(); |
| 4382 | q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); |
Anand Kumar Santhanam | f9cd6cb | 2013-09-18 11:12:59 +0530 | [diff] [blame] | 4383 | circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4384 | |
| 4385 | /* Check if encryption is set */ |
| 4386 | if (pm8001_ha->chip->encrypt && |
| 4387 | !(pm8001_ha->encrypt_info.status) && check_enc_sas_cmd(task)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4388 | pm8001_dbg(pm8001_ha, IO, |
| 4389 | "Encryption enabled.Sending Encrypt SAS command 0x%x\n", |
| 4390 | task->ssp_task.cmd->cmnd[0]); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4391 | opc = OPC_INB_SSP_INI_DIF_ENC_IO; |
| 4392 | /* enable encryption. 0 for SAS 1.1 and SAS 2.0 compatible TLR*/ |
| 4393 | ssp_cmd.dad_dir_m_tlr = cpu_to_le32 |
| 4394 | ((data_dir_flags[task->data_dir] << 8) | 0x20 | 0x0); |
| 4395 | |
| 4396 | /* fill in PRD (scatter/gather) table, if any */ |
| 4397 | if (task->num_scatter > 1) { |
| 4398 | pm8001_chip_make_sg(task->scatter, |
| 4399 | ccb->n_elem, ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4400 | phys_addr = ccb->ccb_dma_handle; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4401 | ssp_cmd.enc_addr_low = |
| 4402 | cpu_to_le32(lower_32_bits(phys_addr)); |
| 4403 | ssp_cmd.enc_addr_high = |
| 4404 | cpu_to_le32(upper_32_bits(phys_addr)); |
| 4405 | ssp_cmd.enc_esgl = cpu_to_le32(1<<31); |
| 4406 | } else if (task->num_scatter == 1) { |
| 4407 | u64 dma_addr = sg_dma_address(task->scatter); |
| 4408 | ssp_cmd.enc_addr_low = |
| 4409 | cpu_to_le32(lower_32_bits(dma_addr)); |
| 4410 | ssp_cmd.enc_addr_high = |
| 4411 | cpu_to_le32(upper_32_bits(dma_addr)); |
| 4412 | ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); |
| 4413 | ssp_cmd.enc_esgl = 0; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4414 | /* Check 4G Boundary */ |
| 4415 | start_addr = cpu_to_le64(dma_addr); |
| 4416 | end_addr = (start_addr + ssp_cmd.enc_len) - 1; |
| 4417 | end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); |
| 4418 | end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); |
| 4419 | if (end_addr_high != ssp_cmd.enc_addr_high) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4420 | pm8001_dbg(pm8001_ha, FAIL, |
| 4421 | "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", |
| 4422 | start_addr, ssp_cmd.enc_len, |
| 4423 | end_addr_high, end_addr_low); |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4424 | pm8001_chip_make_sg(task->scatter, 1, |
| 4425 | ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4426 | phys_addr = ccb->ccb_dma_handle; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4427 | ssp_cmd.enc_addr_low = |
| 4428 | cpu_to_le32(lower_32_bits(phys_addr)); |
| 4429 | ssp_cmd.enc_addr_high = |
| 4430 | cpu_to_le32(upper_32_bits(phys_addr)); |
| 4431 | ssp_cmd.enc_esgl = cpu_to_le32(1<<31); |
| 4432 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4433 | } else if (task->num_scatter == 0) { |
| 4434 | ssp_cmd.enc_addr_low = 0; |
| 4435 | ssp_cmd.enc_addr_high = 0; |
| 4436 | ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); |
| 4437 | ssp_cmd.enc_esgl = 0; |
| 4438 | } |
| 4439 | /* XTS mode. All other fields are 0 */ |
| 4440 | ssp_cmd.key_cmode = 0x6 << 4; |
| 4441 | /* set tweak values. Should be the start lba */ |
James Bottomley | e73823f | 2013-05-07 15:38:18 -0700 | [diff] [blame] | 4442 | ssp_cmd.twk_val0 = cpu_to_le32((task->ssp_task.cmd->cmnd[2] << 24) | |
| 4443 | (task->ssp_task.cmd->cmnd[3] << 16) | |
| 4444 | (task->ssp_task.cmd->cmnd[4] << 8) | |
| 4445 | (task->ssp_task.cmd->cmnd[5])); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4446 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4447 | pm8001_dbg(pm8001_ha, IO, |
| 4448 | "Sending Normal SAS command 0x%x inb q %x\n", |
| 4449 | task->ssp_task.cmd->cmnd[0], q_index); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4450 | /* fill in PRD (scatter/gather) table, if any */ |
| 4451 | if (task->num_scatter > 1) { |
| 4452 | pm8001_chip_make_sg(task->scatter, ccb->n_elem, |
| 4453 | ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4454 | phys_addr = ccb->ccb_dma_handle; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4455 | ssp_cmd.addr_low = |
| 4456 | cpu_to_le32(lower_32_bits(phys_addr)); |
| 4457 | ssp_cmd.addr_high = |
| 4458 | cpu_to_le32(upper_32_bits(phys_addr)); |
| 4459 | ssp_cmd.esgl = cpu_to_le32(1<<31); |
| 4460 | } else if (task->num_scatter == 1) { |
| 4461 | u64 dma_addr = sg_dma_address(task->scatter); |
| 4462 | ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(dma_addr)); |
| 4463 | ssp_cmd.addr_high = |
| 4464 | cpu_to_le32(upper_32_bits(dma_addr)); |
| 4465 | ssp_cmd.len = cpu_to_le32(task->total_xfer_len); |
| 4466 | ssp_cmd.esgl = 0; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4467 | /* Check 4G Boundary */ |
| 4468 | start_addr = cpu_to_le64(dma_addr); |
| 4469 | end_addr = (start_addr + ssp_cmd.len) - 1; |
| 4470 | end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); |
| 4471 | end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); |
| 4472 | if (end_addr_high != ssp_cmd.addr_high) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4473 | pm8001_dbg(pm8001_ha, FAIL, |
| 4474 | "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", |
| 4475 | start_addr, ssp_cmd.len, |
| 4476 | end_addr_high, end_addr_low); |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4477 | pm8001_chip_make_sg(task->scatter, 1, |
| 4478 | ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4479 | phys_addr = ccb->ccb_dma_handle; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4480 | ssp_cmd.addr_low = |
| 4481 | cpu_to_le32(lower_32_bits(phys_addr)); |
| 4482 | ssp_cmd.addr_high = |
| 4483 | cpu_to_le32(upper_32_bits(phys_addr)); |
| 4484 | ssp_cmd.esgl = cpu_to_le32(1<<31); |
| 4485 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4486 | } else if (task->num_scatter == 0) { |
| 4487 | ssp_cmd.addr_low = 0; |
| 4488 | ssp_cmd.addr_high = 0; |
| 4489 | ssp_cmd.len = cpu_to_le32(task->total_xfer_len); |
| 4490 | ssp_cmd.esgl = 0; |
| 4491 | } |
| 4492 | } |
Anand Kumar Santhanam | f9cd6cb | 2013-09-18 11:12:59 +0530 | [diff] [blame] | 4493 | ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4494 | &ssp_cmd, sizeof(ssp_cmd), q_index); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4495 | return ret; |
| 4496 | } |
| 4497 | |
| 4498 | static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, |
| 4499 | struct pm8001_ccb_info *ccb) |
| 4500 | { |
| 4501 | struct sas_task *task = ccb->task; |
| 4502 | struct domain_device *dev = task->dev; |
| 4503 | struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; |
| 4504 | u32 tag = ccb->ccb_tag; |
| 4505 | int ret; |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 4506 | u32 q_index, cpu_id; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4507 | struct sata_start_req sata_cmd; |
| 4508 | u32 hdr_tag, ncg_tag = 0; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4509 | u64 phys_addr, start_addr, end_addr; |
| 4510 | u32 end_addr_high, end_addr_low; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4511 | u32 ATAP = 0x0; |
| 4512 | u32 dir; |
| 4513 | struct inbound_queue_table *circularQ; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4514 | unsigned long flags; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4515 | u32 opc = OPC_INB_SATA_HOST_OPSTART; |
| 4516 | memset(&sata_cmd, 0, sizeof(sata_cmd)); |
Viswas G | 05c6c02 | 2020-10-05 20:20:08 +0530 | [diff] [blame] | 4517 | cpu_id = smp_processor_id(); |
| 4518 | q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); |
Anand Kumar Santhanam | f9cd6cb | 2013-09-18 11:12:59 +0530 | [diff] [blame] | 4519 | circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4520 | |
Christoph Hellwig | f73bdeb | 2018-10-10 19:59:50 +0200 | [diff] [blame] | 4521 | if (task->data_dir == DMA_NONE) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4522 | ATAP = 0x04; /* no data*/ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4523 | pm8001_dbg(pm8001_ha, IO, "no data\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4524 | } else if (likely(!task->ata_task.device_control_reg_update)) { |
| 4525 | if (task->ata_task.dma_xfer) { |
| 4526 | ATAP = 0x06; /* DMA */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4527 | pm8001_dbg(pm8001_ha, IO, "DMA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4528 | } else { |
| 4529 | ATAP = 0x05; /* PIO*/ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4530 | pm8001_dbg(pm8001_ha, IO, "PIO\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4531 | } |
| 4532 | if (task->ata_task.use_ncq && |
Hannes Reinecke | 1cbd772 | 2014-11-05 13:08:20 +0100 | [diff] [blame] | 4533 | dev->sata_dev.class != ATA_DEV_ATAPI) { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4534 | ATAP = 0x07; /* FPDMA */ |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4535 | pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4536 | } |
| 4537 | } |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4538 | if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { |
| 4539 | task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4540 | ncg_tag = hdr_tag; |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4541 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4542 | dir = data_dir_flags[task->data_dir] << 8; |
| 4543 | sata_cmd.tag = cpu_to_le32(tag); |
| 4544 | sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); |
| 4545 | sata_cmd.data_len = cpu_to_le32(task->total_xfer_len); |
| 4546 | |
| 4547 | sata_cmd.sata_fis = task->ata_task.fis; |
| 4548 | if (likely(!task->ata_task.device_control_reg_update)) |
| 4549 | sata_cmd.sata_fis.flags |= 0x80;/* C=1: update ATA cmd reg */ |
| 4550 | sata_cmd.sata_fis.flags &= 0xF0;/* PM_PORT field shall be 0 */ |
| 4551 | |
| 4552 | /* Check if encryption is set */ |
| 4553 | if (pm8001_ha->chip->encrypt && |
| 4554 | !(pm8001_ha->encrypt_info.status) && check_enc_sat_cmd(task)) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4555 | pm8001_dbg(pm8001_ha, IO, |
| 4556 | "Encryption enabled.Sending Encrypt SATA cmd 0x%x\n", |
| 4557 | sata_cmd.sata_fis.command); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4558 | opc = OPC_INB_SATA_DIF_ENC_IO; |
| 4559 | |
| 4560 | /* set encryption bit */ |
| 4561 | sata_cmd.ncqtag_atap_dir_m_dad = |
| 4562 | cpu_to_le32(((ncg_tag & 0xff)<<16)| |
| 4563 | ((ATAP & 0x3f) << 10) | 0x20 | dir); |
| 4564 | /* dad (bit 0-1) is 0 */ |
| 4565 | /* fill in PRD (scatter/gather) table, if any */ |
| 4566 | if (task->num_scatter > 1) { |
| 4567 | pm8001_chip_make_sg(task->scatter, |
| 4568 | ccb->n_elem, ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4569 | phys_addr = ccb->ccb_dma_handle; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4570 | sata_cmd.enc_addr_low = lower_32_bits(phys_addr); |
| 4571 | sata_cmd.enc_addr_high = upper_32_bits(phys_addr); |
| 4572 | sata_cmd.enc_esgl = cpu_to_le32(1 << 31); |
| 4573 | } else if (task->num_scatter == 1) { |
| 4574 | u64 dma_addr = sg_dma_address(task->scatter); |
| 4575 | sata_cmd.enc_addr_low = lower_32_bits(dma_addr); |
| 4576 | sata_cmd.enc_addr_high = upper_32_bits(dma_addr); |
| 4577 | sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); |
| 4578 | sata_cmd.enc_esgl = 0; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4579 | /* Check 4G Boundary */ |
| 4580 | start_addr = cpu_to_le64(dma_addr); |
| 4581 | end_addr = (start_addr + sata_cmd.enc_len) - 1; |
| 4582 | end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); |
| 4583 | end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); |
| 4584 | if (end_addr_high != sata_cmd.enc_addr_high) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4585 | pm8001_dbg(pm8001_ha, FAIL, |
| 4586 | "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", |
| 4587 | start_addr, sata_cmd.enc_len, |
| 4588 | end_addr_high, end_addr_low); |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4589 | pm8001_chip_make_sg(task->scatter, 1, |
| 4590 | ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4591 | phys_addr = ccb->ccb_dma_handle; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4592 | sata_cmd.enc_addr_low = |
| 4593 | lower_32_bits(phys_addr); |
| 4594 | sata_cmd.enc_addr_high = |
| 4595 | upper_32_bits(phys_addr); |
| 4596 | sata_cmd.enc_esgl = |
| 4597 | cpu_to_le32(1 << 31); |
| 4598 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4599 | } else if (task->num_scatter == 0) { |
| 4600 | sata_cmd.enc_addr_low = 0; |
| 4601 | sata_cmd.enc_addr_high = 0; |
| 4602 | sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); |
| 4603 | sata_cmd.enc_esgl = 0; |
| 4604 | } |
| 4605 | /* XTS mode. All other fields are 0 */ |
| 4606 | sata_cmd.key_index_mode = 0x6 << 4; |
| 4607 | /* set tweak values. Should be the start lba */ |
| 4608 | sata_cmd.twk_val0 = |
| 4609 | cpu_to_le32((sata_cmd.sata_fis.lbal_exp << 24) | |
| 4610 | (sata_cmd.sata_fis.lbah << 16) | |
| 4611 | (sata_cmd.sata_fis.lbam << 8) | |
| 4612 | (sata_cmd.sata_fis.lbal)); |
| 4613 | sata_cmd.twk_val1 = |
| 4614 | cpu_to_le32((sata_cmd.sata_fis.lbah_exp << 8) | |
| 4615 | (sata_cmd.sata_fis.lbam_exp)); |
| 4616 | } else { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4617 | pm8001_dbg(pm8001_ha, IO, |
| 4618 | "Sending Normal SATA command 0x%x inb %x\n", |
| 4619 | sata_cmd.sata_fis.command, q_index); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4620 | /* dad (bit 0-1) is 0 */ |
| 4621 | sata_cmd.ncqtag_atap_dir_m_dad = |
| 4622 | cpu_to_le32(((ncg_tag & 0xff)<<16) | |
| 4623 | ((ATAP & 0x3f) << 10) | dir); |
| 4624 | |
| 4625 | /* fill in PRD (scatter/gather) table, if any */ |
| 4626 | if (task->num_scatter > 1) { |
| 4627 | pm8001_chip_make_sg(task->scatter, |
| 4628 | ccb->n_elem, ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4629 | phys_addr = ccb->ccb_dma_handle; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4630 | sata_cmd.addr_low = lower_32_bits(phys_addr); |
| 4631 | sata_cmd.addr_high = upper_32_bits(phys_addr); |
| 4632 | sata_cmd.esgl = cpu_to_le32(1 << 31); |
| 4633 | } else if (task->num_scatter == 1) { |
| 4634 | u64 dma_addr = sg_dma_address(task->scatter); |
| 4635 | sata_cmd.addr_low = lower_32_bits(dma_addr); |
| 4636 | sata_cmd.addr_high = upper_32_bits(dma_addr); |
| 4637 | sata_cmd.len = cpu_to_le32(task->total_xfer_len); |
| 4638 | sata_cmd.esgl = 0; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4639 | /* Check 4G Boundary */ |
| 4640 | start_addr = cpu_to_le64(dma_addr); |
| 4641 | end_addr = (start_addr + sata_cmd.len) - 1; |
| 4642 | end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); |
| 4643 | end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); |
| 4644 | if (end_addr_high != sata_cmd.addr_high) { |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4645 | pm8001_dbg(pm8001_ha, FAIL, |
| 4646 | "The sg list address start_addr=0x%016llx data_len=0x%xend_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", |
| 4647 | start_addr, sata_cmd.len, |
| 4648 | end_addr_high, end_addr_low); |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4649 | pm8001_chip_make_sg(task->scatter, 1, |
| 4650 | ccb->buf_prd); |
Viswas G | 5a14131 | 2020-10-05 20:20:10 +0530 | [diff] [blame] | 4651 | phys_addr = ccb->ccb_dma_handle; |
Anand Kumar Santhanam | 0ecdf00 | 2013-09-18 11:14:54 +0530 | [diff] [blame] | 4652 | sata_cmd.addr_low = |
| 4653 | lower_32_bits(phys_addr); |
| 4654 | sata_cmd.addr_high = |
| 4655 | upper_32_bits(phys_addr); |
| 4656 | sata_cmd.esgl = cpu_to_le32(1 << 31); |
| 4657 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4658 | } else if (task->num_scatter == 0) { |
| 4659 | sata_cmd.addr_low = 0; |
| 4660 | sata_cmd.addr_high = 0; |
| 4661 | sata_cmd.len = cpu_to_le32(task->total_xfer_len); |
| 4662 | sata_cmd.esgl = 0; |
| 4663 | } |
Colin Ian King | 9e2a07e | 2019-03-17 18:15:32 +0000 | [diff] [blame] | 4664 | /* scsi cdb */ |
| 4665 | sata_cmd.atapi_scsi_cdb[0] = |
| 4666 | cpu_to_le32(((task->ata_task.atapi_packet[0]) | |
| 4667 | (task->ata_task.atapi_packet[1] << 8) | |
| 4668 | (task->ata_task.atapi_packet[2] << 16) | |
| 4669 | (task->ata_task.atapi_packet[3] << 24))); |
| 4670 | sata_cmd.atapi_scsi_cdb[1] = |
| 4671 | cpu_to_le32(((task->ata_task.atapi_packet[4]) | |
| 4672 | (task->ata_task.atapi_packet[5] << 8) | |
| 4673 | (task->ata_task.atapi_packet[6] << 16) | |
| 4674 | (task->ata_task.atapi_packet[7] << 24))); |
| 4675 | sata_cmd.atapi_scsi_cdb[2] = |
| 4676 | cpu_to_le32(((task->ata_task.atapi_packet[8]) | |
| 4677 | (task->ata_task.atapi_packet[9] << 8) | |
| 4678 | (task->ata_task.atapi_packet[10] << 16) | |
| 4679 | (task->ata_task.atapi_packet[11] << 24))); |
| 4680 | sata_cmd.atapi_scsi_cdb[3] = |
| 4681 | cpu_to_le32(((task->ata_task.atapi_packet[12]) | |
| 4682 | (task->ata_task.atapi_packet[13] << 8) | |
| 4683 | (task->ata_task.atapi_packet[14] << 16) | |
| 4684 | (task->ata_task.atapi_packet[15] << 24))); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4685 | } |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4686 | |
| 4687 | /* Check for read log for failed drive and return */ |
| 4688 | if (sata_cmd.sata_fis.command == 0x2f) { |
| 4689 | if (pm8001_ha_dev && ((pm8001_ha_dev->id & NCQ_READ_LOG_FLAG) || |
| 4690 | (pm8001_ha_dev->id & NCQ_ABORT_ALL_FLAG) || |
| 4691 | (pm8001_ha_dev->id & NCQ_2ND_RLE_FLAG))) { |
| 4692 | struct task_status_struct *ts; |
| 4693 | |
| 4694 | pm8001_ha_dev->id &= 0xDFFFFFFF; |
| 4695 | ts = &task->task_status; |
| 4696 | |
| 4697 | spin_lock_irqsave(&task->task_state_lock, flags); |
| 4698 | ts->resp = SAS_TASK_COMPLETE; |
| 4699 | ts->stat = SAM_STAT_GOOD; |
| 4700 | task->task_state_flags &= ~SAS_TASK_STATE_PENDING; |
| 4701 | task->task_state_flags &= ~SAS_TASK_AT_INITIATOR; |
| 4702 | task->task_state_flags |= SAS_TASK_STATE_DONE; |
| 4703 | if (unlikely((task->task_state_flags & |
| 4704 | SAS_TASK_STATE_ABORTED))) { |
| 4705 | spin_unlock_irqrestore(&task->task_state_lock, |
| 4706 | flags); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4707 | pm8001_dbg(pm8001_ha, FAIL, |
| 4708 | "task 0x%p resp 0x%x stat 0x%x but aborted by upper layer\n", |
| 4709 | task, ts->resp, |
| 4710 | ts->stat); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4711 | pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); |
| 4712 | return 0; |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 4713 | } else { |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4714 | spin_unlock_irqrestore(&task->task_state_lock, |
| 4715 | flags); |
Suresh Thiagarajan | 2b01d81 | 2014-01-16 15:26:21 +0530 | [diff] [blame] | 4716 | pm8001_ccb_task_free_done(pm8001_ha, task, |
| 4717 | ccb, tag); |
Viswas G | 4a2efd4 | 2020-11-02 22:25:26 +0530 | [diff] [blame] | 4718 | atomic_dec(&pm8001_ha_dev->running_req); |
Sakthivel K | c6b9ef5 | 2013-03-19 18:08:08 +0530 | [diff] [blame] | 4719 | return 0; |
| 4720 | } |
| 4721 | } |
| 4722 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4723 | ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4724 | &sata_cmd, sizeof(sata_cmd), q_index); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4725 | return ret; |
| 4726 | } |
| 4727 | |
| 4728 | /** |
| 4729 | * pm80xx_chip_phy_start_req - start phy via PHY_START COMMAND |
| 4730 | * @pm8001_ha: our hba card information. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4731 | * @phy_id: the phy id which we wanted to start up. |
| 4732 | */ |
| 4733 | static int |
| 4734 | pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) |
| 4735 | { |
| 4736 | struct phy_start_req payload; |
| 4737 | struct inbound_queue_table *circularQ; |
| 4738 | int ret; |
| 4739 | u32 tag = 0x01; |
| 4740 | u32 opcode = OPC_INB_PHYSTART; |
| 4741 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4742 | memset(&payload, 0, sizeof(payload)); |
| 4743 | payload.tag = cpu_to_le32(tag); |
| 4744 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4745 | pm8001_dbg(pm8001_ha, INIT, "PHY START REQ for phy_id %d\n", phy_id); |
Anand Kumar Santhanam | a9a923e | 2013-09-03 15:09:42 +0530 | [diff] [blame] | 4746 | |
peter chang | 3e253d9 | 2019-11-14 15:39:07 +0530 | [diff] [blame] | 4747 | payload.ase_sh_lm_slr_phyid = cpu_to_le32(SPINHOLD_DISABLE | |
| 4748 | LINKMODE_AUTO | pm8001_ha->link_rate | phy_id); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4749 | /* SSC Disable and SAS Analog ST configuration */ |
| 4750 | /** |
| 4751 | payload.ase_sh_lm_slr_phyid = |
| 4752 | cpu_to_le32(SSC_DISABLE_30 | SAS_ASE | SPINHOLD_DISABLE | |
| 4753 | LINKMODE_AUTO | LINKRATE_15 | LINKRATE_30 | LINKRATE_60 | |
| 4754 | phy_id); |
| 4755 | Have to add "SAS PHY Analog Setup SPASTI 1 Byte" Based on need |
| 4756 | **/ |
| 4757 | |
James Bottomley | aa9f832 | 2013-05-07 14:44:06 -0700 | [diff] [blame] | 4758 | payload.sas_identify.dev_type = SAS_END_DEVICE; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4759 | payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; |
| 4760 | memcpy(payload.sas_identify.sas_addr, |
peter chang | 3e253d9 | 2019-11-14 15:39:07 +0530 | [diff] [blame] | 4761 | &pm8001_ha->sas_addr, SAS_ADDR_SIZE); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4762 | payload.sas_identify.phy_id = phy_id; |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4763 | ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, |
| 4764 | sizeof(payload), 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4765 | return ret; |
| 4766 | } |
| 4767 | |
| 4768 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 4769 | * pm80xx_chip_phy_stop_req - start phy via PHY_STOP COMMAND |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4770 | * @pm8001_ha: our hba card information. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4771 | * @phy_id: the phy id which we wanted to start up. |
| 4772 | */ |
| 4773 | static int pm80xx_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, |
| 4774 | u8 phy_id) |
| 4775 | { |
| 4776 | struct phy_stop_req payload; |
| 4777 | struct inbound_queue_table *circularQ; |
| 4778 | int ret; |
| 4779 | u32 tag = 0x01; |
| 4780 | u32 opcode = OPC_INB_PHYSTOP; |
| 4781 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4782 | memset(&payload, 0, sizeof(payload)); |
| 4783 | payload.tag = cpu_to_le32(tag); |
| 4784 | payload.phy_id = cpu_to_le32(phy_id); |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4785 | ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, |
| 4786 | sizeof(payload), 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4787 | return ret; |
| 4788 | } |
| 4789 | |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 4790 | /* |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4791 | * see comments on pm8001_mpi_reg_resp. |
| 4792 | */ |
| 4793 | static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, |
| 4794 | struct pm8001_device *pm8001_dev, u32 flag) |
| 4795 | { |
| 4796 | struct reg_dev_req payload; |
| 4797 | u32 opc; |
| 4798 | u32 stp_sspsmp_sata = 0x4; |
| 4799 | struct inbound_queue_table *circularQ; |
| 4800 | u32 linkrate, phy_id; |
| 4801 | int rc, tag = 0xdeadbeef; |
| 4802 | struct pm8001_ccb_info *ccb; |
| 4803 | u8 retryFlag = 0x1; |
| 4804 | u16 firstBurstSize = 0; |
| 4805 | u16 ITNT = 2000; |
| 4806 | struct domain_device *dev = pm8001_dev->sas_device; |
| 4807 | struct domain_device *parent_dev = dev->parent; |
| 4808 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4809 | |
| 4810 | memset(&payload, 0, sizeof(payload)); |
| 4811 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 4812 | if (rc) |
| 4813 | return rc; |
| 4814 | ccb = &pm8001_ha->ccb_info[tag]; |
| 4815 | ccb->device = pm8001_dev; |
| 4816 | ccb->ccb_tag = tag; |
| 4817 | payload.tag = cpu_to_le32(tag); |
| 4818 | |
| 4819 | if (flag == 1) { |
| 4820 | stp_sspsmp_sata = 0x02; /*direct attached sata */ |
| 4821 | } else { |
James Bottomley | aa9f832 | 2013-05-07 14:44:06 -0700 | [diff] [blame] | 4822 | if (pm8001_dev->dev_type == SAS_SATA_DEV) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4823 | stp_sspsmp_sata = 0x00; /* stp*/ |
James Bottomley | aa9f832 | 2013-05-07 14:44:06 -0700 | [diff] [blame] | 4824 | else if (pm8001_dev->dev_type == SAS_END_DEVICE || |
| 4825 | pm8001_dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
| 4826 | pm8001_dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4827 | stp_sspsmp_sata = 0x01; /*ssp or smp*/ |
| 4828 | } |
John Garry | 924a354 | 2019-06-10 20:41:41 +0800 | [diff] [blame] | 4829 | if (parent_dev && dev_is_expander(parent_dev->dev_type)) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4830 | phy_id = parent_dev->ex_dev.ex_phy->phy_id; |
| 4831 | else |
| 4832 | phy_id = pm8001_dev->attached_phy; |
| 4833 | |
| 4834 | opc = OPC_INB_REG_DEV; |
| 4835 | |
| 4836 | linkrate = (pm8001_dev->sas_device->linkrate < dev->port->linkrate) ? |
| 4837 | pm8001_dev->sas_device->linkrate : dev->port->linkrate; |
| 4838 | |
| 4839 | payload.phyid_portid = |
| 4840 | cpu_to_le32(((pm8001_dev->sas_device->port->id) & 0xFF) | |
| 4841 | ((phy_id & 0xFF) << 8)); |
| 4842 | |
| 4843 | payload.dtype_dlr_mcn_ir_retry = cpu_to_le32((retryFlag & 0x01) | |
| 4844 | ((linkrate & 0x0F) << 24) | |
| 4845 | ((stp_sspsmp_sata & 0x03) << 28)); |
| 4846 | payload.firstburstsize_ITNexustimeout = |
| 4847 | cpu_to_le32(ITNT | (firstBurstSize * 0x10000)); |
| 4848 | |
| 4849 | memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, |
| 4850 | SAS_ADDR_SIZE); |
| 4851 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4852 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 4853 | sizeof(payload), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 4854 | if (rc) |
| 4855 | pm8001_tag_free(pm8001_ha, tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4856 | |
| 4857 | return rc; |
| 4858 | } |
| 4859 | |
| 4860 | /** |
| 4861 | * pm80xx_chip_phy_ctl_req - support the local phy operation |
| 4862 | * @pm8001_ha: our hba card information. |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 4863 | * @phyId: the phy id which we wanted to operate |
| 4864 | * @phy_op: phy operation to request |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4865 | */ |
| 4866 | static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, |
| 4867 | u32 phyId, u32 phy_op) |
| 4868 | { |
Viswas G | 25c6edb | 2017-10-18 11:39:10 +0530 | [diff] [blame] | 4869 | u32 tag; |
| 4870 | int rc; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4871 | struct local_phy_ctl_req payload; |
| 4872 | struct inbound_queue_table *circularQ; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4873 | u32 opc = OPC_INB_LOCAL_PHY_CONTROL; |
| 4874 | memset(&payload, 0, sizeof(payload)); |
Viswas G | 25c6edb | 2017-10-18 11:39:10 +0530 | [diff] [blame] | 4875 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 4876 | if (rc) |
| 4877 | return rc; |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4878 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
Viswas G | 25c6edb | 2017-10-18 11:39:10 +0530 | [diff] [blame] | 4879 | payload.tag = cpu_to_le32(tag); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4880 | payload.phyop_phyid = |
| 4881 | cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4882 | return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 4883 | sizeof(payload), 0); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4884 | } |
| 4885 | |
Colin Ian King | f310a4e | 2019-03-29 23:44:23 +0000 | [diff] [blame] | 4886 | static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4887 | { |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4888 | #ifdef PM8001_USE_MSIX |
| 4889 | return 1; |
Colin Ian King | 292c04c | 2019-03-28 23:43:28 +0000 | [diff] [blame] | 4890 | #else |
| 4891 | u32 value; |
| 4892 | |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4893 | value = pm8001_cr32(pm8001_ha, 0, MSGU_ODR); |
| 4894 | if (value) |
| 4895 | return 1; |
| 4896 | return 0; |
Colin Ian King | 292c04c | 2019-03-28 23:43:28 +0000 | [diff] [blame] | 4897 | #endif |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | /** |
Lee Jones | 7cdaf12 | 2021-03-03 14:46:23 +0000 | [diff] [blame] | 4901 | * pm80xx_chip_isr - PM8001 isr handler. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4902 | * @pm8001_ha: our hba card information. |
Lee Jones | 6ad4a51 | 2020-07-21 17:41:25 +0100 | [diff] [blame] | 4903 | * @vec: irq number. |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4904 | */ |
| 4905 | static irqreturn_t |
| 4906 | pm80xx_chip_isr(struct pm8001_hba_info *pm8001_ha, u8 vec) |
| 4907 | { |
| 4908 | pm80xx_chip_interrupt_disable(pm8001_ha, vec); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4909 | pm8001_dbg(pm8001_ha, DEVIO, |
| 4910 | "irq vec %d, ODMR:0x%x\n", |
| 4911 | vec, pm8001_cr32(pm8001_ha, 0, 0x30)); |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4912 | process_oq(pm8001_ha, vec); |
| 4913 | pm80xx_chip_interrupt_enable(pm8001_ha, vec); |
| 4914 | return IRQ_HANDLED; |
| 4915 | } |
| 4916 | |
Lee Jones | ea310f5 | 2020-07-21 17:41:33 +0100 | [diff] [blame] | 4917 | static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, |
| 4918 | u32 operation, u32 phyid, |
| 4919 | u32 length, u32 *buf) |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4920 | { |
| 4921 | u32 tag , i, j = 0; |
| 4922 | int rc; |
| 4923 | struct set_phy_profile_req payload; |
| 4924 | struct inbound_queue_table *circularQ; |
| 4925 | u32 opc = OPC_INB_SET_PHY_PROFILE; |
| 4926 | |
| 4927 | memset(&payload, 0, sizeof(payload)); |
| 4928 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 4929 | if (rc) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4930 | pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4931 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4932 | payload.tag = cpu_to_le32(tag); |
| 4933 | payload.ppc_phyid = (((operation & 0xF) << 8) | (phyid & 0xFF)); |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4934 | pm8001_dbg(pm8001_ha, INIT, |
| 4935 | " phy profile command for phy %x ,length is %d\n", |
| 4936 | payload.ppc_phyid, length); |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4937 | for (i = length; i < (length + PHY_DWORD_LENGTH - 1); i++) { |
| 4938 | payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); |
| 4939 | j++; |
| 4940 | } |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4941 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 4942 | sizeof(payload), 0); |
Tomas Henzl | 5533abc | 2014-07-09 17:20:49 +0530 | [diff] [blame] | 4943 | if (rc) |
| 4944 | pm8001_tag_free(pm8001_ha, tag); |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4945 | } |
| 4946 | |
| 4947 | void pm8001_set_phy_profile(struct pm8001_hba_info *pm8001_ha, |
| 4948 | u32 length, u8 *buf) |
| 4949 | { |
YueHaibing | fdd0a66 | 2018-09-14 01:38:56 +0000 | [diff] [blame] | 4950 | u32 i; |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4951 | |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4952 | for (i = 0; i < pm8001_ha->chip->n_phy; i++) { |
| 4953 | mpi_set_phy_profile_req(pm8001_ha, |
| 4954 | SAS_PHY_ANALOG_SETTINGS_PAGE, i, length, (u32 *)buf); |
| 4955 | length = length + PHY_DWORD_LENGTH; |
| 4956 | } |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4957 | pm8001_dbg(pm8001_ha, INIT, "phy settings completed\n"); |
Anand Kumar Santhanam | 2790940 | 2013-09-18 13:02:44 +0530 | [diff] [blame] | 4958 | } |
Benjamin Rood | c5614df | 2015-10-30 10:53:28 -0400 | [diff] [blame] | 4959 | |
| 4960 | void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, |
| 4961 | u32 phy, u32 length, u32 *buf) |
| 4962 | { |
| 4963 | u32 tag, opc; |
| 4964 | int rc, i; |
| 4965 | struct set_phy_profile_req payload; |
| 4966 | struct inbound_queue_table *circularQ; |
| 4967 | |
| 4968 | memset(&payload, 0, sizeof(payload)); |
| 4969 | |
| 4970 | rc = pm8001_tag_alloc(pm8001_ha, &tag); |
| 4971 | if (rc) |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4972 | pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n"); |
Benjamin Rood | c5614df | 2015-10-30 10:53:28 -0400 | [diff] [blame] | 4973 | |
| 4974 | circularQ = &pm8001_ha->inbnd_q_tbl[0]; |
| 4975 | opc = OPC_INB_SET_PHY_PROFILE; |
| 4976 | |
| 4977 | payload.tag = cpu_to_le32(tag); |
| 4978 | payload.ppc_phyid = (((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) |
| 4979 | | (phy & 0xFF)); |
| 4980 | |
| 4981 | for (i = 0; i < length; i++) |
| 4982 | payload.reserved[i] = cpu_to_le32(*(buf + i)); |
| 4983 | |
peter chang | 91a43fa | 2019-11-14 15:39:05 +0530 | [diff] [blame] | 4984 | rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, |
| 4985 | sizeof(payload), 0); |
Benjamin Rood | c5614df | 2015-10-30 10:53:28 -0400 | [diff] [blame] | 4986 | if (rc) |
| 4987 | pm8001_tag_free(pm8001_ha, tag); |
| 4988 | |
Joe Perches | 1b5d279 | 2020-11-20 15:16:09 -0800 | [diff] [blame] | 4989 | pm8001_dbg(pm8001_ha, INIT, "PHY %d settings applied\n", phy); |
Benjamin Rood | c5614df | 2015-10-30 10:53:28 -0400 | [diff] [blame] | 4990 | } |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4991 | const struct pm8001_dispatch pm8001_80xx_dispatch = { |
| 4992 | .name = "pmc80xx", |
| 4993 | .chip_init = pm80xx_chip_init, |
| 4994 | .chip_soft_rst = pm80xx_chip_soft_rst, |
| 4995 | .chip_rst = pm80xx_hw_chip_rst, |
| 4996 | .chip_iounmap = pm8001_chip_iounmap, |
| 4997 | .isr = pm80xx_chip_isr, |
Colin Ian King | f310a4e | 2019-03-29 23:44:23 +0000 | [diff] [blame] | 4998 | .is_our_interrupt = pm80xx_chip_is_our_interrupt, |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 4999 | .isr_process_oq = process_oq, |
| 5000 | .interrupt_enable = pm80xx_chip_interrupt_enable, |
| 5001 | .interrupt_disable = pm80xx_chip_interrupt_disable, |
| 5002 | .make_prd = pm8001_chip_make_sg, |
| 5003 | .smp_req = pm80xx_chip_smp_req, |
| 5004 | .ssp_io_req = pm80xx_chip_ssp_io_req, |
| 5005 | .sata_req = pm80xx_chip_sata_req, |
| 5006 | .phy_start_req = pm80xx_chip_phy_start_req, |
| 5007 | .phy_stop_req = pm80xx_chip_phy_stop_req, |
| 5008 | .reg_dev_req = pm80xx_chip_reg_dev_req, |
| 5009 | .dereg_dev_req = pm8001_chip_dereg_dev_req, |
| 5010 | .phy_ctl_req = pm80xx_chip_phy_ctl_req, |
| 5011 | .task_abort = pm8001_chip_abort_task, |
| 5012 | .ssp_tm_req = pm8001_chip_ssp_tm_req, |
| 5013 | .get_nvmd_req = pm8001_chip_get_nvmd_req, |
| 5014 | .set_nvmd_req = pm8001_chip_set_nvmd_req, |
| 5015 | .fw_flash_update_req = pm8001_chip_fw_flash_update_req, |
| 5016 | .set_dev_state_req = pm8001_chip_set_dev_state_req, |
akshatzen | a961ea0 | 2021-01-09 18:08:43 +0530 | [diff] [blame] | 5017 | .fatal_errors = pm80xx_fatal_errors, |
Sakthivel K | f586099 | 2013-04-17 16:37:02 +0530 | [diff] [blame] | 5018 | }; |