.. | .. |
---|
31 | 31 | int i, found; |
---|
32 | 32 | gdth_cmd_str gdtcmd; |
---|
33 | 33 | gdth_cpar_str *pcpar; |
---|
34 | | - u64 paddr; |
---|
35 | 34 | |
---|
36 | 35 | char cmnd[MAX_COMMAND_SIZE]; |
---|
37 | 36 | memset(cmnd, 0xff, 12); |
---|
.. | .. |
---|
113 | 112 | } |
---|
114 | 113 | |
---|
115 | 114 | if (wb_mode) { |
---|
116 | | - if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, &paddr)) |
---|
117 | | - return(-EBUSY); |
---|
| 115 | + unsigned long flags; |
---|
| 116 | + |
---|
| 117 | + BUILD_BUG_ON(sizeof(gdth_cpar_str) > GDTH_SCRATCH); |
---|
| 118 | + |
---|
| 119 | + spin_lock_irqsave(&ha->smp_lock, flags); |
---|
| 120 | + if (ha->scratch_busy) { |
---|
| 121 | + spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
| 122 | + return -EBUSY; |
---|
| 123 | + } |
---|
| 124 | + ha->scratch_busy = TRUE; |
---|
| 125 | + spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
| 126 | + |
---|
118 | 127 | pcpar = (gdth_cpar_str *)ha->pscratch; |
---|
119 | 128 | memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); |
---|
120 | 129 | gdtcmd.Service = CACHESERVICE; |
---|
121 | 130 | gdtcmd.OpCode = GDT_IOCTL; |
---|
122 | | - gdtcmd.u.ioctl.p_param = paddr; |
---|
| 131 | + gdtcmd.u.ioctl.p_param = ha->scratch_phys; |
---|
123 | 132 | gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str); |
---|
124 | 133 | gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; |
---|
125 | 134 | gdtcmd.u.ioctl.channel = INVALID_CHANNEL; |
---|
.. | .. |
---|
127 | 136 | |
---|
128 | 137 | gdth_execute(host, &gdtcmd, cmnd, 30, NULL); |
---|
129 | 138 | |
---|
130 | | - gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr); |
---|
| 139 | + spin_lock_irqsave(&ha->smp_lock, flags); |
---|
| 140 | + ha->scratch_busy = FALSE; |
---|
| 141 | + spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
| 142 | + |
---|
131 | 143 | printk("Done.\n"); |
---|
132 | 144 | return(orig_length); |
---|
133 | 145 | } |
---|
.. | .. |
---|
143 | 155 | int id, i, j, k, sec, flag; |
---|
144 | 156 | int no_mdrv = 0, drv_no, is_mirr; |
---|
145 | 157 | u32 cnt; |
---|
146 | | - u64 paddr; |
---|
| 158 | + dma_addr_t paddr; |
---|
147 | 159 | int rc = -ENOMEM; |
---|
148 | 160 | |
---|
149 | 161 | gdth_cmd_str *gdtcmd; |
---|
.. | .. |
---|
181 | 193 | for (i = 1; i < MAX_RES_ARGS; i++) { |
---|
182 | 194 | if (reserve_list[i] == 0xff) |
---|
183 | 195 | break; |
---|
184 | | - hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]); |
---|
| 196 | + hlen += scnprintf(hrec + hlen, 161 - hlen, ",%d", reserve_list[i]); |
---|
185 | 197 | } |
---|
186 | 198 | } |
---|
187 | 199 | seq_printf(m, |
---|
.. | .. |
---|
217 | 229 | " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", |
---|
218 | 230 | ha->binfo.ser_no, ha->binfo.memsize / 1024); |
---|
219 | 231 | |
---|
220 | | -#ifdef GDTH_DMA_STATISTICS |
---|
221 | | - /* controller statistics */ |
---|
222 | | - seq_puts(m, "\nController Statistics:\n"); |
---|
223 | | - seq_printf(m, |
---|
224 | | - " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n", |
---|
225 | | - ha->dma32_cnt, ha->dma64_cnt); |
---|
226 | | -#endif |
---|
227 | | - |
---|
228 | 232 | if (ha->more_proc) { |
---|
| 233 | + size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str)); |
---|
| 234 | + |
---|
229 | 235 | /* more information: 2. about physical devices */ |
---|
230 | 236 | seq_puts(m, "\nPhysical Devices:"); |
---|
231 | 237 | flag = FALSE; |
---|
232 | 238 | |
---|
233 | | - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); |
---|
| 239 | + buf = dma_alloc_coherent(&ha->pdev->dev, size, &paddr, GFP_KERNEL); |
---|
234 | 240 | if (!buf) |
---|
235 | 241 | goto stop_output; |
---|
236 | 242 | for (i = 0; i < ha->bus_cnt; ++i) { |
---|
.. | .. |
---|
323 | 329 | } |
---|
324 | 330 | } |
---|
325 | 331 | } |
---|
326 | | - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); |
---|
327 | 332 | |
---|
328 | 333 | if (!flag) |
---|
329 | 334 | seq_puts(m, "\n --\n"); |
---|
.. | .. |
---|
332 | 337 | seq_puts(m, "\nLogical Drives:"); |
---|
333 | 338 | flag = FALSE; |
---|
334 | 339 | |
---|
335 | | - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); |
---|
336 | | - if (!buf) |
---|
337 | | - goto stop_output; |
---|
338 | 340 | for (i = 0; i < MAX_LDRIVES; ++i) { |
---|
339 | 341 | if (!ha->hdr[i].is_logdrv) |
---|
340 | 342 | continue; |
---|
.. | .. |
---|
408 | 410 | seq_printf(m, |
---|
409 | 411 | " To Array Drv.:\t%s\n", hrec); |
---|
410 | 412 | } |
---|
411 | | - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); |
---|
412 | | - |
---|
| 413 | + |
---|
413 | 414 | if (!flag) |
---|
414 | 415 | seq_puts(m, "\n --\n"); |
---|
415 | 416 | |
---|
.. | .. |
---|
417 | 418 | seq_puts(m, "\nArray Drives:"); |
---|
418 | 419 | flag = FALSE; |
---|
419 | 420 | |
---|
420 | | - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); |
---|
421 | | - if (!buf) |
---|
422 | | - goto stop_output; |
---|
423 | 421 | for (i = 0; i < MAX_LDRIVES; ++i) { |
---|
424 | 422 | if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master)) |
---|
425 | 423 | continue; |
---|
.. | .. |
---|
468 | 466 | hrec); |
---|
469 | 467 | } |
---|
470 | 468 | } |
---|
471 | | - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); |
---|
472 | | - |
---|
| 469 | + |
---|
473 | 470 | if (!flag) |
---|
474 | 471 | seq_puts(m, "\n --\n"); |
---|
475 | 472 | |
---|
.. | .. |
---|
477 | 474 | seq_puts(m, "\nHost Drives:"); |
---|
478 | 475 | flag = FALSE; |
---|
479 | 476 | |
---|
480 | | - buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); |
---|
481 | | - if (!buf) |
---|
482 | | - goto stop_output; |
---|
483 | 477 | for (i = 0; i < MAX_LDRIVES; ++i) { |
---|
484 | 478 | if (!ha->hdr[i].is_logdrv || |
---|
485 | 479 | (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master)) |
---|
.. | .. |
---|
510 | 504 | } |
---|
511 | 505 | } |
---|
512 | 506 | } |
---|
513 | | - gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr); |
---|
| 507 | + dma_free_coherent(&ha->pdev->dev, size, buf, paddr); |
---|
514 | 508 | |
---|
515 | 509 | for (i = 0; i < MAX_HDRIVES; ++i) { |
---|
516 | 510 | if (!(ha->hdr[i].present)) |
---|
.. | .. |
---|
562 | 556 | kfree(estr); |
---|
563 | 557 | return rc; |
---|
564 | 558 | } |
---|
565 | | - |
---|
566 | | -static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch, |
---|
567 | | - u64 *paddr) |
---|
568 | | -{ |
---|
569 | | - unsigned long flags; |
---|
570 | | - char *ret_val; |
---|
571 | | - |
---|
572 | | - if (size == 0) |
---|
573 | | - return NULL; |
---|
574 | | - |
---|
575 | | - spin_lock_irqsave(&ha->smp_lock, flags); |
---|
576 | | - |
---|
577 | | - if (!ha->scratch_busy && size <= GDTH_SCRATCH) { |
---|
578 | | - ha->scratch_busy = TRUE; |
---|
579 | | - ret_val = ha->pscratch; |
---|
580 | | - *paddr = ha->scratch_phys; |
---|
581 | | - } else if (scratch) { |
---|
582 | | - ret_val = NULL; |
---|
583 | | - } else { |
---|
584 | | - dma_addr_t dma_addr; |
---|
585 | | - |
---|
586 | | - ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr); |
---|
587 | | - *paddr = dma_addr; |
---|
588 | | - } |
---|
589 | | - |
---|
590 | | - spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
591 | | - return ret_val; |
---|
592 | | -} |
---|
593 | | - |
---|
594 | | -static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, u64 paddr) |
---|
595 | | -{ |
---|
596 | | - unsigned long flags; |
---|
597 | | - |
---|
598 | | - if (buf == ha->pscratch) { |
---|
599 | | - spin_lock_irqsave(&ha->smp_lock, flags); |
---|
600 | | - ha->scratch_busy = FALSE; |
---|
601 | | - spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
602 | | - } else { |
---|
603 | | - pci_free_consistent(ha->pdev, size, buf, paddr); |
---|
604 | | - } |
---|
605 | | -} |
---|
606 | | - |
---|
607 | | -#ifdef GDTH_IOCTL_PROC |
---|
608 | | -static int gdth_ioctl_check_bin(gdth_ha_str *ha, u16 size) |
---|
609 | | -{ |
---|
610 | | - unsigned long flags; |
---|
611 | | - int ret_val; |
---|
612 | | - |
---|
613 | | - spin_lock_irqsave(&ha->smp_lock, flags); |
---|
614 | | - |
---|
615 | | - ret_val = FALSE; |
---|
616 | | - if (ha->scratch_busy) { |
---|
617 | | - if (((gdth_iord_str *)ha->pscratch)->size == (u32)size) |
---|
618 | | - ret_val = TRUE; |
---|
619 | | - } |
---|
620 | | - spin_unlock_irqrestore(&ha->smp_lock, flags); |
---|
621 | | - return ret_val; |
---|
622 | | -} |
---|
623 | | -#endif |
---|
624 | 559 | |
---|
625 | 560 | static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id) |
---|
626 | 561 | { |
---|