.. | .. |
---|
41 | 41 | #include <linux/slab.h> |
---|
42 | 42 | #include "pm8001_sas.h" |
---|
43 | 43 | #include "pm8001_chips.h" |
---|
| 44 | +#include "pm80xx_hwi.h" |
---|
| 45 | + |
---|
| 46 | +static ulong logging_level = PM8001_FAIL_LOGGING | PM8001_IOERR_LOGGING; |
---|
| 47 | +module_param(logging_level, ulong, 0644); |
---|
| 48 | +MODULE_PARM_DESC(logging_level, " bits for enabling logging info."); |
---|
| 49 | + |
---|
| 50 | +static ulong link_rate = LINKRATE_15 | LINKRATE_30 | LINKRATE_60 | LINKRATE_120; |
---|
| 51 | +module_param(link_rate, ulong, 0644); |
---|
| 52 | +MODULE_PARM_DESC(link_rate, "Enable link rate.\n" |
---|
| 53 | + " 1: Link rate 1.5G\n" |
---|
| 54 | + " 2: Link rate 3.0G\n" |
---|
| 55 | + " 4: Link rate 6.0G\n" |
---|
| 56 | + " 8: Link rate 12.0G\n"); |
---|
44 | 57 | |
---|
45 | 58 | static struct scsi_transport_template *pm8001_stt; |
---|
| 59 | +static int pm8001_init_ccb_tag(struct pm8001_hba_info *, struct Scsi_Host *, struct pci_dev *); |
---|
46 | 60 | |
---|
47 | | -/** |
---|
| 61 | +/* |
---|
48 | 62 | * chip info structure to identify chip key functionality as |
---|
49 | 63 | * encryption available/not, no of ports, hw specific function ref |
---|
50 | 64 | */ |
---|
.. | .. |
---|
67 | 81 | |
---|
68 | 82 | struct workqueue_struct *pm8001_wq; |
---|
69 | 83 | |
---|
70 | | -/** |
---|
| 84 | +/* |
---|
71 | 85 | * The main structure which LLDD must register for scsi core. |
---|
72 | 86 | */ |
---|
73 | 87 | static struct scsi_host_template pm8001_sht = { |
---|
74 | 88 | .module = THIS_MODULE, |
---|
75 | 89 | .name = DRV_NAME, |
---|
76 | 90 | .queuecommand = sas_queuecommand, |
---|
| 91 | + .dma_need_drain = ata_scsi_dma_need_drain, |
---|
77 | 92 | .target_alloc = sas_target_alloc, |
---|
78 | 93 | .slave_configure = sas_slave_configure, |
---|
79 | 94 | .scan_finished = pm8001_scan_finished, |
---|
.. | .. |
---|
82 | 97 | .bios_param = sas_bios_param, |
---|
83 | 98 | .can_queue = 1, |
---|
84 | 99 | .this_id = -1, |
---|
85 | | - .sg_tablesize = SG_ALL, |
---|
| 100 | + .sg_tablesize = PM8001_MAX_DMA_SG, |
---|
86 | 101 | .max_sectors = SCSI_DEFAULT_MAX_SECTORS, |
---|
87 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
88 | 102 | .eh_device_reset_handler = sas_eh_device_reset_handler, |
---|
89 | 103 | .eh_target_reset_handler = sas_eh_target_reset_handler, |
---|
90 | 104 | .slave_alloc = sas_slave_alloc, |
---|
91 | 105 | .target_destroy = sas_target_destroy, |
---|
92 | 106 | .ioctl = sas_ioctl, |
---|
| 107 | +#ifdef CONFIG_COMPAT |
---|
| 108 | + .compat_ioctl = sas_ioctl, |
---|
| 109 | +#endif |
---|
93 | 110 | .shost_attrs = pm8001_host_attrs, |
---|
94 | 111 | .track_queue_depth = 1, |
---|
95 | 112 | }; |
---|
96 | 113 | |
---|
97 | | -/** |
---|
| 114 | +/* |
---|
98 | 115 | * Sas layer call this function to execute specific task. |
---|
99 | 116 | */ |
---|
100 | 117 | static struct sas_domain_function_template pm8001_transport_ops = { |
---|
.. | .. |
---|
114 | 131 | }; |
---|
115 | 132 | |
---|
116 | 133 | /** |
---|
117 | | - *pm8001_phy_init - initiate our adapter phys |
---|
118 | | - *@pm8001_ha: our hba structure. |
---|
119 | | - *@phy_id: phy id. |
---|
| 134 | + * pm8001_phy_init - initiate our adapter phys |
---|
| 135 | + * @pm8001_ha: our hba structure. |
---|
| 136 | + * @phy_id: phy id. |
---|
120 | 137 | */ |
---|
121 | 138 | static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id) |
---|
122 | 139 | { |
---|
123 | 140 | struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; |
---|
124 | 141 | struct asd_sas_phy *sas_phy = &phy->sas_phy; |
---|
125 | | - phy->phy_state = 0; |
---|
| 142 | + phy->phy_state = PHY_LINK_DISABLE; |
---|
126 | 143 | phy->pm8001_ha = pm8001_ha; |
---|
127 | 144 | sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0; |
---|
128 | 145 | sas_phy->class = SAS; |
---|
.. | .. |
---|
140 | 157 | } |
---|
141 | 158 | |
---|
142 | 159 | /** |
---|
143 | | - *pm8001_free - free hba |
---|
144 | | - *@pm8001_ha: our hba structure. |
---|
145 | | - * |
---|
| 160 | + * pm8001_free - free hba |
---|
| 161 | + * @pm8001_ha: our hba structure. |
---|
146 | 162 | */ |
---|
147 | 163 | static void pm8001_free(struct pm8001_hba_info *pm8001_ha) |
---|
148 | 164 | { |
---|
.. | .. |
---|
153 | 169 | |
---|
154 | 170 | for (i = 0; i < USI_MAX_MEMCNT; i++) { |
---|
155 | 171 | if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) { |
---|
156 | | - pci_free_consistent(pm8001_ha->pdev, |
---|
| 172 | + dma_free_coherent(&pm8001_ha->pdev->dev, |
---|
157 | 173 | (pm8001_ha->memoryMap.region[i].total_len + |
---|
158 | 174 | pm8001_ha->memoryMap.region[i].alignment), |
---|
159 | 175 | pm8001_ha->memoryMap.region[i].virt_ptr, |
---|
.. | .. |
---|
190 | 206 | * pm8001_interrupt_handler_msix - main MSIX interrupt handler. |
---|
191 | 207 | * It obtains the vector number and calls the equivalent bottom |
---|
192 | 208 | * half or services directly. |
---|
| 209 | + * @irq: interrupt number |
---|
193 | 210 | * @opaque: the passed outbound queue/vector. Host structure is |
---|
194 | 211 | * retrieved from the same. |
---|
195 | 212 | */ |
---|
.. | .. |
---|
203 | 220 | |
---|
204 | 221 | if (unlikely(!pm8001_ha)) |
---|
205 | 222 | return IRQ_NONE; |
---|
206 | | - if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) |
---|
| 223 | + if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha)) |
---|
207 | 224 | return IRQ_NONE; |
---|
208 | 225 | #ifdef PM8001_USE_TASKLET |
---|
209 | 226 | tasklet_schedule(&pm8001_ha->tasklet[irq_vector->irq_id]); |
---|
.. | .. |
---|
215 | 232 | |
---|
216 | 233 | /** |
---|
217 | 234 | * pm8001_interrupt_handler_intx - main INTx interrupt handler. |
---|
| 235 | + * @irq: interrupt number |
---|
218 | 236 | * @dev_id: sas_ha structure. The HBA is retrieved from sas_has structure. |
---|
219 | 237 | */ |
---|
220 | 238 | |
---|
.. | .. |
---|
226 | 244 | pm8001_ha = sha->lldd_ha; |
---|
227 | 245 | if (unlikely(!pm8001_ha)) |
---|
228 | 246 | return IRQ_NONE; |
---|
229 | | - if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) |
---|
| 247 | + if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha)) |
---|
230 | 248 | return IRQ_NONE; |
---|
231 | 249 | |
---|
232 | 250 | #ifdef PM8001_USE_TASKLET |
---|
.. | .. |
---|
237 | 255 | return ret; |
---|
238 | 256 | } |
---|
239 | 257 | |
---|
| 258 | +static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha); |
---|
| 259 | + |
---|
240 | 260 | /** |
---|
241 | 261 | * pm8001_alloc - initiate our hba structure and 6 DMAs area. |
---|
242 | | - * @pm8001_ha:our hba structure. |
---|
243 | | - * |
---|
| 262 | + * @pm8001_ha: our hba structure. |
---|
| 263 | + * @ent: PCI device ID structure to match on |
---|
244 | 264 | */ |
---|
245 | 265 | static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, |
---|
246 | 266 | const struct pci_device_id *ent) |
---|
247 | 267 | { |
---|
248 | | - int i; |
---|
| 268 | + int i, count = 0, rc = 0; |
---|
| 269 | + u32 ci_offset, ib_offset, ob_offset, pi_offset; |
---|
| 270 | + struct inbound_queue_table *circularQ; |
---|
| 271 | + |
---|
249 | 272 | spin_lock_init(&pm8001_ha->lock); |
---|
250 | 273 | spin_lock_init(&pm8001_ha->bitmap_lock); |
---|
251 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
252 | | - pm8001_printk("pm8001_alloc: PHY:%x\n", |
---|
253 | | - pm8001_ha->chip->n_phy)); |
---|
| 274 | + pm8001_dbg(pm8001_ha, INIT, "pm8001_alloc: PHY:%x\n", |
---|
| 275 | + pm8001_ha->chip->n_phy); |
---|
| 276 | + |
---|
| 277 | + /* Request Interrupt */ |
---|
| 278 | + rc = pm8001_request_irq(pm8001_ha); |
---|
| 279 | + if (rc) |
---|
| 280 | + goto err_out; |
---|
| 281 | + |
---|
| 282 | + count = pm8001_ha->max_q_num; |
---|
| 283 | + /* Queues are chosen based on the number of cores/msix availability */ |
---|
| 284 | + ib_offset = pm8001_ha->ib_offset = USI_MAX_MEMCNT_BASE; |
---|
| 285 | + ci_offset = pm8001_ha->ci_offset = ib_offset + count; |
---|
| 286 | + ob_offset = pm8001_ha->ob_offset = ci_offset + count; |
---|
| 287 | + pi_offset = pm8001_ha->pi_offset = ob_offset + count; |
---|
| 288 | + pm8001_ha->max_memcnt = pi_offset + count; |
---|
| 289 | + |
---|
254 | 290 | for (i = 0; i < pm8001_ha->chip->n_phy; i++) { |
---|
255 | 291 | pm8001_phy_init(pm8001_ha, i); |
---|
256 | 292 | pm8001_ha->port[i].wide_port_phymap = 0; |
---|
.. | .. |
---|
259 | 295 | INIT_LIST_HEAD(&pm8001_ha->port[i].list); |
---|
260 | 296 | } |
---|
261 | 297 | |
---|
262 | | - pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL); |
---|
263 | | - if (!pm8001_ha->tags) |
---|
264 | | - goto err_out; |
---|
265 | 298 | /* MPI Memory region 1 for AAP Event Log for fw */ |
---|
266 | 299 | pm8001_ha->memoryMap.region[AAP1].num_elements = 1; |
---|
267 | 300 | pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE; |
---|
.. | .. |
---|
274 | 307 | pm8001_ha->memoryMap.region[IOP].total_len = PM8001_EVENT_LOG_SIZE; |
---|
275 | 308 | pm8001_ha->memoryMap.region[IOP].alignment = 32; |
---|
276 | 309 | |
---|
277 | | - for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) { |
---|
| 310 | + for (i = 0; i < count; i++) { |
---|
| 311 | + circularQ = &pm8001_ha->inbnd_q_tbl[i]; |
---|
| 312 | + spin_lock_init(&circularQ->iq_lock); |
---|
278 | 313 | /* MPI Memory region 3 for consumer Index of inbound queues */ |
---|
279 | | - pm8001_ha->memoryMap.region[CI+i].num_elements = 1; |
---|
280 | | - pm8001_ha->memoryMap.region[CI+i].element_size = 4; |
---|
281 | | - pm8001_ha->memoryMap.region[CI+i].total_len = 4; |
---|
282 | | - pm8001_ha->memoryMap.region[CI+i].alignment = 4; |
---|
| 314 | + pm8001_ha->memoryMap.region[ci_offset+i].num_elements = 1; |
---|
| 315 | + pm8001_ha->memoryMap.region[ci_offset+i].element_size = 4; |
---|
| 316 | + pm8001_ha->memoryMap.region[ci_offset+i].total_len = 4; |
---|
| 317 | + pm8001_ha->memoryMap.region[ci_offset+i].alignment = 4; |
---|
283 | 318 | |
---|
284 | 319 | if ((ent->driver_data) != chip_8001) { |
---|
285 | 320 | /* MPI Memory region 5 inbound queues */ |
---|
286 | | - pm8001_ha->memoryMap.region[IB+i].num_elements = |
---|
| 321 | + pm8001_ha->memoryMap.region[ib_offset+i].num_elements = |
---|
287 | 322 | PM8001_MPI_QUEUE; |
---|
288 | | - pm8001_ha->memoryMap.region[IB+i].element_size = 128; |
---|
289 | | - pm8001_ha->memoryMap.region[IB+i].total_len = |
---|
| 323 | + pm8001_ha->memoryMap.region[ib_offset+i].element_size |
---|
| 324 | + = 128; |
---|
| 325 | + pm8001_ha->memoryMap.region[ib_offset+i].total_len = |
---|
290 | 326 | PM8001_MPI_QUEUE * 128; |
---|
291 | | - pm8001_ha->memoryMap.region[IB+i].alignment = 128; |
---|
| 327 | + pm8001_ha->memoryMap.region[ib_offset+i].alignment |
---|
| 328 | + = 128; |
---|
292 | 329 | } else { |
---|
293 | | - pm8001_ha->memoryMap.region[IB+i].num_elements = |
---|
| 330 | + pm8001_ha->memoryMap.region[ib_offset+i].num_elements = |
---|
294 | 331 | PM8001_MPI_QUEUE; |
---|
295 | | - pm8001_ha->memoryMap.region[IB+i].element_size = 64; |
---|
296 | | - pm8001_ha->memoryMap.region[IB+i].total_len = |
---|
| 332 | + pm8001_ha->memoryMap.region[ib_offset+i].element_size |
---|
| 333 | + = 64; |
---|
| 334 | + pm8001_ha->memoryMap.region[ib_offset+i].total_len = |
---|
297 | 335 | PM8001_MPI_QUEUE * 64; |
---|
298 | | - pm8001_ha->memoryMap.region[IB+i].alignment = 64; |
---|
| 336 | + pm8001_ha->memoryMap.region[ib_offset+i].alignment = 64; |
---|
299 | 337 | } |
---|
300 | 338 | } |
---|
301 | 339 | |
---|
302 | | - for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) { |
---|
| 340 | + for (i = 0; i < count; i++) { |
---|
303 | 341 | /* MPI Memory region 4 for producer Index of outbound queues */ |
---|
304 | | - pm8001_ha->memoryMap.region[PI+i].num_elements = 1; |
---|
305 | | - pm8001_ha->memoryMap.region[PI+i].element_size = 4; |
---|
306 | | - pm8001_ha->memoryMap.region[PI+i].total_len = 4; |
---|
307 | | - pm8001_ha->memoryMap.region[PI+i].alignment = 4; |
---|
| 342 | + pm8001_ha->memoryMap.region[pi_offset+i].num_elements = 1; |
---|
| 343 | + pm8001_ha->memoryMap.region[pi_offset+i].element_size = 4; |
---|
| 344 | + pm8001_ha->memoryMap.region[pi_offset+i].total_len = 4; |
---|
| 345 | + pm8001_ha->memoryMap.region[pi_offset+i].alignment = 4; |
---|
308 | 346 | |
---|
309 | 347 | if (ent->driver_data != chip_8001) { |
---|
310 | 348 | /* MPI Memory region 6 Outbound queues */ |
---|
311 | | - pm8001_ha->memoryMap.region[OB+i].num_elements = |
---|
| 349 | + pm8001_ha->memoryMap.region[ob_offset+i].num_elements = |
---|
312 | 350 | PM8001_MPI_QUEUE; |
---|
313 | | - pm8001_ha->memoryMap.region[OB+i].element_size = 128; |
---|
314 | | - pm8001_ha->memoryMap.region[OB+i].total_len = |
---|
| 351 | + pm8001_ha->memoryMap.region[ob_offset+i].element_size |
---|
| 352 | + = 128; |
---|
| 353 | + pm8001_ha->memoryMap.region[ob_offset+i].total_len = |
---|
315 | 354 | PM8001_MPI_QUEUE * 128; |
---|
316 | | - pm8001_ha->memoryMap.region[OB+i].alignment = 128; |
---|
| 355 | + pm8001_ha->memoryMap.region[ob_offset+i].alignment |
---|
| 356 | + = 128; |
---|
317 | 357 | } else { |
---|
318 | 358 | /* MPI Memory region 6 Outbound queues */ |
---|
319 | | - pm8001_ha->memoryMap.region[OB+i].num_elements = |
---|
| 359 | + pm8001_ha->memoryMap.region[ob_offset+i].num_elements = |
---|
320 | 360 | PM8001_MPI_QUEUE; |
---|
321 | | - pm8001_ha->memoryMap.region[OB+i].element_size = 64; |
---|
322 | | - pm8001_ha->memoryMap.region[OB+i].total_len = |
---|
| 361 | + pm8001_ha->memoryMap.region[ob_offset+i].element_size |
---|
| 362 | + = 64; |
---|
| 363 | + pm8001_ha->memoryMap.region[ob_offset+i].total_len = |
---|
323 | 364 | PM8001_MPI_QUEUE * 64; |
---|
324 | | - pm8001_ha->memoryMap.region[OB+i].alignment = 64; |
---|
| 365 | + pm8001_ha->memoryMap.region[ob_offset+i].alignment = 64; |
---|
325 | 366 | } |
---|
326 | 367 | |
---|
327 | 368 | } |
---|
.. | .. |
---|
329 | 370 | pm8001_ha->memoryMap.region[NVMD].num_elements = 1; |
---|
330 | 371 | pm8001_ha->memoryMap.region[NVMD].element_size = 4096; |
---|
331 | 372 | pm8001_ha->memoryMap.region[NVMD].total_len = 4096; |
---|
332 | | - /* Memory region for devices*/ |
---|
333 | | - pm8001_ha->memoryMap.region[DEV_MEM].num_elements = 1; |
---|
334 | | - pm8001_ha->memoryMap.region[DEV_MEM].element_size = PM8001_MAX_DEVICES * |
---|
335 | | - sizeof(struct pm8001_device); |
---|
336 | | - pm8001_ha->memoryMap.region[DEV_MEM].total_len = PM8001_MAX_DEVICES * |
---|
337 | | - sizeof(struct pm8001_device); |
---|
338 | | - |
---|
339 | | - /* Memory region for ccb_info*/ |
---|
340 | | - pm8001_ha->memoryMap.region[CCB_MEM].num_elements = 1; |
---|
341 | | - pm8001_ha->memoryMap.region[CCB_MEM].element_size = PM8001_MAX_CCB * |
---|
342 | | - sizeof(struct pm8001_ccb_info); |
---|
343 | | - pm8001_ha->memoryMap.region[CCB_MEM].total_len = PM8001_MAX_CCB * |
---|
344 | | - sizeof(struct pm8001_ccb_info); |
---|
345 | 373 | |
---|
346 | 374 | /* Memory region for fw flash */ |
---|
347 | 375 | pm8001_ha->memoryMap.region[FW_FLASH].total_len = 4096; |
---|
.. | .. |
---|
350 | 378 | pm8001_ha->memoryMap.region[FORENSIC_MEM].total_len = 0x10000; |
---|
351 | 379 | pm8001_ha->memoryMap.region[FORENSIC_MEM].element_size = 0x10000; |
---|
352 | 380 | pm8001_ha->memoryMap.region[FORENSIC_MEM].alignment = 0x10000; |
---|
353 | | - for (i = 0; i < USI_MAX_MEMCNT; i++) { |
---|
| 381 | + for (i = 0; i < pm8001_ha->max_memcnt; i++) { |
---|
354 | 382 | if (pm8001_mem_alloc(pm8001_ha->pdev, |
---|
355 | 383 | &pm8001_ha->memoryMap.region[i].virt_ptr, |
---|
356 | 384 | &pm8001_ha->memoryMap.region[i].phys_addr, |
---|
.. | .. |
---|
358 | 386 | &pm8001_ha->memoryMap.region[i].phys_addr_lo, |
---|
359 | 387 | pm8001_ha->memoryMap.region[i].total_len, |
---|
360 | 388 | pm8001_ha->memoryMap.region[i].alignment) != 0) { |
---|
361 | | - PM8001_FAIL_DBG(pm8001_ha, |
---|
362 | | - pm8001_printk("Mem%d alloc failed\n", |
---|
363 | | - i)); |
---|
| 389 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 390 | + "Mem%d alloc failed\n", |
---|
| 391 | + i); |
---|
364 | 392 | goto err_out; |
---|
365 | 393 | } |
---|
366 | 394 | } |
---|
367 | 395 | |
---|
368 | | - pm8001_ha->devices = pm8001_ha->memoryMap.region[DEV_MEM].virt_ptr; |
---|
| 396 | + /* Memory region for devices*/ |
---|
| 397 | + pm8001_ha->devices = kzalloc(PM8001_MAX_DEVICES |
---|
| 398 | + * sizeof(struct pm8001_device), GFP_KERNEL); |
---|
| 399 | + if (!pm8001_ha->devices) { |
---|
| 400 | + rc = -ENOMEM; |
---|
| 401 | + goto err_out_nodev; |
---|
| 402 | + } |
---|
369 | 403 | for (i = 0; i < PM8001_MAX_DEVICES; i++) { |
---|
370 | 404 | pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED; |
---|
371 | 405 | pm8001_ha->devices[i].id = i; |
---|
372 | 406 | pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES; |
---|
373 | | - pm8001_ha->devices[i].running_req = 0; |
---|
374 | | - } |
---|
375 | | - pm8001_ha->ccb_info = pm8001_ha->memoryMap.region[CCB_MEM].virt_ptr; |
---|
376 | | - for (i = 0; i < PM8001_MAX_CCB; i++) { |
---|
377 | | - pm8001_ha->ccb_info[i].ccb_dma_handle = |
---|
378 | | - pm8001_ha->memoryMap.region[CCB_MEM].phys_addr + |
---|
379 | | - i * sizeof(struct pm8001_ccb_info); |
---|
380 | | - pm8001_ha->ccb_info[i].task = NULL; |
---|
381 | | - pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff; |
---|
382 | | - pm8001_ha->ccb_info[i].device = NULL; |
---|
383 | | - ++pm8001_ha->tags_num; |
---|
| 407 | + atomic_set(&pm8001_ha->devices[i].running_req, 0); |
---|
384 | 408 | } |
---|
385 | 409 | pm8001_ha->flags = PM8001F_INIT_TIME; |
---|
386 | 410 | /* Initialize tags */ |
---|
387 | 411 | pm8001_tag_init(pm8001_ha); |
---|
388 | 412 | return 0; |
---|
| 413 | + |
---|
| 414 | +err_out_nodev: |
---|
| 415 | + for (i = 0; i < pm8001_ha->max_memcnt; i++) { |
---|
| 416 | + if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) { |
---|
| 417 | + pci_free_consistent(pm8001_ha->pdev, |
---|
| 418 | + (pm8001_ha->memoryMap.region[i].total_len + |
---|
| 419 | + pm8001_ha->memoryMap.region[i].alignment), |
---|
| 420 | + pm8001_ha->memoryMap.region[i].virt_ptr, |
---|
| 421 | + pm8001_ha->memoryMap.region[i].phys_addr); |
---|
| 422 | + } |
---|
| 423 | + } |
---|
389 | 424 | err_out: |
---|
390 | 425 | return 1; |
---|
391 | 426 | } |
---|
.. | .. |
---|
403 | 438 | |
---|
404 | 439 | pdev = pm8001_ha->pdev; |
---|
405 | 440 | /* map pci mem (PMC pci base 0-3)*/ |
---|
406 | | - for (bar = 0; bar < 6; bar++) { |
---|
| 441 | + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { |
---|
407 | 442 | /* |
---|
408 | 443 | ** logical BARs for SPC: |
---|
409 | 444 | ** bar 0 and 1 - logical BAR0 |
---|
.. | .. |
---|
422 | 457 | pm8001_ha->io_mem[logicalBar].memvirtaddr = |
---|
423 | 458 | ioremap(pm8001_ha->io_mem[logicalBar].membase, |
---|
424 | 459 | pm8001_ha->io_mem[logicalBar].memsize); |
---|
425 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
426 | | - pm8001_printk("PCI: bar %d, logicalBar %d ", |
---|
427 | | - bar, logicalBar)); |
---|
428 | | - PM8001_INIT_DBG(pm8001_ha, pm8001_printk( |
---|
429 | | - "base addr %llx virt_addr=%llx len=%d\n", |
---|
430 | | - (u64)pm8001_ha->io_mem[logicalBar].membase, |
---|
431 | | - (u64)(unsigned long) |
---|
432 | | - pm8001_ha->io_mem[logicalBar].memvirtaddr, |
---|
433 | | - pm8001_ha->io_mem[logicalBar].memsize)); |
---|
| 460 | + pm8001_dbg(pm8001_ha, INIT, |
---|
| 461 | + "PCI: bar %d, logicalBar %d\n", |
---|
| 462 | + bar, logicalBar); |
---|
| 463 | + pm8001_dbg(pm8001_ha, INIT, |
---|
| 464 | + "base addr %llx virt_addr=%llx len=%d\n", |
---|
| 465 | + (u64)pm8001_ha->io_mem[logicalBar].membase, |
---|
| 466 | + (u64)(unsigned long) |
---|
| 467 | + pm8001_ha->io_mem[logicalBar].memvirtaddr, |
---|
| 468 | + pm8001_ha->io_mem[logicalBar].memsize); |
---|
434 | 469 | } else { |
---|
435 | 470 | pm8001_ha->io_mem[logicalBar].membase = 0; |
---|
436 | 471 | pm8001_ha->io_mem[logicalBar].memsize = 0; |
---|
437 | | - pm8001_ha->io_mem[logicalBar].memvirtaddr = 0; |
---|
| 472 | + pm8001_ha->io_mem[logicalBar].memvirtaddr = NULL; |
---|
438 | 473 | } |
---|
439 | 474 | logicalBar++; |
---|
440 | 475 | } |
---|
.. | .. |
---|
468 | 503 | pm8001_ha->sas = sha; |
---|
469 | 504 | pm8001_ha->shost = shost; |
---|
470 | 505 | pm8001_ha->id = pm8001_id++; |
---|
471 | | - pm8001_ha->logging_level = 0x01; |
---|
| 506 | + pm8001_ha->logging_level = logging_level; |
---|
| 507 | + pm8001_ha->non_fatal_count = 0; |
---|
| 508 | + if (link_rate >= 1 && link_rate <= 15) |
---|
| 509 | + pm8001_ha->link_rate = (link_rate << 8); |
---|
| 510 | + else { |
---|
| 511 | + pm8001_ha->link_rate = LINKRATE_15 | LINKRATE_30 | |
---|
| 512 | + LINKRATE_60 | LINKRATE_120; |
---|
| 513 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 514 | + "Setting link rate to default value\n"); |
---|
| 515 | + } |
---|
472 | 516 | sprintf(pm8001_ha->name, "%s%d", DRV_NAME, pm8001_ha->id); |
---|
473 | 517 | /* IOMB size is 128 for 8088/89 controllers */ |
---|
474 | 518 | if (pm8001_ha->chip_id != chip_8001) |
---|
.. | .. |
---|
502 | 546 | { |
---|
503 | 547 | int rc; |
---|
504 | 548 | |
---|
505 | | - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(44))) { |
---|
506 | | - rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(44)); |
---|
507 | | - if (rc) { |
---|
508 | | - rc = pci_set_consistent_dma_mask(pdev, |
---|
509 | | - DMA_BIT_MASK(32)); |
---|
510 | | - if (rc) { |
---|
511 | | - dev_printk(KERN_ERR, &pdev->dev, |
---|
512 | | - "44-bit DMA enable failed\n"); |
---|
513 | | - return rc; |
---|
514 | | - } |
---|
515 | | - } |
---|
516 | | - } else { |
---|
517 | | - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
518 | | - if (rc) { |
---|
| 549 | + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); |
---|
| 550 | + if (rc) { |
---|
| 551 | + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
---|
| 552 | + if (rc) |
---|
519 | 553 | dev_printk(KERN_ERR, &pdev->dev, |
---|
520 | 554 | "32-bit DMA enable failed\n"); |
---|
521 | | - return rc; |
---|
522 | | - } |
---|
523 | | - rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
524 | | - if (rc) { |
---|
525 | | - dev_printk(KERN_ERR, &pdev->dev, |
---|
526 | | - "32-bit consistent DMA enable failed\n"); |
---|
527 | | - return rc; |
---|
528 | | - } |
---|
529 | 555 | } |
---|
530 | 556 | return rc; |
---|
531 | 557 | } |
---|
.. | .. |
---|
606 | 632 | |
---|
607 | 633 | /** |
---|
608 | 634 | * pm8001_init_sas_add - initialize sas address |
---|
609 | | - * @chip_info: our ha struct. |
---|
| 635 | + * @pm8001_ha: our ha struct. |
---|
610 | 636 | * |
---|
611 | 637 | * Currently we just set the fixed SAS address to our HBA,for manufacture, |
---|
612 | 638 | * it should read from the EEPROM |
---|
.. | .. |
---|
631 | 657 | if (pm8001_ha->chip_id == chip_8001) { |
---|
632 | 658 | if (deviceid == 0x8081 || deviceid == 0x0042) { |
---|
633 | 659 | payload.minor_function = 4; |
---|
634 | | - payload.length = 4096; |
---|
| 660 | + payload.rd_length = 4096; |
---|
635 | 661 | } else { |
---|
636 | 662 | payload.minor_function = 0; |
---|
637 | | - payload.length = 128; |
---|
| 663 | + payload.rd_length = 128; |
---|
638 | 664 | } |
---|
639 | 665 | } else if ((pm8001_ha->chip_id == chip_8070 || |
---|
640 | 666 | pm8001_ha->chip_id == chip_8072) && |
---|
641 | 667 | pm8001_ha->pdev->subsystem_vendor == PCI_VENDOR_ID_ATTO) { |
---|
642 | 668 | payload.minor_function = 4; |
---|
643 | | - payload.length = 4096; |
---|
| 669 | + payload.rd_length = 4096; |
---|
644 | 670 | } else { |
---|
645 | 671 | payload.minor_function = 1; |
---|
646 | | - payload.length = 4096; |
---|
| 672 | + payload.rd_length = 4096; |
---|
647 | 673 | } |
---|
648 | 674 | payload.offset = 0; |
---|
649 | | - payload.func_specific = kzalloc(payload.length, GFP_KERNEL); |
---|
| 675 | + payload.func_specific = kzalloc(payload.rd_length, GFP_KERNEL); |
---|
650 | 676 | if (!payload.func_specific) { |
---|
651 | | - PM8001_INIT_DBG(pm8001_ha, pm8001_printk("mem alloc fail\n")); |
---|
| 677 | + pm8001_dbg(pm8001_ha, INIT, "mem alloc fail\n"); |
---|
652 | 678 | return; |
---|
653 | 679 | } |
---|
654 | 680 | rc = PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); |
---|
655 | 681 | if (rc) { |
---|
656 | 682 | kfree(payload.func_specific); |
---|
657 | | - PM8001_INIT_DBG(pm8001_ha, pm8001_printk("nvmd failed\n")); |
---|
| 683 | + pm8001_dbg(pm8001_ha, INIT, "nvmd failed\n"); |
---|
658 | 684 | return; |
---|
659 | 685 | } |
---|
660 | 686 | wait_for_completion(&completion); |
---|
.. | .. |
---|
682 | 708 | sas_add[7] = sas_add[7] + 4; |
---|
683 | 709 | memcpy(&pm8001_ha->phy[i].dev_sas_addr, |
---|
684 | 710 | sas_add, SAS_ADDR_SIZE); |
---|
685 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
686 | | - pm8001_printk("phy %d sas_addr = %016llx\n", i, |
---|
687 | | - pm8001_ha->phy[i].dev_sas_addr)); |
---|
| 711 | + pm8001_dbg(pm8001_ha, INIT, "phy %d sas_addr = %016llx\n", i, |
---|
| 712 | + pm8001_ha->phy[i].dev_sas_addr); |
---|
688 | 713 | } |
---|
689 | 714 | kfree(payload.func_specific); |
---|
690 | 715 | #else |
---|
.. | .. |
---|
716 | 741 | /* SAS ADDRESS read from flash / EEPROM */ |
---|
717 | 742 | payload.minor_function = 6; |
---|
718 | 743 | payload.offset = 0; |
---|
719 | | - payload.length = 4096; |
---|
| 744 | + payload.rd_length = 4096; |
---|
720 | 745 | payload.func_specific = kzalloc(4096, GFP_KERNEL); |
---|
721 | 746 | if (!payload.func_specific) |
---|
722 | 747 | return -ENOMEM; |
---|
.. | .. |
---|
724 | 749 | rc = PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); |
---|
725 | 750 | if (rc) { |
---|
726 | 751 | kfree(payload.func_specific); |
---|
727 | | - PM8001_INIT_DBG(pm8001_ha, pm8001_printk("nvmd failed\n")); |
---|
| 752 | + pm8001_dbg(pm8001_ha, INIT, "nvmd failed\n"); |
---|
728 | 753 | return -ENOMEM; |
---|
729 | 754 | } |
---|
730 | 755 | wait_for_completion(&completion); |
---|
.. | .. |
---|
818 | 843 | break; |
---|
819 | 844 | |
---|
820 | 845 | default: |
---|
821 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
822 | | - pm8001_printk("Unknown subsystem device=0x%.04x", |
---|
823 | | - pm8001_ha->pdev->subsystem_device)); |
---|
| 846 | + pm8001_dbg(pm8001_ha, INIT, |
---|
| 847 | + "Unknown subsystem device=0x%.04x\n", |
---|
| 848 | + pm8001_ha->pdev->subsystem_device); |
---|
824 | 849 | } |
---|
825 | 850 | } |
---|
826 | 851 | |
---|
.. | .. |
---|
884 | 909 | #ifdef PM8001_USE_MSIX |
---|
885 | 910 | /** |
---|
886 | 911 | * pm8001_setup_msix - enable MSI-X interrupt |
---|
887 | | - * @chip_info: our ha struct. |
---|
888 | | - * @irq_handler: irq_handler |
---|
| 912 | + * @pm8001_ha: our ha struct. |
---|
889 | 913 | */ |
---|
890 | 914 | static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) |
---|
891 | 915 | { |
---|
892 | | - u32 i = 0, j = 0; |
---|
893 | 916 | u32 number_of_intr; |
---|
894 | | - int flag = 0; |
---|
895 | | - int rc; |
---|
896 | | - static char intr_drvname[PM8001_MAX_MSIX_VEC][sizeof(DRV_NAME)+3]; |
---|
| 917 | + int rc, cpu_online_count; |
---|
| 918 | + unsigned int allocated_irq_vectors; |
---|
897 | 919 | |
---|
898 | 920 | /* SPCv controllers supports 64 msi-x */ |
---|
899 | 921 | if (pm8001_ha->chip_id == chip_8001) { |
---|
900 | 922 | number_of_intr = 1; |
---|
901 | 923 | } else { |
---|
902 | 924 | number_of_intr = PM8001_MAX_MSIX_VEC; |
---|
903 | | - flag &= ~IRQF_SHARED; |
---|
904 | 925 | } |
---|
905 | 926 | |
---|
| 927 | + cpu_online_count = num_online_cpus(); |
---|
| 928 | + number_of_intr = min_t(int, cpu_online_count, number_of_intr); |
---|
906 | 929 | rc = pci_alloc_irq_vectors(pm8001_ha->pdev, number_of_intr, |
---|
907 | 930 | number_of_intr, PCI_IRQ_MSIX); |
---|
| 931 | + allocated_irq_vectors = rc; |
---|
908 | 932 | if (rc < 0) |
---|
909 | 933 | return rc; |
---|
| 934 | + |
---|
| 935 | + /* Assigns the number of interrupts */ |
---|
| 936 | + number_of_intr = min_t(int, allocated_irq_vectors, number_of_intr); |
---|
910 | 937 | pm8001_ha->number_of_intr = number_of_intr; |
---|
911 | 938 | |
---|
912 | | - PM8001_INIT_DBG(pm8001_ha, pm8001_printk( |
---|
913 | | - "pci_alloc_irq_vectors request ret:%d no of intr %d\n", |
---|
914 | | - rc, pm8001_ha->number_of_intr)); |
---|
| 939 | + /* Maximum queue number updating in HBA structure */ |
---|
| 940 | + pm8001_ha->max_q_num = number_of_intr; |
---|
915 | 941 | |
---|
916 | | - for (i = 0; i < number_of_intr; i++) { |
---|
917 | | - snprintf(intr_drvname[i], sizeof(intr_drvname[0]), |
---|
918 | | - DRV_NAME"%d", i); |
---|
| 942 | + pm8001_dbg(pm8001_ha, INIT, |
---|
| 943 | + "pci_alloc_irq_vectors request ret:%d no of intr %d\n", |
---|
| 944 | + rc, pm8001_ha->number_of_intr); |
---|
| 945 | + return 0; |
---|
| 946 | +} |
---|
| 947 | + |
---|
| 948 | +static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha) |
---|
| 949 | +{ |
---|
| 950 | + u32 i = 0, j = 0; |
---|
| 951 | + int flag = 0, rc = 0; |
---|
| 952 | + |
---|
| 953 | + if (pm8001_ha->chip_id != chip_8001) |
---|
| 954 | + flag &= ~IRQF_SHARED; |
---|
| 955 | + |
---|
| 956 | + pm8001_dbg(pm8001_ha, INIT, |
---|
| 957 | + "pci_enable_msix request number of intr %d\n", |
---|
| 958 | + pm8001_ha->number_of_intr); |
---|
| 959 | + |
---|
| 960 | + for (i = 0; i < pm8001_ha->number_of_intr; i++) { |
---|
| 961 | + snprintf(pm8001_ha->intr_drvname[i], |
---|
| 962 | + sizeof(pm8001_ha->intr_drvname[0]), |
---|
| 963 | + "%s-%d", pm8001_ha->name, i); |
---|
919 | 964 | pm8001_ha->irq_vector[i].irq_id = i; |
---|
920 | 965 | pm8001_ha->irq_vector[i].drv_inst = pm8001_ha; |
---|
921 | 966 | |
---|
922 | 967 | rc = request_irq(pci_irq_vector(pm8001_ha->pdev, i), |
---|
923 | 968 | pm8001_interrupt_handler_msix, flag, |
---|
924 | | - intr_drvname[i], &(pm8001_ha->irq_vector[i])); |
---|
| 969 | + pm8001_ha->intr_drvname[i], |
---|
| 970 | + &(pm8001_ha->irq_vector[i])); |
---|
925 | 971 | if (rc) { |
---|
926 | 972 | for (j = 0; j < i; j++) { |
---|
927 | 973 | free_irq(pci_irq_vector(pm8001_ha->pdev, i), |
---|
.. | .. |
---|
938 | 984 | |
---|
939 | 985 | /** |
---|
940 | 986 | * pm8001_request_irq - register interrupt |
---|
941 | | - * @chip_info: our ha struct. |
---|
| 987 | + * @pm8001_ha: our ha struct. |
---|
942 | 988 | */ |
---|
943 | 989 | static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha) |
---|
944 | 990 | { |
---|
945 | | - struct pci_dev *pdev; |
---|
| 991 | + struct pci_dev *pdev = pm8001_ha->pdev; |
---|
| 992 | +#ifdef PM8001_USE_MSIX |
---|
946 | 993 | int rc; |
---|
947 | 994 | |
---|
948 | | - pdev = pm8001_ha->pdev; |
---|
| 995 | + if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { |
---|
| 996 | + rc = pm8001_setup_msix(pm8001_ha); |
---|
| 997 | + if (rc) { |
---|
| 998 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 999 | + "pm8001_setup_irq failed [ret: %d]\n", rc); |
---|
| 1000 | + return rc; |
---|
| 1001 | + } |
---|
949 | 1002 | |
---|
950 | | -#ifdef PM8001_USE_MSIX |
---|
951 | | - if (pdev->msix_cap && pci_msi_enabled()) |
---|
952 | | - return pm8001_setup_msix(pm8001_ha); |
---|
953 | | - else { |
---|
954 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
955 | | - pm8001_printk("MSIX not supported!!!\n")); |
---|
956 | | - goto intx; |
---|
| 1003 | + if (pdev->msix_cap && pci_msi_enabled()) |
---|
| 1004 | + return pm8001_request_msix(pm8001_ha); |
---|
957 | 1005 | } |
---|
| 1006 | + |
---|
| 1007 | + pm8001_dbg(pm8001_ha, INIT, "MSIX not supported!!!\n"); |
---|
958 | 1008 | #endif |
---|
959 | 1009 | |
---|
960 | | -intx: |
---|
961 | 1010 | /* initialize the INT-X interrupt */ |
---|
962 | 1011 | pm8001_ha->irq_vector[0].irq_id = 0; |
---|
963 | 1012 | pm8001_ha->irq_vector[0].drv_inst = pm8001_ha; |
---|
964 | | - rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED, |
---|
965 | | - DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost)); |
---|
966 | | - return rc; |
---|
| 1013 | + |
---|
| 1014 | + return request_irq(pdev->irq, pm8001_interrupt_handler_intx, |
---|
| 1015 | + IRQF_SHARED, pm8001_ha->name, |
---|
| 1016 | + SHOST_TO_SAS_HA(pm8001_ha->shost)); |
---|
967 | 1017 | } |
---|
968 | 1018 | |
---|
969 | 1019 | /** |
---|
.. | .. |
---|
984 | 1034 | struct pm8001_hba_info *pm8001_ha; |
---|
985 | 1035 | struct Scsi_Host *shost = NULL; |
---|
986 | 1036 | const struct pm8001_chip_info *chip; |
---|
| 1037 | + struct sas_ha_struct *sha; |
---|
987 | 1038 | |
---|
988 | 1039 | dev_printk(KERN_INFO, &pdev->dev, |
---|
989 | 1040 | "pm80xx: driver version %s\n", DRV_VERSION); |
---|
.. | .. |
---|
1012 | 1063 | goto err_out_regions; |
---|
1013 | 1064 | } |
---|
1014 | 1065 | chip = &pm8001_chips[ent->driver_data]; |
---|
1015 | | - SHOST_TO_SAS_HA(shost) = |
---|
1016 | | - kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL); |
---|
1017 | | - if (!SHOST_TO_SAS_HA(shost)) { |
---|
| 1066 | + sha = kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL); |
---|
| 1067 | + if (!sha) { |
---|
1018 | 1068 | rc = -ENOMEM; |
---|
1019 | 1069 | goto err_out_free_host; |
---|
1020 | 1070 | } |
---|
| 1071 | + SHOST_TO_SAS_HA(shost) = sha; |
---|
1021 | 1072 | |
---|
1022 | 1073 | rc = pm8001_prep_sas_ha_init(shost, chip); |
---|
1023 | 1074 | if (rc) { |
---|
.. | .. |
---|
1031 | 1082 | rc = -ENOMEM; |
---|
1032 | 1083 | goto err_out_free; |
---|
1033 | 1084 | } |
---|
1034 | | - list_add_tail(&pm8001_ha->list, &hba_list); |
---|
| 1085 | + |
---|
1035 | 1086 | PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); |
---|
1036 | 1087 | rc = PM8001_CHIP_DISP->chip_init(pm8001_ha); |
---|
1037 | 1088 | if (rc) { |
---|
1038 | | - PM8001_FAIL_DBG(pm8001_ha, pm8001_printk( |
---|
1039 | | - "chip_init failed [ret: %d]\n", rc)); |
---|
| 1089 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 1090 | + "chip_init failed [ret: %d]\n", rc); |
---|
1040 | 1091 | goto err_out_ha_free; |
---|
1041 | 1092 | } |
---|
| 1093 | + |
---|
| 1094 | + rc = pm8001_init_ccb_tag(pm8001_ha, shost, pdev); |
---|
| 1095 | + if (rc) |
---|
| 1096 | + goto err_out_enable; |
---|
1042 | 1097 | |
---|
1043 | 1098 | rc = scsi_add_host(shost, &pdev->dev); |
---|
1044 | 1099 | if (rc) |
---|
1045 | 1100 | goto err_out_ha_free; |
---|
1046 | | - rc = pm8001_request_irq(pm8001_ha); |
---|
1047 | | - if (rc) { |
---|
1048 | | - PM8001_FAIL_DBG(pm8001_ha, pm8001_printk( |
---|
1049 | | - "pm8001_request_irq failed [ret: %d]\n", rc)); |
---|
1050 | | - goto err_out_shost; |
---|
1051 | | - } |
---|
1052 | 1101 | |
---|
1053 | 1102 | PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0); |
---|
1054 | 1103 | if (pm8001_ha->chip_id != chip_8001) { |
---|
.. | .. |
---|
1066 | 1115 | |
---|
1067 | 1116 | pm8001_post_sas_ha_init(shost, chip); |
---|
1068 | 1117 | rc = sas_register_ha(SHOST_TO_SAS_HA(shost)); |
---|
1069 | | - if (rc) |
---|
| 1118 | + if (rc) { |
---|
| 1119 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 1120 | + "sas_register_ha failed [ret: %d]\n", rc); |
---|
1070 | 1121 | goto err_out_shost; |
---|
| 1122 | + } |
---|
| 1123 | + list_add_tail(&pm8001_ha->list, &hba_list); |
---|
| 1124 | + pm8001_ha->flags = PM8001F_RUN_TIME; |
---|
1071 | 1125 | scsi_scan_host(pm8001_ha->shost); |
---|
1072 | 1126 | return 0; |
---|
1073 | 1127 | |
---|
.. | .. |
---|
1076 | 1130 | err_out_ha_free: |
---|
1077 | 1131 | pm8001_free(pm8001_ha); |
---|
1078 | 1132 | err_out_free: |
---|
1079 | | - kfree(SHOST_TO_SAS_HA(shost)); |
---|
| 1133 | + kfree(sha); |
---|
1080 | 1134 | err_out_free_host: |
---|
1081 | 1135 | scsi_host_put(shost); |
---|
1082 | 1136 | err_out_regions: |
---|
.. | .. |
---|
1085 | 1139 | pci_disable_device(pdev); |
---|
1086 | 1140 | err_out_enable: |
---|
1087 | 1141 | return rc; |
---|
| 1142 | +} |
---|
| 1143 | + |
---|
| 1144 | +/* |
---|
| 1145 | + * pm8001_init_ccb_tag - allocate memory to CCB and tag. |
---|
| 1146 | + * @pm8001_ha: our hba card information. |
---|
| 1147 | + * @shost: scsi host which has been allocated outside. |
---|
| 1148 | + */ |
---|
| 1149 | +static int |
---|
| 1150 | +pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, |
---|
| 1151 | + struct pci_dev *pdev) |
---|
| 1152 | +{ |
---|
| 1153 | + int i = 0; |
---|
| 1154 | + u32 max_out_io, ccb_count; |
---|
| 1155 | + u32 can_queue; |
---|
| 1156 | + |
---|
| 1157 | + max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io; |
---|
| 1158 | + ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io); |
---|
| 1159 | + |
---|
| 1160 | + /* Update to the scsi host*/ |
---|
| 1161 | + can_queue = ccb_count - PM8001_RESERVE_SLOT; |
---|
| 1162 | + shost->can_queue = can_queue; |
---|
| 1163 | + |
---|
| 1164 | + pm8001_ha->tags = kzalloc(ccb_count, GFP_KERNEL); |
---|
| 1165 | + if (!pm8001_ha->tags) |
---|
| 1166 | + goto err_out; |
---|
| 1167 | + |
---|
| 1168 | + /* Memory region for ccb_info*/ |
---|
| 1169 | + pm8001_ha->ccb_info = (struct pm8001_ccb_info *) |
---|
| 1170 | + kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL); |
---|
| 1171 | + if (!pm8001_ha->ccb_info) { |
---|
| 1172 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 1173 | + "Unable to allocate memory for ccb\n"); |
---|
| 1174 | + goto err_out_noccb; |
---|
| 1175 | + } |
---|
| 1176 | + for (i = 0; i < ccb_count; i++) { |
---|
| 1177 | + pm8001_ha->ccb_info[i].buf_prd = pci_alloc_consistent(pdev, |
---|
| 1178 | + sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG, |
---|
| 1179 | + &pm8001_ha->ccb_info[i].ccb_dma_handle); |
---|
| 1180 | + if (!pm8001_ha->ccb_info[i].buf_prd) { |
---|
| 1181 | + pm8001_dbg(pm8001_ha, FAIL, |
---|
| 1182 | + "pm80xx: ccb prd memory allocation error\n"); |
---|
| 1183 | + goto err_out; |
---|
| 1184 | + } |
---|
| 1185 | + pm8001_ha->ccb_info[i].task = NULL; |
---|
| 1186 | + pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff; |
---|
| 1187 | + pm8001_ha->ccb_info[i].device = NULL; |
---|
| 1188 | + ++pm8001_ha->tags_num; |
---|
| 1189 | + } |
---|
| 1190 | + return 0; |
---|
| 1191 | + |
---|
| 1192 | +err_out_noccb: |
---|
| 1193 | + kfree(pm8001_ha->devices); |
---|
| 1194 | +err_out: |
---|
| 1195 | + return -ENOMEM; |
---|
1088 | 1196 | } |
---|
1089 | 1197 | |
---|
1090 | 1198 | static void pm8001_pci_remove(struct pci_dev *pdev) |
---|
.. | .. |
---|
1215 | 1323 | /* chip soft rst only for spc */ |
---|
1216 | 1324 | if (pm8001_ha->chip_id == chip_8001) { |
---|
1217 | 1325 | PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); |
---|
1218 | | - PM8001_INIT_DBG(pm8001_ha, |
---|
1219 | | - pm8001_printk("chip soft reset successful\n")); |
---|
| 1326 | + pm8001_dbg(pm8001_ha, INIT, "chip soft reset successful\n"); |
---|
1220 | 1327 | } |
---|
1221 | 1328 | rc = PM8001_CHIP_DISP->chip_init(pm8001_ha); |
---|
1222 | 1329 | if (rc) |
---|