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