Lines Matching +full:flash +full:- +full:dma
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2011-2013 QLogic Corporation
16 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_read_flash()
17 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_read_flash()
21 uint8_t *flash = NULL; in qla4xxx_read_flash() local
22 int rval = -EINVAL; in qla4xxx_read_flash()
24 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_read_flash()
26 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_read_flash()
31 rval = -EBUSY; in qla4xxx_read_flash()
35 if (ha->flash_state != QLFLASH_WAITING) { in qla4xxx_read_flash()
36 ql4_printk(KERN_ERR, ha, "%s: another flash operation " in qla4xxx_read_flash()
38 rval = -EBUSY; in qla4xxx_read_flash()
42 ha->flash_state = QLFLASH_READING; in qla4xxx_read_flash()
43 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_read_flash()
44 length = bsg_job->reply_payload.payload_len; in qla4xxx_read_flash()
46 flash = dma_alloc_coherent(&ha->pdev->dev, length, &flash_dma, in qla4xxx_read_flash()
48 if (!flash) { in qla4xxx_read_flash()
49 ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash " in qla4xxx_read_flash()
51 rval = -ENOMEM; in qla4xxx_read_flash()
57 ql4_printk(KERN_ERR, ha, "%s: get flash failed\n", __func__); in qla4xxx_read_flash()
58 bsg_reply->result = DID_ERROR << 16; in qla4xxx_read_flash()
59 rval = -EIO; in qla4xxx_read_flash()
61 bsg_reply->reply_payload_rcv_len = in qla4xxx_read_flash()
62 sg_copy_from_buffer(bsg_job->reply_payload.sg_list, in qla4xxx_read_flash()
63 bsg_job->reply_payload.sg_cnt, in qla4xxx_read_flash()
64 flash, length); in qla4xxx_read_flash()
65 bsg_reply->result = DID_OK << 16; in qla4xxx_read_flash()
68 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_read_flash()
69 bsg_reply->reply_payload_rcv_len); in qla4xxx_read_flash()
70 dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma); in qla4xxx_read_flash()
72 ha->flash_state = QLFLASH_WAITING; in qla4xxx_read_flash()
81 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_update_flash()
82 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_update_flash()
87 uint8_t *flash = NULL; in qla4xxx_update_flash() local
88 int rval = -EINVAL; in qla4xxx_update_flash()
90 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_update_flash()
92 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_update_flash()
97 rval = -EBUSY; in qla4xxx_update_flash()
101 if (ha->flash_state != QLFLASH_WAITING) { in qla4xxx_update_flash()
102 ql4_printk(KERN_ERR, ha, "%s: another flash operation " in qla4xxx_update_flash()
104 rval = -EBUSY; in qla4xxx_update_flash()
108 ha->flash_state = QLFLASH_WRITING; in qla4xxx_update_flash()
109 length = bsg_job->request_payload.payload_len; in qla4xxx_update_flash()
110 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_update_flash()
111 options = bsg_req->rqst_data.h_vendor.vendor_cmd[2]; in qla4xxx_update_flash()
113 flash = dma_alloc_coherent(&ha->pdev->dev, length, &flash_dma, in qla4xxx_update_flash()
115 if (!flash) { in qla4xxx_update_flash()
116 ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash " in qla4xxx_update_flash()
118 rval = -ENOMEM; in qla4xxx_update_flash()
122 sg_copy_to_buffer(bsg_job->request_payload.sg_list, in qla4xxx_update_flash()
123 bsg_job->request_payload.sg_cnt, flash, length); in qla4xxx_update_flash()
127 ql4_printk(KERN_ERR, ha, "%s: set flash failed\n", __func__); in qla4xxx_update_flash()
128 bsg_reply->result = DID_ERROR << 16; in qla4xxx_update_flash()
129 rval = -EIO; in qla4xxx_update_flash()
131 bsg_reply->result = DID_OK << 16; in qla4xxx_update_flash()
133 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_update_flash()
134 bsg_reply->reply_payload_rcv_len); in qla4xxx_update_flash()
135 dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma); in qla4xxx_update_flash()
137 ha->flash_state = QLFLASH_WAITING; in qla4xxx_update_flash()
146 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_get_acb_state()
147 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_get_acb_state()
151 int rval = -EINVAL; in qla4xxx_get_acb_state()
153 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_get_acb_state()
155 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_get_acb_state()
164 rval = -EBUSY; in qla4xxx_get_acb_state()
168 if (bsg_job->reply_payload.payload_len < sizeof(status)) { in qla4xxx_get_acb_state()
170 __func__, bsg_job->reply_payload.payload_len); in qla4xxx_get_acb_state()
171 rval = -EINVAL; in qla4xxx_get_acb_state()
175 acb_idx = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_get_acb_state()
176 ip_idx = bsg_req->rqst_data.h_vendor.vendor_cmd[2]; in qla4xxx_get_acb_state()
182 bsg_reply->result = DID_ERROR << 16; in qla4xxx_get_acb_state()
183 rval = -EIO; in qla4xxx_get_acb_state()
185 bsg_reply->reply_payload_rcv_len = in qla4xxx_get_acb_state()
186 sg_copy_from_buffer(bsg_job->reply_payload.sg_list, in qla4xxx_get_acb_state()
187 bsg_job->reply_payload.sg_cnt, in qla4xxx_get_acb_state()
189 bsg_reply->result = DID_OK << 16; in qla4xxx_get_acb_state()
192 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_get_acb_state()
193 bsg_reply->reply_payload_rcv_len); in qla4xxx_get_acb_state()
203 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_read_nvram()
204 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_read_nvram()
210 int rval = -EINVAL; in qla4xxx_read_nvram()
212 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_read_nvram()
214 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_read_nvram()
223 rval = -EBUSY; in qla4xxx_read_nvram()
227 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_read_nvram()
228 len = bsg_job->reply_payload.payload_len; in qla4xxx_read_nvram()
241 nvram = dma_alloc_coherent(&ha->pdev->dev, len, &nvram_dma, in qla4xxx_read_nvram()
244 ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for nvram " in qla4xxx_read_nvram()
246 rval = -ENOMEM; in qla4xxx_read_nvram()
253 bsg_reply->result = DID_ERROR << 16; in qla4xxx_read_nvram()
254 rval = -EIO; in qla4xxx_read_nvram()
256 bsg_reply->reply_payload_rcv_len = in qla4xxx_read_nvram()
257 sg_copy_from_buffer(bsg_job->reply_payload.sg_list, in qla4xxx_read_nvram()
258 bsg_job->reply_payload.sg_cnt, in qla4xxx_read_nvram()
260 bsg_reply->result = DID_OK << 16; in qla4xxx_read_nvram()
263 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_read_nvram()
264 bsg_reply->reply_payload_rcv_len); in qla4xxx_read_nvram()
265 dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma); in qla4xxx_read_nvram()
275 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_update_nvram()
276 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_update_nvram()
282 int rval = -EINVAL; in qla4xxx_update_nvram()
284 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_update_nvram()
286 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_update_nvram()
294 rval = -EBUSY; in qla4xxx_update_nvram()
298 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_update_nvram()
299 len = bsg_job->request_payload.payload_len; in qla4xxx_update_nvram()
312 nvram = dma_alloc_coherent(&ha->pdev->dev, len, &nvram_dma, in qla4xxx_update_nvram()
315 ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash " in qla4xxx_update_nvram()
317 rval = -ENOMEM; in qla4xxx_update_nvram()
321 sg_copy_to_buffer(bsg_job->request_payload.sg_list, in qla4xxx_update_nvram()
322 bsg_job->request_payload.sg_cnt, nvram, len); in qla4xxx_update_nvram()
327 bsg_reply->result = DID_ERROR << 16; in qla4xxx_update_nvram()
328 rval = -EIO; in qla4xxx_update_nvram()
330 bsg_reply->result = DID_OK << 16; in qla4xxx_update_nvram()
332 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_update_nvram()
333 bsg_reply->reply_payload_rcv_len); in qla4xxx_update_nvram()
334 dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma); in qla4xxx_update_nvram()
344 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_restore_defaults()
345 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_restore_defaults()
349 int rval = -EINVAL; in qla4xxx_restore_defaults()
351 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_restore_defaults()
353 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_restore_defaults()
361 rval = -EBUSY; in qla4xxx_restore_defaults()
365 region = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_restore_defaults()
366 field0 = bsg_req->rqst_data.h_vendor.vendor_cmd[2]; in qla4xxx_restore_defaults()
367 field1 = bsg_req->rqst_data.h_vendor.vendor_cmd[3]; in qla4xxx_restore_defaults()
372 bsg_reply->result = DID_ERROR << 16; in qla4xxx_restore_defaults()
373 rval = -EIO; in qla4xxx_restore_defaults()
375 bsg_reply->result = DID_OK << 16; in qla4xxx_restore_defaults()
377 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_restore_defaults()
378 bsg_reply->reply_payload_rcv_len); in qla4xxx_restore_defaults()
388 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_bsg_get_acb()
389 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_bsg_get_acb()
394 int rval = -EINVAL; in qla4xxx_bsg_get_acb()
396 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_bsg_get_acb()
398 if (unlikely(pci_channel_offline(ha->pdev))) in qla4xxx_bsg_get_acb()
407 rval = -EBUSY; in qla4xxx_bsg_get_acb()
411 acb_type = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_bsg_get_acb()
412 len = bsg_job->reply_payload.payload_len; in qla4xxx_bsg_get_acb()
416 rval = -EINVAL; in qla4xxx_bsg_get_acb()
420 acb = dma_alloc_coherent(&ha->pdev->dev, len, &acb_dma, GFP_KERNEL); in qla4xxx_bsg_get_acb()
422 ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for acb " in qla4xxx_bsg_get_acb()
424 rval = -ENOMEM; in qla4xxx_bsg_get_acb()
431 bsg_reply->result = DID_ERROR << 16; in qla4xxx_bsg_get_acb()
432 rval = -EIO; in qla4xxx_bsg_get_acb()
434 bsg_reply->reply_payload_rcv_len = in qla4xxx_bsg_get_acb()
435 sg_copy_from_buffer(bsg_job->reply_payload.sg_list, in qla4xxx_bsg_get_acb()
436 bsg_job->reply_payload.sg_cnt, in qla4xxx_bsg_get_acb()
438 bsg_reply->result = DID_OK << 16; in qla4xxx_bsg_get_acb()
441 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_bsg_get_acb()
442 bsg_reply->reply_payload_rcv_len); in qla4xxx_bsg_get_acb()
443 dma_free_coherent(&ha->pdev->dev, len, acb, acb_dma); in qla4xxx_bsg_get_acb()
452 struct iscsi_bsg_request *bsg_req = bsg_job->request; in ql4xxx_execute_diag_cmd()
453 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in ql4xxx_execute_diag_cmd()
461 if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in ql4xxx_execute_diag_cmd()
464 bsg_reply->result = DID_ERROR << 16; in ql4xxx_execute_diag_cmd()
468 bsg_reply->reply_payload_rcv_len = 0; in ql4xxx_execute_diag_cmd()
469 memcpy(mbox_cmd, &bsg_req->rqst_data.h_vendor.vendor_cmd[1], in ql4xxx_execute_diag_cmd()
488 bsg_reply->result = DID_OK << 16; in ql4xxx_execute_diag_cmd()
490 bsg_reply->result = DID_ERROR << 16; in ql4xxx_execute_diag_cmd()
493 bsg_job->reply_len = sizeof(struct iscsi_bsg_reply) + sizeof(mbox_sts); in ql4xxx_execute_diag_cmd()
499 "%s: bsg_reply->result = x%x, status = %s\n", in ql4xxx_execute_diag_cmd()
500 __func__, bsg_reply->result, STATUS(status))); in ql4xxx_execute_diag_cmd()
502 bsg_job_done(bsg_job, bsg_reply->result, in ql4xxx_execute_diag_cmd()
503 bsg_reply->reply_payload_rcv_len); in ql4xxx_execute_diag_cmd()
511 if (!wait_for_completion_timeout(&ha->idc_comp, (IDC_COMP_TOV * HZ))) { in qla4_83xx_wait_for_loopback_config_comp()
513 __func__, ha->idc_extend_tmo); in qla4_83xx_wait_for_loopback_config_comp()
514 if (ha->idc_extend_tmo) { in qla4_83xx_wait_for_loopback_config_comp()
515 if (!wait_for_completion_timeout(&ha->idc_comp, in qla4_83xx_wait_for_loopback_config_comp()
516 (ha->idc_extend_tmo * HZ))) { in qla4_83xx_wait_for_loopback_config_comp()
517 ha->notify_idc_comp = 0; in qla4_83xx_wait_for_loopback_config_comp()
518 ha->notify_link_up_comp = 0; in qla4_83xx_wait_for_loopback_config_comp()
534 ha->notify_idc_comp = 0; in qla4_83xx_wait_for_loopback_config_comp()
537 if (!wait_for_completion_timeout(&ha->link_up_comp, in qla4_83xx_wait_for_loopback_config_comp()
539 ha->notify_link_up_comp = 0; in qla4_83xx_wait_for_loopback_config_comp()
549 ha->notify_link_up_comp = 0; in qla4_83xx_wait_for_loopback_config_comp()
589 ha->notify_idc_comp = 1; in qla4_83xx_pre_loopback_config()
590 ha->notify_link_up_comp = 1; in qla4_83xx_pre_loopback_config()
597 ha->notify_idc_comp = 0; in qla4_83xx_pre_loopback_config()
598 ha->notify_link_up_comp = 0; in qla4_83xx_pre_loopback_config()
633 ha->notify_idc_comp = 1; in qla4_83xx_post_loopback_config()
634 if (ha->addl_fw_state & FW_ADDSTATE_LINK_UP) in qla4_83xx_post_loopback_config()
635 ha->notify_link_up_comp = 1; in qla4_83xx_post_loopback_config()
641 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4_83xx_post_loopback_config()
642 clear_bit(AF_LOOPBACK, &ha->flags); in qla4_83xx_post_loopback_config()
656 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_execute_diag_loopback_cmd()
657 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_execute_diag_loopback_cmd()
666 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_execute_diag_loopback_cmd()
668 if (test_bit(AF_LOOPBACK, &ha->flags)) { in qla4xxx_execute_diag_loopback_cmd()
671 bsg_reply->result = DID_ERROR << 16; in qla4xxx_execute_diag_loopback_cmd()
675 if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in qla4xxx_execute_diag_loopback_cmd()
678 bsg_reply->result = DID_ERROR << 16; in qla4xxx_execute_diag_loopback_cmd()
682 memcpy(mbox_cmd, &bsg_req->rqst_data.h_vendor.vendor_cmd[1], in qla4xxx_execute_diag_loopback_cmd()
688 bsg_reply->result = DID_ERROR << 16; in qla4xxx_execute_diag_loopback_cmd()
695 bsg_reply->result = DID_TIME_OUT << 16; in qla4xxx_execute_diag_loopback_cmd()
710 bsg_reply->result = DID_OK << 16; in qla4xxx_execute_diag_loopback_cmd()
712 bsg_reply->result = DID_ERROR << 16; in qla4xxx_execute_diag_loopback_cmd()
721 bsg_job->reply_len = sizeof(struct iscsi_bsg_reply) + sizeof(mbox_sts); in qla4xxx_execute_diag_loopback_cmd()
728 bsg_reply->result = DID_ERROR << 16; in qla4xxx_execute_diag_loopback_cmd()
734 if (!(ha->addl_fw_state & FW_ADDSTATE_LINK_UP)) in qla4xxx_execute_diag_loopback_cmd()
740 bsg_reply->result = DID_TIME_OUT << 16; in qla4xxx_execute_diag_loopback_cmd()
746 "%s: bsg_reply->result = x%x, status = %s\n", in qla4xxx_execute_diag_loopback_cmd()
747 __func__, bsg_reply->result, STATUS(status))); in qla4xxx_execute_diag_loopback_cmd()
748 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_execute_diag_loopback_cmd()
749 bsg_reply->reply_payload_rcv_len); in qla4xxx_execute_diag_loopback_cmd()
756 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_execute_diag_test()
758 int rval = -EINVAL; in qla4xxx_execute_diag_test()
762 diag_cmd = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; in qla4xxx_execute_diag_test()
764 switch (bsg_req->rqst_data.h_vendor.vendor_cmd[2]) { in qla4xxx_execute_diag_test()
773 /* Execute diag test for adapter RAM/FLASH */ in qla4xxx_execute_diag_test()
791 bsg_req->rqst_data.h_vendor.vendor_cmd[2]); in qla4xxx_execute_diag_test()
806 * qla4xxx_process_vendor_specific - handle vendor specific bsg request
811 struct iscsi_bsg_reply *bsg_reply = bsg_job->reply; in qla4xxx_process_vendor_specific()
812 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_process_vendor_specific()
816 switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) { in qla4xxx_process_vendor_specific()
843 "0x%x\n", __func__, bsg_req->msgcode); in qla4xxx_process_vendor_specific()
844 bsg_reply->result = (DID_ERROR << 16); in qla4xxx_process_vendor_specific()
845 bsg_reply->reply_payload_rcv_len = 0; in qla4xxx_process_vendor_specific()
846 bsg_job_done(bsg_job, bsg_reply->result, in qla4xxx_process_vendor_specific()
847 bsg_reply->reply_payload_rcv_len); in qla4xxx_process_vendor_specific()
848 return -ENOSYS; in qla4xxx_process_vendor_specific()
853 * qla4xxx_bsg_request - handle bsg request from ISCSI transport
858 struct iscsi_bsg_request *bsg_req = bsg_job->request; in qla4xxx_bsg_request()
862 switch (bsg_req->msgcode) { in qla4xxx_bsg_request()
868 __func__, bsg_req->msgcode); in qla4xxx_bsg_request()
871 return -ENOSYS; in qla4xxx_bsg_request()