aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/sbp2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r--drivers/ieee1394/sbp2.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 1eda11abeb1e..2b889d91e673 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -51,6 +51,7 @@
51 * Grep for inline FIXME comments below. 51 * Grep for inline FIXME comments below.
52 */ 52 */
53 53
54#include <linux/blkdev.h>
54#include <linux/compiler.h> 55#include <linux/compiler.h>
55#include <linux/delay.h> 56#include <linux/delay.h>
56#include <linux/device.h> 57#include <linux/device.h>
@@ -127,17 +128,21 @@ MODULE_PARM_DESC(serialize_io, "Serialize requests coming from SCSI drivers "
127 "(default = Y, faster but buggy = N)"); 128 "(default = Y, faster but buggy = N)");
128 129
129/* 130/*
130 * Bump up max_sectors if you'd like to support very large sized 131 * Adjust max_sectors if you'd like to influence how many sectors each SCSI
131 * transfers. Please note that some older sbp2 bridge chips are broken for 132 * command can transfer at most. Please note that some older SBP-2 bridge
132 * transfers greater or equal to 128KB. Default is a value of 255 133 * chips are broken for transfers greater or equal to 128KB, therefore
133 * sectors, or just under 128KB (at 512 byte sector size). I can note that 134 * max_sectors used to be a safe 255 sectors for many years. We now have a
134 * the Oxsemi sbp2 chipsets have no problems supporting very large 135 * default of 0 here which means that we let the SCSI stack choose a limit.
135 * transfer sizes. 136 *
137 * The SBP2_WORKAROUND_128K_MAX_TRANS flag, if set either in the workarounds
138 * module parameter or in the sbp2_workarounds_table[], will override the
139 * value of max_sectors. We should use sbp2_workarounds_table[] to cover any
140 * bridge chip which becomes known to need the 255 sectors limit.
136 */ 141 */
137static int sbp2_max_sectors = SBP2_MAX_SECTORS; 142static int sbp2_max_sectors;
138module_param_named(max_sectors, sbp2_max_sectors, int, 0444); 143module_param_named(max_sectors, sbp2_max_sectors, int, 0444);
139MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported " 144MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported "
140 "(default = " __stringify(SBP2_MAX_SECTORS) ")"); 145 "(default = 0 = use SCSI stack's default)");
141 146
142/* 147/*
143 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should 148 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should
@@ -1451,7 +1456,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1451 struct sbp2_fwhost_info *hi, 1456 struct sbp2_fwhost_info *hi,
1452 struct sbp2_command_info *cmd, 1457 struct sbp2_command_info *cmd,
1453 unsigned int scsi_use_sg, 1458 unsigned int scsi_use_sg,
1454 struct scatterlist *sgpnt, 1459 struct scatterlist *sg,
1455 u32 orb_direction, 1460 u32 orb_direction,
1456 enum dma_data_direction dma_dir) 1461 enum dma_data_direction dma_dir)
1457{ 1462{
@@ -1461,12 +1466,12 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1461 1466
1462 /* special case if only one element (and less than 64KB in size) */ 1467 /* special case if only one element (and less than 64KB in size) */
1463 if ((scsi_use_sg == 1) && 1468 if ((scsi_use_sg == 1) &&
1464 (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { 1469 (sg_dma_len(sg) <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
1465 1470
1466 cmd->dma_size = sgpnt[0].length; 1471 cmd->dma_size = sg_dma_len(sg);
1467 cmd->dma_type = CMD_DMA_PAGE; 1472 cmd->dma_type = CMD_DMA_PAGE;
1468 cmd->cmd_dma = dma_map_page(hi->host->device.parent, 1473 cmd->cmd_dma = dma_map_page(hi->host->device.parent,
1469 sg_page(&sgpnt[0]), sgpnt[0].offset, 1474 sg_page(sg), sg->offset,
1470 cmd->dma_size, cmd->dma_dir); 1475 cmd->dma_size, cmd->dma_dir);
1471 1476
1472 orb->data_descriptor_lo = cmd->cmd_dma; 1477 orb->data_descriptor_lo = cmd->cmd_dma;
@@ -1477,11 +1482,11 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1477 &cmd->scatter_gather_element[0]; 1482 &cmd->scatter_gather_element[0];
1478 u32 sg_count, sg_len; 1483 u32 sg_count, sg_len;
1479 dma_addr_t sg_addr; 1484 dma_addr_t sg_addr;
1480 int i, count = dma_map_sg(hi->host->device.parent, sgpnt, 1485 int i, count = dma_map_sg(hi->host->device.parent, sg,
1481 scsi_use_sg, dma_dir); 1486 scsi_use_sg, dma_dir);
1482 1487
1483 cmd->dma_size = scsi_use_sg; 1488 cmd->dma_size = scsi_use_sg;
1484 cmd->sge_buffer = sgpnt; 1489 cmd->sge_buffer = sg;
1485 1490
1486 /* use page tables (s/g) */ 1491 /* use page tables (s/g) */
1487 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); 1492 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
@@ -1489,9 +1494,9 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1489 1494
1490 /* loop through and fill out our SBP-2 page tables 1495 /* loop through and fill out our SBP-2 page tables
1491 * (and split up anything too large) */ 1496 * (and split up anything too large) */
1492 for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { 1497 for (i = 0, sg_count = 0; i < count; i++, sg = sg_next(sg)) {
1493 sg_len = sg_dma_len(sgpnt); 1498 sg_len = sg_dma_len(sg);
1494 sg_addr = sg_dma_address(sgpnt); 1499 sg_addr = sg_dma_address(sg);
1495 while (sg_len) { 1500 while (sg_len) {
1496 sg_element[sg_count].segment_base_lo = sg_addr; 1501 sg_element[sg_count].segment_base_lo = sg_addr;
1497 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { 1502 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
@@ -1521,11 +1526,10 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
1521 unchar *scsi_cmd, 1526 unchar *scsi_cmd,
1522 unsigned int scsi_use_sg, 1527 unsigned int scsi_use_sg,
1523 unsigned int scsi_request_bufflen, 1528 unsigned int scsi_request_bufflen,
1524 void *scsi_request_buffer, 1529 struct scatterlist *sg,
1525 enum dma_data_direction dma_dir) 1530 enum dma_data_direction dma_dir)
1526{ 1531{
1527 struct sbp2_fwhost_info *hi = lu->hi; 1532 struct sbp2_fwhost_info *hi = lu->hi;
1528 struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
1529 struct sbp2_command_orb *orb = &cmd->command_orb; 1533 struct sbp2_command_orb *orb = &cmd->command_orb;
1530 u32 orb_direction; 1534 u32 orb_direction;
1531 1535
@@ -1560,7 +1564,7 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
1560 orb->data_descriptor_lo = 0x0; 1564 orb->data_descriptor_lo = 0x0;
1561 orb->misc |= ORB_SET_DIRECTION(1); 1565 orb->misc |= ORB_SET_DIRECTION(1);
1562 } else 1566 } else
1563 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt, 1567 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sg,
1564 orb_direction, dma_dir); 1568 orb_direction, dma_dir);
1565 1569
1566 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb)); 1570 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
@@ -1650,7 +1654,6 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
1650 void (*done)(struct scsi_cmnd *)) 1654 void (*done)(struct scsi_cmnd *))
1651{ 1655{
1652 unchar *scsi_cmd = (unchar *)SCpnt->cmnd; 1656 unchar *scsi_cmd = (unchar *)SCpnt->cmnd;
1653 unsigned int request_bufflen = scsi_bufflen(SCpnt);
1654 struct sbp2_command_info *cmd; 1657 struct sbp2_command_info *cmd;
1655 1658
1656 cmd = sbp2util_allocate_command_orb(lu, SCpnt, done); 1659 cmd = sbp2util_allocate_command_orb(lu, SCpnt, done);
@@ -1658,7 +1661,7 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
1658 return -EIO; 1661 return -EIO;
1659 1662
1660 sbp2_create_command_orb(lu, cmd, scsi_cmd, scsi_sg_count(SCpnt), 1663 sbp2_create_command_orb(lu, cmd, scsi_cmd, scsi_sg_count(SCpnt),
1661 request_bufflen, scsi_sglist(SCpnt), 1664 scsi_bufflen(SCpnt), scsi_sglist(SCpnt),
1662 SCpnt->sc_data_direction); 1665 SCpnt->sc_data_direction);
1663 sbp2_link_orb_command(lu, cmd); 1666 sbp2_link_orb_command(lu, cmd);
1664 1667
@@ -1987,6 +1990,8 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
1987 sdev->skip_ms_page_8 = 1; 1990 sdev->skip_ms_page_8 = 1;
1988 if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) 1991 if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
1989 sdev->fix_capacity = 1; 1992 sdev->fix_capacity = 1;
1993 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1994 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
1990 return 0; 1995 return 0;
1991} 1996}
1992 1997
@@ -2093,9 +2098,6 @@ static int sbp2_module_init(void)
2093 sbp2_shost_template.cmd_per_lun = 1; 2098 sbp2_shost_template.cmd_per_lun = 1;
2094 } 2099 }
2095 2100
2096 if (sbp2_default_workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
2097 (sbp2_max_sectors * 512) > (128 * 1024))
2098 sbp2_max_sectors = 128 * 1024 / 512;
2099 sbp2_shost_template.max_sectors = sbp2_max_sectors; 2101 sbp2_shost_template.max_sectors = sbp2_max_sectors;
2100 2102
2101 hpsb_register_highlevel(&sbp2_highlevel); 2103 hpsb_register_highlevel(&sbp2_highlevel);