diff options
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r-- | drivers/ieee1394/sbp2.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 4edfff46b1e6..4cb6fa2bcfb7 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -59,8 +59,10 @@ | |||
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/kernel.h> | 60 | #include <linux/kernel.h> |
61 | #include <linux/list.h> | 61 | #include <linux/list.h> |
62 | #include <linux/mm.h> | ||
62 | #include <linux/module.h> | 63 | #include <linux/module.h> |
63 | #include <linux/moduleparam.h> | 64 | #include <linux/moduleparam.h> |
65 | #include <linux/sched.h> | ||
64 | #include <linux/slab.h> | 66 | #include <linux/slab.h> |
65 | #include <linux/spinlock.h> | 67 | #include <linux/spinlock.h> |
66 | #include <linux/stat.h> | 68 | #include <linux/stat.h> |
@@ -469,19 +471,13 @@ static void sbp2util_write_doorbell(struct work_struct *work) | |||
469 | static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu) | 471 | static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu) |
470 | { | 472 | { |
471 | struct sbp2_fwhost_info *hi = lu->hi; | 473 | struct sbp2_fwhost_info *hi = lu->hi; |
472 | int i; | ||
473 | unsigned long flags, orbs; | ||
474 | struct sbp2_command_info *cmd; | 474 | struct sbp2_command_info *cmd; |
475 | int i, orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS; | ||
475 | 476 | ||
476 | orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS; | ||
477 | |||
478 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); | ||
479 | for (i = 0; i < orbs; i++) { | 477 | for (i = 0; i < orbs; i++) { |
480 | cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC); | 478 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
481 | if (!cmd) { | 479 | if (!cmd) |
482 | spin_unlock_irqrestore(&lu->cmd_orb_lock, flags); | ||
483 | return -ENOMEM; | 480 | return -ENOMEM; |
484 | } | ||
485 | cmd->command_orb_dma = dma_map_single(hi->host->device.parent, | 481 | cmd->command_orb_dma = dma_map_single(hi->host->device.parent, |
486 | &cmd->command_orb, | 482 | &cmd->command_orb, |
487 | sizeof(struct sbp2_command_orb), | 483 | sizeof(struct sbp2_command_orb), |
@@ -489,11 +485,10 @@ static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu) | |||
489 | cmd->sge_dma = dma_map_single(hi->host->device.parent, | 485 | cmd->sge_dma = dma_map_single(hi->host->device.parent, |
490 | &cmd->scatter_gather_element, | 486 | &cmd->scatter_gather_element, |
491 | sizeof(cmd->scatter_gather_element), | 487 | sizeof(cmd->scatter_gather_element), |
492 | DMA_BIDIRECTIONAL); | 488 | DMA_TO_DEVICE); |
493 | INIT_LIST_HEAD(&cmd->list); | 489 | INIT_LIST_HEAD(&cmd->list); |
494 | list_add_tail(&cmd->list, &lu->cmd_orb_completed); | 490 | list_add_tail(&cmd->list, &lu->cmd_orb_completed); |
495 | } | 491 | } |
496 | spin_unlock_irqrestore(&lu->cmd_orb_lock, flags); | ||
497 | return 0; | 492 | return 0; |
498 | } | 493 | } |
499 | 494 | ||
@@ -514,7 +509,7 @@ static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu) | |||
514 | DMA_TO_DEVICE); | 509 | DMA_TO_DEVICE); |
515 | dma_unmap_single(host->device.parent, cmd->sge_dma, | 510 | dma_unmap_single(host->device.parent, cmd->sge_dma, |
516 | sizeof(cmd->scatter_gather_element), | 511 | sizeof(cmd->scatter_gather_element), |
517 | DMA_BIDIRECTIONAL); | 512 | DMA_TO_DEVICE); |
518 | kfree(cmd); | 513 | kfree(cmd); |
519 | } | 514 | } |
520 | spin_unlock_irqrestore(&lu->cmd_orb_lock, flags); | 515 | spin_unlock_irqrestore(&lu->cmd_orb_lock, flags); |
@@ -757,6 +752,11 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud) | |||
757 | SBP2_ERR("failed to register lower 4GB address range"); | 752 | SBP2_ERR("failed to register lower 4GB address range"); |
758 | goto failed_alloc; | 753 | goto failed_alloc; |
759 | } | 754 | } |
755 | #else | ||
756 | if (dma_set_mask(hi->host->device.parent, DMA_32BIT_MASK)) { | ||
757 | SBP2_ERR("failed to set 4GB DMA mask"); | ||
758 | goto failed_alloc; | ||
759 | } | ||
760 | #endif | 760 | #endif |
761 | } | 761 | } |
762 | 762 | ||
@@ -865,11 +865,8 @@ static int sbp2_start_device(struct sbp2_lu *lu) | |||
865 | if (!lu->login_orb) | 865 | if (!lu->login_orb) |
866 | goto alloc_fail; | 866 | goto alloc_fail; |
867 | 867 | ||
868 | if (sbp2util_create_command_orb_pool(lu)) { | 868 | if (sbp2util_create_command_orb_pool(lu)) |
869 | SBP2_ERR("sbp2util_create_command_orb_pool failed!"); | 869 | goto alloc_fail; |
870 | sbp2_remove_device(lu); | ||
871 | return -ENOMEM; | ||
872 | } | ||
873 | 870 | ||
874 | /* Wait a second before trying to log in. Previously logged in | 871 | /* Wait a second before trying to log in. Previously logged in |
875 | * initiators need a chance to reconnect. */ | 872 | * initiators need a chance to reconnect. */ |
@@ -1628,7 +1625,7 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu, | |||
1628 | DMA_TO_DEVICE); | 1625 | DMA_TO_DEVICE); |
1629 | dma_sync_single_for_device(hi->host->device.parent, cmd->sge_dma, | 1626 | dma_sync_single_for_device(hi->host->device.parent, cmd->sge_dma, |
1630 | sizeof(cmd->scatter_gather_element), | 1627 | sizeof(cmd->scatter_gather_element), |
1631 | DMA_BIDIRECTIONAL); | 1628 | DMA_TO_DEVICE); |
1632 | 1629 | ||
1633 | /* check to see if there are any previous orbs to use */ | 1630 | /* check to see if there are any previous orbs to use */ |
1634 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); | 1631 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); |
@@ -1794,7 +1791,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, | |||
1794 | DMA_TO_DEVICE); | 1791 | DMA_TO_DEVICE); |
1795 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, | 1792 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, |
1796 | sizeof(cmd->scatter_gather_element), | 1793 | sizeof(cmd->scatter_gather_element), |
1797 | DMA_BIDIRECTIONAL); | 1794 | DMA_TO_DEVICE); |
1798 | /* Grab SCSI command pointers and check status. */ | 1795 | /* Grab SCSI command pointers and check status. */ |
1799 | /* | 1796 | /* |
1800 | * FIXME: If the src field in the status is 1, the ORB DMA must | 1797 | * FIXME: If the src field in the status is 1, the ORB DMA must |
@@ -1926,7 +1923,7 @@ static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status) | |||
1926 | DMA_TO_DEVICE); | 1923 | DMA_TO_DEVICE); |
1927 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, | 1924 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, |
1928 | sizeof(cmd->scatter_gather_element), | 1925 | sizeof(cmd->scatter_gather_element), |
1929 | DMA_BIDIRECTIONAL); | 1926 | DMA_TO_DEVICE); |
1930 | sbp2util_mark_command_completed(lu, cmd); | 1927 | sbp2util_mark_command_completed(lu, cmd); |
1931 | if (cmd->Current_SCpnt) { | 1928 | if (cmd->Current_SCpnt) { |
1932 | cmd->Current_SCpnt->result = status << 16; | 1929 | cmd->Current_SCpnt->result = status << 16; |
@@ -2057,7 +2054,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) | |||
2057 | dma_sync_single_for_cpu(hi->host->device.parent, | 2054 | dma_sync_single_for_cpu(hi->host->device.parent, |
2058 | cmd->sge_dma, | 2055 | cmd->sge_dma, |
2059 | sizeof(cmd->scatter_gather_element), | 2056 | sizeof(cmd->scatter_gather_element), |
2060 | DMA_BIDIRECTIONAL); | 2057 | DMA_TO_DEVICE); |
2061 | sbp2util_mark_command_completed(lu, cmd); | 2058 | sbp2util_mark_command_completed(lu, cmd); |
2062 | if (cmd->Current_SCpnt) { | 2059 | if (cmd->Current_SCpnt) { |
2063 | cmd->Current_SCpnt->result = DID_ABORT << 16; | 2060 | cmd->Current_SCpnt->result = DID_ABORT << 16; |