1 // SPDX-License-Identifier: GPL-2.0-only
3 * QLogic iSCSI HBA Driver
4 * Copyright (c) 2003-2013 QLogic Corporation
6 #include <linux/delay.h>
9 #include <linux/ratelimit.h>
12 #include "ql4_inline.h"
14 #include <linux/io-64-nonatomic-lo-hi.h>
16 #define TIMEOUT_100_MS 100
17 #define MASK(n) DMA_BIT_MASK(n)
18 #define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff))
19 #define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff))
20 #define MS_WIN(addr) (addr & 0x0ffc0000)
21 #define QLA82XX_PCI_MN_2M (0)
22 #define QLA82XX_PCI_MS_2M (0x80000)
23 #define QLA82XX_PCI_OCM0_2M (0xc0000)
24 #define VALID_OCM_ADDR(addr) (((addr) & 0x3f800) != 0x3f800)
25 #define GET_MEM_OFFS_2M(addr) (addr & MASK(18))
27 /* CRB window related */
28 #define CRB_BLK(off) ((off >> 20) & 0x3f)
29 #define CRB_SUBBLK(off) ((off >> 16) & 0xf)
30 #define CRB_WINDOW_2M (0x130060)
31 #define CRB_HI(off) ((qla4_82xx_crb_hub_agt[CRB_BLK(off)] << 20) | \
33 #define QLA82XX_PCI_CAMQM_2M_END (0x04800800UL)
34 #define QLA82XX_PCI_CAMQM_2M_BASE (0x000ff800UL)
35 #define CRB_INDIRECT_2M (0x1e0000UL)
37 static inline void __iomem
*
38 qla4_8xxx_pci_base_offsetfset(struct scsi_qla_host
*ha
, unsigned long off
)
40 if ((off
< ha
->first_page_group_end
) &&
41 (off
>= ha
->first_page_group_start
))
42 return (void __iomem
*)(ha
->nx_pcibase
+ off
);
47 static const int MD_MIU_TEST_AGT_RDDATA
[] = { 0x410000A8,
48 0x410000AC, 0x410000B8, 0x410000BC };
49 #define MAX_CRB_XFORM 60
50 static unsigned long crb_addr_xform
[MAX_CRB_XFORM
];
51 static int qla4_8xxx_crb_table_initialized
;
53 #define qla4_8xxx_crb_addr_transform(name) \
54 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \
55 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20)
57 qla4_82xx_crb_addr_transform_setup(void)
59 qla4_8xxx_crb_addr_transform(XDMA
);
60 qla4_8xxx_crb_addr_transform(TIMR
);
61 qla4_8xxx_crb_addr_transform(SRE
);
62 qla4_8xxx_crb_addr_transform(SQN3
);
63 qla4_8xxx_crb_addr_transform(SQN2
);
64 qla4_8xxx_crb_addr_transform(SQN1
);
65 qla4_8xxx_crb_addr_transform(SQN0
);
66 qla4_8xxx_crb_addr_transform(SQS3
);
67 qla4_8xxx_crb_addr_transform(SQS2
);
68 qla4_8xxx_crb_addr_transform(SQS1
);
69 qla4_8xxx_crb_addr_transform(SQS0
);
70 qla4_8xxx_crb_addr_transform(RPMX7
);
71 qla4_8xxx_crb_addr_transform(RPMX6
);
72 qla4_8xxx_crb_addr_transform(RPMX5
);
73 qla4_8xxx_crb_addr_transform(RPMX4
);
74 qla4_8xxx_crb_addr_transform(RPMX3
);
75 qla4_8xxx_crb_addr_transform(RPMX2
);
76 qla4_8xxx_crb_addr_transform(RPMX1
);
77 qla4_8xxx_crb_addr_transform(RPMX0
);
78 qla4_8xxx_crb_addr_transform(ROMUSB
);
79 qla4_8xxx_crb_addr_transform(SN
);
80 qla4_8xxx_crb_addr_transform(QMN
);
81 qla4_8xxx_crb_addr_transform(QMS
);
82 qla4_8xxx_crb_addr_transform(PGNI
);
83 qla4_8xxx_crb_addr_transform(PGND
);
84 qla4_8xxx_crb_addr_transform(PGN3
);
85 qla4_8xxx_crb_addr_transform(PGN2
);
86 qla4_8xxx_crb_addr_transform(PGN1
);
87 qla4_8xxx_crb_addr_transform(PGN0
);
88 qla4_8xxx_crb_addr_transform(PGSI
);
89 qla4_8xxx_crb_addr_transform(PGSD
);
90 qla4_8xxx_crb_addr_transform(PGS3
);
91 qla4_8xxx_crb_addr_transform(PGS2
);
92 qla4_8xxx_crb_addr_transform(PGS1
);
93 qla4_8xxx_crb_addr_transform(PGS0
);
94 qla4_8xxx_crb_addr_transform(PS
);
95 qla4_8xxx_crb_addr_transform(PH
);
96 qla4_8xxx_crb_addr_transform(NIU
);
97 qla4_8xxx_crb_addr_transform(I2Q
);
98 qla4_8xxx_crb_addr_transform(EG
);
99 qla4_8xxx_crb_addr_transform(MN
);
100 qla4_8xxx_crb_addr_transform(MS
);
101 qla4_8xxx_crb_addr_transform(CAS2
);
102 qla4_8xxx_crb_addr_transform(CAS1
);
103 qla4_8xxx_crb_addr_transform(CAS0
);
104 qla4_8xxx_crb_addr_transform(CAM
);
105 qla4_8xxx_crb_addr_transform(C2C1
);
106 qla4_8xxx_crb_addr_transform(C2C0
);
107 qla4_8xxx_crb_addr_transform(SMB
);
108 qla4_8xxx_crb_addr_transform(OCM0
);
109 qla4_8xxx_crb_addr_transform(I2C0
);
111 qla4_8xxx_crb_table_initialized
= 1;
114 static struct crb_128M_2M_block_map crb_128M_2M_map
[64] = {
115 {{{0, 0, 0, 0} } }, /* 0: PCI */
116 {{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */
117 {1, 0x0110000, 0x0120000, 0x130000},
118 {1, 0x0120000, 0x0122000, 0x124000},
119 {1, 0x0130000, 0x0132000, 0x126000},
120 {1, 0x0140000, 0x0142000, 0x128000},
121 {1, 0x0150000, 0x0152000, 0x12a000},
122 {1, 0x0160000, 0x0170000, 0x110000},
123 {1, 0x0170000, 0x0172000, 0x12e000},
124 {0, 0x0000000, 0x0000000, 0x000000},
125 {0, 0x0000000, 0x0000000, 0x000000},
126 {0, 0x0000000, 0x0000000, 0x000000},
127 {0, 0x0000000, 0x0000000, 0x000000},
128 {0, 0x0000000, 0x0000000, 0x000000},
129 {0, 0x0000000, 0x0000000, 0x000000},
130 {1, 0x01e0000, 0x01e0800, 0x122000},
131 {0, 0x0000000, 0x0000000, 0x000000} } },
132 {{{1, 0x0200000, 0x0210000, 0x180000} } },/* 2: MN */
133 {{{0, 0, 0, 0} } }, /* 3: */
134 {{{1, 0x0400000, 0x0401000, 0x169000} } },/* 4: P2NR1 */
135 {{{1, 0x0500000, 0x0510000, 0x140000} } },/* 5: SRE */
136 {{{1, 0x0600000, 0x0610000, 0x1c0000} } },/* 6: NIU */
137 {{{1, 0x0700000, 0x0704000, 0x1b8000} } },/* 7: QM */
138 {{{1, 0x0800000, 0x0802000, 0x170000}, /* 8: SQM0 */
139 {0, 0x0000000, 0x0000000, 0x000000},
140 {0, 0x0000000, 0x0000000, 0x000000},
141 {0, 0x0000000, 0x0000000, 0x000000},
142 {0, 0x0000000, 0x0000000, 0x000000},
143 {0, 0x0000000, 0x0000000, 0x000000},
144 {0, 0x0000000, 0x0000000, 0x000000},
145 {0, 0x0000000, 0x0000000, 0x000000},
146 {0, 0x0000000, 0x0000000, 0x000000},
147 {0, 0x0000000, 0x0000000, 0x000000},
148 {0, 0x0000000, 0x0000000, 0x000000},
149 {0, 0x0000000, 0x0000000, 0x000000},
150 {0, 0x0000000, 0x0000000, 0x000000},
151 {0, 0x0000000, 0x0000000, 0x000000},
152 {0, 0x0000000, 0x0000000, 0x000000},
153 {1, 0x08f0000, 0x08f2000, 0x172000} } },
154 {{{1, 0x0900000, 0x0902000, 0x174000}, /* 9: SQM1*/
155 {0, 0x0000000, 0x0000000, 0x000000},
156 {0, 0x0000000, 0x0000000, 0x000000},
157 {0, 0x0000000, 0x0000000, 0x000000},
158 {0, 0x0000000, 0x0000000, 0x000000},
159 {0, 0x0000000, 0x0000000, 0x000000},
160 {0, 0x0000000, 0x0000000, 0x000000},
161 {0, 0x0000000, 0x0000000, 0x000000},
162 {0, 0x0000000, 0x0000000, 0x000000},
163 {0, 0x0000000, 0x0000000, 0x000000},
164 {0, 0x0000000, 0x0000000, 0x000000},
165 {0, 0x0000000, 0x0000000, 0x000000},
166 {0, 0x0000000, 0x0000000, 0x000000},
167 {0, 0x0000000, 0x0000000, 0x000000},
168 {0, 0x0000000, 0x0000000, 0x000000},
169 {1, 0x09f0000, 0x09f2000, 0x176000} } },
170 {{{0, 0x0a00000, 0x0a02000, 0x178000}, /* 10: SQM2*/
171 {0, 0x0000000, 0x0000000, 0x000000},
172 {0, 0x0000000, 0x0000000, 0x000000},
173 {0, 0x0000000, 0x0000000, 0x000000},
174 {0, 0x0000000, 0x0000000, 0x000000},
175 {0, 0x0000000, 0x0000000, 0x000000},
176 {0, 0x0000000, 0x0000000, 0x000000},
177 {0, 0x0000000, 0x0000000, 0x000000},
178 {0, 0x0000000, 0x0000000, 0x000000},
179 {0, 0x0000000, 0x0000000, 0x000000},
180 {0, 0x0000000, 0x0000000, 0x000000},
181 {0, 0x0000000, 0x0000000, 0x000000},
182 {0, 0x0000000, 0x0000000, 0x000000},
183 {0, 0x0000000, 0x0000000, 0x000000},
184 {0, 0x0000000, 0x0000000, 0x000000},
185 {1, 0x0af0000, 0x0af2000, 0x17a000} } },
186 {{{0, 0x0b00000, 0x0b02000, 0x17c000}, /* 11: SQM3*/
187 {0, 0x0000000, 0x0000000, 0x000000},
188 {0, 0x0000000, 0x0000000, 0x000000},
189 {0, 0x0000000, 0x0000000, 0x000000},
190 {0, 0x0000000, 0x0000000, 0x000000},
191 {0, 0x0000000, 0x0000000, 0x000000},
192 {0, 0x0000000, 0x0000000, 0x000000},
193 {0, 0x0000000, 0x0000000, 0x000000},
194 {0, 0x0000000, 0x0000000, 0x000000},
195 {0, 0x0000000, 0x0000000, 0x000000},
196 {0, 0x0000000, 0x0000000, 0x000000},
197 {0, 0x0000000, 0x0000000, 0x000000},
198 {0, 0x0000000, 0x0000000, 0x000000},
199 {0, 0x0000000, 0x0000000, 0x000000},
200 {0, 0x0000000, 0x0000000, 0x000000},
201 {1, 0x0bf0000, 0x0bf2000, 0x17e000} } },
202 {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },/* 12: I2Q */
203 {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },/* 13: TMR */
204 {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },/* 14: ROMUSB */
205 {{{1, 0x0f00000, 0x0f01000, 0x164000} } },/* 15: PEG4 */
206 {{{0, 0x1000000, 0x1004000, 0x1a8000} } },/* 16: XDMA */
207 {{{1, 0x1100000, 0x1101000, 0x160000} } },/* 17: PEG0 */
208 {{{1, 0x1200000, 0x1201000, 0x161000} } },/* 18: PEG1 */
209 {{{1, 0x1300000, 0x1301000, 0x162000} } },/* 19: PEG2 */
210 {{{1, 0x1400000, 0x1401000, 0x163000} } },/* 20: PEG3 */
211 {{{1, 0x1500000, 0x1501000, 0x165000} } },/* 21: P2ND */
212 {{{1, 0x1600000, 0x1601000, 0x166000} } },/* 22: P2NI */
213 {{{0, 0, 0, 0} } }, /* 23: */
214 {{{0, 0, 0, 0} } }, /* 24: */
215 {{{0, 0, 0, 0} } }, /* 25: */
216 {{{0, 0, 0, 0} } }, /* 26: */
217 {{{0, 0, 0, 0} } }, /* 27: */
218 {{{0, 0, 0, 0} } }, /* 28: */
219 {{{1, 0x1d00000, 0x1d10000, 0x190000} } },/* 29: MS */
220 {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },/* 30: P2NR2 */
221 {{{1, 0x1f00000, 0x1f10000, 0x150000} } },/* 31: EPG */
222 {{{0} } }, /* 32: PCI */
223 {{{1, 0x2100000, 0x2102000, 0x120000}, /* 33: PCIE */
224 {1, 0x2110000, 0x2120000, 0x130000},
225 {1, 0x2120000, 0x2122000, 0x124000},
226 {1, 0x2130000, 0x2132000, 0x126000},
227 {1, 0x2140000, 0x2142000, 0x128000},
228 {1, 0x2150000, 0x2152000, 0x12a000},
229 {1, 0x2160000, 0x2170000, 0x110000},
230 {1, 0x2170000, 0x2172000, 0x12e000},
231 {0, 0x0000000, 0x0000000, 0x000000},
232 {0, 0x0000000, 0x0000000, 0x000000},
233 {0, 0x0000000, 0x0000000, 0x000000},
234 {0, 0x0000000, 0x0000000, 0x000000},
235 {0, 0x0000000, 0x0000000, 0x000000},
236 {0, 0x0000000, 0x0000000, 0x000000},
237 {0, 0x0000000, 0x0000000, 0x000000},
238 {0, 0x0000000, 0x0000000, 0x000000} } },
239 {{{1, 0x2200000, 0x2204000, 0x1b0000} } },/* 34: CAM */
245 {{{1, 0x2800000, 0x2804000, 0x1a4000} } },/* 40: TMR */
246 {{{1, 0x2900000, 0x2901000, 0x16b000} } },/* 41: P2NR3 */
247 {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },/* 42: RPMX1 */
248 {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },/* 43: RPMX2 */
249 {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },/* 44: RPMX3 */
250 {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },/* 45: RPMX4 */
251 {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },/* 46: RPMX5 */
252 {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },/* 47: RPMX6 */
253 {{{1, 0x3000000, 0x3000400, 0x1adc00} } },/* 48: RPMX7 */
254 {{{0, 0x3100000, 0x3104000, 0x1a8000} } },/* 49: XDMA */
255 {{{1, 0x3200000, 0x3204000, 0x1d4000} } },/* 50: I2Q */
256 {{{1, 0x3300000, 0x3304000, 0x1a0000} } },/* 51: ROMUSB */
258 {{{1, 0x3500000, 0x3500400, 0x1ac000} } },/* 53: RPMX0 */
259 {{{1, 0x3600000, 0x3600400, 0x1ae000} } },/* 54: RPMX8 */
260 {{{1, 0x3700000, 0x3700400, 0x1ae400} } },/* 55: RPMX9 */
261 {{{1, 0x3800000, 0x3804000, 0x1d0000} } },/* 56: OCM0 */
262 {{{1, 0x3900000, 0x3904000, 0x1b4000} } },/* 57: CRYPTO */
263 {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },/* 58: SMB */
264 {{{0} } }, /* 59: I2C0 */
265 {{{0} } }, /* 60: I2C1 */
266 {{{1, 0x3d00000, 0x3d04000, 0x1dc000} } },/* 61: LPC */
267 {{{1, 0x3e00000, 0x3e01000, 0x167000} } },/* 62: P2NC */
268 {{{1, 0x3f00000, 0x3f01000, 0x168000} } } /* 63: P2NR0 */
272 * top 12 bits of crb internal address (hub, agent)
274 static unsigned qla4_82xx_crb_hub_agt
[64] = {
276 QLA82XX_HW_CRB_HUB_AGT_ADR_PS
,
277 QLA82XX_HW_CRB_HUB_AGT_ADR_MN
,
278 QLA82XX_HW_CRB_HUB_AGT_ADR_MS
,
280 QLA82XX_HW_CRB_HUB_AGT_ADR_SRE
,
281 QLA82XX_HW_CRB_HUB_AGT_ADR_NIU
,
282 QLA82XX_HW_CRB_HUB_AGT_ADR_QMN
,
283 QLA82XX_HW_CRB_HUB_AGT_ADR_SQN0
,
284 QLA82XX_HW_CRB_HUB_AGT_ADR_SQN1
,
285 QLA82XX_HW_CRB_HUB_AGT_ADR_SQN2
,
286 QLA82XX_HW_CRB_HUB_AGT_ADR_SQN3
,
287 QLA82XX_HW_CRB_HUB_AGT_ADR_I2Q
,
288 QLA82XX_HW_CRB_HUB_AGT_ADR_TIMR
,
289 QLA82XX_HW_CRB_HUB_AGT_ADR_ROMUSB
,
290 QLA82XX_HW_CRB_HUB_AGT_ADR_PGN4
,
291 QLA82XX_HW_CRB_HUB_AGT_ADR_XDMA
,
292 QLA82XX_HW_CRB_HUB_AGT_ADR_PGN0
,
293 QLA82XX_HW_CRB_HUB_AGT_ADR_PGN1
,
294 QLA82XX_HW_CRB_HUB_AGT_ADR_PGN2
,
295 QLA82XX_HW_CRB_HUB_AGT_ADR_PGN3
,
296 QLA82XX_HW_CRB_HUB_AGT_ADR_PGND
,
297 QLA82XX_HW_CRB_HUB_AGT_ADR_PGNI
,
298 QLA82XX_HW_CRB_HUB_AGT_ADR_PGS0
,
299 QLA82XX_HW_CRB_HUB_AGT_ADR_PGS1
,
300 QLA82XX_HW_CRB_HUB_AGT_ADR_PGS2
,
301 QLA82XX_HW_CRB_HUB_AGT_ADR_PGS3
,
303 QLA82XX_HW_CRB_HUB_AGT_ADR_PGSI
,
304 QLA82XX_HW_CRB_HUB_AGT_ADR_SN
,
306 QLA82XX_HW_CRB_HUB_AGT_ADR_EG
,
308 QLA82XX_HW_CRB_HUB_AGT_ADR_PS
,
309 QLA82XX_HW_CRB_HUB_AGT_ADR_CAM
,
315 QLA82XX_HW_CRB_HUB_AGT_ADR_TIMR
,
317 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX1
,
318 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX2
,
319 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX3
,
320 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX4
,
321 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX5
,
322 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX6
,
323 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX7
,
324 QLA82XX_HW_CRB_HUB_AGT_ADR_XDMA
,
325 QLA82XX_HW_CRB_HUB_AGT_ADR_I2Q
,
326 QLA82XX_HW_CRB_HUB_AGT_ADR_ROMUSB
,
328 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX0
,
329 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX8
,
330 QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX9
,
331 QLA82XX_HW_CRB_HUB_AGT_ADR_OCM0
,
333 QLA82XX_HW_CRB_HUB_AGT_ADR_SMB
,
334 QLA82XX_HW_CRB_HUB_AGT_ADR_I2C0
,
335 QLA82XX_HW_CRB_HUB_AGT_ADR_I2C1
,
337 QLA82XX_HW_CRB_HUB_AGT_ADR_PGNC
,
342 static char *qdev_state
[] = {
354 * In: 'off' is offset from CRB space in 128M pci map
355 * Out: 'off' is 2M pci map addr
356 * side effect: lock crb window
359 qla4_82xx_pci_set_crbwindow_2M(struct scsi_qla_host
*ha
, ulong
*off
)
363 ha
->crb_win
= CRB_HI(*off
);
365 (void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
367 /* Read back value to make sure write has gone through before trying
369 win_read
= readl((void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
370 if (win_read
!= ha
->crb_win
) {
371 DEBUG2(ql4_printk(KERN_INFO
, ha
,
372 "%s: Written crbwin (0x%x) != Read crbwin (0x%x),"
373 " off=0x%lx\n", __func__
, ha
->crb_win
, win_read
, *off
));
375 *off
= (*off
& MASK(16)) + CRB_INDIRECT_2M
+ ha
->nx_pcibase
;
378 #define CRB_WIN_LOCK_TIMEOUT 100000000
383 static int qla4_82xx_crb_win_lock(struct scsi_qla_host
*ha
)
385 int done
= 0, timeout
= 0;
388 /* acquire semaphore3 from PCI HW block */
389 done
= qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM7_LOCK
));
392 if (timeout
>= CRB_WIN_LOCK_TIMEOUT
)
398 qla4_82xx_wr_32(ha
, QLA82XX_CRB_WIN_LOCK_ID
, ha
->func_num
);
402 void qla4_82xx_crb_win_unlock(struct scsi_qla_host
*ha
)
404 qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM7_UNLOCK
));
408 qla4_82xx_wr_32(struct scsi_qla_host
*ha
, ulong off
, u32 data
)
410 unsigned long flags
= 0;
413 rv
= qla4_82xx_pci_get_crb_addr_2M(ha
, &off
);
418 write_lock_irqsave(&ha
->hw_lock
, flags
);
419 qla4_82xx_crb_win_lock(ha
);
420 qla4_82xx_pci_set_crbwindow_2M(ha
, &off
);
423 writel(data
, (void __iomem
*)off
);
426 qla4_82xx_crb_win_unlock(ha
);
427 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
431 uint32_t qla4_82xx_rd_32(struct scsi_qla_host
*ha
, ulong off
)
433 unsigned long flags
= 0;
437 rv
= qla4_82xx_pci_get_crb_addr_2M(ha
, &off
);
442 write_lock_irqsave(&ha
->hw_lock
, flags
);
443 qla4_82xx_crb_win_lock(ha
);
444 qla4_82xx_pci_set_crbwindow_2M(ha
, &off
);
446 data
= readl((void __iomem
*)off
);
449 qla4_82xx_crb_win_unlock(ha
);
450 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
455 /* Minidump related functions */
456 int qla4_82xx_md_rd_32(struct scsi_qla_host
*ha
, uint32_t off
, uint32_t *data
)
458 uint32_t win_read
, off_value
;
459 int rval
= QLA_SUCCESS
;
461 off_value
= off
& 0xFFFF0000;
462 writel(off_value
, (void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
465 * Read back value to make sure write has gone through before trying
468 win_read
= readl((void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
469 if (win_read
!= off_value
) {
470 DEBUG2(ql4_printk(KERN_INFO
, ha
,
471 "%s: Written (0x%x) != Read (0x%x), off=0x%x\n",
472 __func__
, off_value
, win_read
, off
));
475 off_value
= off
& 0x0000FFFF;
476 *data
= readl((void __iomem
*)(off_value
+ CRB_INDIRECT_2M
+
482 int qla4_82xx_md_wr_32(struct scsi_qla_host
*ha
, uint32_t off
, uint32_t data
)
484 uint32_t win_read
, off_value
;
485 int rval
= QLA_SUCCESS
;
487 off_value
= off
& 0xFFFF0000;
488 writel(off_value
, (void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
490 /* Read back value to make sure write has gone through before trying
493 win_read
= readl((void __iomem
*)(CRB_WINDOW_2M
+ ha
->nx_pcibase
));
494 if (win_read
!= off_value
) {
495 DEBUG2(ql4_printk(KERN_INFO
, ha
,
496 "%s: Written (0x%x) != Read (0x%x), off=0x%x\n",
497 __func__
, off_value
, win_read
, off
));
500 off_value
= off
& 0x0000FFFF;
501 writel(data
, (void __iomem
*)(off_value
+ CRB_INDIRECT_2M
+
507 #define IDC_LOCK_TIMEOUT 100000000
510 * qla4_82xx_idc_lock - hw_lock
511 * @ha: pointer to adapter structure
513 * General purpose lock used to synchronize access to
514 * CRB_DEV_STATE, CRB_DEV_REF_COUNT, etc.
516 * Context: task, can sleep
518 int qla4_82xx_idc_lock(struct scsi_qla_host
*ha
)
520 int done
= 0, timeout
= 0;
525 /* acquire semaphore5 from PCI HW block */
526 done
= qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM5_LOCK
));
529 if (timeout
>= IDC_LOCK_TIMEOUT
)
538 void qla4_82xx_idc_unlock(struct scsi_qla_host
*ha
)
540 qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM5_UNLOCK
));
544 qla4_82xx_pci_get_crb_addr_2M(struct scsi_qla_host
*ha
, ulong
*off
)
546 struct crb_128M_2M_sub_block_map
*m
;
548 if (*off
>= QLA82XX_CRB_MAX
)
551 if (*off
>= QLA82XX_PCI_CAMQM
&& (*off
< QLA82XX_PCI_CAMQM_2M_END
)) {
552 *off
= (*off
- QLA82XX_PCI_CAMQM
) +
553 QLA82XX_PCI_CAMQM_2M_BASE
+ ha
->nx_pcibase
;
557 if (*off
< QLA82XX_PCI_CRBSPACE
)
560 *off
-= QLA82XX_PCI_CRBSPACE
;
565 m
= &crb_128M_2M_map
[CRB_BLK(*off
)].sub_block
[CRB_SUBBLK(*off
)];
567 if (m
->valid
&& (m
->start_128M
<= *off
) && (m
->end_128M
> *off
)) {
568 *off
= *off
+ m
->start_2M
- m
->start_128M
+ ha
->nx_pcibase
;
573 * Not in direct map, use crb window
579 * check memory access boundary.
580 * used by test agent. support ddr access only for now
583 qla4_82xx_pci_mem_bound_check(struct scsi_qla_host
*ha
,
584 unsigned long long addr
, int size
)
586 if (!QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_DDR_NET
,
587 QLA8XXX_ADDR_DDR_NET_MAX
) ||
588 !QLA8XXX_ADDR_IN_RANGE(addr
+ size
- 1,
589 QLA8XXX_ADDR_DDR_NET
, QLA8XXX_ADDR_DDR_NET_MAX
) ||
590 ((size
!= 1) && (size
!= 2) && (size
!= 4) && (size
!= 8))) {
596 static int qla4_82xx_pci_set_window_warning_count
;
599 qla4_82xx_pci_set_window(struct scsi_qla_host
*ha
, unsigned long long addr
)
604 if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_DDR_NET
,
605 QLA8XXX_ADDR_DDR_NET_MAX
)) {
606 /* DDR network side */
607 window
= MN_WIN(addr
);
608 ha
->ddr_mn_window
= window
;
609 qla4_82xx_wr_32(ha
, ha
->mn_win_crb
|
610 QLA82XX_PCI_CRBSPACE
, window
);
611 win_read
= qla4_82xx_rd_32(ha
, ha
->mn_win_crb
|
612 QLA82XX_PCI_CRBSPACE
);
613 if ((win_read
<< 17) != window
) {
614 ql4_printk(KERN_WARNING
, ha
,
615 "%s: Written MNwin (0x%x) != Read MNwin (0x%x)\n",
616 __func__
, window
, win_read
);
618 addr
= GET_MEM_OFFS_2M(addr
) + QLA82XX_PCI_DDR_NET
;
619 } else if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_OCM0
,
620 QLA8XXX_ADDR_OCM0_MAX
)) {
622 /* if bits 19:18&17:11 are on */
623 if ((addr
& 0x00ff800) == 0xff800) {
624 printk("%s: QM access not handled.\n", __func__
);
628 window
= OCM_WIN(addr
);
629 ha
->ddr_mn_window
= window
;
630 qla4_82xx_wr_32(ha
, ha
->mn_win_crb
|
631 QLA82XX_PCI_CRBSPACE
, window
);
632 win_read
= qla4_82xx_rd_32(ha
, ha
->mn_win_crb
|
633 QLA82XX_PCI_CRBSPACE
);
634 temp1
= ((window
& 0x1FF) << 7) |
635 ((window
& 0x0FFFE0000) >> 17);
636 if (win_read
!= temp1
) {
637 printk("%s: Written OCMwin (0x%x) != Read"
638 " OCMwin (0x%x)\n", __func__
, temp1
, win_read
);
640 addr
= GET_MEM_OFFS_2M(addr
) + QLA82XX_PCI_OCM0_2M
;
642 } else if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_QDR_NET
,
643 QLA82XX_P3_ADDR_QDR_NET_MAX
)) {
644 /* QDR network side */
645 window
= MS_WIN(addr
);
646 ha
->qdr_sn_window
= window
;
647 qla4_82xx_wr_32(ha
, ha
->ms_win_crb
|
648 QLA82XX_PCI_CRBSPACE
, window
);
649 win_read
= qla4_82xx_rd_32(ha
,
650 ha
->ms_win_crb
| QLA82XX_PCI_CRBSPACE
);
651 if (win_read
!= window
) {
652 printk("%s: Written MSwin (0x%x) != Read "
653 "MSwin (0x%x)\n", __func__
, window
, win_read
);
655 addr
= GET_MEM_OFFS_2M(addr
) + QLA82XX_PCI_QDR_NET
;
659 * peg gdb frequently accesses memory that doesn't exist,
660 * this limits the chit chat so debugging isn't slowed down.
662 if ((qla4_82xx_pci_set_window_warning_count
++ < 8) ||
663 (qla4_82xx_pci_set_window_warning_count
%64 == 0)) {
664 printk("%s: Warning:%s Unknown address range!\n",
665 __func__
, DRIVER_NAME
);
672 /* check if address is in the same windows as the previous access */
673 static int qla4_82xx_pci_is_same_window(struct scsi_qla_host
*ha
,
674 unsigned long long addr
)
677 unsigned long long qdr_max
;
679 qdr_max
= QLA82XX_P3_ADDR_QDR_NET_MAX
;
681 if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_DDR_NET
,
682 QLA8XXX_ADDR_DDR_NET_MAX
)) {
683 /* DDR network side */
684 BUG(); /* MN access can not come here */
685 } else if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_OCM0
,
686 QLA8XXX_ADDR_OCM0_MAX
)) {
688 } else if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_OCM1
,
689 QLA8XXX_ADDR_OCM1_MAX
)) {
691 } else if (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_QDR_NET
,
693 /* QDR network side */
694 window
= ((addr
- QLA8XXX_ADDR_QDR_NET
) >> 22) & 0x3f;
695 if (ha
->qdr_sn_window
== window
)
702 static int qla4_82xx_pci_mem_read_direct(struct scsi_qla_host
*ha
,
703 u64 off
, void *data
, int size
)
709 void __iomem
*mem_ptr
= NULL
;
710 unsigned long mem_base
;
711 unsigned long mem_page
;
713 write_lock_irqsave(&ha
->hw_lock
, flags
);
716 * If attempting to access unknown address or straddle hw windows,
719 start
= qla4_82xx_pci_set_window(ha
, off
);
720 if ((start
== -1UL) ||
721 (qla4_82xx_pci_is_same_window(ha
, off
+ size
- 1) == 0)) {
722 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
723 printk(KERN_ERR
"%s out of bound pci memory access. "
724 "offset is 0x%llx\n", DRIVER_NAME
, off
);
728 addr
= qla4_8xxx_pci_base_offsetfset(ha
, start
);
730 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
731 mem_base
= pci_resource_start(ha
->pdev
, 0);
732 mem_page
= start
& PAGE_MASK
;
733 /* Map two pages whenever user tries to access addresses in two
736 if (mem_page
!= ((start
+ size
- 1) & PAGE_MASK
))
737 mem_ptr
= ioremap(mem_base
+ mem_page
, PAGE_SIZE
* 2);
739 mem_ptr
= ioremap(mem_base
+ mem_page
, PAGE_SIZE
);
741 if (mem_ptr
== NULL
) {
746 addr
+= start
& (PAGE_SIZE
- 1);
747 write_lock_irqsave(&ha
->hw_lock
, flags
);
752 *(u8
*)data
= readb(addr
);
755 *(u16
*)data
= readw(addr
);
758 *(u32
*)data
= readl(addr
);
761 *(u64
*)data
= readq(addr
);
767 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
775 qla4_82xx_pci_mem_write_direct(struct scsi_qla_host
*ha
, u64 off
,
776 void *data
, int size
)
782 void __iomem
*mem_ptr
= NULL
;
783 unsigned long mem_base
;
784 unsigned long mem_page
;
786 write_lock_irqsave(&ha
->hw_lock
, flags
);
789 * If attempting to access unknown address or straddle hw windows,
792 start
= qla4_82xx_pci_set_window(ha
, off
);
793 if ((start
== -1UL) ||
794 (qla4_82xx_pci_is_same_window(ha
, off
+ size
- 1) == 0)) {
795 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
796 printk(KERN_ERR
"%s out of bound pci memory access. "
797 "offset is 0x%llx\n", DRIVER_NAME
, off
);
801 addr
= qla4_8xxx_pci_base_offsetfset(ha
, start
);
803 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
804 mem_base
= pci_resource_start(ha
->pdev
, 0);
805 mem_page
= start
& PAGE_MASK
;
806 /* Map two pages whenever user tries to access addresses in two
809 if (mem_page
!= ((start
+ size
- 1) & PAGE_MASK
))
810 mem_ptr
= ioremap(mem_base
+ mem_page
, PAGE_SIZE
*2);
812 mem_ptr
= ioremap(mem_base
+ mem_page
, PAGE_SIZE
);
817 addr
+= start
& (PAGE_SIZE
- 1);
818 write_lock_irqsave(&ha
->hw_lock
, flags
);
823 writeb(*(u8
*)data
, addr
);
826 writew(*(u16
*)data
, addr
);
829 writel(*(u32
*)data
, addr
);
832 writeq(*(u64
*)data
, addr
);
838 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
844 #define MTU_FUDGE_FACTOR 100
847 qla4_82xx_decode_crb_addr(unsigned long addr
)
850 unsigned long base_addr
, offset
, pci_base
;
852 if (!qla4_8xxx_crb_table_initialized
)
853 qla4_82xx_crb_addr_transform_setup();
855 pci_base
= ADDR_ERROR
;
856 base_addr
= addr
& 0xfff00000;
857 offset
= addr
& 0x000fffff;
859 for (i
= 0; i
< MAX_CRB_XFORM
; i
++) {
860 if (crb_addr_xform
[i
] == base_addr
) {
865 if (pci_base
== ADDR_ERROR
)
868 return pci_base
+ offset
;
871 static long rom_max_timeout
= 100;
872 static long qla4_82xx_rom_lock_timeout
= 100;
875 * Context: task, can_sleep
878 qla4_82xx_rom_lock(struct scsi_qla_host
*ha
)
880 int done
= 0, timeout
= 0;
885 /* acquire semaphore2 from PCI HW block */
886 done
= qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM2_LOCK
));
889 if (timeout
>= qla4_82xx_rom_lock_timeout
)
895 qla4_82xx_wr_32(ha
, QLA82XX_ROM_LOCK_ID
, ROM_LOCK_DRIVER
);
900 qla4_82xx_rom_unlock(struct scsi_qla_host
*ha
)
902 qla4_82xx_rd_32(ha
, QLA82XX_PCIE_REG(PCIE_SEM2_UNLOCK
));
906 qla4_82xx_wait_rom_done(struct scsi_qla_host
*ha
)
912 done
= qla4_82xx_rd_32(ha
, QLA82XX_ROMUSB_GLB_STATUS
);
915 if (timeout
>= rom_max_timeout
) {
916 printk("%s: Timeout reached waiting for rom done",
925 qla4_82xx_do_rom_fast_read(struct scsi_qla_host
*ha
, int addr
, int *valp
)
927 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_ADDRESS
, addr
);
928 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_DUMMY_BYTE_CNT
, 0);
929 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_ABYTE_CNT
, 3);
930 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_INSTR_OPCODE
, 0xb);
931 if (qla4_82xx_wait_rom_done(ha
)) {
932 printk("%s: Error waiting for rom done\n", DRIVER_NAME
);
935 /* reset abyte_cnt and dummy_byte_cnt */
936 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_DUMMY_BYTE_CNT
, 0);
938 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_ROM_ABYTE_CNT
, 0);
940 *valp
= qla4_82xx_rd_32(ha
, QLA82XX_ROMUSB_ROM_RDATA
);
945 qla4_82xx_rom_fast_read(struct scsi_qla_host
*ha
, int addr
, int *valp
)
949 while ((qla4_82xx_rom_lock(ha
) != 0) && (loops
< 50000)) {
953 if (loops
>= 50000) {
954 ql4_printk(KERN_WARNING
, ha
, "%s: qla4_82xx_rom_lock failed\n",
958 ret
= qla4_82xx_do_rom_fast_read(ha
, addr
, valp
);
959 qla4_82xx_rom_unlock(ha
);
964 * This routine does CRB initialize sequence
965 * to put the ISP into operational state
968 qla4_82xx_pinit_from_rom(struct scsi_qla_host
*ha
, int verbose
)
972 struct crb_addr_pair
*buf
;
976 struct crb_addr_pair
{
981 /* Halt all the indiviual PEGs and other blocks of the ISP */
982 qla4_82xx_rom_lock(ha
);
984 /* disable all I2Q */
985 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x10, 0x0);
986 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x14, 0x0);
987 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x18, 0x0);
988 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x1c, 0x0);
989 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x20, 0x0);
990 qla4_82xx_wr_32(ha
, QLA82XX_CRB_I2Q
+ 0x24, 0x0);
992 /* disable all niu interrupts */
993 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0x40, 0xff);
994 /* disable xge rx/tx */
995 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0x70000, 0x00);
996 /* disable xg1 rx/tx */
997 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0x80000, 0x00);
998 /* disable sideband mac */
999 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0x90000, 0x00);
1000 /* disable ap0 mac */
1001 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0xa0000, 0x00);
1002 /* disable ap1 mac */
1003 qla4_82xx_wr_32(ha
, QLA82XX_CRB_NIU
+ 0xb0000, 0x00);
1006 val
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_SRE
+ 0x1000);
1007 qla4_82xx_wr_32(ha
, QLA82XX_CRB_SRE
+ 0x1000, val
& (~(0x1)));
1010 qla4_82xx_wr_32(ha
, QLA82XX_CRB_EPG
+ 0x1300, 0x1);
1013 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x0, 0x0);
1014 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x8, 0x0);
1015 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x10, 0x0);
1016 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x18, 0x0);
1017 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x100, 0x0);
1018 qla4_82xx_wr_32(ha
, QLA82XX_CRB_TIMER
+ 0x200, 0x0);
1021 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_0
+ 0x3c, 1);
1022 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_1
+ 0x3c, 1);
1023 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_2
+ 0x3c, 1);
1024 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_3
+ 0x3c, 1);
1025 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_4
+ 0x3c, 1);
1029 if (test_bit(DPC_RESET_HA
, &ha
->dpc_flags
))
1030 /* don't reset CAM block on reset */
1031 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_GLB_SW_RESET
, 0xfeffffff);
1033 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_GLB_SW_RESET
, 0xffffffff);
1035 qla4_82xx_rom_unlock(ha
);
1037 /* Read the signature value from the flash.
1038 * Offset 0: Contain signature (0xcafecafe)
1039 * Offset 4: Offset and number of addr/value pairs
1040 * that present in CRB initialize sequence
1042 if (qla4_82xx_rom_fast_read(ha
, 0, &n
) != 0 || n
!= 0xcafecafeUL
||
1043 qla4_82xx_rom_fast_read(ha
, 4, &n
) != 0) {
1044 ql4_printk(KERN_WARNING
, ha
,
1045 "[ERROR] Reading crb_init area: n: %08x\n", n
);
1049 /* Offset in flash = lower 16 bits
1050 * Number of enteries = upper 16 bits
1052 offset
= n
& 0xffffU
;
1053 n
= (n
>> 16) & 0xffffU
;
1055 /* number of addr/value pair should not exceed 1024 enteries */
1057 ql4_printk(KERN_WARNING
, ha
,
1058 "%s: %s:n=0x%x [ERROR] Card flash not initialized.\n",
1059 DRIVER_NAME
, __func__
, n
);
1063 ql4_printk(KERN_INFO
, ha
,
1064 "%s: %d CRB init values found in ROM.\n", DRIVER_NAME
, n
);
1066 buf
= kmalloc_array(n
, sizeof(struct crb_addr_pair
), GFP_KERNEL
);
1068 ql4_printk(KERN_WARNING
, ha
,
1069 "%s: [ERROR] Unable to malloc memory.\n", DRIVER_NAME
);
1073 for (i
= 0; i
< n
; i
++) {
1074 if (qla4_82xx_rom_fast_read(ha
, 8*i
+ 4*offset
, &val
) != 0 ||
1075 qla4_82xx_rom_fast_read(ha
, 8*i
+ 4*offset
+ 4, &addr
) !=
1085 for (i
= 0; i
< n
; i
++) {
1086 /* Translate internal CRB initialization
1087 * address to PCI bus address
1089 off
= qla4_82xx_decode_crb_addr((unsigned long)buf
[i
].addr
) +
1090 QLA82XX_PCI_CRBSPACE
;
1091 /* Not all CRB addr/value pair to be written,
1092 * some of them are skipped
1095 /* skip if LS bit is set*/
1097 DEBUG2(ql4_printk(KERN_WARNING
, ha
,
1098 "Skip CRB init replay for offset = 0x%lx\n", off
));
1102 /* skipping cold reboot MAGIC */
1103 if (off
== QLA82XX_CAM_RAM(0x1fc))
1106 /* do not reset PCI */
1107 if (off
== (ROMUSB_GLB
+ 0xbc))
1110 /* skip core clock, so that firmware can increase the clock */
1111 if (off
== (ROMUSB_GLB
+ 0xc8))
1114 /* skip the function enable register */
1115 if (off
== QLA82XX_PCIE_REG(PCIE_SETUP_FUNCTION
))
1118 if (off
== QLA82XX_PCIE_REG(PCIE_SETUP_FUNCTION2
))
1121 if ((off
& 0x0ff00000) == QLA82XX_CRB_SMB
)
1124 if ((off
& 0x0ff00000) == QLA82XX_CRB_DDR_NET
)
1127 if (off
== ADDR_ERROR
) {
1128 ql4_printk(KERN_WARNING
, ha
,
1129 "%s: [ERROR] Unknown addr: 0x%08lx\n",
1130 DRIVER_NAME
, buf
[i
].addr
);
1134 qla4_82xx_wr_32(ha
, off
, buf
[i
].data
);
1136 /* ISP requires much bigger delay to settle down,
1137 * else crb_window returns 0xffffffff
1139 if (off
== QLA82XX_ROMUSB_GLB_SW_RESET
)
1142 /* ISP requires millisec delay between
1143 * successive CRB register updation
1150 /* Resetting the data and instruction cache */
1151 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_D
+0xec, 0x1e);
1152 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_D
+0x4c, 8);
1153 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_I
+0x4c, 8);
1155 /* Clear all protocol processing engines */
1156 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_0
+0x8, 0);
1157 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_0
+0xc, 0);
1158 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_1
+0x8, 0);
1159 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_1
+0xc, 0);
1160 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_2
+0x8, 0);
1161 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_2
+0xc, 0);
1162 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_3
+0x8, 0);
1163 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_3
+0xc, 0);
1169 * qla4_8xxx_ms_mem_write_128b - Writes data to MS/off-chip memory
1170 * @ha: Pointer to adapter structure
1171 * @addr: Flash address to write to
1172 * @data: Data to be written
1173 * @count: word_count to be written
1175 * Return: On success return QLA_SUCCESS
1176 * On error return QLA_ERROR
1178 int qla4_8xxx_ms_mem_write_128b(struct scsi_qla_host
*ha
, uint64_t addr
,
1179 uint32_t *data
, uint32_t count
)
1183 unsigned long flags
;
1184 int ret_val
= QLA_SUCCESS
;
1186 /* Only 128-bit aligned access */
1188 ret_val
= QLA_ERROR
;
1189 goto exit_ms_mem_write
;
1192 write_lock_irqsave(&ha
->hw_lock
, flags
);
1195 ret_val
= ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_ADDR_HI
, 0);
1196 if (ret_val
== QLA_ERROR
) {
1197 ql4_printk(KERN_ERR
, ha
, "%s: write to AGT_ADDR_HI failed\n",
1199 goto exit_ms_mem_write_unlock
;
1202 for (i
= 0; i
< count
; i
++, addr
+= 16) {
1203 if (!((QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_QDR_NET
,
1204 QLA8XXX_ADDR_QDR_NET_MAX
)) ||
1205 (QLA8XXX_ADDR_IN_RANGE(addr
, QLA8XXX_ADDR_DDR_NET
,
1206 QLA8XXX_ADDR_DDR_NET_MAX
)))) {
1207 ret_val
= QLA_ERROR
;
1208 goto exit_ms_mem_write_unlock
;
1211 ret_val
= ha
->isp_ops
->wr_reg_indirect(ha
,
1212 MD_MIU_TEST_AGT_ADDR_LO
,
1215 ret_val
|= ha
->isp_ops
->wr_reg_indirect(ha
,
1216 MD_MIU_TEST_AGT_WRDATA_LO
,
1218 ret_val
|= ha
->isp_ops
->wr_reg_indirect(ha
,
1219 MD_MIU_TEST_AGT_WRDATA_HI
,
1221 ret_val
|= ha
->isp_ops
->wr_reg_indirect(ha
,
1222 MD_MIU_TEST_AGT_WRDATA_ULO
,
1224 ret_val
|= ha
->isp_ops
->wr_reg_indirect(ha
,
1225 MD_MIU_TEST_AGT_WRDATA_UHI
,
1227 if (ret_val
== QLA_ERROR
) {
1228 ql4_printk(KERN_ERR
, ha
, "%s: write to AGT_WRDATA failed\n",
1230 goto exit_ms_mem_write_unlock
;
1233 /* Check write status */
1234 ret_val
= ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_CTRL
,
1235 MIU_TA_CTL_WRITE_ENABLE
);
1236 ret_val
|= ha
->isp_ops
->wr_reg_indirect(ha
,
1237 MD_MIU_TEST_AGT_CTRL
,
1238 MIU_TA_CTL_WRITE_START
);
1239 if (ret_val
== QLA_ERROR
) {
1240 ql4_printk(KERN_ERR
, ha
, "%s: write to AGT_CTRL failed\n",
1242 goto exit_ms_mem_write_unlock
;
1245 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1246 ret_val
= ha
->isp_ops
->rd_reg_indirect(ha
,
1247 MD_MIU_TEST_AGT_CTRL
,
1249 if (ret_val
== QLA_ERROR
) {
1250 ql4_printk(KERN_ERR
, ha
, "%s: failed to read MD_MIU_TEST_AGT_CTRL\n",
1252 goto exit_ms_mem_write_unlock
;
1254 if ((agt_ctrl
& MIU_TA_CTL_BUSY
) == 0)
1258 /* Status check failed */
1259 if (j
>= MAX_CTL_CHECK
) {
1260 printk_ratelimited(KERN_ERR
"%s: MS memory write failed!\n",
1262 ret_val
= QLA_ERROR
;
1263 goto exit_ms_mem_write_unlock
;
1267 exit_ms_mem_write_unlock
:
1268 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
1275 qla4_82xx_load_from_flash(struct scsi_qla_host
*ha
, uint32_t image_start
)
1279 long flashaddr
, memaddr
;
1283 flashaddr
= memaddr
= ha
->hw
.flt_region_bootload
;
1284 size
= (image_start
- flashaddr
) / 8;
1286 DEBUG2(printk("scsi%ld: %s: bootldr=0x%lx, fw_image=0x%x\n",
1287 ha
->host_no
, __func__
, flashaddr
, image_start
));
1289 for (i
= 0; i
< size
; i
++) {
1290 if ((qla4_82xx_rom_fast_read(ha
, flashaddr
, (int *)&low
)) ||
1291 (qla4_82xx_rom_fast_read(ha
, flashaddr
+ 4,
1294 goto exit_load_from_flash
;
1296 data
= ((u64
)high
<< 32) | low
;
1297 rval
= qla4_82xx_pci_mem_write_2M(ha
, memaddr
, &data
, 8);
1299 goto exit_load_from_flash
;
1304 if (i
% 0x1000 == 0)
1311 read_lock(&ha
->hw_lock
);
1312 qla4_82xx_wr_32(ha
, QLA82XX_CRB_PEG_NET_0
+ 0x18, 0x1020);
1313 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_GLB_SW_RESET
, 0x80001e);
1314 read_unlock(&ha
->hw_lock
);
1316 exit_load_from_flash
:
1320 static int qla4_82xx_load_fw(struct scsi_qla_host
*ha
, uint32_t image_start
)
1324 qla4_82xx_wr_32(ha
, CRB_CMDPEG_STATE
, 0);
1325 if (qla4_82xx_pinit_from_rom(ha
, 0) != QLA_SUCCESS
) {
1326 printk(KERN_WARNING
"%s: Error during CRB Initialization\n",
1333 /* at this point, QM is in reset. This could be a problem if there are
1334 * incoming d* transition queue messages. QM/PCIE could wedge.
1335 * To get around this, QM is brought out of reset.
1338 rst
= qla4_82xx_rd_32(ha
, QLA82XX_ROMUSB_GLB_SW_RESET
);
1341 qla4_82xx_wr_32(ha
, QLA82XX_ROMUSB_GLB_SW_RESET
, rst
);
1343 if (qla4_82xx_load_from_flash(ha
, image_start
)) {
1344 printk("%s: Error trying to load fw from flash!\n", __func__
);
1352 qla4_82xx_pci_mem_read_2M(struct scsi_qla_host
*ha
,
1353 u64 off
, void *data
, int size
)
1355 int i
, j
= 0, k
, start
, end
, loop
, sz
[2], off0
[2];
1358 uint64_t off8
, val
, mem_crb
, word
[2] = {0, 0};
1361 * If not MN, go check for MS or invalid.
1364 if (off
>= QLA8XXX_ADDR_QDR_NET
&& off
<= QLA82XX_P3_ADDR_QDR_NET_MAX
)
1365 mem_crb
= QLA82XX_CRB_QDR_NET
;
1367 mem_crb
= QLA82XX_CRB_DDR_NET
;
1368 if (qla4_82xx_pci_mem_bound_check(ha
, off
, size
) == 0)
1369 return qla4_82xx_pci_mem_read_direct(ha
,
1374 off8
= off
& 0xfffffff0;
1375 off0
[0] = off
& 0xf;
1376 sz
[0] = (size
< (16 - off0
[0])) ? size
: (16 - off0
[0]);
1379 loop
= ((off0
[0] + size
- 1) >> shift_amount
) + 1;
1381 sz
[1] = size
- sz
[0];
1383 for (i
= 0; i
< loop
; i
++) {
1384 temp
= off8
+ (i
<< shift_amount
);
1385 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_ADDR_LO
, temp
);
1387 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_ADDR_HI
, temp
);
1388 temp
= MIU_TA_CTL_ENABLE
;
1389 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_CTRL
, temp
);
1390 temp
= MIU_TA_CTL_START_ENABLE
;
1391 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_CTRL
, temp
);
1393 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1394 temp
= qla4_82xx_rd_32(ha
, mem_crb
+ MIU_TEST_AGT_CTRL
);
1395 if ((temp
& MIU_TA_CTL_BUSY
) == 0)
1399 if (j
>= MAX_CTL_CHECK
) {
1400 printk_ratelimited(KERN_ERR
1401 "%s: failed to read through agent\n",
1406 start
= off0
[i
] >> 2;
1407 end
= (off0
[i
] + sz
[i
] - 1) >> 2;
1408 for (k
= start
; k
<= end
; k
++) {
1409 temp
= qla4_82xx_rd_32(ha
,
1410 mem_crb
+ MIU_TEST_AGT_RDDATA(k
));
1411 word
[i
] |= ((uint64_t)temp
<< (32 * (k
& 1)));
1415 if (j
>= MAX_CTL_CHECK
)
1418 if ((off0
[0] & 7) == 0) {
1421 val
= ((word
[0] >> (off0
[0] * 8)) & (~(~0ULL << (sz
[0] * 8)))) |
1422 ((word
[1] & (~(~0ULL << (sz
[1] * 8)))) << (sz
[0] * 8));
1427 *(uint8_t *)data
= val
;
1430 *(uint16_t *)data
= val
;
1433 *(uint32_t *)data
= val
;
1436 *(uint64_t *)data
= val
;
1443 qla4_82xx_pci_mem_write_2M(struct scsi_qla_host
*ha
,
1444 u64 off
, void *data
, int size
)
1446 int i
, j
, ret
= 0, loop
, sz
[2], off0
;
1447 int scale
, shift_amount
, startword
;
1449 uint64_t off8
, mem_crb
, tmpw
, word
[2] = {0, 0};
1452 * If not MN, go check for MS or invalid.
1454 if (off
>= QLA8XXX_ADDR_QDR_NET
&& off
<= QLA82XX_P3_ADDR_QDR_NET_MAX
)
1455 mem_crb
= QLA82XX_CRB_QDR_NET
;
1457 mem_crb
= QLA82XX_CRB_DDR_NET
;
1458 if (qla4_82xx_pci_mem_bound_check(ha
, off
, size
) == 0)
1459 return qla4_82xx_pci_mem_write_direct(ha
,
1464 sz
[0] = (size
< (8 - off0
)) ? size
: (8 - off0
);
1465 sz
[1] = size
- sz
[0];
1467 off8
= off
& 0xfffffff0;
1468 loop
= (((off
& 0xf) + size
- 1) >> 4) + 1;
1471 startword
= (off
& 0xf)/8;
1473 for (i
= 0; i
< loop
; i
++) {
1474 if (qla4_82xx_pci_mem_read_2M(ha
, off8
+
1475 (i
<< shift_amount
), &word
[i
* scale
], 8))
1481 tmpw
= *((uint8_t *)data
);
1484 tmpw
= *((uint16_t *)data
);
1487 tmpw
= *((uint32_t *)data
);
1491 tmpw
= *((uint64_t *)data
);
1496 word
[startword
] = tmpw
;
1499 ~((~(~0ULL << (sz
[0] * 8))) << (off0
* 8));
1500 word
[startword
] |= tmpw
<< (off0
* 8);
1504 word
[startword
+1] &= ~(~0ULL << (sz
[1] * 8));
1505 word
[startword
+1] |= tmpw
>> (sz
[0] * 8);
1508 for (i
= 0; i
< loop
; i
++) {
1509 temp
= off8
+ (i
<< shift_amount
);
1510 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_ADDR_LO
, temp
);
1512 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_ADDR_HI
, temp
);
1513 temp
= word
[i
* scale
] & 0xffffffff;
1514 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_WRDATA_LO
, temp
);
1515 temp
= (word
[i
* scale
] >> 32) & 0xffffffff;
1516 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_WRDATA_HI
, temp
);
1517 temp
= word
[i
*scale
+ 1] & 0xffffffff;
1518 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_WRDATA_UPPER_LO
,
1520 temp
= (word
[i
*scale
+ 1] >> 32) & 0xffffffff;
1521 qla4_82xx_wr_32(ha
, mem_crb
+ MIU_TEST_AGT_WRDATA_UPPER_HI
,
1524 temp
= MIU_TA_CTL_WRITE_ENABLE
;
1525 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_CTRL
, temp
);
1526 temp
= MIU_TA_CTL_WRITE_START
;
1527 qla4_82xx_wr_32(ha
, mem_crb
+MIU_TEST_AGT_CTRL
, temp
);
1529 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
1530 temp
= qla4_82xx_rd_32(ha
, mem_crb
+ MIU_TEST_AGT_CTRL
);
1531 if ((temp
& MIU_TA_CTL_BUSY
) == 0)
1535 if (j
>= MAX_CTL_CHECK
) {
1536 if (printk_ratelimit())
1537 ql4_printk(KERN_ERR
, ha
,
1538 "%s: failed to read through agent\n",
1548 static int qla4_82xx_cmdpeg_ready(struct scsi_qla_host
*ha
, int pegtune_val
)
1555 val
= qla4_82xx_rd_32(ha
, CRB_CMDPEG_STATE
);
1556 if ((val
== PHAN_INITIALIZE_COMPLETE
) ||
1557 (val
== PHAN_INITIALIZE_ACK
))
1559 set_current_state(TASK_UNINTERRUPTIBLE
);
1560 schedule_timeout(500);
1562 } while (--retries
);
1565 pegtune_val
= qla4_82xx_rd_32(ha
,
1566 QLA82XX_ROMUSB_GLB_PEGTUNE_DONE
);
1567 printk(KERN_WARNING
"%s: init failed, "
1568 "pegtune_val = %x\n", __func__
, pegtune_val
);
1575 static int qla4_82xx_rcvpeg_ready(struct scsi_qla_host
*ha
)
1581 read_lock(&ha
->hw_lock
);
1582 state
= qla4_82xx_rd_32(ha
, CRB_RCVPEG_STATE
);
1583 read_unlock(&ha
->hw_lock
);
1585 while ((state
!= PHAN_PEG_RCV_INITIALIZED
) && (loops
< 30000)) {
1588 read_lock(&ha
->hw_lock
);
1589 state
= qla4_82xx_rd_32(ha
, CRB_RCVPEG_STATE
);
1590 read_unlock(&ha
->hw_lock
);
1595 if (loops
>= 30000) {
1596 DEBUG2(ql4_printk(KERN_INFO
, ha
,
1597 "Receive Peg initialization not complete: 0x%x.\n", state
));
1605 qla4_8xxx_set_drv_active(struct scsi_qla_host
*ha
)
1607 uint32_t drv_active
;
1609 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
1612 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1613 * shift 1 by func_num to set a bit for the function.
1614 * For ISP8022, drv_active has 4 bits per function
1616 if (is_qla8032(ha
) || is_qla8042(ha
))
1617 drv_active
|= (1 << ha
->func_num
);
1619 drv_active
|= (1 << (ha
->func_num
* 4));
1621 ql4_printk(KERN_INFO
, ha
, "%s(%ld): drv_active: 0x%08x\n",
1622 __func__
, ha
->host_no
, drv_active
);
1623 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
, drv_active
);
1627 qla4_8xxx_clear_drv_active(struct scsi_qla_host
*ha
)
1629 uint32_t drv_active
;
1631 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
1634 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1635 * shift 1 by func_num to set a bit for the function.
1636 * For ISP8022, drv_active has 4 bits per function
1638 if (is_qla8032(ha
) || is_qla8042(ha
))
1639 drv_active
&= ~(1 << (ha
->func_num
));
1641 drv_active
&= ~(1 << (ha
->func_num
* 4));
1643 ql4_printk(KERN_INFO
, ha
, "%s(%ld): drv_active: 0x%08x\n",
1644 __func__
, ha
->host_no
, drv_active
);
1645 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
, drv_active
);
1648 inline int qla4_8xxx_need_reset(struct scsi_qla_host
*ha
)
1650 uint32_t drv_state
, drv_active
;
1653 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
1654 drv_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_STATE
);
1657 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1658 * shift 1 by func_num to set a bit for the function.
1659 * For ISP8022, drv_active has 4 bits per function
1661 if (is_qla8032(ha
) || is_qla8042(ha
))
1662 rval
= drv_state
& (1 << ha
->func_num
);
1664 rval
= drv_state
& (1 << (ha
->func_num
* 4));
1666 if ((test_bit(AF_EEH_BUSY
, &ha
->flags
)) && drv_active
)
1672 void qla4_8xxx_set_rst_ready(struct scsi_qla_host
*ha
)
1676 drv_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_STATE
);
1679 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1680 * shift 1 by func_num to set a bit for the function.
1681 * For ISP8022, drv_active has 4 bits per function
1683 if (is_qla8032(ha
) || is_qla8042(ha
))
1684 drv_state
|= (1 << ha
->func_num
);
1686 drv_state
|= (1 << (ha
->func_num
* 4));
1688 ql4_printk(KERN_INFO
, ha
, "%s(%ld): drv_state: 0x%08x\n",
1689 __func__
, ha
->host_no
, drv_state
);
1690 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_STATE
, drv_state
);
1693 void qla4_8xxx_clear_rst_ready(struct scsi_qla_host
*ha
)
1697 drv_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_STATE
);
1700 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1701 * shift 1 by func_num to set a bit for the function.
1702 * For ISP8022, drv_active has 4 bits per function
1704 if (is_qla8032(ha
) || is_qla8042(ha
))
1705 drv_state
&= ~(1 << ha
->func_num
);
1707 drv_state
&= ~(1 << (ha
->func_num
* 4));
1709 ql4_printk(KERN_INFO
, ha
, "%s(%ld): drv_state: 0x%08x\n",
1710 __func__
, ha
->host_no
, drv_state
);
1711 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_STATE
, drv_state
);
1715 qla4_8xxx_set_qsnt_ready(struct scsi_qla_host
*ha
)
1717 uint32_t qsnt_state
;
1719 qsnt_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_STATE
);
1722 * For ISP8324 and ISP8042, drv_active register has 1 bit per function,
1723 * shift 1 by func_num to set a bit for the function.
1724 * For ISP8022, drv_active has 4 bits per function.
1726 if (is_qla8032(ha
) || is_qla8042(ha
))
1727 qsnt_state
|= (1 << ha
->func_num
);
1729 qsnt_state
|= (2 << (ha
->func_num
* 4));
1731 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_STATE
, qsnt_state
);
1736 qla4_82xx_start_firmware(struct scsi_qla_host
*ha
, uint32_t image_start
)
1740 /* scrub dma mask expansion register */
1741 qla4_82xx_wr_32(ha
, CRB_DMA_SHIFT
, 0x55555555);
1743 /* Overwrite stale initialization register values */
1744 qla4_82xx_wr_32(ha
, CRB_CMDPEG_STATE
, 0);
1745 qla4_82xx_wr_32(ha
, CRB_RCVPEG_STATE
, 0);
1746 qla4_82xx_wr_32(ha
, QLA82XX_PEG_HALT_STATUS1
, 0);
1747 qla4_82xx_wr_32(ha
, QLA82XX_PEG_HALT_STATUS2
, 0);
1749 if (qla4_82xx_load_fw(ha
, image_start
) != QLA_SUCCESS
) {
1750 printk("%s: Error trying to start fw!\n", __func__
);
1754 /* Handshake with the card before we register the devices. */
1755 if (qla4_82xx_cmdpeg_ready(ha
, 0) != QLA_SUCCESS
) {
1756 printk("%s: Error during card handshake!\n", __func__
);
1760 /* Negotiated Link width */
1761 pcie_capability_read_word(ha
->pdev
, PCI_EXP_LNKSTA
, &lnk
);
1762 ha
->link_width
= (lnk
>> 4) & 0x3f;
1764 /* Synchronize with Receive peg */
1765 return qla4_82xx_rcvpeg_ready(ha
);
1768 int qla4_82xx_try_start_fw(struct scsi_qla_host
*ha
)
1774 * 1) Operational firmware residing in flash.
1778 ql4_printk(KERN_INFO
, ha
,
1779 "FW: Retrieving flash offsets from FLT/FDT ...\n");
1780 rval
= qla4_8xxx_get_flash_info(ha
);
1781 if (rval
!= QLA_SUCCESS
)
1784 ql4_printk(KERN_INFO
, ha
,
1785 "FW: Attempting to load firmware from flash...\n");
1786 rval
= qla4_82xx_start_firmware(ha
, ha
->hw
.flt_region_fw
);
1788 if (rval
!= QLA_SUCCESS
) {
1789 ql4_printk(KERN_ERR
, ha
, "FW: Load firmware from flash"
1797 void qla4_82xx_rom_lock_recovery(struct scsi_qla_host
*ha
)
1799 if (qla4_82xx_rom_lock(ha
)) {
1800 /* Someone else is holding the lock. */
1801 dev_info(&ha
->pdev
->dev
, "Resetting rom_lock\n");
1805 * Either we got the lock, or someone
1806 * else died while holding it.
1807 * In either case, unlock.
1809 qla4_82xx_rom_unlock(ha
);
1812 static uint32_t ql4_84xx_poll_wait_for_ready(struct scsi_qla_host
*ha
,
1813 uint32_t addr1
, uint32_t mask
)
1815 unsigned long timeout
;
1816 uint32_t rval
= QLA_SUCCESS
;
1819 timeout
= jiffies
+ msecs_to_jiffies(TIMEOUT_100_MS
);
1821 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &temp
);
1822 if ((temp
& mask
) != 0)
1825 if (time_after_eq(jiffies
, timeout
)) {
1826 ql4_printk(KERN_INFO
, ha
, "Error in processing rdmdio entry\n");
1834 static uint32_t ql4_84xx_ipmdio_rd_reg(struct scsi_qla_host
*ha
, uint32_t addr1
,
1835 uint32_t addr3
, uint32_t mask
, uint32_t addr
,
1838 int rval
= QLA_SUCCESS
;
1842 rval
= ql4_84xx_poll_wait_for_ready(ha
, addr1
, mask
);
1844 goto exit_ipmdio_rd_reg
;
1846 temp
= (0x40000000 | addr
);
1847 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
, temp
);
1849 rval
= ql4_84xx_poll_wait_for_ready(ha
, addr1
, mask
);
1851 goto exit_ipmdio_rd_reg
;
1853 ha
->isp_ops
->rd_reg_indirect(ha
, addr3
, &data
);
1861 static uint32_t ql4_84xx_poll_wait_ipmdio_bus_idle(struct scsi_qla_host
*ha
,
1867 unsigned long timeout
;
1869 uint32_t rval
= QLA_SUCCESS
;
1871 timeout
= jiffies
+ msecs_to_jiffies(TIMEOUT_100_MS
);
1873 ql4_84xx_ipmdio_rd_reg(ha
, addr1
, addr3
, mask
, addr2
, &temp
);
1874 if ((temp
& 0x1) != 1)
1876 if (time_after_eq(jiffies
, timeout
)) {
1877 ql4_printk(KERN_INFO
, ha
, "Error in processing mdiobus idle\n");
1885 static int ql4_84xx_ipmdio_wr_reg(struct scsi_qla_host
*ha
,
1886 uint32_t addr1
, uint32_t addr3
,
1887 uint32_t mask
, uint32_t addr
,
1890 int rval
= QLA_SUCCESS
;
1892 rval
= ql4_84xx_poll_wait_for_ready(ha
, addr1
, mask
);
1894 goto exit_ipmdio_wr_reg
;
1896 ha
->isp_ops
->wr_reg_indirect(ha
, addr3
, value
);
1897 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
, addr
);
1899 rval
= ql4_84xx_poll_wait_for_ready(ha
, addr1
, mask
);
1901 goto exit_ipmdio_wr_reg
;
1907 static void qla4_8xxx_minidump_process_rdcrb(struct scsi_qla_host
*ha
,
1908 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
1911 uint32_t r_addr
, r_stride
, loop_cnt
, i
, r_value
;
1912 struct qla8xxx_minidump_entry_crb
*crb_hdr
;
1913 uint32_t *data_ptr
= *d_ptr
;
1915 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
1916 crb_hdr
= (struct qla8xxx_minidump_entry_crb
*)entry_hdr
;
1917 r_addr
= crb_hdr
->addr
;
1918 r_stride
= crb_hdr
->crb_strd
.addr_stride
;
1919 loop_cnt
= crb_hdr
->op_count
;
1921 for (i
= 0; i
< loop_cnt
; i
++) {
1922 ha
->isp_ops
->rd_reg_indirect(ha
, r_addr
, &r_value
);
1923 *data_ptr
++ = cpu_to_le32(r_addr
);
1924 *data_ptr
++ = cpu_to_le32(r_value
);
1930 static int qla4_83xx_check_dma_engine_state(struct scsi_qla_host
*ha
)
1932 int rval
= QLA_SUCCESS
;
1933 uint32_t dma_eng_num
= 0, cmd_sts_and_cntrl
= 0;
1934 uint64_t dma_base_addr
= 0;
1935 struct qla4_8xxx_minidump_template_hdr
*tmplt_hdr
= NULL
;
1937 tmplt_hdr
= (struct qla4_8xxx_minidump_template_hdr
*)
1938 ha
->fw_dump_tmplt_hdr
;
1940 tmplt_hdr
->saved_state_array
[QLA83XX_PEX_DMA_ENGINE_INDEX
];
1941 dma_base_addr
= QLA83XX_PEX_DMA_BASE_ADDRESS
+
1942 (dma_eng_num
* QLA83XX_PEX_DMA_NUM_OFFSET
);
1944 /* Read the pex-dma's command-status-and-control register. */
1945 rval
= ha
->isp_ops
->rd_reg_indirect(ha
,
1946 (dma_base_addr
+ QLA83XX_PEX_DMA_CMD_STS_AND_CNTRL
),
1947 &cmd_sts_and_cntrl
);
1952 /* Check if requested pex-dma engine is available. */
1953 if (cmd_sts_and_cntrl
& BIT_31
)
1959 static int qla4_83xx_start_pex_dma(struct scsi_qla_host
*ha
,
1960 struct qla4_83xx_minidump_entry_rdmem_pex_dma
*m_hdr
)
1962 int rval
= QLA_SUCCESS
, wait
= 0;
1963 uint32_t dma_eng_num
= 0, cmd_sts_and_cntrl
= 0;
1964 uint64_t dma_base_addr
= 0;
1965 struct qla4_8xxx_minidump_template_hdr
*tmplt_hdr
= NULL
;
1967 tmplt_hdr
= (struct qla4_8xxx_minidump_template_hdr
*)
1968 ha
->fw_dump_tmplt_hdr
;
1970 tmplt_hdr
->saved_state_array
[QLA83XX_PEX_DMA_ENGINE_INDEX
];
1971 dma_base_addr
= QLA83XX_PEX_DMA_BASE_ADDRESS
+
1972 (dma_eng_num
* QLA83XX_PEX_DMA_NUM_OFFSET
);
1974 rval
= ha
->isp_ops
->wr_reg_indirect(ha
,
1975 dma_base_addr
+ QLA83XX_PEX_DMA_CMD_ADDR_LOW
,
1976 m_hdr
->desc_card_addr
);
1980 rval
= ha
->isp_ops
->wr_reg_indirect(ha
,
1981 dma_base_addr
+ QLA83XX_PEX_DMA_CMD_ADDR_HIGH
, 0);
1985 rval
= ha
->isp_ops
->wr_reg_indirect(ha
,
1986 dma_base_addr
+ QLA83XX_PEX_DMA_CMD_STS_AND_CNTRL
,
1987 m_hdr
->start_dma_cmd
);
1991 /* Wait for dma operation to complete. */
1992 for (wait
= 0; wait
< QLA83XX_PEX_DMA_MAX_WAIT
; wait
++) {
1993 rval
= ha
->isp_ops
->rd_reg_indirect(ha
,
1994 (dma_base_addr
+ QLA83XX_PEX_DMA_CMD_STS_AND_CNTRL
),
1995 &cmd_sts_and_cntrl
);
1999 if ((cmd_sts_and_cntrl
& BIT_1
) == 0)
2005 /* Wait a max of 100 ms, otherwise fallback to rdmem entry read */
2006 if (wait
>= QLA83XX_PEX_DMA_MAX_WAIT
) {
2015 static int qla4_8xxx_minidump_pex_dma_read(struct scsi_qla_host
*ha
,
2016 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2019 int rval
= QLA_SUCCESS
;
2020 struct qla4_83xx_minidump_entry_rdmem_pex_dma
*m_hdr
= NULL
;
2021 uint32_t size
, read_size
;
2022 uint8_t *data_ptr
= (uint8_t *)*d_ptr
;
2023 void *rdmem_buffer
= NULL
;
2024 dma_addr_t rdmem_dma
;
2025 struct qla4_83xx_pex_dma_descriptor dma_desc
;
2027 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2029 rval
= qla4_83xx_check_dma_engine_state(ha
);
2030 if (rval
!= QLA_SUCCESS
) {
2031 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2032 "%s: DMA engine not available. Fallback to rdmem-read.\n",
2037 m_hdr
= (struct qla4_83xx_minidump_entry_rdmem_pex_dma
*)entry_hdr
;
2038 rdmem_buffer
= dma_alloc_coherent(&ha
->pdev
->dev
,
2039 QLA83XX_PEX_DMA_READ_SIZE
,
2040 &rdmem_dma
, GFP_KERNEL
);
2041 if (!rdmem_buffer
) {
2042 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2043 "%s: Unable to allocate rdmem dma buffer\n",
2048 /* Prepare pex-dma descriptor to be written to MS memory. */
2049 /* dma-desc-cmd layout:
2050 * 0-3: dma-desc-cmd 0-3
2051 * 4-7: pcid function number
2052 * 8-15: dma-desc-cmd 8-15
2054 dma_desc
.cmd
.dma_desc_cmd
= (m_hdr
->dma_desc_cmd
& 0xff0f);
2055 dma_desc
.cmd
.dma_desc_cmd
|= ((PCI_FUNC(ha
->pdev
->devfn
) & 0xf) << 0x4);
2056 dma_desc
.dma_bus_addr
= rdmem_dma
;
2061 * Perform rdmem operation using pex-dma.
2062 * Prepare dma in chunks of QLA83XX_PEX_DMA_READ_SIZE.
2064 while (read_size
< m_hdr
->read_data_size
) {
2065 if (m_hdr
->read_data_size
- read_size
>=
2066 QLA83XX_PEX_DMA_READ_SIZE
)
2067 size
= QLA83XX_PEX_DMA_READ_SIZE
;
2069 size
= (m_hdr
->read_data_size
- read_size
);
2072 dma_free_coherent(&ha
->pdev
->dev
,
2073 QLA83XX_PEX_DMA_READ_SIZE
,
2074 rdmem_buffer
, rdmem_dma
);
2076 rdmem_buffer
= dma_alloc_coherent(&ha
->pdev
->dev
, size
,
2079 if (!rdmem_buffer
) {
2080 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2081 "%s: Unable to allocate rdmem dma buffer\n",
2085 dma_desc
.dma_bus_addr
= rdmem_dma
;
2088 dma_desc
.src_addr
= m_hdr
->read_addr
+ read_size
;
2089 dma_desc
.cmd
.read_data_size
= size
;
2091 /* Prepare: Write pex-dma descriptor to MS memory. */
2092 rval
= qla4_8xxx_ms_mem_write_128b(ha
,
2093 (uint64_t)m_hdr
->desc_card_addr
,
2094 (uint32_t *)&dma_desc
,
2095 (sizeof(struct qla4_83xx_pex_dma_descriptor
)/16));
2096 if (rval
!= QLA_SUCCESS
) {
2097 ql4_printk(KERN_INFO
, ha
,
2098 "%s: Error writing rdmem-dma-init to MS !!!\n",
2103 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2104 "%s: Dma-desc: Instruct for rdmem dma (size 0x%x).\n",
2106 /* Execute: Start pex-dma operation. */
2107 rval
= qla4_83xx_start_pex_dma(ha
, m_hdr
);
2108 if (rval
!= QLA_SUCCESS
) {
2109 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2110 "scsi(%ld): start-pex-dma failed rval=0x%x\n",
2111 ha
->host_no
, rval
));
2115 memcpy(data_ptr
, rdmem_buffer
, size
);
2120 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Leaving fn: %s\n", __func__
));
2122 *d_ptr
= (uint32_t *)data_ptr
;
2126 dma_free_coherent(&ha
->pdev
->dev
, size
, rdmem_buffer
,
2132 static int qla4_8xxx_minidump_process_l2tag(struct scsi_qla_host
*ha
,
2133 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2136 uint32_t addr
, r_addr
, c_addr
, t_r_addr
;
2137 uint32_t i
, k
, loop_count
, t_value
, r_cnt
, r_value
;
2138 unsigned long p_wait
, w_time
, p_mask
;
2139 uint32_t c_value_w
, c_value_r
;
2140 struct qla8xxx_minidump_entry_cache
*cache_hdr
;
2141 int rval
= QLA_ERROR
;
2142 uint32_t *data_ptr
= *d_ptr
;
2144 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2145 cache_hdr
= (struct qla8xxx_minidump_entry_cache
*)entry_hdr
;
2147 loop_count
= cache_hdr
->op_count
;
2148 r_addr
= cache_hdr
->read_addr
;
2149 c_addr
= cache_hdr
->control_addr
;
2150 c_value_w
= cache_hdr
->cache_ctrl
.write_value
;
2152 t_r_addr
= cache_hdr
->tag_reg_addr
;
2153 t_value
= cache_hdr
->addr_ctrl
.init_tag_value
;
2154 r_cnt
= cache_hdr
->read_ctrl
.read_addr_cnt
;
2155 p_wait
= cache_hdr
->cache_ctrl
.poll_wait
;
2156 p_mask
= cache_hdr
->cache_ctrl
.poll_mask
;
2158 for (i
= 0; i
< loop_count
; i
++) {
2159 ha
->isp_ops
->wr_reg_indirect(ha
, t_r_addr
, t_value
);
2162 ha
->isp_ops
->wr_reg_indirect(ha
, c_addr
, c_value_w
);
2165 w_time
= jiffies
+ p_wait
;
2167 ha
->isp_ops
->rd_reg_indirect(ha
, c_addr
,
2169 if ((c_value_r
& p_mask
) == 0) {
2171 } else if (time_after_eq(jiffies
, w_time
)) {
2172 /* capturing dump failed */
2179 for (k
= 0; k
< r_cnt
; k
++) {
2180 ha
->isp_ops
->rd_reg_indirect(ha
, addr
, &r_value
);
2181 *data_ptr
++ = cpu_to_le32(r_value
);
2182 addr
+= cache_hdr
->read_ctrl
.read_addr_stride
;
2185 t_value
+= cache_hdr
->addr_ctrl
.tag_value_stride
;
2191 static int qla4_8xxx_minidump_process_control(struct scsi_qla_host
*ha
,
2192 struct qla8xxx_minidump_entry_hdr
*entry_hdr
)
2194 struct qla8xxx_minidump_entry_crb
*crb_entry
;
2195 uint32_t read_value
, opcode
, poll_time
, addr
, index
, rval
= QLA_SUCCESS
;
2197 unsigned long wtime
;
2198 struct qla4_8xxx_minidump_template_hdr
*tmplt_hdr
;
2201 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2202 tmplt_hdr
= (struct qla4_8xxx_minidump_template_hdr
*)
2203 ha
->fw_dump_tmplt_hdr
;
2204 crb_entry
= (struct qla8xxx_minidump_entry_crb
*)entry_hdr
;
2206 crb_addr
= crb_entry
->addr
;
2207 for (i
= 0; i
< crb_entry
->op_count
; i
++) {
2208 opcode
= crb_entry
->crb_ctrl
.opcode
;
2209 if (opcode
& QLA8XXX_DBG_OPCODE_WR
) {
2210 ha
->isp_ops
->wr_reg_indirect(ha
, crb_addr
,
2211 crb_entry
->value_1
);
2212 opcode
&= ~QLA8XXX_DBG_OPCODE_WR
;
2214 if (opcode
& QLA8XXX_DBG_OPCODE_RW
) {
2215 ha
->isp_ops
->rd_reg_indirect(ha
, crb_addr
, &read_value
);
2216 ha
->isp_ops
->wr_reg_indirect(ha
, crb_addr
, read_value
);
2217 opcode
&= ~QLA8XXX_DBG_OPCODE_RW
;
2219 if (opcode
& QLA8XXX_DBG_OPCODE_AND
) {
2220 ha
->isp_ops
->rd_reg_indirect(ha
, crb_addr
, &read_value
);
2221 read_value
&= crb_entry
->value_2
;
2222 opcode
&= ~QLA8XXX_DBG_OPCODE_AND
;
2223 if (opcode
& QLA8XXX_DBG_OPCODE_OR
) {
2224 read_value
|= crb_entry
->value_3
;
2225 opcode
&= ~QLA8XXX_DBG_OPCODE_OR
;
2227 ha
->isp_ops
->wr_reg_indirect(ha
, crb_addr
, read_value
);
2229 if (opcode
& QLA8XXX_DBG_OPCODE_OR
) {
2230 ha
->isp_ops
->rd_reg_indirect(ha
, crb_addr
, &read_value
);
2231 read_value
|= crb_entry
->value_3
;
2232 ha
->isp_ops
->wr_reg_indirect(ha
, crb_addr
, read_value
);
2233 opcode
&= ~QLA8XXX_DBG_OPCODE_OR
;
2235 if (opcode
& QLA8XXX_DBG_OPCODE_POLL
) {
2236 poll_time
= crb_entry
->crb_strd
.poll_timeout
;
2237 wtime
= jiffies
+ poll_time
;
2238 ha
->isp_ops
->rd_reg_indirect(ha
, crb_addr
, &read_value
);
2241 if ((read_value
& crb_entry
->value_2
) ==
2242 crb_entry
->value_1
) {
2244 } else if (time_after_eq(jiffies
, wtime
)) {
2245 /* capturing dump failed */
2249 ha
->isp_ops
->rd_reg_indirect(ha
,
2250 crb_addr
, &read_value
);
2253 opcode
&= ~QLA8XXX_DBG_OPCODE_POLL
;
2256 if (opcode
& QLA8XXX_DBG_OPCODE_RDSTATE
) {
2257 if (crb_entry
->crb_strd
.state_index_a
) {
2258 index
= crb_entry
->crb_strd
.state_index_a
;
2259 addr
= tmplt_hdr
->saved_state_array
[index
];
2264 ha
->isp_ops
->rd_reg_indirect(ha
, addr
, &read_value
);
2265 index
= crb_entry
->crb_ctrl
.state_index_v
;
2266 tmplt_hdr
->saved_state_array
[index
] = read_value
;
2267 opcode
&= ~QLA8XXX_DBG_OPCODE_RDSTATE
;
2270 if (opcode
& QLA8XXX_DBG_OPCODE_WRSTATE
) {
2271 if (crb_entry
->crb_strd
.state_index_a
) {
2272 index
= crb_entry
->crb_strd
.state_index_a
;
2273 addr
= tmplt_hdr
->saved_state_array
[index
];
2278 if (crb_entry
->crb_ctrl
.state_index_v
) {
2279 index
= crb_entry
->crb_ctrl
.state_index_v
;
2281 tmplt_hdr
->saved_state_array
[index
];
2283 read_value
= crb_entry
->value_1
;
2286 ha
->isp_ops
->wr_reg_indirect(ha
, addr
, read_value
);
2287 opcode
&= ~QLA8XXX_DBG_OPCODE_WRSTATE
;
2290 if (opcode
& QLA8XXX_DBG_OPCODE_MDSTATE
) {
2291 index
= crb_entry
->crb_ctrl
.state_index_v
;
2292 read_value
= tmplt_hdr
->saved_state_array
[index
];
2293 read_value
<<= crb_entry
->crb_ctrl
.shl
;
2294 read_value
>>= crb_entry
->crb_ctrl
.shr
;
2295 if (crb_entry
->value_2
)
2296 read_value
&= crb_entry
->value_2
;
2297 read_value
|= crb_entry
->value_3
;
2298 read_value
+= crb_entry
->value_1
;
2299 tmplt_hdr
->saved_state_array
[index
] = read_value
;
2300 opcode
&= ~QLA8XXX_DBG_OPCODE_MDSTATE
;
2302 crb_addr
+= crb_entry
->crb_strd
.addr_stride
;
2304 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Leaving fn: %s\n", __func__
));
2308 static void qla4_8xxx_minidump_process_rdocm(struct scsi_qla_host
*ha
,
2309 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2312 uint32_t r_addr
, r_stride
, loop_cnt
, i
, r_value
;
2313 struct qla8xxx_minidump_entry_rdocm
*ocm_hdr
;
2314 uint32_t *data_ptr
= *d_ptr
;
2316 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2317 ocm_hdr
= (struct qla8xxx_minidump_entry_rdocm
*)entry_hdr
;
2318 r_addr
= ocm_hdr
->read_addr
;
2319 r_stride
= ocm_hdr
->read_addr_stride
;
2320 loop_cnt
= ocm_hdr
->op_count
;
2322 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2323 "[%s]: r_addr: 0x%x, r_stride: 0x%x, loop_cnt: 0x%x\n",
2324 __func__
, r_addr
, r_stride
, loop_cnt
));
2326 for (i
= 0; i
< loop_cnt
; i
++) {
2327 r_value
= readl((void __iomem
*)(r_addr
+ ha
->nx_pcibase
));
2328 *data_ptr
++ = cpu_to_le32(r_value
);
2331 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Leaving fn: %s datacount: 0x%lx\n",
2332 __func__
, (long unsigned int) (loop_cnt
* sizeof(uint32_t))));
2336 static void qla4_8xxx_minidump_process_rdmux(struct scsi_qla_host
*ha
,
2337 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2340 uint32_t r_addr
, s_stride
, s_addr
, s_value
, loop_cnt
, i
, r_value
;
2341 struct qla8xxx_minidump_entry_mux
*mux_hdr
;
2342 uint32_t *data_ptr
= *d_ptr
;
2344 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2345 mux_hdr
= (struct qla8xxx_minidump_entry_mux
*)entry_hdr
;
2346 r_addr
= mux_hdr
->read_addr
;
2347 s_addr
= mux_hdr
->select_addr
;
2348 s_stride
= mux_hdr
->select_value_stride
;
2349 s_value
= mux_hdr
->select_value
;
2350 loop_cnt
= mux_hdr
->op_count
;
2352 for (i
= 0; i
< loop_cnt
; i
++) {
2353 ha
->isp_ops
->wr_reg_indirect(ha
, s_addr
, s_value
);
2354 ha
->isp_ops
->rd_reg_indirect(ha
, r_addr
, &r_value
);
2355 *data_ptr
++ = cpu_to_le32(s_value
);
2356 *data_ptr
++ = cpu_to_le32(r_value
);
2357 s_value
+= s_stride
;
2362 static void qla4_8xxx_minidump_process_l1cache(struct scsi_qla_host
*ha
,
2363 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2366 uint32_t addr
, r_addr
, c_addr
, t_r_addr
;
2367 uint32_t i
, k
, loop_count
, t_value
, r_cnt
, r_value
;
2369 struct qla8xxx_minidump_entry_cache
*cache_hdr
;
2370 uint32_t *data_ptr
= *d_ptr
;
2372 cache_hdr
= (struct qla8xxx_minidump_entry_cache
*)entry_hdr
;
2373 loop_count
= cache_hdr
->op_count
;
2374 r_addr
= cache_hdr
->read_addr
;
2375 c_addr
= cache_hdr
->control_addr
;
2376 c_value_w
= cache_hdr
->cache_ctrl
.write_value
;
2378 t_r_addr
= cache_hdr
->tag_reg_addr
;
2379 t_value
= cache_hdr
->addr_ctrl
.init_tag_value
;
2380 r_cnt
= cache_hdr
->read_ctrl
.read_addr_cnt
;
2382 for (i
= 0; i
< loop_count
; i
++) {
2383 ha
->isp_ops
->wr_reg_indirect(ha
, t_r_addr
, t_value
);
2384 ha
->isp_ops
->wr_reg_indirect(ha
, c_addr
, c_value_w
);
2386 for (k
= 0; k
< r_cnt
; k
++) {
2387 ha
->isp_ops
->rd_reg_indirect(ha
, addr
, &r_value
);
2388 *data_ptr
++ = cpu_to_le32(r_value
);
2389 addr
+= cache_hdr
->read_ctrl
.read_addr_stride
;
2391 t_value
+= cache_hdr
->addr_ctrl
.tag_value_stride
;
2396 static void qla4_8xxx_minidump_process_queue(struct scsi_qla_host
*ha
,
2397 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2400 uint32_t s_addr
, r_addr
;
2401 uint32_t r_stride
, r_value
, r_cnt
, qid
= 0;
2402 uint32_t i
, k
, loop_cnt
;
2403 struct qla8xxx_minidump_entry_queue
*q_hdr
;
2404 uint32_t *data_ptr
= *d_ptr
;
2406 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2407 q_hdr
= (struct qla8xxx_minidump_entry_queue
*)entry_hdr
;
2408 s_addr
= q_hdr
->select_addr
;
2409 r_cnt
= q_hdr
->rd_strd
.read_addr_cnt
;
2410 r_stride
= q_hdr
->rd_strd
.read_addr_stride
;
2411 loop_cnt
= q_hdr
->op_count
;
2413 for (i
= 0; i
< loop_cnt
; i
++) {
2414 ha
->isp_ops
->wr_reg_indirect(ha
, s_addr
, qid
);
2415 r_addr
= q_hdr
->read_addr
;
2416 for (k
= 0; k
< r_cnt
; k
++) {
2417 ha
->isp_ops
->rd_reg_indirect(ha
, r_addr
, &r_value
);
2418 *data_ptr
++ = cpu_to_le32(r_value
);
2421 qid
+= q_hdr
->q_strd
.queue_id_stride
;
2426 #define MD_DIRECT_ROM_WINDOW 0x42110030
2427 #define MD_DIRECT_ROM_READ_BASE 0x42150000
2429 static void qla4_82xx_minidump_process_rdrom(struct scsi_qla_host
*ha
,
2430 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2433 uint32_t r_addr
, r_value
;
2434 uint32_t i
, loop_cnt
;
2435 struct qla8xxx_minidump_entry_rdrom
*rom_hdr
;
2436 uint32_t *data_ptr
= *d_ptr
;
2438 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2439 rom_hdr
= (struct qla8xxx_minidump_entry_rdrom
*)entry_hdr
;
2440 r_addr
= rom_hdr
->read_addr
;
2441 loop_cnt
= rom_hdr
->read_data_size
/sizeof(uint32_t);
2443 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2444 "[%s]: flash_addr: 0x%x, read_data_size: 0x%x\n",
2445 __func__
, r_addr
, loop_cnt
));
2447 for (i
= 0; i
< loop_cnt
; i
++) {
2448 ha
->isp_ops
->wr_reg_indirect(ha
, MD_DIRECT_ROM_WINDOW
,
2449 (r_addr
& 0xFFFF0000));
2450 ha
->isp_ops
->rd_reg_indirect(ha
,
2451 MD_DIRECT_ROM_READ_BASE
+ (r_addr
& 0x0000FFFF),
2453 *data_ptr
++ = cpu_to_le32(r_value
);
2454 r_addr
+= sizeof(uint32_t);
2459 #define MD_MIU_TEST_AGT_CTRL 0x41000090
2460 #define MD_MIU_TEST_AGT_ADDR_LO 0x41000094
2461 #define MD_MIU_TEST_AGT_ADDR_HI 0x41000098
2463 static int __qla4_8xxx_minidump_process_rdmem(struct scsi_qla_host
*ha
,
2464 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2467 uint32_t r_addr
, r_value
, r_data
;
2468 uint32_t i
, j
, loop_cnt
;
2469 struct qla8xxx_minidump_entry_rdmem
*m_hdr
;
2470 unsigned long flags
;
2471 uint32_t *data_ptr
= *d_ptr
;
2473 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Entering fn: %s\n", __func__
));
2474 m_hdr
= (struct qla8xxx_minidump_entry_rdmem
*)entry_hdr
;
2475 r_addr
= m_hdr
->read_addr
;
2476 loop_cnt
= m_hdr
->read_data_size
/16;
2478 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2479 "[%s]: Read addr: 0x%x, read_data_size: 0x%x\n",
2480 __func__
, r_addr
, m_hdr
->read_data_size
));
2483 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2484 "[%s]: Read addr 0x%x not 16 bytes aligned\n",
2489 if (m_hdr
->read_data_size
% 16) {
2490 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2491 "[%s]: Read data[0x%x] not multiple of 16 bytes\n",
2492 __func__
, m_hdr
->read_data_size
));
2496 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2497 "[%s]: rdmem_addr: 0x%x, read_data_size: 0x%x, loop_cnt: 0x%x\n",
2498 __func__
, r_addr
, m_hdr
->read_data_size
, loop_cnt
));
2500 write_lock_irqsave(&ha
->hw_lock
, flags
);
2501 for (i
= 0; i
< loop_cnt
; i
++) {
2502 ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_ADDR_LO
,
2505 ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_ADDR_HI
,
2507 r_value
= MIU_TA_CTL_ENABLE
;
2508 ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_CTRL
, r_value
);
2509 r_value
= MIU_TA_CTL_START_ENABLE
;
2510 ha
->isp_ops
->wr_reg_indirect(ha
, MD_MIU_TEST_AGT_CTRL
, r_value
);
2512 for (j
= 0; j
< MAX_CTL_CHECK
; j
++) {
2513 ha
->isp_ops
->rd_reg_indirect(ha
, MD_MIU_TEST_AGT_CTRL
,
2515 if ((r_value
& MIU_TA_CTL_BUSY
) == 0)
2519 if (j
>= MAX_CTL_CHECK
) {
2520 printk_ratelimited(KERN_ERR
2521 "%s: failed to read through agent\n",
2523 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
2527 for (j
= 0; j
< 4; j
++) {
2528 ha
->isp_ops
->rd_reg_indirect(ha
,
2529 MD_MIU_TEST_AGT_RDDATA
[j
],
2531 *data_ptr
++ = cpu_to_le32(r_data
);
2536 write_unlock_irqrestore(&ha
->hw_lock
, flags
);
2538 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Leaving fn: %s datacount: 0x%x\n",
2539 __func__
, (loop_cnt
* 16)));
2545 static int qla4_8xxx_minidump_process_rdmem(struct scsi_qla_host
*ha
,
2546 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2549 uint32_t *data_ptr
= *d_ptr
;
2550 int rval
= QLA_SUCCESS
;
2552 rval
= qla4_8xxx_minidump_pex_dma_read(ha
, entry_hdr
, &data_ptr
);
2553 if (rval
!= QLA_SUCCESS
)
2554 rval
= __qla4_8xxx_minidump_process_rdmem(ha
, entry_hdr
,
2560 static void qla4_8xxx_mark_entry_skipped(struct scsi_qla_host
*ha
,
2561 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2564 entry_hdr
->d_ctrl
.driver_flags
|= QLA8XXX_DBG_SKIPPED_FLAG
;
2565 DEBUG2(ql4_printk(KERN_INFO
, ha
,
2566 "scsi(%ld): Skipping entry[%d]: ETYPE[0x%x]-ELEVEL[0x%x]\n",
2567 ha
->host_no
, index
, entry_hdr
->entry_type
,
2568 entry_hdr
->d_ctrl
.entry_capture_mask
));
2569 /* If driver encounters a new entry type that it cannot process,
2570 * it should just skip the entry and adjust the total buffer size by
2571 * from subtracting the skipped bytes from it
2573 ha
->fw_dump_skip_size
+= entry_hdr
->entry_capture_size
;
2576 /* ISP83xx functions to process new minidump entries... */
2577 static uint32_t qla83xx_minidump_process_pollrd(struct scsi_qla_host
*ha
,
2578 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2581 uint32_t r_addr
, s_addr
, s_value
, r_value
, poll_wait
, poll_mask
;
2582 uint16_t s_stride
, i
;
2583 uint32_t *data_ptr
= *d_ptr
;
2584 uint32_t rval
= QLA_SUCCESS
;
2585 struct qla83xx_minidump_entry_pollrd
*pollrd_hdr
;
2587 pollrd_hdr
= (struct qla83xx_minidump_entry_pollrd
*)entry_hdr
;
2588 s_addr
= le32_to_cpu(pollrd_hdr
->select_addr
);
2589 r_addr
= le32_to_cpu(pollrd_hdr
->read_addr
);
2590 s_value
= le32_to_cpu(pollrd_hdr
->select_value
);
2591 s_stride
= le32_to_cpu(pollrd_hdr
->select_value_stride
);
2593 poll_wait
= le32_to_cpu(pollrd_hdr
->poll_wait
);
2594 poll_mask
= le32_to_cpu(pollrd_hdr
->poll_mask
);
2596 for (i
= 0; i
< le32_to_cpu(pollrd_hdr
->op_count
); i
++) {
2597 ha
->isp_ops
->wr_reg_indirect(ha
, s_addr
, s_value
);
2598 poll_wait
= le32_to_cpu(pollrd_hdr
->poll_wait
);
2600 ha
->isp_ops
->rd_reg_indirect(ha
, s_addr
, &r_value
);
2602 if ((r_value
& poll_mask
) != 0) {
2606 if (--poll_wait
== 0) {
2607 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT\n",
2610 goto exit_process_pollrd
;
2614 ha
->isp_ops
->rd_reg_indirect(ha
, r_addr
, &r_value
);
2615 *data_ptr
++ = cpu_to_le32(s_value
);
2616 *data_ptr
++ = cpu_to_le32(r_value
);
2617 s_value
+= s_stride
;
2622 exit_process_pollrd
:
2626 static uint32_t qla4_84xx_minidump_process_rddfe(struct scsi_qla_host
*ha
,
2627 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2631 uint32_t addr1
, addr2
, value
, data
, temp
, wrval
;
2632 uint8_t stride
, stride2
;
2634 uint32_t poll
, mask
, modify_mask
;
2635 uint32_t wait_count
= 0;
2636 uint32_t *data_ptr
= *d_ptr
;
2637 struct qla8044_minidump_entry_rddfe
*rddfe
;
2638 uint32_t rval
= QLA_SUCCESS
;
2640 rddfe
= (struct qla8044_minidump_entry_rddfe
*)entry_hdr
;
2641 addr1
= le32_to_cpu(rddfe
->addr_1
);
2642 value
= le32_to_cpu(rddfe
->value
);
2643 stride
= le32_to_cpu(rddfe
->stride
);
2644 stride2
= le32_to_cpu(rddfe
->stride2
);
2645 count
= le32_to_cpu(rddfe
->count
);
2647 poll
= le32_to_cpu(rddfe
->poll
);
2648 mask
= le32_to_cpu(rddfe
->mask
);
2649 modify_mask
= le32_to_cpu(rddfe
->modify_mask
);
2651 addr2
= addr1
+ stride
;
2653 for (loop_cnt
= 0x0; loop_cnt
< count
; loop_cnt
++) {
2654 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
, (0x40000000 | value
));
2657 while (wait_count
< poll
) {
2658 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &temp
);
2659 if ((temp
& mask
) != 0)
2664 if (wait_count
== poll
) {
2665 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT\n", __func__
);
2667 goto exit_process_rddfe
;
2669 ha
->isp_ops
->rd_reg_indirect(ha
, addr2
, &temp
);
2670 temp
= temp
& modify_mask
;
2671 temp
= (temp
| ((loop_cnt
<< 16) | loop_cnt
));
2672 wrval
= ((temp
<< 16) | temp
);
2674 ha
->isp_ops
->wr_reg_indirect(ha
, addr2
, wrval
);
2675 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
, value
);
2678 while (wait_count
< poll
) {
2679 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &temp
);
2680 if ((temp
& mask
) != 0)
2684 if (wait_count
== poll
) {
2685 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT\n",
2688 goto exit_process_rddfe
;
2691 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
,
2692 ((0x40000000 | value
) +
2695 while (wait_count
< poll
) {
2696 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &temp
);
2697 if ((temp
& mask
) != 0)
2702 if (wait_count
== poll
) {
2703 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT\n",
2706 goto exit_process_rddfe
;
2709 ha
->isp_ops
->rd_reg_indirect(ha
, addr2
, &data
);
2711 *data_ptr
++ = cpu_to_le32(wrval
);
2712 *data_ptr
++ = cpu_to_le32(data
);
2721 static uint32_t qla4_84xx_minidump_process_rdmdio(struct scsi_qla_host
*ha
,
2722 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2725 int rval
= QLA_SUCCESS
;
2726 uint32_t addr1
, addr2
, value1
, value2
, data
, selval
;
2727 uint8_t stride1
, stride2
;
2728 uint32_t addr3
, addr4
, addr5
, addr6
, addr7
;
2729 uint16_t count
, loop_cnt
;
2731 uint32_t *data_ptr
= *d_ptr
;
2732 struct qla8044_minidump_entry_rdmdio
*rdmdio
;
2734 rdmdio
= (struct qla8044_minidump_entry_rdmdio
*)entry_hdr
;
2735 addr1
= le32_to_cpu(rdmdio
->addr_1
);
2736 addr2
= le32_to_cpu(rdmdio
->addr_2
);
2737 value1
= le32_to_cpu(rdmdio
->value_1
);
2738 stride1
= le32_to_cpu(rdmdio
->stride_1
);
2739 stride2
= le32_to_cpu(rdmdio
->stride_2
);
2740 count
= le32_to_cpu(rdmdio
->count
);
2742 mask
= le32_to_cpu(rdmdio
->mask
);
2743 value2
= le32_to_cpu(rdmdio
->value_2
);
2745 addr3
= addr1
+ stride1
;
2747 for (loop_cnt
= 0; loop_cnt
< count
; loop_cnt
++) {
2748 rval
= ql4_84xx_poll_wait_ipmdio_bus_idle(ha
, addr1
, addr2
,
2751 goto exit_process_rdmdio
;
2753 addr4
= addr2
- stride1
;
2754 rval
= ql4_84xx_ipmdio_wr_reg(ha
, addr1
, addr3
, mask
, addr4
,
2757 goto exit_process_rdmdio
;
2759 addr5
= addr2
- (2 * stride1
);
2760 rval
= ql4_84xx_ipmdio_wr_reg(ha
, addr1
, addr3
, mask
, addr5
,
2763 goto exit_process_rdmdio
;
2765 addr6
= addr2
- (3 * stride1
);
2766 rval
= ql4_84xx_ipmdio_wr_reg(ha
, addr1
, addr3
, mask
,
2769 goto exit_process_rdmdio
;
2771 rval
= ql4_84xx_poll_wait_ipmdio_bus_idle(ha
, addr1
, addr2
,
2774 goto exit_process_rdmdio
;
2776 addr7
= addr2
- (4 * stride1
);
2777 rval
= ql4_84xx_ipmdio_rd_reg(ha
, addr1
, addr3
,
2778 mask
, addr7
, &data
);
2780 goto exit_process_rdmdio
;
2782 selval
= (value2
<< 18) | (value1
<< 2) | 2;
2784 stride2
= le32_to_cpu(rdmdio
->stride_2
);
2785 *data_ptr
++ = cpu_to_le32(selval
);
2786 *data_ptr
++ = cpu_to_le32(data
);
2788 value1
= value1
+ stride2
;
2792 exit_process_rdmdio
:
2796 static uint32_t qla4_84xx_minidump_process_pollwr(struct scsi_qla_host
*ha
,
2797 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2800 uint32_t addr1
, addr2
, value1
, value2
, poll
, r_value
;
2801 struct qla8044_minidump_entry_pollwr
*pollwr_hdr
;
2802 uint32_t wait_count
= 0;
2803 uint32_t rval
= QLA_SUCCESS
;
2805 pollwr_hdr
= (struct qla8044_minidump_entry_pollwr
*)entry_hdr
;
2806 addr1
= le32_to_cpu(pollwr_hdr
->addr_1
);
2807 addr2
= le32_to_cpu(pollwr_hdr
->addr_2
);
2808 value1
= le32_to_cpu(pollwr_hdr
->value_1
);
2809 value2
= le32_to_cpu(pollwr_hdr
->value_2
);
2811 poll
= le32_to_cpu(pollwr_hdr
->poll
);
2813 while (wait_count
< poll
) {
2814 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &r_value
);
2816 if ((r_value
& poll
) != 0)
2822 if (wait_count
== poll
) {
2823 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT\n", __func__
);
2825 goto exit_process_pollwr
;
2828 ha
->isp_ops
->wr_reg_indirect(ha
, addr2
, value2
);
2829 ha
->isp_ops
->wr_reg_indirect(ha
, addr1
, value1
);
2832 while (wait_count
< poll
) {
2833 ha
->isp_ops
->rd_reg_indirect(ha
, addr1
, &r_value
);
2835 if ((r_value
& poll
) != 0)
2840 exit_process_pollwr
:
2844 static void qla83xx_minidump_process_rdmux2(struct scsi_qla_host
*ha
,
2845 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2848 uint32_t sel_val1
, sel_val2
, t_sel_val
, data
, i
;
2849 uint32_t sel_addr1
, sel_addr2
, sel_val_mask
, read_addr
;
2850 struct qla83xx_minidump_entry_rdmux2
*rdmux2_hdr
;
2851 uint32_t *data_ptr
= *d_ptr
;
2853 rdmux2_hdr
= (struct qla83xx_minidump_entry_rdmux2
*)entry_hdr
;
2854 sel_val1
= le32_to_cpu(rdmux2_hdr
->select_value_1
);
2855 sel_val2
= le32_to_cpu(rdmux2_hdr
->select_value_2
);
2856 sel_addr1
= le32_to_cpu(rdmux2_hdr
->select_addr_1
);
2857 sel_addr2
= le32_to_cpu(rdmux2_hdr
->select_addr_2
);
2858 sel_val_mask
= le32_to_cpu(rdmux2_hdr
->select_value_mask
);
2859 read_addr
= le32_to_cpu(rdmux2_hdr
->read_addr
);
2861 for (i
= 0; i
< rdmux2_hdr
->op_count
; i
++) {
2862 ha
->isp_ops
->wr_reg_indirect(ha
, sel_addr1
, sel_val1
);
2863 t_sel_val
= sel_val1
& sel_val_mask
;
2864 *data_ptr
++ = cpu_to_le32(t_sel_val
);
2866 ha
->isp_ops
->wr_reg_indirect(ha
, sel_addr2
, t_sel_val
);
2867 ha
->isp_ops
->rd_reg_indirect(ha
, read_addr
, &data
);
2869 *data_ptr
++ = cpu_to_le32(data
);
2871 ha
->isp_ops
->wr_reg_indirect(ha
, sel_addr1
, sel_val2
);
2872 t_sel_val
= sel_val2
& sel_val_mask
;
2873 *data_ptr
++ = cpu_to_le32(t_sel_val
);
2875 ha
->isp_ops
->wr_reg_indirect(ha
, sel_addr2
, t_sel_val
);
2876 ha
->isp_ops
->rd_reg_indirect(ha
, read_addr
, &data
);
2878 *data_ptr
++ = cpu_to_le32(data
);
2880 sel_val1
+= rdmux2_hdr
->select_value_stride
;
2881 sel_val2
+= rdmux2_hdr
->select_value_stride
;
2887 static uint32_t qla83xx_minidump_process_pollrdmwr(struct scsi_qla_host
*ha
,
2888 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2891 uint32_t poll_wait
, poll_mask
, r_value
, data
;
2892 uint32_t addr_1
, addr_2
, value_1
, value_2
;
2893 uint32_t *data_ptr
= *d_ptr
;
2894 uint32_t rval
= QLA_SUCCESS
;
2895 struct qla83xx_minidump_entry_pollrdmwr
*poll_hdr
;
2897 poll_hdr
= (struct qla83xx_minidump_entry_pollrdmwr
*)entry_hdr
;
2898 addr_1
= le32_to_cpu(poll_hdr
->addr_1
);
2899 addr_2
= le32_to_cpu(poll_hdr
->addr_2
);
2900 value_1
= le32_to_cpu(poll_hdr
->value_1
);
2901 value_2
= le32_to_cpu(poll_hdr
->value_2
);
2902 poll_mask
= le32_to_cpu(poll_hdr
->poll_mask
);
2904 ha
->isp_ops
->wr_reg_indirect(ha
, addr_1
, value_1
);
2906 poll_wait
= le32_to_cpu(poll_hdr
->poll_wait
);
2908 ha
->isp_ops
->rd_reg_indirect(ha
, addr_1
, &r_value
);
2910 if ((r_value
& poll_mask
) != 0) {
2914 if (--poll_wait
== 0) {
2915 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT_1\n",
2918 goto exit_process_pollrdmwr
;
2923 ha
->isp_ops
->rd_reg_indirect(ha
, addr_2
, &data
);
2924 data
&= le32_to_cpu(poll_hdr
->modify_mask
);
2925 ha
->isp_ops
->wr_reg_indirect(ha
, addr_2
, data
);
2926 ha
->isp_ops
->wr_reg_indirect(ha
, addr_1
, value_2
);
2928 poll_wait
= le32_to_cpu(poll_hdr
->poll_wait
);
2930 ha
->isp_ops
->rd_reg_indirect(ha
, addr_1
, &r_value
);
2932 if ((r_value
& poll_mask
) != 0) {
2936 if (--poll_wait
== 0) {
2937 ql4_printk(KERN_ERR
, ha
, "%s: TIMEOUT_2\n",
2940 goto exit_process_pollrdmwr
;
2945 *data_ptr
++ = cpu_to_le32(addr_2
);
2946 *data_ptr
++ = cpu_to_le32(data
);
2949 exit_process_pollrdmwr
:
2953 static uint32_t qla4_83xx_minidump_process_rdrom(struct scsi_qla_host
*ha
,
2954 struct qla8xxx_minidump_entry_hdr
*entry_hdr
,
2957 uint32_t fl_addr
, u32_count
, rval
;
2958 struct qla8xxx_minidump_entry_rdrom
*rom_hdr
;
2959 uint32_t *data_ptr
= *d_ptr
;
2961 rom_hdr
= (struct qla8xxx_minidump_entry_rdrom
*)entry_hdr
;
2962 fl_addr
= le32_to_cpu(rom_hdr
->read_addr
);
2963 u32_count
= le32_to_cpu(rom_hdr
->read_data_size
)/sizeof(uint32_t);
2965 DEBUG2(ql4_printk(KERN_INFO
, ha
, "[%s]: fl_addr: 0x%x, count: 0x%x\n",
2966 __func__
, fl_addr
, u32_count
));
2968 rval
= qla4_83xx_lockless_flash_read_u32(ha
, fl_addr
,
2969 (u8
*)(data_ptr
), u32_count
);
2971 if (rval
== QLA_ERROR
) {
2972 ql4_printk(KERN_ERR
, ha
, "%s: Flash Read Error,Count=%d\n",
2973 __func__
, u32_count
);
2974 goto exit_process_rdrom
;
2977 data_ptr
+= u32_count
;
2985 * qla4_8xxx_collect_md_data - Retrieve firmware minidump data.
2986 * @ha: pointer to adapter structure
2988 static int qla4_8xxx_collect_md_data(struct scsi_qla_host
*ha
)
2990 int num_entry_hdr
= 0;
2991 struct qla8xxx_minidump_entry_hdr
*entry_hdr
;
2992 struct qla4_8xxx_minidump_template_hdr
*tmplt_hdr
;
2994 uint32_t data_collected
= 0;
2995 int i
, rval
= QLA_ERROR
;
2999 ha
->fw_dump_skip_size
= 0;
3001 ql4_printk(KERN_INFO
, ha
, "%s(%ld) No buffer to dump\n",
3002 __func__
, ha
->host_no
);
3006 tmplt_hdr
= (struct qla4_8xxx_minidump_template_hdr
*)
3007 ha
->fw_dump_tmplt_hdr
;
3008 data_ptr
= (uint32_t *)((uint8_t *)ha
->fw_dump
+
3009 ha
->fw_dump_tmplt_size
);
3010 data_collected
+= ha
->fw_dump_tmplt_size
;
3012 num_entry_hdr
= tmplt_hdr
->num_of_entries
;
3013 ql4_printk(KERN_INFO
, ha
, "[%s]: starting data ptr: %p\n",
3014 __func__
, data_ptr
);
3015 ql4_printk(KERN_INFO
, ha
,
3016 "[%s]: no of entry headers in Template: 0x%x\n",
3017 __func__
, num_entry_hdr
);
3018 ql4_printk(KERN_INFO
, ha
, "[%s]: Capture Mask obtained: 0x%x\n",
3019 __func__
, ha
->fw_dump_capture_mask
);
3020 ql4_printk(KERN_INFO
, ha
, "[%s]: Total_data_size 0x%x, %d obtained\n",
3021 __func__
, ha
->fw_dump_size
, ha
->fw_dump_size
);
3023 /* Update current timestamp before taking dump */
3024 now
= get_jiffies_64();
3025 timestamp
= (u32
)(jiffies_to_msecs(now
) / 1000);
3026 tmplt_hdr
->driver_timestamp
= timestamp
;
3028 entry_hdr
= (struct qla8xxx_minidump_entry_hdr
*)
3029 (((uint8_t *)ha
->fw_dump_tmplt_hdr
) +
3030 tmplt_hdr
->first_entry_offset
);
3032 if (is_qla8032(ha
) || is_qla8042(ha
))
3033 tmplt_hdr
->saved_state_array
[QLA83XX_SS_OCM_WNDREG_INDEX
] =
3034 tmplt_hdr
->ocm_window_reg
[ha
->func_num
];
3036 /* Walk through the entry headers - validate/perform required action */
3037 for (i
= 0; i
< num_entry_hdr
; i
++) {
3038 if (data_collected
> ha
->fw_dump_size
) {
3039 ql4_printk(KERN_INFO
, ha
,
3040 "Data collected: [0x%x], Total Dump size: [0x%x]\n",
3041 data_collected
, ha
->fw_dump_size
);
3045 if (!(entry_hdr
->d_ctrl
.entry_capture_mask
&
3046 ha
->fw_dump_capture_mask
)) {
3047 entry_hdr
->d_ctrl
.driver_flags
|=
3048 QLA8XXX_DBG_SKIPPED_FLAG
;
3049 goto skip_nxt_entry
;
3052 DEBUG2(ql4_printk(KERN_INFO
, ha
,
3053 "Data collected: [0x%x], Dump size left:[0x%x]\n",
3055 (ha
->fw_dump_size
- data_collected
)));
3057 /* Decode the entry type and take required action to capture
3060 switch (entry_hdr
->entry_type
) {
3062 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3065 rval
= qla4_8xxx_minidump_process_control(ha
,
3067 if (rval
!= QLA_SUCCESS
) {
3068 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3073 qla4_8xxx_minidump_process_rdcrb(ha
, entry_hdr
,
3077 rval
= qla4_8xxx_minidump_process_rdmem(ha
, entry_hdr
,
3079 if (rval
!= QLA_SUCCESS
) {
3080 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3086 if (is_qla8022(ha
)) {
3087 qla4_82xx_minidump_process_rdrom(ha
, entry_hdr
,
3089 } else if (is_qla8032(ha
) || is_qla8042(ha
)) {
3090 rval
= qla4_83xx_minidump_process_rdrom(ha
,
3093 if (rval
!= QLA_SUCCESS
)
3094 qla4_8xxx_mark_entry_skipped(ha
,
3103 rval
= qla4_8xxx_minidump_process_l2tag(ha
, entry_hdr
,
3105 if (rval
!= QLA_SUCCESS
) {
3106 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3114 qla4_8xxx_minidump_process_l1cache(ha
, entry_hdr
,
3118 qla4_8xxx_minidump_process_rdocm(ha
, entry_hdr
,
3122 qla4_8xxx_minidump_process_rdmux(ha
, entry_hdr
,
3126 qla4_8xxx_minidump_process_queue(ha
, entry_hdr
,
3129 case QLA83XX_POLLRD
:
3130 if (is_qla8022(ha
)) {
3131 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3134 rval
= qla83xx_minidump_process_pollrd(ha
, entry_hdr
,
3136 if (rval
!= QLA_SUCCESS
)
3137 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3139 case QLA83XX_RDMUX2
:
3140 if (is_qla8022(ha
)) {
3141 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3144 qla83xx_minidump_process_rdmux2(ha
, entry_hdr
,
3147 case QLA83XX_POLLRDMWR
:
3148 if (is_qla8022(ha
)) {
3149 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3152 rval
= qla83xx_minidump_process_pollrdmwr(ha
, entry_hdr
,
3154 if (rval
!= QLA_SUCCESS
)
3155 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3158 rval
= qla4_84xx_minidump_process_rddfe(ha
, entry_hdr
,
3160 if (rval
!= QLA_SUCCESS
)
3161 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3163 case QLA8044_RDMDIO
:
3164 rval
= qla4_84xx_minidump_process_rdmdio(ha
, entry_hdr
,
3166 if (rval
!= QLA_SUCCESS
)
3167 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3169 case QLA8044_POLLWR
:
3170 rval
= qla4_84xx_minidump_process_pollwr(ha
, entry_hdr
,
3172 if (rval
!= QLA_SUCCESS
)
3173 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3177 qla4_8xxx_mark_entry_skipped(ha
, entry_hdr
, i
);
3181 data_collected
= (uint8_t *)data_ptr
- (uint8_t *)ha
->fw_dump
;
3183 /* next entry in the template */
3184 entry_hdr
= (struct qla8xxx_minidump_entry_hdr
*)
3185 (((uint8_t *)entry_hdr
) +
3186 entry_hdr
->entry_size
);
3189 if ((data_collected
+ ha
->fw_dump_skip_size
) != ha
->fw_dump_size
) {
3190 ql4_printk(KERN_INFO
, ha
,
3191 "Dump data mismatch: Data collected: [0x%x], total_data_size:[0x%x]\n",
3192 data_collected
, ha
->fw_dump_size
);
3197 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Leaving fn: %s Last entry: 0x%x\n",
3204 * qla4_8xxx_uevent_emit - Send uevent when the firmware dump is ready.
3205 * @ha: pointer to adapter structure
3206 * @code: uevent code to act upon
3208 static void qla4_8xxx_uevent_emit(struct scsi_qla_host
*ha
, u32 code
)
3210 char event_string
[40];
3211 char *envp
[] = { event_string
, NULL
};
3214 case QL4_UEVENT_CODE_FW_DUMP
:
3215 snprintf(event_string
, sizeof(event_string
), "FW_DUMP=%lu",
3223 kobject_uevent_env(&(&ha
->pdev
->dev
)->kobj
, KOBJ_CHANGE
, envp
);
3226 void qla4_8xxx_get_minidump(struct scsi_qla_host
*ha
)
3228 if (ql4xenablemd
&& test_bit(AF_FW_RECOVERY
, &ha
->flags
) &&
3229 !test_bit(AF_82XX_FW_DUMPED
, &ha
->flags
)) {
3230 if (!qla4_8xxx_collect_md_data(ha
)) {
3231 qla4_8xxx_uevent_emit(ha
, QL4_UEVENT_CODE_FW_DUMP
);
3232 set_bit(AF_82XX_FW_DUMPED
, &ha
->flags
);
3234 ql4_printk(KERN_INFO
, ha
, "%s: Unable to collect minidump\n",
3241 * qla4_8xxx_device_bootstrap - Initialize device, set DEV_READY, start fw
3242 * @ha: pointer to adapter structure
3244 * Note: IDC lock must be held upon entry
3246 int qla4_8xxx_device_bootstrap(struct scsi_qla_host
*ha
)
3248 int rval
= QLA_ERROR
;
3250 uint32_t old_count
, count
;
3253 need_reset
= ha
->isp_ops
->need_reset(ha
);
3256 /* We are trying to perform a recovery here. */
3257 if (test_bit(AF_FW_RECOVERY
, &ha
->flags
))
3258 ha
->isp_ops
->rom_lock_recovery(ha
);
3260 old_count
= qla4_8xxx_rd_direct(ha
, QLA8XXX_PEG_ALIVE_COUNTER
);
3261 for (i
= 0; i
< 10; i
++) {
3263 count
= qla4_8xxx_rd_direct(ha
,
3264 QLA8XXX_PEG_ALIVE_COUNTER
);
3265 if (count
!= old_count
) {
3270 ha
->isp_ops
->rom_lock_recovery(ha
);
3273 /* set to DEV_INITIALIZING */
3274 ql4_printk(KERN_INFO
, ha
, "HW State: INITIALIZING\n");
3275 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DEV_STATE
,
3276 QLA8XXX_DEV_INITIALIZING
);
3278 ha
->isp_ops
->idc_unlock(ha
);
3281 qla4_8xxx_get_minidump(ha
);
3283 rval
= ha
->isp_ops
->restart_firmware(ha
);
3284 ha
->isp_ops
->idc_lock(ha
);
3286 if (rval
!= QLA_SUCCESS
) {
3287 ql4_printk(KERN_INFO
, ha
, "HW State: FAILED\n");
3288 qla4_8xxx_clear_drv_active(ha
);
3289 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DEV_STATE
,
3290 QLA8XXX_DEV_FAILED
);
3295 ql4_printk(KERN_INFO
, ha
, "HW State: READY\n");
3296 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DEV_STATE
, QLA8XXX_DEV_READY
);
3302 * qla4_82xx_need_reset_handler - Code to start reset sequence
3303 * @ha: pointer to adapter structure
3305 * Note: IDC lock must be held upon entry
3308 qla4_82xx_need_reset_handler(struct scsi_qla_host
*ha
)
3310 uint32_t dev_state
, drv_state
, drv_active
;
3311 uint32_t active_mask
= 0xFFFFFFFF;
3312 unsigned long reset_timeout
;
3314 ql4_printk(KERN_INFO
, ha
,
3315 "Performing ISP error recovery\n");
3317 if (test_and_clear_bit(AF_ONLINE
, &ha
->flags
)) {
3318 qla4_82xx_idc_unlock(ha
);
3319 ha
->isp_ops
->disable_intrs(ha
);
3320 qla4_82xx_idc_lock(ha
);
3323 if (!test_bit(AF_8XXX_RST_OWNER
, &ha
->flags
)) {
3324 DEBUG2(ql4_printk(KERN_INFO
, ha
,
3325 "%s(%ld): reset acknowledged\n",
3326 __func__
, ha
->host_no
));
3327 qla4_8xxx_set_rst_ready(ha
);
3329 active_mask
= (~(1 << (ha
->func_num
* 4)));
3332 /* wait for 10 seconds for reset ack from all functions */
3333 reset_timeout
= jiffies
+ (ha
->nx_reset_timeout
* HZ
);
3335 drv_state
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DRV_STATE
);
3336 drv_active
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DRV_ACTIVE
);
3338 ql4_printk(KERN_INFO
, ha
,
3339 "%s(%ld): drv_state = 0x%x, drv_active = 0x%x\n",
3340 __func__
, ha
->host_no
, drv_state
, drv_active
);
3342 while (drv_state
!= (drv_active
& active_mask
)) {
3343 if (time_after_eq(jiffies
, reset_timeout
)) {
3344 ql4_printk(KERN_INFO
, ha
,
3345 "%s: RESET TIMEOUT! drv_state: 0x%08x, drv_active: 0x%08x\n",
3346 DRIVER_NAME
, drv_state
, drv_active
);
3351 * When reset_owner times out, check which functions
3354 if (test_bit(AF_8XXX_RST_OWNER
, &ha
->flags
)) {
3355 ql4_printk(KERN_INFO
, ha
,
3356 "%s(%ld): drv_state = 0x%x, drv_active = 0x%x\n",
3357 __func__
, ha
->host_no
, drv_state
,
3360 qla4_82xx_idc_unlock(ha
);
3362 qla4_82xx_idc_lock(ha
);
3364 drv_state
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DRV_STATE
);
3365 drv_active
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DRV_ACTIVE
);
3368 /* Clear RESET OWNER as we are not going to use it any further */
3369 clear_bit(AF_8XXX_RST_OWNER
, &ha
->flags
);
3371 dev_state
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DEV_STATE
);
3372 ql4_printk(KERN_INFO
, ha
, "Device state is 0x%x = %s\n", dev_state
,
3373 dev_state
< MAX_STATES
? qdev_state
[dev_state
] : "Unknown");
3375 /* Force to DEV_COLD unless someone else is starting a reset */
3376 if (dev_state
!= QLA8XXX_DEV_INITIALIZING
) {
3377 ql4_printk(KERN_INFO
, ha
, "HW State: COLD/RE-INIT\n");
3378 qla4_82xx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
, QLA8XXX_DEV_COLD
);
3379 qla4_8xxx_set_rst_ready(ha
);
3384 * qla4_8xxx_need_qsnt_handler - Code to start qsnt
3385 * @ha: pointer to adapter structure
3388 qla4_8xxx_need_qsnt_handler(struct scsi_qla_host
*ha
)
3390 ha
->isp_ops
->idc_lock(ha
);
3391 qla4_8xxx_set_qsnt_ready(ha
);
3392 ha
->isp_ops
->idc_unlock(ha
);
3395 static void qla4_82xx_set_idc_ver(struct scsi_qla_host
*ha
)
3398 uint32_t drv_active
;
3400 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
3401 if (drv_active
== (1 << (ha
->func_num
* 4))) {
3402 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_IDC_VERSION
,
3403 QLA82XX_IDC_VERSION
);
3404 ql4_printk(KERN_INFO
, ha
,
3405 "%s: IDC version updated to %d\n", __func__
,
3406 QLA82XX_IDC_VERSION
);
3408 idc_ver
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_IDC_VERSION
);
3409 if (QLA82XX_IDC_VERSION
!= idc_ver
) {
3410 ql4_printk(KERN_INFO
, ha
,
3411 "%s: qla4xxx driver IDC version %d is not compatible with IDC version %d of other drivers!\n",
3412 __func__
, QLA82XX_IDC_VERSION
, idc_ver
);
3417 static int qla4_83xx_set_idc_ver(struct scsi_qla_host
*ha
)
3420 uint32_t drv_active
;
3421 int rval
= QLA_SUCCESS
;
3423 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
3424 if (drv_active
== (1 << ha
->func_num
)) {
3425 idc_ver
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_IDC_VERSION
);
3427 idc_ver
|= QLA83XX_IDC_VER_MAJ_VALUE
;
3428 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DRV_IDC_VERSION
, idc_ver
);
3429 ql4_printk(KERN_INFO
, ha
,
3430 "%s: IDC version updated to %d\n", __func__
,
3433 idc_ver
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_IDC_VERSION
);
3435 if (QLA83XX_IDC_VER_MAJ_VALUE
!= idc_ver
) {
3436 ql4_printk(KERN_INFO
, ha
,
3437 "%s: qla4xxx driver IDC version %d is not compatible with IDC version %d of other drivers!\n",
3438 __func__
, QLA83XX_IDC_VER_MAJ_VALUE
,
3441 goto exit_set_idc_ver
;
3445 /* Update IDC_MINOR_VERSION */
3446 idc_ver
= qla4_83xx_rd_reg(ha
, QLA83XX_CRB_IDC_VER_MINOR
);
3447 idc_ver
&= ~(0x03 << (ha
->func_num
* 2));
3448 idc_ver
|= (QLA83XX_IDC_VER_MIN_VALUE
<< (ha
->func_num
* 2));
3449 qla4_83xx_wr_reg(ha
, QLA83XX_CRB_IDC_VER_MINOR
, idc_ver
);
3455 int qla4_8xxx_update_idc_reg(struct scsi_qla_host
*ha
)
3457 uint32_t drv_active
;
3458 int rval
= QLA_SUCCESS
;
3460 if (test_bit(AF_INIT_DONE
, &ha
->flags
))
3461 goto exit_update_idc_reg
;
3463 ha
->isp_ops
->idc_lock(ha
);
3464 qla4_8xxx_set_drv_active(ha
);
3467 * If we are the first driver to load and
3468 * ql4xdontresethba is not set, clear IDC_CTRL BIT0.
3470 if (is_qla8032(ha
) || is_qla8042(ha
)) {
3471 drv_active
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DRV_ACTIVE
);
3472 if ((drv_active
== (1 << ha
->func_num
)) && !ql4xdontresethba
)
3473 qla4_83xx_clear_idc_dontreset(ha
);
3476 if (is_qla8022(ha
)) {
3477 qla4_82xx_set_idc_ver(ha
);
3478 } else if (is_qla8032(ha
) || is_qla8042(ha
)) {
3479 rval
= qla4_83xx_set_idc_ver(ha
);
3480 if (rval
== QLA_ERROR
)
3481 qla4_8xxx_clear_drv_active(ha
);
3484 ha
->isp_ops
->idc_unlock(ha
);
3486 exit_update_idc_reg
:
3491 * qla4_8xxx_device_state_handler - Adapter state machine
3492 * @ha: pointer to host adapter structure.
3494 * Note: IDC lock must be UNLOCKED upon entry
3496 int qla4_8xxx_device_state_handler(struct scsi_qla_host
*ha
)
3499 int rval
= QLA_SUCCESS
;
3500 unsigned long dev_init_timeout
;
3502 rval
= qla4_8xxx_update_idc_reg(ha
);
3503 if (rval
== QLA_ERROR
)
3504 goto exit_state_handler
;
3506 dev_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DEV_STATE
);
3507 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Device state is 0x%x = %s\n",
3508 dev_state
, dev_state
< MAX_STATES
?
3509 qdev_state
[dev_state
] : "Unknown"));
3511 /* wait for 30 seconds for device to go ready */
3512 dev_init_timeout
= jiffies
+ (ha
->nx_dev_init_timeout
* HZ
);
3514 ha
->isp_ops
->idc_lock(ha
);
3517 if (time_after_eq(jiffies
, dev_init_timeout
)) {
3518 ql4_printk(KERN_WARNING
, ha
,
3519 "%s: Device Init Failed 0x%x = %s\n",
3521 dev_state
, dev_state
< MAX_STATES
?
3522 qdev_state
[dev_state
] : "Unknown");
3523 qla4_8xxx_wr_direct(ha
, QLA8XXX_CRB_DEV_STATE
,
3524 QLA8XXX_DEV_FAILED
);
3527 dev_state
= qla4_8xxx_rd_direct(ha
, QLA8XXX_CRB_DEV_STATE
);
3528 ql4_printk(KERN_INFO
, ha
, "Device state is 0x%x = %s\n",
3529 dev_state
, dev_state
< MAX_STATES
?
3530 qdev_state
[dev_state
] : "Unknown");
3532 /* NOTE: Make sure idc unlocked upon exit of switch statement */
3533 switch (dev_state
) {
3534 case QLA8XXX_DEV_READY
:
3536 case QLA8XXX_DEV_COLD
:
3537 rval
= qla4_8xxx_device_bootstrap(ha
);
3539 case QLA8XXX_DEV_INITIALIZING
:
3540 ha
->isp_ops
->idc_unlock(ha
);
3542 ha
->isp_ops
->idc_lock(ha
);
3544 case QLA8XXX_DEV_NEED_RESET
:
3546 * For ISP8324 and ISP8042, if NEED_RESET is set by any
3547 * driver, it should be honored, irrespective of
3548 * IDC_CTRL DONTRESET_BIT0
3550 if (is_qla8032(ha
) || is_qla8042(ha
)) {
3551 qla4_83xx_need_reset_handler(ha
);
3552 } else if (is_qla8022(ha
)) {
3553 if (!ql4xdontresethba
) {
3554 qla4_82xx_need_reset_handler(ha
);
3555 /* Update timeout value after need
3557 dev_init_timeout
= jiffies
+
3558 (ha
->nx_dev_init_timeout
* HZ
);
3560 ha
->isp_ops
->idc_unlock(ha
);
3562 ha
->isp_ops
->idc_lock(ha
);
3566 case QLA8XXX_DEV_NEED_QUIESCENT
:
3567 /* idc locked/unlocked in handler */
3568 qla4_8xxx_need_qsnt_handler(ha
);
3570 case QLA8XXX_DEV_QUIESCENT
:
3571 ha
->isp_ops
->idc_unlock(ha
);
3573 ha
->isp_ops
->idc_lock(ha
);
3575 case QLA8XXX_DEV_FAILED
:
3576 ha
->isp_ops
->idc_unlock(ha
);
3577 qla4xxx_dead_adapter_cleanup(ha
);
3579 ha
->isp_ops
->idc_lock(ha
);
3582 ha
->isp_ops
->idc_unlock(ha
);
3583 qla4xxx_dead_adapter_cleanup(ha
);
3585 ha
->isp_ops
->idc_lock(ha
);
3590 ha
->isp_ops
->idc_unlock(ha
);
3595 int qla4_8xxx_load_risc(struct scsi_qla_host
*ha
)
3599 /* clear the interrupt */
3600 if (is_qla8032(ha
) || is_qla8042(ha
)) {
3601 writel(0, &ha
->qla4_83xx_reg
->risc_intr
);
3602 readl(&ha
->qla4_83xx_reg
->risc_intr
);
3603 } else if (is_qla8022(ha
)) {
3604 writel(0, &ha
->qla4_82xx_reg
->host_int
);
3605 readl(&ha
->qla4_82xx_reg
->host_int
);
3608 retval
= qla4_8xxx_device_state_handler(ha
);
3610 /* Initialize request and response queues. */
3611 if (retval
== QLA_SUCCESS
)
3612 qla4xxx_init_rings(ha
);
3614 if (retval
== QLA_SUCCESS
&& !test_bit(AF_IRQ_ATTACHED
, &ha
->flags
))
3615 retval
= qla4xxx_request_irqs(ha
);
3620 /*****************************************************************************/
3621 /* Flash Manipulation Routines */
3622 /*****************************************************************************/
3624 #define OPTROM_BURST_SIZE 0x1000
3625 #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
3627 #define FARX_DATA_FLAG BIT_31
3628 #define FARX_ACCESS_FLASH_CONF 0x7FFD0000
3629 #define FARX_ACCESS_FLASH_DATA 0x7FF00000
3631 static inline uint32_t
3632 flash_conf_addr(struct ql82xx_hw_data
*hw
, uint32_t faddr
)
3634 return hw
->flash_conf_off
| faddr
;
3638 qla4_82xx_read_flash_data(struct scsi_qla_host
*ha
, uint32_t *dwptr
,
3639 uint32_t faddr
, uint32_t length
)
3644 while ((qla4_82xx_rom_lock(ha
) != 0) && (loops
< 50000)) {
3649 if (loops
>= 50000) {
3650 ql4_printk(KERN_WARNING
, ha
, "ROM lock failed\n");
3654 /* Dword reads to flash. */
3655 for (i
= 0; i
< length
/4; i
++, faddr
+= 4) {
3656 if (qla4_82xx_do_rom_fast_read(ha
, faddr
, &val
)) {
3657 ql4_printk(KERN_WARNING
, ha
,
3658 "Do ROM fast read failed\n");
3661 dwptr
[i
] = cpu_to_le32(val
);
3665 qla4_82xx_rom_unlock(ha
);
3670 * Address and length are byte address
3673 qla4_82xx_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
3674 uint32_t offset
, uint32_t length
)
3676 qla4_82xx_read_flash_data(ha
, (uint32_t *)buf
, offset
, length
);
3681 qla4_8xxx_find_flt_start(struct scsi_qla_host
*ha
, uint32_t *start
)
3683 const char *loc
, *locations
[] = { "DEF", "PCI" };
3686 * FLT-location structure resides after the last PCI region.
3689 /* Begin with sane defaults. */
3691 *start
= FA_FLASH_LAYOUT_ADDR_82
;
3693 DEBUG2(ql4_printk(KERN_INFO
, ha
, "FLTL[%s] = 0x%x.\n", loc
, *start
));
3698 qla4_8xxx_get_flt_info(struct scsi_qla_host
*ha
, uint32_t flt_addr
)
3700 const char *loc
, *locations
[] = { "DEF", "FLT" };
3702 uint16_t cnt
, chksum
;
3703 uint32_t start
, status
;
3704 struct qla_flt_header
*flt
;
3705 struct qla_flt_region
*region
;
3706 struct ql82xx_hw_data
*hw
= &ha
->hw
;
3708 hw
->flt_region_flt
= flt_addr
;
3709 wptr
= (uint16_t *)ha
->request_ring
;
3710 flt
= (struct qla_flt_header
*)ha
->request_ring
;
3711 region
= (struct qla_flt_region
*)&flt
[1];
3713 if (is_qla8022(ha
)) {
3714 qla4_82xx_read_optrom_data(ha
, (uint8_t *)ha
->request_ring
,
3715 flt_addr
<< 2, OPTROM_BURST_SIZE
);
3716 } else if (is_qla8032(ha
) || is_qla8042(ha
)) {
3717 status
= qla4_83xx_flash_read_u32(ha
, flt_addr
<< 2,
3718 (uint8_t *)ha
->request_ring
,
3720 if (status
!= QLA_SUCCESS
)
3724 if (*wptr
== cpu_to_le16(0xffff))
3726 if (flt
->version
!= cpu_to_le16(1)) {
3727 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Unsupported FLT detected: "
3728 "version=0x%x length=0x%x checksum=0x%x.\n",
3729 le16_to_cpu(flt
->version
), le16_to_cpu(flt
->length
),
3730 le16_to_cpu(flt
->checksum
)));
3734 cnt
= (sizeof(struct qla_flt_header
) + le16_to_cpu(flt
->length
)) >> 1;
3735 for (chksum
= 0; cnt
; cnt
--)
3736 chksum
+= le16_to_cpu(*wptr
++);
3738 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Inconsistent FLT detected: "
3739 "version=0x%x length=0x%x checksum=0x%x.\n",
3740 le16_to_cpu(flt
->version
), le16_to_cpu(flt
->length
),
3746 cnt
= le16_to_cpu(flt
->length
) / sizeof(struct qla_flt_region
);
3747 for ( ; cnt
; cnt
--, region
++) {
3748 /* Store addresses as DWORD offsets. */
3749 start
= le32_to_cpu(region
->start
) >> 2;
3751 DEBUG3(ql4_printk(KERN_DEBUG
, ha
, "FLT[%02x]: start=0x%x "
3752 "end=0x%x size=0x%x.\n", le32_to_cpu(region
->code
), start
,
3753 le32_to_cpu(region
->end
) >> 2, le32_to_cpu(region
->size
)));
3755 switch (le32_to_cpu(region
->code
) & 0xff) {
3757 hw
->flt_region_fdt
= start
;
3759 case FLT_REG_BOOT_CODE_82
:
3760 hw
->flt_region_boot
= start
;
3763 case FLT_REG_FW_82_1
:
3764 hw
->flt_region_fw
= start
;
3766 case FLT_REG_BOOTLOAD_82
:
3767 hw
->flt_region_bootload
= start
;
3769 case FLT_REG_ISCSI_PARAM
:
3770 hw
->flt_iscsi_param
= start
;
3772 case FLT_REG_ISCSI_CHAP
:
3773 hw
->flt_region_chap
= start
;
3774 hw
->flt_chap_size
= le32_to_cpu(region
->size
);
3776 case FLT_REG_ISCSI_DDB
:
3777 hw
->flt_region_ddb
= start
;
3778 hw
->flt_ddb_size
= le32_to_cpu(region
->size
);
3785 /* Use hardcoded defaults. */
3788 hw
->flt_region_fdt
= FA_FLASH_DESCR_ADDR_82
;
3789 hw
->flt_region_boot
= FA_BOOT_CODE_ADDR_82
;
3790 hw
->flt_region_bootload
= FA_BOOT_LOAD_ADDR_82
;
3791 hw
->flt_region_fw
= FA_RISC_CODE_ADDR_82
;
3792 hw
->flt_region_chap
= FA_FLASH_ISCSI_CHAP
>> 2;
3793 hw
->flt_chap_size
= FA_FLASH_CHAP_SIZE
;
3794 hw
->flt_region_ddb
= FA_FLASH_ISCSI_DDB
>> 2;
3795 hw
->flt_ddb_size
= FA_FLASH_DDB_SIZE
;
3798 DEBUG2(ql4_printk(KERN_INFO
, ha
,
3799 "FLT[%s]: flt=0x%x fdt=0x%x boot=0x%x bootload=0x%x fw=0x%x chap=0x%x chap_size=0x%x ddb=0x%x ddb_size=0x%x\n",
3800 loc
, hw
->flt_region_flt
, hw
->flt_region_fdt
,
3801 hw
->flt_region_boot
, hw
->flt_region_bootload
,
3802 hw
->flt_region_fw
, hw
->flt_region_chap
,
3803 hw
->flt_chap_size
, hw
->flt_region_ddb
,
3808 qla4_82xx_get_fdt_info(struct scsi_qla_host
*ha
)
3810 #define FLASH_BLK_SIZE_4K 0x1000
3811 #define FLASH_BLK_SIZE_32K 0x8000
3812 #define FLASH_BLK_SIZE_64K 0x10000
3813 const char *loc
, *locations
[] = { "MID", "FDT" };
3814 uint16_t cnt
, chksum
;
3816 struct qla_fdt_layout
*fdt
;
3819 struct ql82xx_hw_data
*hw
= &ha
->hw
;
3821 hw
->flash_conf_off
= FARX_ACCESS_FLASH_CONF
;
3822 hw
->flash_data_off
= FARX_ACCESS_FLASH_DATA
;
3824 wptr
= (uint16_t *)ha
->request_ring
;
3825 fdt
= (struct qla_fdt_layout
*)ha
->request_ring
;
3826 qla4_82xx_read_optrom_data(ha
, (uint8_t *)ha
->request_ring
,
3827 hw
->flt_region_fdt
<< 2, OPTROM_BURST_SIZE
);
3829 if (*wptr
== cpu_to_le16(0xffff))
3832 if (fdt
->sig
[0] != 'Q' || fdt
->sig
[1] != 'L' || fdt
->sig
[2] != 'I' ||
3836 for (cnt
= 0, chksum
= 0; cnt
< sizeof(struct qla_fdt_layout
) >> 1;
3838 chksum
+= le16_to_cpu(*wptr
++);
3841 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Inconsistent FDT detected: "
3842 "checksum=0x%x id=%c version=0x%x.\n", chksum
, fdt
->sig
[0],
3843 le16_to_cpu(fdt
->version
)));
3848 mid
= le16_to_cpu(fdt
->man_id
);
3849 fid
= le16_to_cpu(fdt
->id
);
3850 hw
->fdt_wrt_disable
= fdt
->wrt_disable_bits
;
3851 hw
->fdt_erase_cmd
= flash_conf_addr(hw
, 0x0300 | fdt
->erase_cmd
);
3852 hw
->fdt_block_size
= le32_to_cpu(fdt
->block_size
);
3854 if (fdt
->unprotect_sec_cmd
) {
3855 hw
->fdt_unprotect_sec_cmd
= flash_conf_addr(hw
, 0x0300 |
3856 fdt
->unprotect_sec_cmd
);
3857 hw
->fdt_protect_sec_cmd
= fdt
->protect_sec_cmd
?
3858 flash_conf_addr(hw
, 0x0300 | fdt
->protect_sec_cmd
) :
3859 flash_conf_addr(hw
, 0x0336);
3865 hw
->fdt_block_size
= FLASH_BLK_SIZE_64K
;
3867 DEBUG2(ql4_printk(KERN_INFO
, ha
, "FDT[%s]: (0x%x/0x%x) erase=0x%x "
3868 "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n", loc
, mid
, fid
,
3869 hw
->fdt_erase_cmd
, hw
->fdt_protect_sec_cmd
,
3870 hw
->fdt_unprotect_sec_cmd
, hw
->fdt_wrt_disable
,
3871 hw
->fdt_block_size
));
3875 qla4_82xx_get_idc_param(struct scsi_qla_host
*ha
)
3877 #define QLA82XX_IDC_PARAM_ADDR 0x003e885c
3880 if (!is_qla8022(ha
))
3882 wptr
= (uint32_t *)ha
->request_ring
;
3883 qla4_82xx_read_optrom_data(ha
, (uint8_t *)ha
->request_ring
,
3884 QLA82XX_IDC_PARAM_ADDR
, 8);
3886 if (*wptr
== cpu_to_le32(0xffffffff)) {
3887 ha
->nx_dev_init_timeout
= ROM_DEV_INIT_TIMEOUT
;
3888 ha
->nx_reset_timeout
= ROM_DRV_RESET_ACK_TIMEOUT
;
3890 ha
->nx_dev_init_timeout
= le32_to_cpu(*wptr
++);
3891 ha
->nx_reset_timeout
= le32_to_cpu(*wptr
);
3894 DEBUG2(ql4_printk(KERN_DEBUG
, ha
,
3895 "ha->nx_dev_init_timeout = %d\n", ha
->nx_dev_init_timeout
));
3896 DEBUG2(ql4_printk(KERN_DEBUG
, ha
,
3897 "ha->nx_reset_timeout = %d\n", ha
->nx_reset_timeout
));
3901 void qla4_82xx_queue_mbox_cmd(struct scsi_qla_host
*ha
, uint32_t *mbx_cmd
,
3906 /* Load all mailbox registers, except mailbox 0. */
3907 for (i
= 1; i
< in_count
; i
++)
3908 writel(mbx_cmd
[i
], &ha
->qla4_82xx_reg
->mailbox_in
[i
]);
3910 /* Wakeup firmware */
3911 writel(mbx_cmd
[0], &ha
->qla4_82xx_reg
->mailbox_in
[0]);
3912 readl(&ha
->qla4_82xx_reg
->mailbox_in
[0]);
3913 writel(HINT_MBX_INT_PENDING
, &ha
->qla4_82xx_reg
->hint
);
3914 readl(&ha
->qla4_82xx_reg
->hint
);
3917 void qla4_82xx_process_mbox_intr(struct scsi_qla_host
*ha
, int out_count
)
3921 intr_status
= readl(&ha
->qla4_82xx_reg
->host_int
);
3922 if (intr_status
& ISRX_82XX_RISC_INT
) {
3923 ha
->mbox_status_count
= out_count
;
3924 intr_status
= readl(&ha
->qla4_82xx_reg
->host_status
);
3925 ha
->isp_ops
->interrupt_service_routine(ha
, intr_status
);
3927 if (test_bit(AF_INTERRUPTS_ON
, &ha
->flags
) &&
3928 (!ha
->pdev
->msi_enabled
&& !ha
->pdev
->msix_enabled
))
3929 qla4_82xx_wr_32(ha
, ha
->nx_legacy_intr
.tgt_mask_reg
,
3935 qla4_8xxx_get_flash_info(struct scsi_qla_host
*ha
)
3940 ret
= qla4_8xxx_find_flt_start(ha
, &flt_addr
);
3941 if (ret
!= QLA_SUCCESS
)
3944 qla4_8xxx_get_flt_info(ha
, flt_addr
);
3945 if (is_qla8022(ha
)) {
3946 qla4_82xx_get_fdt_info(ha
);
3947 qla4_82xx_get_idc_param(ha
);
3948 } else if (is_qla8032(ha
) || is_qla8042(ha
)) {
3949 qla4_83xx_get_idc_param(ha
);
3956 * qla4_8xxx_stop_firmware - stops firmware on specified adapter instance
3957 * @ha: pointer to host adapter structure.
3960 * For iSCSI, throws away all I/O and AENs into bit bucket, so they will
3961 * not be available after successful return. Driver must cleanup potential
3962 * outstanding I/O's after calling this funcion.
3965 qla4_8xxx_stop_firmware(struct scsi_qla_host
*ha
)
3968 uint32_t mbox_cmd
[MBOX_REG_COUNT
];
3969 uint32_t mbox_sts
[MBOX_REG_COUNT
];
3971 memset(&mbox_cmd
, 0, sizeof(mbox_cmd
));
3972 memset(&mbox_sts
, 0, sizeof(mbox_sts
));
3974 mbox_cmd
[0] = MBOX_CMD_STOP_FW
;
3975 status
= qla4xxx_mailbox_command(ha
, MBOX_REG_COUNT
, 1,
3976 &mbox_cmd
[0], &mbox_sts
[0]);
3978 DEBUG2(printk("scsi%ld: %s: status = %d\n", ha
->host_no
,
3984 * qla4_82xx_isp_reset - Resets ISP and aborts all outstanding commands.
3985 * @ha: pointer to host adapter structure.
3988 qla4_82xx_isp_reset(struct scsi_qla_host
*ha
)
3993 qla4_82xx_idc_lock(ha
);
3994 dev_state
= qla4_82xx_rd_32(ha
, QLA82XX_CRB_DEV_STATE
);
3996 if (dev_state
== QLA8XXX_DEV_READY
) {
3997 ql4_printk(KERN_INFO
, ha
, "HW State: NEED RESET\n");
3998 qla4_82xx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
,
3999 QLA8XXX_DEV_NEED_RESET
);
4000 set_bit(AF_8XXX_RST_OWNER
, &ha
->flags
);
4002 ql4_printk(KERN_INFO
, ha
, "HW State: DEVICE INITIALIZING\n");
4004 qla4_82xx_idc_unlock(ha
);
4006 rval
= qla4_8xxx_device_state_handler(ha
);
4008 qla4_82xx_idc_lock(ha
);
4009 qla4_8xxx_clear_rst_ready(ha
);
4010 qla4_82xx_idc_unlock(ha
);
4012 if (rval
== QLA_SUCCESS
) {
4013 ql4_printk(KERN_INFO
, ha
, "Clearing AF_RECOVERY in qla4_82xx_isp_reset\n");
4014 clear_bit(AF_FW_RECOVERY
, &ha
->flags
);
4021 * qla4_8xxx_get_sys_info - get adapter MAC address(es) and serial number
4022 * @ha: pointer to host adapter structure.
4025 int qla4_8xxx_get_sys_info(struct scsi_qla_host
*ha
)
4027 uint32_t mbox_cmd
[MBOX_REG_COUNT
];
4028 uint32_t mbox_sts
[MBOX_REG_COUNT
];
4029 struct mbx_sys_info
*sys_info
;
4030 dma_addr_t sys_info_dma
;
4031 int status
= QLA_ERROR
;
4033 sys_info
= dma_alloc_coherent(&ha
->pdev
->dev
, sizeof(*sys_info
),
4034 &sys_info_dma
, GFP_KERNEL
);
4035 if (sys_info
== NULL
) {
4036 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
4037 ha
->host_no
, __func__
));
4041 memset(&mbox_cmd
, 0, sizeof(mbox_cmd
));
4042 memset(&mbox_sts
, 0, sizeof(mbox_sts
));
4044 mbox_cmd
[0] = MBOX_CMD_GET_SYS_INFO
;
4045 mbox_cmd
[1] = LSDW(sys_info_dma
);
4046 mbox_cmd
[2] = MSDW(sys_info_dma
);
4047 mbox_cmd
[4] = sizeof(*sys_info
);
4049 if (qla4xxx_mailbox_command(ha
, MBOX_REG_COUNT
, 6, &mbox_cmd
[0],
4050 &mbox_sts
[0]) != QLA_SUCCESS
) {
4051 DEBUG2(printk("scsi%ld: %s: GET_SYS_INFO failed\n",
4052 ha
->host_no
, __func__
));
4053 goto exit_validate_mac82
;
4056 /* Make sure we receive the minimum required data to cache internally */
4057 if (((is_qla8032(ha
) || is_qla8042(ha
)) ? mbox_sts
[3] : mbox_sts
[4]) <
4058 offsetof(struct mbx_sys_info
, reserved
)) {
4059 DEBUG2(printk("scsi%ld: %s: GET_SYS_INFO data receive"
4060 " error (%x)\n", ha
->host_no
, __func__
, mbox_sts
[4]));
4061 goto exit_validate_mac82
;
4064 /* Save M.A.C. address & serial_number */
4065 ha
->port_num
= sys_info
->port_num
;
4066 memcpy(ha
->my_mac
, &sys_info
->mac_addr
[0],
4067 min(sizeof(ha
->my_mac
), sizeof(sys_info
->mac_addr
)));
4068 memcpy(ha
->serial_number
, &sys_info
->serial_number
,
4069 min(sizeof(ha
->serial_number
), sizeof(sys_info
->serial_number
)));
4070 memcpy(ha
->model_name
, &sys_info
->board_id_str
,
4071 min(sizeof(ha
->model_name
), sizeof(sys_info
->board_id_str
)));
4072 ha
->phy_port_cnt
= sys_info
->phys_port_cnt
;
4073 ha
->phy_port_num
= sys_info
->port_num
;
4074 ha
->iscsi_pci_func_cnt
= sys_info
->iscsi_pci_func_cnt
;
4076 DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
4077 ha
->host_no
, __func__
, ha
->my_mac
, ha
->serial_number
));
4079 status
= QLA_SUCCESS
;
4081 exit_validate_mac82
:
4082 dma_free_coherent(&ha
->pdev
->dev
, sizeof(*sys_info
), sys_info
,
4087 /* Interrupt handling helpers. */
4089 int qla4_8xxx_intr_enable(struct scsi_qla_host
*ha
)
4091 uint32_t mbox_cmd
[MBOX_REG_COUNT
];
4092 uint32_t mbox_sts
[MBOX_REG_COUNT
];
4094 DEBUG2(ql4_printk(KERN_INFO
, ha
, "%s\n", __func__
));
4096 memset(&mbox_cmd
, 0, sizeof(mbox_cmd
));
4097 memset(&mbox_sts
, 0, sizeof(mbox_sts
));
4098 mbox_cmd
[0] = MBOX_CMD_ENABLE_INTRS
;
4099 mbox_cmd
[1] = INTR_ENABLE
;
4100 if (qla4xxx_mailbox_command(ha
, MBOX_REG_COUNT
, 1, &mbox_cmd
[0],
4101 &mbox_sts
[0]) != QLA_SUCCESS
) {
4102 DEBUG2(ql4_printk(KERN_INFO
, ha
,
4103 "%s: MBOX_CMD_ENABLE_INTRS failed (0x%04x)\n",
4104 __func__
, mbox_sts
[0]));
4110 int qla4_8xxx_intr_disable(struct scsi_qla_host
*ha
)
4112 uint32_t mbox_cmd
[MBOX_REG_COUNT
];
4113 uint32_t mbox_sts
[MBOX_REG_COUNT
];
4115 DEBUG2(ql4_printk(KERN_INFO
, ha
, "%s\n", __func__
));
4117 memset(&mbox_cmd
, 0, sizeof(mbox_cmd
));
4118 memset(&mbox_sts
, 0, sizeof(mbox_sts
));
4119 mbox_cmd
[0] = MBOX_CMD_ENABLE_INTRS
;
4120 mbox_cmd
[1] = INTR_DISABLE
;
4121 if (qla4xxx_mailbox_command(ha
, MBOX_REG_COUNT
, 1, &mbox_cmd
[0],
4122 &mbox_sts
[0]) != QLA_SUCCESS
) {
4123 DEBUG2(ql4_printk(KERN_INFO
, ha
,
4124 "%s: MBOX_CMD_ENABLE_INTRS failed (0x%04x)\n",
4125 __func__
, mbox_sts
[0]));
4133 qla4_82xx_enable_intrs(struct scsi_qla_host
*ha
)
4135 qla4_8xxx_intr_enable(ha
);
4137 spin_lock_irq(&ha
->hardware_lock
);
4138 /* BIT 10 - reset */
4139 qla4_82xx_wr_32(ha
, ha
->nx_legacy_intr
.tgt_mask_reg
, 0xfbff);
4140 spin_unlock_irq(&ha
->hardware_lock
);
4141 set_bit(AF_INTERRUPTS_ON
, &ha
->flags
);
4145 qla4_82xx_disable_intrs(struct scsi_qla_host
*ha
)
4147 if (test_and_clear_bit(AF_INTERRUPTS_ON
, &ha
->flags
))
4148 qla4_8xxx_intr_disable(ha
);
4150 spin_lock_irq(&ha
->hardware_lock
);
4152 qla4_82xx_wr_32(ha
, ha
->nx_legacy_intr
.tgt_mask_reg
, 0x0400);
4153 spin_unlock_irq(&ha
->hardware_lock
);
4157 qla4_8xxx_enable_msix(struct scsi_qla_host
*ha
)
4161 ret
= pci_alloc_irq_vectors(ha
->pdev
, QLA_MSIX_ENTRIES
,
4162 QLA_MSIX_ENTRIES
, PCI_IRQ_MSIX
);
4164 ql4_printk(KERN_WARNING
, ha
,
4165 "MSI-X: Failed to enable support -- %d/%d\n",
4166 QLA_MSIX_ENTRIES
, ret
);
4170 ret
= request_irq(pci_irq_vector(ha
->pdev
, 0),
4171 qla4_8xxx_default_intr_handler
, 0, "qla4xxx (default)",
4174 goto out_free_vectors
;
4176 ret
= request_irq(pci_irq_vector(ha
->pdev
, 1),
4177 qla4_8xxx_msix_rsp_q
, 0, "qla4xxx (rsp_q)", ha
);
4179 goto out_free_default_irq
;
4183 out_free_default_irq
:
4184 free_irq(pci_irq_vector(ha
->pdev
, 0), ha
);
4186 pci_free_irq_vectors(ha
->pdev
);
4190 int qla4_8xxx_check_init_adapter_retry(struct scsi_qla_host
*ha
)
4192 int status
= QLA_SUCCESS
;
4194 /* Dont retry adapter initialization if IRQ allocation failed */
4195 if (!test_bit(AF_IRQ_ATTACHED
, &ha
->flags
)) {
4196 ql4_printk(KERN_WARNING
, ha
, "%s: Skipping retry of adapter initialization as IRQs are not attached\n",
4199 goto exit_init_adapter_failure
;
4202 /* Since interrupts are registered in start_firmware for
4203 * 8xxx, release them here if initialize_adapter fails
4204 * and retry adapter initialization */
4205 qla4xxx_free_irqs(ha
);
4207 exit_init_adapter_failure
: