aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/aachba.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aacraid/aachba.c')
-rw-r--r--drivers/scsi/aacraid/aachba.c66
1 files changed, 56 insertions, 10 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index a26baab09dbf..6800e578e4b1 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -194,8 +194,7 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
194 struct scsi_device *device; 194 struct scsi_device *device;
195 195
196 if (unlikely(!scsicmd || !scsicmd->scsi_done )) { 196 if (unlikely(!scsicmd || !scsicmd->scsi_done )) {
197 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n")) 197 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
198;
199 aac_fib_complete(fibptr); 198 aac_fib_complete(fibptr);
200 aac_fib_free(fibptr); 199 aac_fib_free(fibptr);
201 return 0; 200 return 0;
@@ -1689,23 +1688,23 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1689 if (!aac_valid_context(cmd, fibptr)) 1688 if (!aac_valid_context(cmd, fibptr))
1690 return; 1689 return;
1691 1690
1692 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 1691 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
1693 smp_processor_id(), jiffies)); 1692 smp_processor_id(), jiffies));
1694 BUG_ON(fibptr == NULL); 1693 BUG_ON(fibptr == NULL);
1695 1694
1696 1695
1697 synchronizereply = fib_data(fibptr); 1696 synchronizereply = fib_data(fibptr);
1698 if (le32_to_cpu(synchronizereply->status) == CT_OK) 1697 if (le32_to_cpu(synchronizereply->status) == CT_OK)
1699 cmd->result = DID_OK << 16 | 1698 cmd->result = DID_OK << 16 |
1700 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1699 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1701 else { 1700 else {
1702 struct scsi_device *sdev = cmd->device; 1701 struct scsi_device *sdev = cmd->device;
1703 struct aac_dev *dev = fibptr->dev; 1702 struct aac_dev *dev = fibptr->dev;
1704 u32 cid = sdev_id(sdev); 1703 u32 cid = sdev_id(sdev);
1705 printk(KERN_WARNING 1704 printk(KERN_WARNING
1706 "synchronize_callback: synchronize failed, status = %d\n", 1705 "synchronize_callback: synchronize failed, status = %d\n",
1707 le32_to_cpu(synchronizereply->status)); 1706 le32_to_cpu(synchronizereply->status));
1708 cmd->result = DID_OK << 16 | 1707 cmd->result = DID_OK << 16 |
1709 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1708 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1710 set_sense((u8 *)&dev->fsa_dev[cid].sense_data, 1709 set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
1711 HARDWARE_ERROR, 1710 HARDWARE_ERROR,
@@ -1713,7 +1712,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1713 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1712 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1714 0, 0); 1713 0, 0);
1715 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1714 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1716 min(sizeof(dev->fsa_dev[cid].sense_data), 1715 min(sizeof(dev->fsa_dev[cid].sense_data),
1717 sizeof(cmd->sense_buffer))); 1716 sizeof(cmd->sense_buffer)));
1718 } 1717 }
1719 1718
@@ -1731,6 +1730,9 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1731 struct scsi_device *sdev = scsicmd->device; 1730 struct scsi_device *sdev = scsicmd->device;
1732 int active = 0; 1731 int active = 0;
1733 struct aac_dev *aac; 1732 struct aac_dev *aac;
1733 u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) |
1734 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1735 u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1734 unsigned long flags; 1736 unsigned long flags;
1735 1737
1736 /* 1738 /*
@@ -1739,7 +1741,51 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1739 */ 1741 */
1740 spin_lock_irqsave(&sdev->list_lock, flags); 1742 spin_lock_irqsave(&sdev->list_lock, flags);
1741 list_for_each_entry(cmd, &sdev->cmd_list, list) 1743 list_for_each_entry(cmd, &sdev->cmd_list, list)
1742 if (cmd != scsicmd && cmd->SCp.phase == AAC_OWNER_FIRMWARE) { 1744 if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
1745 u64 cmnd_lba;
1746 u32 cmnd_count;
1747
1748 if (cmd->cmnd[0] == WRITE_6) {
1749 cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) |
1750 (cmd->cmnd[2] << 8) |
1751 cmd->cmnd[3];
1752 cmnd_count = cmd->cmnd[4];
1753 if (cmnd_count == 0)
1754 cmnd_count = 256;
1755 } else if (cmd->cmnd[0] == WRITE_16) {
1756 cmnd_lba = ((u64)cmd->cmnd[2] << 56) |
1757 ((u64)cmd->cmnd[3] << 48) |
1758 ((u64)cmd->cmnd[4] << 40) |
1759 ((u64)cmd->cmnd[5] << 32) |
1760 ((u64)cmd->cmnd[6] << 24) |
1761 (cmd->cmnd[7] << 16) |
1762 (cmd->cmnd[8] << 8) |
1763 cmd->cmnd[9];
1764 cmnd_count = (cmd->cmnd[10] << 24) |
1765 (cmd->cmnd[11] << 16) |
1766 (cmd->cmnd[12] << 8) |
1767 cmd->cmnd[13];
1768 } else if (cmd->cmnd[0] == WRITE_12) {
1769 cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
1770 (cmd->cmnd[3] << 16) |
1771 (cmd->cmnd[4] << 8) |
1772 cmd->cmnd[5];
1773 cmnd_count = (cmd->cmnd[6] << 24) |
1774 (cmd->cmnd[7] << 16) |
1775 (cmd->cmnd[8] << 8) |
1776 cmd->cmnd[9];
1777 } else if (cmd->cmnd[0] == WRITE_10) {
1778 cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
1779 (cmd->cmnd[3] << 16) |
1780 (cmd->cmnd[4] << 8) |
1781 cmd->cmnd[5];
1782 cmnd_count = (cmd->cmnd[7] << 8) |
1783 cmd->cmnd[8];
1784 } else
1785 continue;
1786 if (((cmnd_lba + cmnd_count) < lba) ||
1787 (count && ((lba + count) < cmnd_lba)))
1788 continue;
1743 ++active; 1789 ++active;
1744 break; 1790 break;
1745 } 1791 }
@@ -1768,7 +1814,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1768 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); 1814 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
1769 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); 1815 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
1770 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); 1816 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
1771 synchronizecmd->count = 1817 synchronizecmd->count =
1772 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); 1818 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
1773 1819
1774 /* 1820 /*
@@ -1790,7 +1836,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1790 return 0; 1836 return 0;
1791 } 1837 }
1792 1838
1793 printk(KERN_WARNING 1839 printk(KERN_WARNING
1794 "aac_synchronize: aac_fib_send failed with status: %d.\n", status); 1840 "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
1795 aac_fib_complete(cmd_fibcontext); 1841 aac_fib_complete(cmd_fibcontext);
1796 aac_fib_free(cmd_fibcontext); 1842 aac_fib_free(cmd_fibcontext);