24 #include <linux/kernel.h>
25 #include <linux/module.h>
28 #include <linux/device.h>
29 #include <linux/pci.h>
30 #include <linux/list.h>
36 #include <scsi/scsi.h>
64 for (i = 0; i <
size; i++)
65 st->
stack[i] = size - 1 - i;
81 static bool tag_is_empty(
struct mvumi_tag *st)
89 static void mvumi_unmap_pci_addr(
struct pci_dev *
dev,
void **addr_array)
99 static int mvumi_map_pci_addr(
struct pci_dev *dev,
void **addr_array)
105 addr_array[
i] = pci_iomap(dev, i, 0);
106 if (!addr_array[i]) {
109 mvumi_unmap_pci_addr(dev, addr_array);
113 addr_array[
i] =
NULL;
115 dev_dbg(&dev->
dev,
"Bar %d : %p.\n", i, addr_array[i]);
128 "Failed to allocate memory for resource manager.\n");
137 "unable to allocate memory,size = %d.\n", size);
149 "unable to allocate consistent mem,"
150 "size = %d.\n", size);
158 dev_err(&mhba->
pdev->dev,
"unknown resource type %d.\n", type);
165 INIT_LIST_HEAD(&res->
entry);
171 static void mvumi_release_mem_resource(
struct mvumi_hba *mhba)
186 "unknown resource type %d\n", res->
type);
205 void *sgl_p,
unsigned char *
sg_count)
210 unsigned int sgnum = scsi_sg_count(scmd);
214 sg = scsi_sglist(scmd);
215 *sg_count = pci_map_sg(mhba->
pdev, sg, sgnum,
217 if (*sg_count > mhba->
max_sge) {
218 dev_err(&mhba->
pdev->dev,
"sg count[0x%x] is bigger "
219 "than max sg[0x%x].\n",
229 if ((i + 1) == *sg_count)
235 scmd->
SCp.dma_handle = scsi_bufflen(scmd) ?
236 pci_map_single(mhba->
pdev, scsi_sglist(scmd),
240 busaddr = scmd->
SCp.dma_handle;
265 memset(virt_addr, 0, size);
268 cmd->
frame->sg_counts = 1;
286 dev_err(&mhba->
pdev->dev,
"failed to create a internal cmd\n");
294 dev_err(&mhba->
pdev->dev,
"failed to allocate memory for FW"
301 if (mvumi_internal_cmd_sgl(mhba, cmd, buf_size)) {
302 dev_err(&mhba->
pdev->dev,
"failed to allocate memory"
303 " for internal frame\n");
310 cmd->
frame->sg_counts = 0;
315 static void mvumi_delete_internal_cmd(
struct mvumi_hba *mhba,
322 if (cmd && cmd->
frame) {
323 if (cmd->
frame->sg_counts) {
364 static inline void mvumi_return_cmd(
struct mvumi_hba *mhba,
375 static void mvumi_free_cmds(
struct mvumi_hba *mhba)
379 while (!list_empty(&mhba->
cmd_pool)) {
394 static int mvumi_alloc_cmds(
struct mvumi_hba *mhba)
399 for (i = 0; i < mhba->
max_io; i++) {
419 "failed to allocate memory for cmd[0x%x].\n", i);
420 while (!list_empty(&mhba->
cmd_pool)) {
431 static unsigned int mvumi_check_ib_list_9143(
struct mvumi_hba *mhba)
433 unsigned int ib_rp_reg;
453 static unsigned int mvumi_check_ib_list_9580(
struct mvumi_hba *mhba)
464 static void mvumi_get_ib_list_entry(
struct mvumi_hba *mhba,
void **ib_entry)
466 unsigned int cur_ib_entry;
477 *ib_entry = mhba->
ib_list + cur_ib_entry *
485 static void mvumi_send_ib_list_entry(
struct mvumi_hba *mhba)
491 static char mvumi_check_ob_frame(
struct mvumi_hba *mhba,
499 tag = p_outb_frame->
tag;
501 dev_err(&mhba->
pdev->dev,
"ob frame data error\n");
505 dev_err(&mhba->
pdev->dev,
"tag[0x%x] with NO command\n", tag);
507 }
else if (mhba->
tag_cmd[tag]->request_id != request_id &&
509 dev_err(&mhba->
pdev->dev,
"request ID from FW:0x%x,"
510 "cmd request ID:0x%x\n", request_id,
511 mhba->
tag_cmd[tag]->request_id);
518 static int mvumi_check_ob_list_9143(
struct mvumi_hba *mhba,
519 unsigned int *cur_obf,
unsigned int *assign_obf_end)
521 unsigned int ob_write, ob_write_shadow;
530 *assign_obf_end = ob_write & mhba->
regs->cl_slot_num_mask;
539 static int mvumi_check_ob_list_9580(
struct mvumi_hba *mhba,
540 unsigned int *cur_obf,
unsigned int *assign_obf_end)
542 unsigned int ob_write;
548 *assign_obf_end = ob_write & mhba->
regs->cl_slot_num_mask;
549 if (*assign_obf_end < *cur_obf)
551 else if (*assign_obf_end == *cur_obf)
556 static void mvumi_receive_ob_list_entry(
struct mvumi_hba *mhba)
558 unsigned int cur_obf, assign_obf_end,
i;
563 if (mhba->
instancet->check_ob_list(mhba, &cur_obf, &assign_obf_end))
566 for (i = (assign_obf_end - cur_obf); i != 0; i--) {
581 mhba->
tag_cmd[p_outb_frame->
tag]->request_id))
582 if (mvumi_check_ob_frame(mhba, cur_obf, p_outb_frame))
589 list_del_init(&ob_data->
list);
601 p_outb_frame->
tag = 0xff;
610 static void mvumi_reset(
struct mvumi_hba *mhba)
621 static unsigned char mvumi_start(
struct mvumi_hba *mhba);
623 static int mvumi_wait_for_outstanding(
struct mvumi_hba *mhba)
628 if (mvumi_start(mhba))
634 static int mvumi_wait_for_fw(
struct mvumi_hba *mhba)
638 unsigned long before;
647 "FW reset failed [0x%x].\n", tmp);
659 static void mvumi_backup_bar_addr(
struct mvumi_hba *mhba)
664 pci_read_config_dword(mhba->
pdev, 0x10 + i * 4,
669 static void mvumi_restore_bar_addr(
struct mvumi_hba *mhba)
675 pci_write_config_dword(mhba->
pdev, 0x10 + i * 4,
680 static unsigned int mvumi_pci_set_master(
struct pci_dev *pdev)
682 unsigned int ret = 0;
694 static int mvumi_reset_host_9580(
struct mvumi_hba *mhba)
707 dev_err(&mhba->
pdev->dev,
"enable device failed\n");
710 if (mvumi_pci_set_master(mhba->
pdev)) {
714 mvumi_restore_bar_addr(mhba);
715 if (mvumi_wait_for_fw(mhba) ==
FAILED)
718 return mvumi_wait_for_outstanding(mhba);
721 static int mvumi_reset_host_9143(
struct mvumi_hba *mhba)
723 return mvumi_wait_for_outstanding(mhba);
726 static int mvumi_host_reset(
struct scsi_cmnd *scmd)
735 return mhba->
instancet->reset_host(mhba);
738 static int mvumi_issue_blocked_cmd(
struct mvumi_hba *mhba,
747 "last blocked cmd not finished, sync_cmd = %d\n",
755 spin_unlock_irqrestore(mhba->
shost->host_lock, flags);
767 dev_warn(&mhba->
pdev->dev,
"TIMEOUT:release tag [%d]\n",
773 "TIMEOUT:A internal command doesn't send!\n");
778 spin_unlock_irqrestore(mhba->
shost->host_lock, flags);
783 static void mvumi_release_fw(
struct mvumi_hba *mhba)
785 mvumi_free_cmds(mhba);
786 mvumi_release_mem_resource(mhba);
794 static unsigned char mvumi_flush_cache(
struct mvumi_hba *mhba)
799 unsigned char bitcount =
sizeof(
unsigned char) * 8;
801 for (device_id = 0; device_id < mhba->
max_target_id; device_id++) {
802 if (!(mhba->
target_map[device_id / bitcount] &
803 (1 << (device_id % bitcount))))
805 get_cmd: cmd = mvumi_create_internal_cmd(mhba, 0);
809 " for internal flush cache cmd for "
810 "device %d", device_id);
830 mvumi_issue_blocked_cmd(mhba, cmd);
833 "device %d flush cache failed, status=0x%x.\n",
837 mvumi_delete_internal_cmd(mhba, cmd);
847 unsigned char ret = 0,
i;
850 for (i = 0; i < len; i++) {
858 static void mvumi_hs_build_page(
struct mvumi_hba *mhba,
865 unsigned int local_time;
884 local_time = (
unsigned int) (
time.tv_sec -
885 (
sys_tz.tz_minuteswest * 60));
887 hs_header->
checksum = mvumi_calculate_checksum(hs_header,
895 hs_header->
checksum = mvumi_calculate_checksum(hs_header,
922 hs_header->
checksum = mvumi_calculate_checksum(hs_header,
927 dev_err(&mhba->
pdev->dev,
"cannot build page, code[0x%x]\n",
937 static int mvumi_init_data(
struct mvumi_hba *mhba)
941 unsigned int tmp_size,
offset,
i;
953 tmp_size += 8 +
sizeof(
u32)*2 + 16;
955 res_mgnt = mvumi_alloc_mem_resource(mhba,
959 "failed to allocate memory for inbound list\n");
960 goto fail_alloc_dma_buf;
1019 res_mgnt = mvumi_alloc_mem_resource(mhba,
1023 "failed to allocate memory for outbound data buffer\n");
1024 goto fail_alloc_dma_buf;
1028 for (i = mhba->
max_io; i != 0; i--) {
1034 tmp_size =
sizeof(
unsigned short) * mhba->
max_io +
1037 (
sizeof(
unsigned char) * 8);
1039 res_mgnt = mvumi_alloc_mem_resource(mhba,
1043 "failed to allocate memory for tag and target map\n");
1044 goto fail_alloc_dma_buf;
1062 mvumi_release_mem_resource(mhba);
1066 static int mvumi_hs_process_page(
struct mvumi_hba *mhba,
1070 unsigned char page_checksum;
1072 page_checksum = mvumi_calculate_checksum(hs_header,
1074 if (page_checksum != hs_header->
checksum) {
1095 hs_page1->
fw_ver.ver_build);
1105 dev_err(&mhba->
pdev->dev,
"handshake: page code error\n");
1120 static int mvumi_handshake(
struct mvumi_hba *mhba)
1122 unsigned int hs_state,
tmp, hs_fun;
1131 dev_dbg(&mhba->
pdev->dev,
"handshake state[0x%x].\n", hs_state);
1173 if (mvumi_hs_process_page(mhba, hs_header)) {
1177 if (mvumi_init_data(mhba)) {
1189 mvumi_hs_build_page(mhba, hs_header);
1232 dev_err(&mhba->
pdev->dev,
"unknown handshake state [0x%x].\n",
1239 static unsigned char mvumi_handshake_event(
struct mvumi_hba *mhba)
1241 unsigned int isr_status;
1242 unsigned long before;
1245 mvumi_handshake(mhba);
1247 isr_status = mhba->
instancet->read_fw_status_reg(mhba);
1253 "no handshake response at state 0x%x.\n",
1256 "isr : global=0x%x,status=0x%x.\n",
1267 static unsigned char mvumi_check_handshake(
struct mvumi_hba *mhba)
1270 unsigned long before;
1277 mhba->
regs->pciea_to_arm_drbl_reg);
1280 "invalid signature [0x%x].\n", tmp);
1289 dev_dbg(&mhba->
pdev->dev,
"start firmware handshake...\n");
1291 if (mvumi_handshake_event(mhba)) {
1293 "handshake failed at state 0x%x.\n",
1299 dev_dbg(&mhba->
pdev->dev,
"firmware handshake done\n");
1304 static unsigned char mvumi_start(
struct mvumi_hba *mhba)
1317 if (mvumi_check_handshake(mhba))
1356 if (scsi_bufflen(scmd)) {
1357 if (scsi_sg_count(scmd)) {
1358 pci_unmap_sg(mhba->
pdev,
1360 scsi_sg_count(scmd),
1363 pci_unmap_single(mhba->
pdev,
1364 scmd->
SCp.dma_handle,
1368 scmd->
SCp.dma_handle = 0;
1371 cmd->
scmd->scsi_done(scmd);
1372 mvumi_return_cmd(mhba, cmd);
1375 static void mvumi_complete_internal_cmd(
struct mvumi_hba *mhba,
1393 static void mvumi_show_event(
struct mvumi_hba *mhba,
1399 "Event[0x%x] id[0x%x] severity[0x%x] device id[0x%x]\n",
1427 dev_dbg(&mhba->
pdev->dev,
"remove disk %d-%d-%d.\n", 0,
1433 dev_err(&mhba->
pdev->dev,
" no disk[%d] to remove\n",
1439 dev_dbg(&mhba->
pdev->dev,
" add disk %d-%d-%d.\n", 0,
1443 dev_err(&mhba->
pdev->dev,
" don't add disk %d-%d-%d.\n",
1457 int data_buf_len = 64;
1460 cmd = mvumi_create_internal_cmd(mhba, data_buf_len);
1481 mvumi_issue_blocked_cmd(mhba, cmd);
1491 "inquiry device(0:%d:0) wwid(%llx)\n",
id, wwid);
1496 mvumi_delete_internal_cmd(mhba, cmd);
1501 static void mvumi_detach_devices(
struct mvumi_hba *mhba)
1512 list_del_init(&mv_dev->
list);
1513 dev_dbg(&mhba->
pdev->dev,
"release device(0:%d:0) wwid(%llx)\n",
1514 mv_dev->
id, mv_dev->
wwid);
1518 list_del_init(&mv_dev->
list);
1519 dev_dbg(&mhba->
pdev->dev,
"release device(0:%d:0) wwid(%llx)\n",
1520 mv_dev->
id, mv_dev->
wwid);
1537 static void mvumi_rescan_devices(
struct mvumi_hba *mhba,
int id)
1548 static int mvumi_match_devices(
struct mvumi_hba *mhba,
int id,
u64 wwid)
1553 if (mv_dev->
wwid == wwid) {
1554 if (mv_dev->
id !=
id) {
1556 "%s has same wwid[%llx] ,"
1557 " but different id[%d %d]\n",
1558 __func__, mv_dev->
wwid, mv_dev->
id,
id);
1561 if (mhba->
pdev->device ==
1563 mvumi_rescan_devices(mhba,
id);
1571 static void mvumi_remove_devices(
struct mvumi_hba *mhba,
int id)
1577 if (mv_dev->
id ==
id) {
1579 "detach device(0:%d:0) wwid(%llx) from HOST\n",
1580 mv_dev->
id, mv_dev->
wwid);
1582 list_del_init(&mv_dev->
list);
1588 static int mvumi_probe_devices(
struct mvumi_hba *mhba)
1596 cmd = mvumi_create_internal_cmd(mhba, 64);
1605 for (
id = 0;
id < maxid;
id++) {
1606 wwid = mvumi_inquiry(mhba,
id, cmd);
1609 mvumi_remove_devices(mhba,
id);
1612 found = mvumi_match_devices(mhba,
id, wwid);
1614 mvumi_remove_devices(mhba,
id);
1619 "%s alloc mv_dev failed\n",
1626 INIT_LIST_HEAD(&mv_dev->
list);
1630 "probe a new device(0:%d:0)"
1631 " wwid(%llx)\n",
id, mv_dev->
wwid);
1632 }
else if (found == -1)
1640 mvumi_delete_internal_cmd(mhba, cmd);
1645 static int mvumi_rescan_bus(
void *
data)
1661 ret = mvumi_probe_devices(mhba);
1665 if (mvumi_handle_hotplug(mhba, mv_dev->
id,
1668 "%s add device(0:%d:0) failed"
1669 "wwid(%llx) has exist\n",
1671 mv_dev->
id, mv_dev->
wwid);
1672 list_del_init(&mv_dev->
list);
1675 list_move_tail(&mv_dev->
list,
1685 static void mvumi_proc_msg(
struct mvumi_hba *mhba,
1689 const unsigned long *ar_bitmap;
1690 const unsigned long *re_bitmap;
1695 ar_bitmap = (
const unsigned long *) param->
bitmap;
1696 re_bitmap = (
const unsigned long *) ¶m->
bitmap[size >> 3];
1725 dev_err(&mhba->
pdev->dev,
"event count[0x%x] is bigger"
1726 " than max event count[0x%x].\n",
1730 for (i = 0; i <
count; i++) {
1732 mvumi_show_event(mhba, param);
1735 mvumi_proc_msg(mhba, buffer);
1739 static int mvumi_get_event(
struct mvumi_hba *mhba,
unsigned char msg)
1744 cmd = mvumi_create_internal_cmd(mhba, 512);
1759 mvumi_issue_blocked_cmd(mhba, cmd);
1762 dev_err(&mhba->
pdev->dev,
"get event failed, status=0x%x.\n",
1765 mvumi_notification(mhba, cmd->
frame->cdb[1], cmd->
data_buf);
1767 mvumi_delete_internal_cmd(mhba, cmd);
1776 mvumi_get_event(mu_ev->
mhba, mu_ev->
event);
1780 static void mvumi_launch_events(
struct mvumi_hba *mhba,
u32 isr_status)
1804 static void mvumi_handle_clob(
struct mvumi_hba *mhba)
1813 list_del_init(&pool->
list);
1821 tag_release_one(mhba, &mhba->
tag_pool, ob_frame->
tag);
1823 mvumi_complete_cmd(mhba, cmd, ob_frame);
1825 mvumi_complete_internal_cmd(mhba, cmd, ob_frame);
1830 static irqreturn_t mvumi_isr_handler(
int irq,
void *devp)
1833 unsigned long flags;
1837 spin_unlock_irqrestore(mhba->
shost->host_lock, flags);
1845 dev_warn(&mhba->
pdev->dev,
"enter handshake again!\n");
1846 mvumi_handshake(mhba);
1852 mvumi_receive_ob_list_entry(mhba);
1857 mvumi_handle_clob(mhba);
1858 spin_unlock_irqrestore(mhba->
shost->host_lock, flags);
1867 unsigned int frame_len;
1869 ib_frame = cmd->
frame;
1871 dev_dbg(&mhba->
pdev->dev,
"firmware not ready.\n");
1874 if (tag_is_empty(&mhba->
tag_pool)) {
1878 mvumi_get_ib_list_entry(mhba, &ib_entry);
1884 frame_len =
sizeof(*ib_frame) - 4 +
1893 dle->
if_length = (frame_len >> 2) & 0xFFF;
1895 memcpy(ib_entry, ib_frame, frame_len);
1902 unsigned short num_of_cl_sent = 0;
1908 count = mhba->
instancet->check_ib_list(mhba);
1916 result = mvumi_send_command(mhba, cmd);
1923 if (num_of_cl_sent > 0)
1924 mvumi_send_ib_list_entry(mhba);
1930 if (num_of_cl_sent > 0)
1931 mvumi_send_ib_list_entry(mhba);
1938 static void mvumi_enable_intr(
struct mvumi_hba *mhba)
1953 static void mvumi_disable_intr(
struct mvumi_hba *mhba)
1965 static int mvumi_clear_intr(
void *extend)
1968 unsigned int status, isr_status = 0, tmp = 0;
1972 if (!(status & regs->
int_mu) || status == 0xFFFFFFFF)
1987 status ^= mhba->
regs->int_comaerr;
2011 static unsigned int mvumi_read_fw_status_reg(
struct mvumi_hba *mhba)
2022 .fire_cmd = mvumi_fire_cmd,
2023 .enable_intr = mvumi_enable_intr,
2024 .disable_intr = mvumi_disable_intr,
2025 .clear_intr = mvumi_clear_intr,
2026 .read_fw_status_reg = mvumi_read_fw_status_reg,
2027 .check_ib_list = mvumi_check_ib_list_9143,
2028 .check_ob_list = mvumi_check_ob_list_9143,
2029 .reset_host = mvumi_reset_host_9143,
2033 .fire_cmd = mvumi_fire_cmd,
2034 .enable_intr = mvumi_enable_intr,
2035 .disable_intr = mvumi_disable_intr,
2036 .clear_intr = mvumi_clear_intr,
2037 .read_fw_status_reg = mvumi_read_fw_status_reg,
2038 .check_ib_list = mvumi_check_ib_list_9580,
2039 .check_ob_list = mvumi_check_ob_list_9580,
2040 .reset_host = mvumi_reset_host_9580,
2043 static int mvumi_slave_configure(
struct scsi_device *sdev)
2046 unsigned char bitcount =
sizeof(
unsigned char) * 8;
2052 mhba->
target_map[sdev->
id / bitcount] |= (1 << (sdev->
id % bitcount));
2065 static unsigned char mvumi_build_frame(
struct mvumi_hba *mhba,
2072 pframe = cmd->
frame;
2089 dev_warn(&mhba->
pdev->dev,
"unexpected data direction[%d] "
2097 if (scsi_bufflen(scmd)) {
2098 if (mvumi_make_sgl(mhba, scmd, &pframe->
payload[0],
2127 unsigned long irq_flags;
2132 mhba = (
struct mvumi_hba *) shost->hostdata;
2134 cmd = mvumi_get_cmd(mhba);
2136 spin_unlock_irqrestore(shost->
host_lock, irq_flags);
2140 if (
unlikely(mvumi_build_frame(mhba, scmd, cmd)))
2141 goto out_return_cmd;
2144 scmd->
SCp.ptr = (
char *) cmd;
2146 spin_unlock_irqrestore(shost->
host_lock, irq_flags);
2150 mvumi_return_cmd(mhba, cmd);
2152 spin_unlock_irqrestore(shost->
host_lock, irq_flags);
2156 static enum blk_eh_timer_return mvumi_timed_out(
struct scsi_cmnd *scmd)
2161 unsigned long flags;
2176 if (scsi_bufflen(scmd)) {
2177 if (scsi_sg_count(scmd)) {
2178 pci_unmap_sg(mhba->
pdev,
2180 scsi_sg_count(scmd),
2183 pci_unmap_single(mhba->
pdev,
2184 scmd->
SCp.dma_handle,
2188 scmd->
SCp.dma_handle = 0;
2191 mvumi_return_cmd(mhba, cmd);
2192 spin_unlock_irqrestore(mhba->
shost->host_lock, flags);
2194 return BLK_EH_NOT_HANDLED;
2211 if (capacity >= 0x200000) {
2228 .name =
"Marvell Storage Controller",
2229 .slave_configure = mvumi_slave_configure,
2230 .queuecommand = mvumi_queue_command,
2231 .eh_host_reset_handler = mvumi_host_reset,
2232 .bios_param = mvumi_bios_param,
2237 .eh_timed_out = mvumi_timed_out,
2240 static int mvumi_cfg_hw_reg(
struct mvumi_hba *mhba)
2245 switch (mhba->
pdev->device) {
2364 static int mvumi_init_fw(
struct mvumi_hba *mhba)
2369 dev_err(&mhba->
pdev->dev,
"IO memory region busy!\n");
2376 switch (mhba->
pdev->device) {
2389 dev_err(&mhba->
pdev->dev,
"device 0x%x not supported!\n",
2390 mhba->
pdev->device);
2393 goto fail_alloc_mem;
2395 dev_dbg(&mhba->
pdev->dev,
"device id : %04X is found.\n",
2396 mhba->
pdev->device);
2397 ret = mvumi_cfg_hw_reg(mhba);
2400 "failed to allocate memory for reg\n");
2402 goto fail_alloc_mem;
2408 "failed to allocate memory for handshake\n");
2410 goto fail_alloc_page;
2413 if (mvumi_start(mhba)) {
2415 goto fail_ready_state;
2417 ret = mvumi_alloc_cmds(mhba);
2419 goto fail_ready_state;
2424 mvumi_release_mem_resource(mhba);
2441 static int mvumi_io_attach(
struct mvumi_hba *mhba)
2457 host->
transportt = &mvumi_transport_template;
2459 ret = scsi_add_host(host, &mhba->
pdev->dev);
2461 dev_err(&mhba->
pdev->dev,
"scsi_add_host failed\n");
2472 dev_err(&mhba->
pdev->dev,
"add virtual device failed\n");
2474 goto fail_add_device;
2478 mhba,
"mvumi_scanthread");
2481 "failed to create device scan thread\n");
2483 goto fail_create_thread;
2516 dev_dbg(&pdev->
dev,
" %#4.04x:%#4.04x:%#4.04x:%#4.04x: ",
2531 goto fail_set_dma_mask;
2536 goto fail_set_dma_mask;
2541 dev_err(&pdev->
dev,
"scsi_host_alloc failed\n");
2543 goto fail_alloc_instance;
2545 mhba = shost_priv(host);
2563 ret = mvumi_init_fw(mhba);
2570 dev_err(&pdev->
dev,
"failed to register IRQ\n");
2575 pci_set_drvdata(pdev, mhba);
2577 ret = mvumi_io_attach(mhba);
2579 goto fail_io_attach;
2581 mvumi_backup_bar_addr(mhba);
2582 dev_dbg(&pdev->
dev,
"probe mvumi driver successfully.\n");
2587 pci_set_drvdata(pdev,
NULL);
2591 mvumi_release_fw(mhba);
2595 fail_alloc_instance:
2602 static void mvumi_detach_one(
struct pci_dev *pdev)
2607 mhba = pci_get_drvdata(pdev);
2613 mvumi_detach_devices(mhba);
2616 mvumi_flush_cache(mhba);
2620 mvumi_release_fw(mhba);
2622 pci_set_drvdata(pdev,
NULL);
2631 static void mvumi_shutdown(
struct pci_dev *pdev)
2633 struct mvumi_hba *mhba = pci_get_drvdata(pdev);
2635 mvumi_flush_cache(mhba);
2642 mhba = pci_get_drvdata(pdev);
2643 mvumi_flush_cache(mhba);
2645 pci_set_drvdata(pdev, mhba);
2648 mvumi_unmap_pci_addr(pdev, mhba->
base_addr);
2657 static int mvumi_resume(
struct pci_dev *pdev)
2662 mhba = pci_get_drvdata(pdev);
2665 pci_enable_wake(pdev,
PCI_D0, 0);
2670 dev_err(&pdev->
dev,
"enable device failed\n");
2691 goto release_regions;
2693 if (mvumi_cfg_hw_reg(mhba)) {
2695 goto unmap_pci_addr;
2701 if (mvumi_start(mhba)) {
2703 goto unmap_pci_addr;
2709 dev_err(&pdev->
dev,
"failed to register IRQ\n");
2710 goto unmap_pci_addr;
2717 mvumi_unmap_pci_addr(pdev, mhba->
base_addr);
2726 static struct pci_driver mvumi_pci_driver = {
2729 .id_table = mvumi_pci_table,
2730 .probe = mvumi_probe_one,
2732 .shutdown = mvumi_shutdown,
2734 .suspend = mvumi_suspend,
2735 .resume = mvumi_resume,
2742 static int __init mvumi_init(
void)
2744 return pci_register_driver(&mvumi_pci_driver);
2750 static void __exit mvumi_exit(
void)