aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/cciss.c89
1 files changed, 29 insertions, 60 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 429b9b6ff590..4321c94b5525 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -179,12 +179,12 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time, int via_ioctl);
179static int deregister_disk(ctlr_info_t *h, int drv_index, 179static int deregister_disk(ctlr_info_t *h, int drv_index,
180 int clear_all, int via_ioctl); 180 int clear_all, int via_ioctl);
181 181
182static void cciss_read_capacity(int ctlr, int logvol, int withirq, 182static void cciss_read_capacity(int ctlr, int logvol,
183 sector_t *total_size, unsigned int *block_size); 183 sector_t *total_size, unsigned int *block_size);
184static void cciss_read_capacity_16(int ctlr, int logvol, int withirq, 184static void cciss_read_capacity_16(int ctlr, int logvol,
185 sector_t *total_size, unsigned int *block_size); 185 sector_t *total_size, unsigned int *block_size);
186static void cciss_geometry_inquiry(int ctlr, int logvol, 186static void cciss_geometry_inquiry(int ctlr, int logvol,
187 int withirq, sector_t total_size, 187 sector_t total_size,
188 unsigned int block_size, InquiryData_struct *inq_buff, 188 unsigned int block_size, InquiryData_struct *inq_buff,
189 drive_info_struct *drv); 189 drive_info_struct *drv);
190static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, 190static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *,
@@ -1701,7 +1701,7 @@ static inline void log_unit_to_scsi3addr(ctlr_info_t *h,
1701 * via the inquiry page 0. Model, vendor, and rev are set to empty strings if 1701 * via the inquiry page 0. Model, vendor, and rev are set to empty strings if
1702 * they cannot be read. 1702 * they cannot be read.
1703 */ 1703 */
1704static void cciss_get_device_descr(int ctlr, int logvol, int withirq, 1704static void cciss_get_device_descr(int ctlr, int logvol,
1705 char *vendor, char *model, char *rev) 1705 char *vendor, char *model, char *rev)
1706{ 1706{
1707 int rc; 1707 int rc;
@@ -1717,14 +1717,8 @@ static void cciss_get_device_descr(int ctlr, int logvol, int withirq,
1717 return; 1717 return;
1718 1718
1719 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); 1719 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
1720 if (withirq) 1720 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buf, sizeof(*inq_buf), 0,
1721 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buf, 1721 scsi3addr, TYPE_CMD);
1722 sizeof(InquiryData_struct), 0,
1723 scsi3addr, TYPE_CMD);
1724 else
1725 rc = sendcmd(CISS_INQUIRY, ctlr, inq_buf,
1726 sizeof(InquiryData_struct), 0,
1727 scsi3addr, TYPE_CMD);
1728 if (rc == IO_OK) { 1722 if (rc == IO_OK) {
1729 memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN); 1723 memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN);
1730 vendor[VENDOR_LEN] = '\0'; 1724 vendor[VENDOR_LEN] = '\0';
@@ -1743,7 +1737,7 @@ static void cciss_get_device_descr(int ctlr, int logvol, int withirq,
1743 * number cannot be had, for whatever reason, 16 bytes of 0xff 1737 * number cannot be had, for whatever reason, 16 bytes of 0xff
1744 * are returned instead. 1738 * are returned instead.
1745 */ 1739 */
1746static void cciss_get_serial_no(int ctlr, int logvol, int withirq, 1740static void cciss_get_serial_no(int ctlr, int logvol,
1747 unsigned char *serial_no, int buflen) 1741 unsigned char *serial_no, int buflen)
1748{ 1742{
1749#define PAGE_83_INQ_BYTES 64 1743#define PAGE_83_INQ_BYTES 64
@@ -1759,12 +1753,8 @@ static void cciss_get_serial_no(int ctlr, int logvol, int withirq,
1759 return; 1753 return;
1760 memset(serial_no, 0, buflen); 1754 memset(serial_no, 0, buflen);
1761 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); 1755 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
1762 if (withirq) 1756 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, buf,
1763 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, buf, 1757 PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD);
1764 PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD);
1765 else
1766 rc = sendcmd(CISS_INQUIRY, ctlr, buf,
1767 PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD);
1768 if (rc == IO_OK) 1758 if (rc == IO_OK)
1769 memcpy(serial_no, &buf[8], buflen); 1759 memcpy(serial_no, &buf[8], buflen);
1770 kfree(buf); 1760 kfree(buf);
@@ -1852,18 +1842,16 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time,
1852 1842
1853 /* testing to see if 16-byte CDBs are already being used */ 1843 /* testing to see if 16-byte CDBs are already being used */
1854 if (h->cciss_read == CCISS_READ_16) { 1844 if (h->cciss_read == CCISS_READ_16) {
1855 cciss_read_capacity_16(h->ctlr, drv_index, 1, 1845 cciss_read_capacity_16(h->ctlr, drv_index,
1856 &total_size, &block_size); 1846 &total_size, &block_size);
1857 1847
1858 } else { 1848 } else {
1859 cciss_read_capacity(ctlr, drv_index, 1, 1849 cciss_read_capacity(ctlr, drv_index, &total_size, &block_size);
1860 &total_size, &block_size);
1861
1862 /* if read_capacity returns all F's this volume is >2TB */ 1850 /* if read_capacity returns all F's this volume is >2TB */
1863 /* in size so we switch to 16-byte CDB's for all */ 1851 /* in size so we switch to 16-byte CDB's for all */
1864 /* read/write ops */ 1852 /* read/write ops */
1865 if (total_size == 0xFFFFFFFFULL) { 1853 if (total_size == 0xFFFFFFFFULL) {
1866 cciss_read_capacity_16(ctlr, drv_index, 1, 1854 cciss_read_capacity_16(ctlr, drv_index,
1867 &total_size, &block_size); 1855 &total_size, &block_size);
1868 h->cciss_read = CCISS_READ_16; 1856 h->cciss_read = CCISS_READ_16;
1869 h->cciss_write = CCISS_WRITE_16; 1857 h->cciss_write = CCISS_WRITE_16;
@@ -1873,14 +1861,14 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time,
1873 } 1861 }
1874 } 1862 }
1875 1863
1876 cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, 1864 cciss_geometry_inquiry(ctlr, drv_index, total_size, block_size,
1877 inq_buff, drvinfo); 1865 inq_buff, drvinfo);
1878 drvinfo->block_size = block_size; 1866 drvinfo->block_size = block_size;
1879 drvinfo->nr_blocks = total_size + 1; 1867 drvinfo->nr_blocks = total_size + 1;
1880 1868
1881 cciss_get_device_descr(ctlr, drv_index, 1, drvinfo->vendor, 1869 cciss_get_device_descr(ctlr, drv_index, drvinfo->vendor,
1882 drvinfo->model, drvinfo->rev); 1870 drvinfo->model, drvinfo->rev);
1883 cciss_get_serial_no(ctlr, drv_index, 1, drvinfo->serial_no, 1871 cciss_get_serial_no(ctlr, drv_index, drvinfo->serial_no,
1884 sizeof(drvinfo->serial_no)); 1872 sizeof(drvinfo->serial_no));
1885 /* Save the lunid in case we deregister the disk, below. */ 1873 /* Save the lunid in case we deregister the disk, below. */
1886 memcpy(drvinfo->LunID, h->drv[drv_index]->LunID, 1874 memcpy(drvinfo->LunID, h->drv[drv_index]->LunID,
@@ -2674,7 +2662,7 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
2674} 2662}
2675 2663
2676static void cciss_geometry_inquiry(int ctlr, int logvol, 2664static void cciss_geometry_inquiry(int ctlr, int logvol,
2677 int withirq, sector_t total_size, 2665 sector_t total_size,
2678 unsigned int block_size, 2666 unsigned int block_size,
2679 InquiryData_struct *inq_buff, 2667 InquiryData_struct *inq_buff,
2680 drive_info_struct *drv) 2668 drive_info_struct *drv)
@@ -2685,14 +2673,8 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
2685 2673
2686 memset(inq_buff, 0, sizeof(InquiryData_struct)); 2674 memset(inq_buff, 0, sizeof(InquiryData_struct));
2687 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); 2675 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2688 if (withirq) 2676 return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buff,
2689 return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, 2677 sizeof(*inq_buff), 0xC1, scsi3addr, TYPE_CMD);
2690 inq_buff, sizeof(*inq_buff),
2691 0xC1, scsi3addr, TYPE_CMD);
2692 else
2693 return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff,
2694 sizeof(*inq_buff), 0xC1, scsi3addr,
2695 TYPE_CMD);
2696 if (return_code == IO_OK) { 2678 if (return_code == IO_OK) {
2697 if (inq_buff->data_byte[8] == 0xFF) { 2679 if (inq_buff->data_byte[8] == 0xFF) {
2698 printk(KERN_WARNING 2680 printk(KERN_WARNING
@@ -2725,7 +2707,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
2725} 2707}
2726 2708
2727static void 2709static void
2728cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size, 2710cciss_read_capacity(int ctlr, int logvol, sector_t *total_size,
2729 unsigned int *block_size) 2711 unsigned int *block_size)
2730{ 2712{
2731 ReadCapdata_struct *buf; 2713 ReadCapdata_struct *buf;
@@ -2739,14 +2721,8 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
2739 } 2721 }
2740 2722
2741 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); 2723 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2742 if (withirq) 2724 return_code = sendcmd_withirq(CCISS_READ_CAPACITY, ctlr, buf,
2743 return_code = sendcmd_withirq(CCISS_READ_CAPACITY, 2725 sizeof(ReadCapdata_struct), 0, scsi3addr, TYPE_CMD);
2744 ctlr, buf, sizeof(ReadCapdata_struct),
2745 0, scsi3addr, TYPE_CMD);
2746 else
2747 return_code = sendcmd(CCISS_READ_CAPACITY,
2748 ctlr, buf, sizeof(ReadCapdata_struct),
2749 0, scsi3addr, TYPE_CMD);
2750 if (return_code == IO_OK) { 2726 if (return_code == IO_OK) {
2751 *total_size = be32_to_cpu(*(__be32 *) buf->total_size); 2727 *total_size = be32_to_cpu(*(__be32 *) buf->total_size);
2752 *block_size = be32_to_cpu(*(__be32 *) buf->block_size); 2728 *block_size = be32_to_cpu(*(__be32 *) buf->block_size);
@@ -2758,8 +2734,8 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
2758 kfree(buf); 2734 kfree(buf);
2759} 2735}
2760 2736
2761static void 2737static void cciss_read_capacity_16(int ctlr, int logvol,
2762cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size, unsigned int *block_size) 2738 sector_t *total_size, unsigned int *block_size)
2763{ 2739{
2764 ReadCapdata_struct_16 *buf; 2740 ReadCapdata_struct_16 *buf;
2765 int return_code; 2741 int return_code;
@@ -2772,16 +2748,9 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
2772 } 2748 }
2773 2749
2774 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); 2750 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2775 if (withirq) { 2751 return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16,
2776 return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16, 2752 ctlr, buf, sizeof(ReadCapdata_struct_16),
2777 ctlr, buf, sizeof(ReadCapdata_struct_16), 2753 0, scsi3addr, TYPE_CMD);
2778 0, scsi3addr, TYPE_CMD);
2779 }
2780 else {
2781 return_code = sendcmd(CCISS_READ_CAPACITY_16,
2782 ctlr, buf, sizeof(ReadCapdata_struct_16),
2783 0, scsi3addr, TYPE_CMD);
2784 }
2785 if (return_code == IO_OK) { 2754 if (return_code == IO_OK) {
2786 *total_size = be64_to_cpu(*(__be64 *) buf->total_size); 2755 *total_size = be64_to_cpu(*(__be64 *) buf->total_size);
2787 *block_size = be32_to_cpu(*(__be32 *) buf->block_size); 2756 *block_size = be32_to_cpu(*(__be32 *) buf->block_size);
@@ -2822,13 +2791,13 @@ static int cciss_revalidate(struct gendisk *disk)
2822 return 1; 2791 return 1;
2823 } 2792 }
2824 if (h->cciss_read == CCISS_READ_10) { 2793 if (h->cciss_read == CCISS_READ_10) {
2825 cciss_read_capacity(h->ctlr, logvol, 1, 2794 cciss_read_capacity(h->ctlr, logvol,
2826 &total_size, &block_size); 2795 &total_size, &block_size);
2827 } else { 2796 } else {
2828 cciss_read_capacity_16(h->ctlr, logvol, 1, 2797 cciss_read_capacity_16(h->ctlr, logvol,
2829 &total_size, &block_size); 2798 &total_size, &block_size);
2830 } 2799 }
2831 cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, 2800 cciss_geometry_inquiry(h->ctlr, logvol, total_size, block_size,
2832 inq_buff, drv); 2801 inq_buff, drv);
2833 2802
2834 blk_queue_logical_block_size(drv->queue, drv->block_size); 2803 blk_queue_logical_block_size(drv->queue, drv->block_size);