Lines Matching full:a
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
38 * You should have received a copy of the GNU General Public License
47 * Buffered ioctl handlers. A buffered ioctl is one which requires that we
48 * allocate a DMA-able memory area to communicate with the firmware. In
50 * we will allocate a global buffer the first time we need it and re-use
68 struct esas2r_adapter *a; member
82 static void complete_fm_api_req(struct esas2r_adapter *a, in complete_fm_api_req() argument
85 a->fm_api_command_done = 1; in complete_fm_api_req()
86 wake_up_interruptible(&a->fm_api_waiter); in complete_fm_api_req()
92 struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter; in get_physaddr_fm_api() local
93 int offset = sgc->cur_offset - a->save_offset; in get_physaddr_fm_api()
95 (*addr) = a->firmware.phys + offset; in get_physaddr_fm_api()
96 return a->firmware.orig_len - offset; in get_physaddr_fm_api()
101 struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter; in get_physaddr_fm_api_header() local
102 int offset = sgc->cur_offset - a->save_offset; in get_physaddr_fm_api_header()
104 (*addr) = a->firmware.header_buff_phys + offset; in get_physaddr_fm_api_header()
109 static void do_fm_api(struct esas2r_adapter *a, struct esas2r_flash_img *fi) in do_fm_api() argument
113 if (mutex_lock_interruptible(&a->fm_api_mutex)) { in do_fm_api()
118 rq = esas2r_alloc_request(a); in do_fm_api()
124 if (fi == &a->firmware.header) { in do_fm_api()
125 a->firmware.header_buff = dma_alloc_coherent(&a->pcid->dev, in do_fm_api()
129 (dma_addr_t *)&a-> in do_fm_api()
134 if (a->firmware.header_buff == NULL) { in do_fm_api()
140 memcpy(a->firmware.header_buff, fi, in do_fm_api()
142 a->save_offset = a->firmware.header_buff; in do_fm_api()
143 a->fm_api_sgc.get_phys_addr = in do_fm_api()
146 a->save_offset = (u8 *)fi; in do_fm_api()
147 a->fm_api_sgc.get_phys_addr = in do_fm_api()
152 a->fm_api_command_done = 0; in do_fm_api()
153 a->fm_api_sgc.cur_offset = a->save_offset; in do_fm_api()
155 if (!esas2r_fm_api(a, (struct esas2r_flash_img *)a->save_offset, rq, in do_fm_api()
156 &a->fm_api_sgc)) in do_fm_api()
160 while (!a->fm_api_command_done) in do_fm_api()
161 wait_event_interruptible(a->fm_api_waiter, in do_fm_api()
162 a->fm_api_command_done); in do_fm_api()
164 if (fi == &a->firmware.header) { in do_fm_api()
165 memcpy(fi, a->firmware.header_buff, in do_fm_api()
168 dma_free_coherent(&a->pcid->dev, in do_fm_api()
170 a->firmware.header_buff, in do_fm_api()
171 (dma_addr_t)a->firmware.header_buff_phys); in do_fm_api()
174 esas2r_free_request(a, (struct esas2r_request *)rq); in do_fm_api()
176 mutex_unlock(&a->fm_api_mutex); in do_fm_api()
181 static void complete_nvr_req(struct esas2r_adapter *a, in complete_nvr_req() argument
184 a->nvram_command_done = 1; in complete_nvr_req()
185 wake_up_interruptible(&a->nvram_waiter); in complete_nvr_req()
198 static void complete_buffered_ioctl_req(struct esas2r_adapter *a, in complete_buffered_ioctl_req() argument
201 a->buffered_ioctl_done = 1; in complete_buffered_ioctl_req()
202 wake_up_interruptible(&a->buffered_ioctl_waiter); in complete_buffered_ioctl_req()
207 struct esas2r_adapter *a = bi->a; in handle_buffered_ioctl() local
215 /* allocate a buffer or use the existing buffer. */ in handle_buffered_ioctl()
218 /* free the too-small buffer and get a new one */ in handle_buffered_ioctl()
219 dma_free_coherent(&a->pcid->dev, in handle_buffered_ioctl()
229 esas2r_buffered_ioctl_pcid = a->pcid; in handle_buffered_ioctl()
230 esas2r_buffered_ioctl = dma_alloc_coherent(&a->pcid->dev, in handle_buffered_ioctl()
241 "for a buffered ioctl!", in handle_buffered_ioctl()
251 rq = esas2r_alloc_request(a); in handle_buffered_ioctl()
261 a->buffered_ioctl_done = 0; in handle_buffered_ioctl()
267 if (!(*bi->callback)(a, rq, &sgc, bi->context)) { in handle_buffered_ioctl()
269 a->buffered_ioctl_done = 0; in handle_buffered_ioctl()
274 while (!a->buffered_ioctl_done) in handle_buffered_ioctl()
275 wait_event_interruptible(a->buffered_ioctl_waiter, in handle_buffered_ioctl()
276 a->buffered_ioctl_done); in handle_buffered_ioctl()
280 (*bi->done_callback)(a, rq, bi->done_context); in handle_buffered_ioctl()
282 esas2r_free_request(a, rq); in handle_buffered_ioctl()
293 static int smp_ioctl_callback(struct esas2r_adapter *a, in smp_ioctl_callback() argument
300 esas2r_sgc_init(sgc, a, rq, rq->vrq->ioctl.sge); in smp_ioctl_callback()
301 esas2r_build_ioctl_req(a, rq, sgc->length, VDA_IOCTL_SMP); in smp_ioctl_callback()
303 if (!esas2r_build_sg_list(a, rq, sgc)) { in smp_ioctl_callback()
308 esas2r_start_request(a, rq); in smp_ioctl_callback()
312 static u8 handle_smp_ioctl(struct esas2r_adapter *a, struct atto_ioctl_smp *si) in handle_smp_ioctl() argument
318 bi.a = a; in handle_smp_ioctl()
330 static void esas2r_csmi_ioctl_tunnel_comp_cb(struct esas2r_adapter *a, in esas2r_csmi_ioctl_tunnel_comp_cb() argument
337 (*rq->aux_req_cb)(a, rq); in esas2r_csmi_ioctl_tunnel_comp_cb()
340 /* Tunnel a CSMI IOCTL to the back end driver for processing. */
341 static bool csmi_ioctl_tunnel(struct esas2r_adapter *a, in csmi_ioctl_tunnel() argument
350 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in csmi_ioctl_tunnel()
353 esas2r_sgc_init(sgc, a, rq, rq->vrq->ioctl.sge); in csmi_ioctl_tunnel()
354 esas2r_build_ioctl_req(a, rq, sgc->length, VDA_IOCTL_CSMI); in csmi_ioctl_tunnel()
367 if (!esas2r_build_sg_list(a, rq, sgc)) in csmi_ioctl_tunnel()
370 esas2r_start_request(a, rq); in csmi_ioctl_tunnel()
390 static int csmi_ioctl_callback(struct esas2r_adapter *a, in csmi_ioctl_callback() argument
432 strcpy(gdi->description, esas2r_get_model_name(a)); in csmi_ioctl_callback()
443 pci_read_config_dword(a->pcid, PCI_BASE_ADDRESS_2, in csmi_ioctl_callback()
445 pci_read_config_dword(a->pcid, PCI_BASE_ADDRESS_3, in csmi_ioctl_callback()
447 gcc->board_id = MAKEDWORD(a->pcid->subsystem_device, in csmi_ioctl_callback()
448 a->pcid->subsystem_vendor); in csmi_ioctl_callback()
452 gcc->pci_addr.bus_num = a->pcid->bus->number; in csmi_ioctl_callback()
453 gcc->pci_addr.device_num = PCI_SLOT(a->pcid->devfn); in csmi_ioctl_callback()
454 gcc->pci_addr.function_num = PCI_FUNC(a->pcid->devfn); in csmi_ioctl_callback()
458 gcc->major_rev = LOBYTE(LOWORD(a->fw_version)); in csmi_ioctl_callback()
459 gcc->minor_rev = HIBYTE(LOWORD(a->fw_version)); in csmi_ioctl_callback()
460 gcc->build_rev = LOBYTE(HIWORD(a->fw_version)); in csmi_ioctl_callback()
461 gcc->release_rev = HIBYTE(HIWORD(a->fw_version)); in csmi_ioctl_callback()
462 gcc->bios_major_rev = HIBYTE(HIWORD(a->flash_ver)); in csmi_ioctl_callback()
463 gcc->bios_minor_rev = LOBYTE(HIWORD(a->flash_ver)); in csmi_ioctl_callback()
464 gcc->bios_build_rev = LOWORD(a->flash_ver); in csmi_ioctl_callback()
466 if (test_bit(AF2_THUNDERLINK, &a->flags2)) in csmi_ioctl_callback()
488 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in csmi_ioctl_callback()
514 if (!csmi_ioctl_tunnel(a, ioctl_csmi, rq, sgc, in csmi_ioctl_callback()
537 spin_lock_irqsave(&a->mem_lock, flags); in csmi_ioctl_callback()
538 t = esas2r_targ_db_find_by_sas_addr(a, (u64 *)gsa->sas_addr); in csmi_ioctl_callback()
539 spin_unlock_irqrestore(&a->mem_lock, flags); in csmi_ioctl_callback()
548 rq->target_id = esas2r_targ_get_id(t, a); in csmi_ioctl_callback()
557 t = a->targetdb + rq->target_id; in csmi_ioctl_callback()
559 if (t >= a->targetdb_end in csmi_ioctl_callback()
576 t = a->targetdb + rq->target_id; in csmi_ioctl_callback()
578 if (t >= a->targetdb_end in csmi_ioctl_callback()
585 if (!csmi_ioctl_tunnel(a, ioctl_csmi, rq, sgc, in csmi_ioctl_callback()
606 static void csmi_ioctl_done_callback(struct esas2r_adapter *a, in csmi_ioctl_done_callback() argument
646 static u8 handle_csmi_ioctl(struct esas2r_adapter *a, struct atto_csmi *ci) in handle_csmi_ioctl() argument
652 bi.a = a; in handle_csmi_ioctl()
667 static bool hba_ioctl_tunnel(struct esas2r_adapter *a, in hba_ioctl_tunnel() argument
672 esas2r_sgc_init(sgc, a, rq, rq->vrq->ioctl.sge); in hba_ioctl_tunnel()
674 esas2r_build_ioctl_req(a, rq, sgc->length, VDA_IOCTL_HBA); in hba_ioctl_tunnel()
676 if (!esas2r_build_sg_list(a, rq, sgc)) { in hba_ioctl_tunnel()
682 esas2r_start_request(a, rq); in hba_ioctl_tunnel()
687 static void scsi_passthru_comp_cb(struct esas2r_adapter *a, in scsi_passthru_comp_cb() argument
738 esas2r_targ_db_find_next_present(a, (u16)spt->target_id); in scsi_passthru_comp_cb()
741 (*rq->aux_req_cb)(a, rq); in scsi_passthru_comp_cb()
744 static int hba_ioctl_callback(struct esas2r_adapter *a, in hba_ioctl_callback() argument
756 u8 *class_code = (u8 *)&a->pcid->class; in hba_ioctl_callback()
774 gai->pci.vendor_id = a->pcid->vendor; in hba_ioctl_callback()
775 gai->pci.device_id = a->pcid->device; in hba_ioctl_callback()
776 gai->pci.ss_vendor_id = a->pcid->subsystem_vendor; in hba_ioctl_callback()
777 gai->pci.ss_device_id = a->pcid->subsystem_device; in hba_ioctl_callback()
781 gai->pci.rev_id = a->pcid->revision; in hba_ioctl_callback()
782 gai->pci.bus_num = a->pcid->bus->number; in hba_ioctl_callback()
783 gai->pci.dev_num = PCI_SLOT(a->pcid->devfn); in hba_ioctl_callback()
784 gai->pci.func_num = PCI_FUNC(a->pcid->devfn); in hba_ioctl_callback()
786 if (pci_is_pcie(a->pcid)) { in hba_ioctl_callback()
790 pcie_capability_read_word(a->pcid, PCI_EXP_LNKSTA, in hba_ioctl_callback()
792 pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP, in hba_ioctl_callback()
809 if (a->pcid->msix_enabled) in hba_ioctl_callback()
811 else if (a->pcid->msi_enabled) in hba_ioctl_callback()
818 if (test_bit(AF2_THUNDERLINK, &a->flags2)) in hba_ioctl_callback()
821 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in hba_ioctl_callback()
827 if (a->pcid->subsystem_device == ATTO_ESAS_R60F in hba_ioctl_callback()
828 || a->pcid->subsystem_device == ATTO_ESAS_R608 in hba_ioctl_callback()
829 || a->pcid->subsystem_device == ATTO_ESAS_R644 in hba_ioctl_callback()
830 || a->pcid->subsystem_device == ATTO_TSSC_3808E) in hba_ioctl_callback()
836 strcpy(gai->firmware_rev, a->fw_rev); in hba_ioctl_callback()
837 strcpy(gai->flash_rev, a->flash_rev); in hba_ioctl_callback()
838 strcpy(gai->model_name_short, esas2r_get_model_name_short(a)); in hba_ioctl_callback()
839 strcpy(gai->model_name, esas2r_get_model_name(a)); in hba_ioctl_callback()
847 if (a->pcid->subsystem_device == ATTO_ESAS_R6F0 in hba_ioctl_callback()
848 || a->pcid->subsystem_device == ATTO_ESAS_R60F) in hba_ioctl_callback()
855 gai->num_targets_backend = a->num_targets_backend; in hba_ioctl_callback()
857 gai->tunnel_flags = a->ioctl_tunnel in hba_ioctl_callback()
888 &a->nvram->sas_addr[0], sizeof(u64)); in hba_ioctl_callback()
901 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
917 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
936 /* Size is zero if a core dump isn't present */ in hba_ioctl_callback()
937 if (!test_bit(AF2_COREDUMP_SAVED, &a->flags2)) in hba_ioctl_callback()
951 a->fw_coredump_buff + offset, in hba_ioctl_callback()
956 memset(a->fw_coredump_buff, 0, in hba_ioctl_callback()
959 clear_bit(AF2_COREDUMP_SAVED, &a->flags2); in hba_ioctl_callback()
971 if (!test_bit(AF2_COREDUMP_SAVED, &a->flags2)) in hba_ioctl_callback()
988 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
1005 esas2r_sgc_init(sgc, a, rq, NULL); in hba_ioctl_callback()
1047 if (!esas2r_build_sg_list(a, rq, sgc)) { in hba_ioctl_callback()
1052 esas2r_start_request(a, rq); in hba_ioctl_callback()
1064 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
1081 t = a->targetdb + (u16)gda->target_id; in hba_ioctl_callback()
1102 esas2r_targ_db_find_next_present(a, in hba_ioctl_callback()
1110 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
1132 esas2r_reset_adapter(a); in hba_ioctl_callback()
1138 if (test_bit(AF_CHPRST_NEEDED, &a->flags)) in hba_ioctl_callback()
1140 else if (test_bit(AF_CHPRST_PENDING, &a->flags)) in hba_ioctl_callback()
1142 else if (test_bit(AF_DISC_PENDING, &a->flags)) in hba_ioctl_callback()
1144 else if (test_bit(AF_DISABLED, &a->flags)) in hba_ioctl_callback()
1146 else if (test_bit(AF_DEGRADED_MODE, &a->flags)) in hba_ioctl_callback()
1160 if (hba_ioctl_tunnel(a, hi, rq, sgc)) in hba_ioctl_callback()
1177 t = a->targetdb + (u16)gdi->target_id; in hba_ioctl_callback()
1182 esas2r_targ_db_find_next_present(a, in hba_ioctl_callback()
1203 static void hba_ioctl_done_callback(struct esas2r_adapter *a, in hba_ioctl_done_callback() argument
1209 esas2r_debug("hba_ioctl_done_callback %d", a->index); in hba_ioctl_done_callback()
1229 u8 handle_hba_ioctl(struct esas2r_adapter *a, in handle_hba_ioctl() argument
1236 bi.a = a; in handle_hba_ioctl()
1249 int esas2r_write_params(struct esas2r_adapter *a, struct esas2r_request *rq, in esas2r_write_params() argument
1254 a->nvram_command_done = 0; in esas2r_write_params()
1257 if (esas2r_nvram_write(a, rq, data)) { in esas2r_write_params()
1259 while (!a->nvram_command_done) in esas2r_write_params()
1260 wait_event_interruptible(a->nvram_waiter, in esas2r_write_params()
1261 a->nvram_command_done); in esas2r_write_params()
1276 struct esas2r_adapter *a; in esas2r_ioctl_handler() local
1337 a = (struct esas2r_adapter *)hostdata; in esas2r_ioctl_handler()
1347 a = esas2r_adapters[ioctl->header.channel]; in esas2r_ioctl_handler()
1354 err = esas2r_write_fw(a, in esas2r_ioctl_handler()
1361 err = esas2r_read_fw(a, in esas2r_ioctl_handler()
1369 err = esas2r_write_fs(a, in esas2r_ioctl_handler()
1376 err = esas2r_read_fs(a, in esas2r_ioctl_handler()
1391 memcpy(ioctl->data.prw.data_buffer, a->nvram, in esas2r_ioctl_handler()
1398 rq = esas2r_alloc_request(a); in esas2r_ioctl_handler()
1406 code = esas2r_write_params(a, rq, in esas2r_ioctl_handler()
1410 esas2r_free_request(a, rq); in esas2r_ioctl_handler()
1416 esas2r_nvram_get_defaults(a, in esas2r_ioctl_handler()
1425 ioctl->data.chaninfo.IRQ = a->pcid->irq; in esas2r_ioctl_handler()
1426 ioctl->data.chaninfo.device_id = a->pcid->device; in esas2r_ioctl_handler()
1427 ioctl->data.chaninfo.vendor_id = a->pcid->vendor; in esas2r_ioctl_handler()
1428 ioctl->data.chaninfo.ven_dev_id = a->pcid->subsystem_device; in esas2r_ioctl_handler()
1429 ioctl->data.chaninfo.revision_id = a->pcid->revision; in esas2r_ioctl_handler()
1430 ioctl->data.chaninfo.pci_bus = a->pcid->bus->number; in esas2r_ioctl_handler()
1431 ioctl->data.chaninfo.pci_dev_func = a->pcid->devfn; in esas2r_ioctl_handler()
1433 ioctl->data.chaninfo.host_no = a->host->host_no; in esas2r_ioctl_handler()
1438 ioctl->header.return_code = handle_smp_ioctl(a, in esas2r_ioctl_handler()
1445 handle_csmi_ioctl(a, &ioctl->data.csmi); in esas2r_ioctl_handler()
1449 ioctl->header.return_code = handle_hba_ioctl(a, in esas2r_ioctl_handler()
1455 err = esas2r_write_vda(a, in esas2r_ioctl_handler()
1462 err = esas2r_read_vda(a, in esas2r_ioctl_handler()
1476 ioctl->data.modinfo.adapter = a; in esas2r_ioctl_handler()
1477 ioctl->data.modinfo.pci_dev = a->pcid; in esas2r_ioctl_handler()
1478 ioctl->data.modinfo.scsi_host = a->host; in esas2r_ioctl_handler()
1479 ioctl->data.modinfo.host_no = a->host->host_no; in esas2r_ioctl_handler()
1533 static void free_fw_buffers(struct esas2r_adapter *a) in free_fw_buffers() argument
1535 if (a->firmware.data) { in free_fw_buffers()
1536 dma_free_coherent(&a->pcid->dev, in free_fw_buffers()
1537 (size_t)a->firmware.orig_len, in free_fw_buffers()
1538 a->firmware.data, in free_fw_buffers()
1539 (dma_addr_t)a->firmware.phys); in free_fw_buffers()
1541 a->firmware.data = NULL; in free_fw_buffers()
1545 static int allocate_fw_buffers(struct esas2r_adapter *a, u32 length) in allocate_fw_buffers() argument
1547 free_fw_buffers(a); in allocate_fw_buffers()
1549 a->firmware.orig_len = length; in allocate_fw_buffers()
1551 a->firmware.data = dma_alloc_coherent(&a->pcid->dev, in allocate_fw_buffers()
1553 (dma_addr_t *)&a->firmware.phys, in allocate_fw_buffers()
1556 if (!a->firmware.data) { in allocate_fw_buffers()
1564 /* Handle a call to read firmware. */
1565 int esas2r_read_fw(struct esas2r_adapter *a, char *buf, long off, int count) in esas2r_read_fw() argument
1568 /* if the cached header is a status, simply copy it over and return. */ in esas2r_read_fw()
1569 if (a->firmware.state == FW_STATUS_ST) { in esas2r_read_fw()
1570 int size = min_t(int, count, sizeof(a->firmware.header)); in esas2r_read_fw()
1572 memcpy(buf, &a->firmware.header, size); in esas2r_read_fw()
1578 * if the cached header is a command, do it if at in esas2r_read_fw()
1582 if (a->firmware.state == FW_COMMAND_ST) { in esas2r_read_fw()
1583 u32 length = a->firmware.header.length; in esas2r_read_fw()
1591 if (a->firmware.header.action == FI_ACT_UP) { in esas2r_read_fw()
1592 if (!allocate_fw_buffers(a, length)) in esas2r_read_fw()
1598 memcpy(a->firmware.data, in esas2r_read_fw()
1599 &a->firmware.header, in esas2r_read_fw()
1600 sizeof(a->firmware.header)); in esas2r_read_fw()
1602 do_fm_api(a, in esas2r_read_fw()
1603 (struct esas2r_flash_img *)a->firmware.data); in esas2r_read_fw()
1604 } else if (a->firmware.header.action == FI_ACT_UPSZ) { in esas2r_read_fw()
1607 (int)sizeof(a->firmware.header)); in esas2r_read_fw()
1608 do_fm_api(a, &a->firmware.header); in esas2r_read_fw()
1609 memcpy(buf, &a->firmware.header, size); in esas2r_read_fw()
1614 a->firmware.header.action); in esas2r_read_fw()
1625 if (!a->firmware.data) { in esas2r_read_fw()
1635 memcpy(buf, &a->firmware.data[off], count); in esas2r_read_fw()
1642 free_fw_buffers(a); in esas2r_read_fw()
1650 a->firmware.state); in esas2r_read_fw()
1655 /* Handle a call to write firmware. */
1656 int esas2r_write_fw(struct esas2r_adapter *a, const char *buf, long off, in esas2r_write_fw() argument
1669 a->firmware.state = FW_INVALID_ST; in esas2r_write_fw()
1680 /* See if its a version 1 flash image */ in esas2r_write_fw()
1702 * If this is a write command, allocate memory because in esas2r_write_fw()
1708 if (!allocate_fw_buffers(a, length)) in esas2r_write_fw()
1715 memcpy(&a->firmware.header, in esas2r_write_fw()
1721 memcpy(&a->firmware.header, in esas2r_write_fw()
1725 a->firmware.state = FW_COMMAND_ST; in esas2r_write_fw()
1739 a->firmware.header.action); in esas2r_write_fw()
1743 length = a->firmware.header.length; in esas2r_write_fw()
1747 * We only get here on a download command, regardless of offset. in esas2r_write_fw()
1761 * On a full upload, the system tries sending the whole buffer. in esas2r_write_fw()
1765 if (a->firmware.header.action == FI_ACT_UP) in esas2r_write_fw()
1768 if (!a->firmware.data) { in esas2r_write_fw()
1774 memcpy(&a->firmware.data[off], buf, count); in esas2r_write_fw()
1777 do_fm_api(a, in esas2r_write_fw()
1778 (struct esas2r_flash_img *)a->firmware.data); in esas2r_write_fw()
1784 memcpy(&a->firmware.header, in esas2r_write_fw()
1785 a->firmware.data, in esas2r_write_fw()
1786 sizeof(a->firmware.header)); in esas2r_write_fw()
1788 a->firmware.state = FW_STATUS_ST; in esas2r_write_fw()
1794 * this can leak is if a root user writes a program in esas2r_write_fw()
1795 * that writes a shorter buffer than it claims, and the in esas2r_write_fw()
1798 free_fw_buffers(a); in esas2r_write_fw()
1805 /* Callback for the completion of a VDA request. */
1806 static void vda_complete_req(struct esas2r_adapter *a, in vda_complete_req() argument
1809 a->vda_command_done = 1; in vda_complete_req()
1810 wake_up_interruptible(&a->vda_waiter); in vda_complete_req()
1816 struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter; in get_physaddr_vda() local
1817 int offset = (u8 *)sgc->cur_offset - (u8 *)a->vda_buffer; in get_physaddr_vda()
1819 (*addr) = a->ppvda_buffer + offset; in get_physaddr_vda()
1823 /* Handle a call to read a VDA command. */
1824 int esas2r_read_vda(struct esas2r_adapter *a, char *buf, long off, int count) in esas2r_read_vda() argument
1826 if (!a->vda_buffer) in esas2r_read_vda()
1832 (struct atto_ioctl_vda *)a->vda_buffer; in esas2r_read_vda()
1842 /* allocate a request */ in esas2r_read_vda()
1843 rq = esas2r_alloc_request(a); in esas2r_read_vda()
1852 sgc.adapter = a; in esas2r_read_vda()
1853 sgc.cur_offset = a->vda_buffer + VDA_BUFFER_HEADER_SZ; in esas2r_read_vda()
1856 a->vda_command_done = 0; in esas2r_read_vda()
1859 esas2r_process_vda_ioctl(a, vi, rq, &sgc); in esas2r_read_vda()
1864 while (!a->vda_command_done) in esas2r_read_vda()
1865 wait_event_interruptible(a->vda_waiter, in esas2r_read_vda()
1866 a->vda_command_done); in esas2r_read_vda()
1869 esas2r_free_request(a, (struct esas2r_request *)rq); in esas2r_read_vda()
1881 memcpy(buf, a->vda_buffer + off, count); in esas2r_read_vda()
1886 /* Handle a call to write a VDA command. */
1887 int esas2r_write_vda(struct esas2r_adapter *a, const char *buf, long off, in esas2r_write_vda() argument
1895 if (!a->vda_buffer) { in esas2r_write_vda()
1897 a->vda_buffer = dma_alloc_coherent(&a->pcid->dev, in esas2r_write_vda()
1903 a->ppvda_buffer = dma_addr; in esas2r_write_vda()
1906 if (!a->vda_buffer) in esas2r_write_vda()
1918 memcpy(a->vda_buffer + off, buf, count); in esas2r_write_vda()
1924 static void fs_api_complete_req(struct esas2r_adapter *a, in fs_api_complete_req() argument
1927 a->fs_api_command_done = 1; in fs_api_complete_req()
1929 wake_up_interruptible(&a->fs_api_waiter); in fs_api_complete_req()
1935 struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter; in get_physaddr_fs_api() local
1937 (struct esas2r_ioctl_fs *)a->fs_api_buffer; in get_physaddr_fs_api()
1940 (*addr) = a->ppfs_api_buffer + offset; in get_physaddr_fs_api()
1942 return a->fs_api_buffer_size - offset; in get_physaddr_fs_api()
1945 /* Handle a call to read firmware via FS_API. */
1946 int esas2r_read_fs(struct esas2r_adapter *a, char *buf, long off, int count) in esas2r_read_fs() argument
1948 if (!a->fs_api_buffer) in esas2r_read_fs()
1955 (struct esas2r_ioctl_fs *)a->fs_api_buffer; in esas2r_read_fs()
1958 if (mutex_lock_interruptible(&a->fs_api_mutex)) { in esas2r_read_fs()
1968 * chip and reply. Allocate a request in esas2r_read_fs()
1971 rq = esas2r_alloc_request(a); in esas2r_read_fs()
1974 mutex_unlock(&a->fs_api_mutex); in esas2r_read_fs()
1985 a->fs_api_command_done = 0; in esas2r_read_fs()
1987 if (!esas2r_process_fs_ioctl(a, fs, rq, &sgc)) { in esas2r_read_fs()
1996 while (!a->fs_api_command_done) in esas2r_read_fs()
1997 wait_event_interruptible(a->fs_api_waiter, in esas2r_read_fs()
1998 a->fs_api_command_done); in esas2r_read_fs()
2002 mutex_unlock(&a->fs_api_mutex); in esas2r_read_fs()
2003 esas2r_free_request(a, (struct esas2r_request *)rq); in esas2r_read_fs()
2010 if (off > a->fs_api_buffer_size) in esas2r_read_fs()
2013 if (count + off > a->fs_api_buffer_size) in esas2r_read_fs()
2014 count = a->fs_api_buffer_size - off; in esas2r_read_fs()
2019 memcpy(buf, a->fs_api_buffer + off, count); in esas2r_read_fs()
2024 /* Handle a call to write firmware via FS_API. */
2025 int esas2r_write_fs(struct esas2r_adapter *a, const char *buf, long off, in esas2r_write_fs() argument
2043 * Beginning a command. We assume we'll get at least in esas2r_write_fs()
2051 /* Allocate a buffer or use the existing buffer. */ in esas2r_write_fs()
2052 if (a->fs_api_buffer) { in esas2r_write_fs()
2053 if (a->fs_api_buffer_size < length) { in esas2r_write_fs()
2054 /* Free too-small buffer and get a new one */ in esas2r_write_fs()
2055 dma_free_coherent(&a->pcid->dev, in esas2r_write_fs()
2056 (size_t)a->fs_api_buffer_size, in esas2r_write_fs()
2057 a->fs_api_buffer, in esas2r_write_fs()
2058 (dma_addr_t)a->ppfs_api_buffer); in esas2r_write_fs()
2064 a->fs_api_buffer_size = length; in esas2r_write_fs()
2066 a->fs_api_buffer = dma_alloc_coherent(&a->pcid->dev, in esas2r_write_fs()
2067 (size_t)a->fs_api_buffer_size, in esas2r_write_fs()
2068 (dma_addr_t *)&a->ppfs_api_buffer, in esas2r_write_fs()
2073 if (!a->fs_api_buffer) in esas2r_write_fs()
2076 if (off > a->fs_api_buffer_size) in esas2r_write_fs()
2079 if (count + off > a->fs_api_buffer_size) in esas2r_write_fs()
2080 count = a->fs_api_buffer_size - off; in esas2r_write_fs()
2085 memcpy(a->fs_api_buffer + off, buf, count); in esas2r_write_fs()