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.c211
1 files changed, 147 insertions, 64 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index f4206604db03..5413dc43b9f1 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -42,6 +42,7 @@
42#include <linux/kernel.h> 42#include <linux/kernel.h>
43#include <linux/list.h> 43#include <linux/list.h>
44#include <linux/string.h> 44#include <linux/string.h>
45#include <linux/stringify.h>
45#include <linux/slab.h> 46#include <linux/slab.h>
46#include <linux/interrupt.h> 47#include <linux/interrupt.h>
47#include <linux/fs.h> 48#include <linux/fs.h>
@@ -117,7 +118,8 @@ MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default
117 */ 118 */
118static int max_sectors = SBP2_MAX_SECTORS; 119static int max_sectors = SBP2_MAX_SECTORS;
119module_param(max_sectors, int, 0444); 120module_param(max_sectors, int, 0444);
120MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = 255)"); 121MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = "
122 __stringify(SBP2_MAX_SECTORS) ")");
121 123
122/* 124/*
123 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should 125 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should
@@ -135,18 +137,45 @@ module_param(exclusive_login, int, 0644);
135MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)"); 137MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)");
136 138
137/* 139/*
138 * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on 140 * If any of the following workarounds is required for your device to work,
139 * if your sbp2 device is not properly handling the SCSI inquiry command. 141 * please submit the kernel messages logged by sbp2 to the linux1394-devel
140 * This hack makes the inquiry look more like a typical MS Windows inquiry 142 * mailing list.
141 * by enforcing 36 byte inquiry and avoiding access to mode_sense page 8.
142 * 143 *
143 * If force_inquiry_hack=1 is required for your device to work, 144 * - 128kB max transfer
144 * please submit the logged sbp2_firmware_revision value of this device to 145 * Limit transfer size. Necessary for some old bridges.
145 * the linux1394-devel mailing list. 146 *
147 * - 36 byte inquiry
148 * When scsi_mod probes the device, let the inquiry command look like that
149 * from MS Windows.
150 *
151 * - skip mode page 8
152 * Suppress sending of mode_sense for mode page 8 if the device pretends to
153 * support the SCSI Primary Block commands instead of Reduced Block Commands.
154 *
155 * - fix capacity
156 * Tell sd_mod to correct the last sector number reported by read_capacity.
157 * Avoids access beyond actual disk limits on devices with an off-by-one bug.
158 * Don't use this with devices which don't have this bug.
159 *
160 * - override internal blacklist
161 * Instead of adding to the built-in blacklist, use only the workarounds
162 * specified in the module load parameter.
163 * Useful if a blacklist entry interfered with a non-broken device.
146 */ 164 */
165static int sbp2_default_workarounds;
166module_param_named(workarounds, sbp2_default_workarounds, int, 0644);
167MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
168 ", 128kB max transfer = " __stringify(SBP2_WORKAROUND_128K_MAX_TRANS)
169 ", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36)
170 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
171 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
172 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
173 ", or a combination)");
174
175/* legacy parameter */
147static int force_inquiry_hack; 176static int force_inquiry_hack;
148module_param(force_inquiry_hack, int, 0644); 177module_param(force_inquiry_hack, int, 0644);
149MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); 178MODULE_PARM_DESC(force_inquiry_hack, "Deprecated, use 'workarounds'");
150 179
151/* 180/*
152 * Export information about protocols/devices supported by this driver. 181 * Export information about protocols/devices supported by this driver.
@@ -266,14 +295,55 @@ static struct hpsb_protocol_driver sbp2_driver = {
266}; 295};
267 296
268/* 297/*
269 * List of device firmwares that require the inquiry hack. 298 * List of devices with known bugs.
270 * Yields a few false positives but did not break other devices so far. 299 *
300 * The firmware_revision field, masked with 0xffff00, is the best indicator
301 * for the type of bridge chip of a device. It yields a few false positives
302 * but this did not break correctly behaving devices so far.
271 */ 303 */
272static u32 sbp2_broken_inquiry_list[] = { 304static const struct {
273 0x00002800, /* Stefan Richter <stefanr@s5r6.in-berlin.de> */ 305 u32 firmware_revision;
274 /* DViCO Momobay CX-1 */ 306 u32 model_id;
275 0x00000200 /* Andreas Plesch <plesch@fas.harvard.edu> */ 307 unsigned workarounds;
276 /* QPS Fire DVDBurner */ 308} sbp2_workarounds_table[] = {
309 /* TSB42AA9 */ {
310 .firmware_revision = 0x002800,
311 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
312 SBP2_WORKAROUND_MODE_SENSE_8,
313 },
314 /* Initio bridges, actually only needed for some older ones */ {
315 .firmware_revision = 0x000200,
316 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
317 },
318 /* Symbios bridge */ {
319 .firmware_revision = 0xa0b800,
320 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
321 },
322 /*
323 * Note about the following Apple iPod blacklist entries:
324 *
325 * There are iPods (2nd gen, 3rd gen) with model_id==0. Since our
326 * matching logic treats 0 as a wildcard, we cannot match this ID
327 * without rewriting the matching routine. Fortunately these iPods
328 * do not feature the read_capacity bug according to one report.
329 * Read_capacity behaviour as well as model_id could change due to
330 * Apple-supplied firmware updates though.
331 */
332 /* iPod 4th generation */ {
333 .firmware_revision = 0x0a2700,
334 .model_id = 0x000021,
335 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
336 },
337 /* iPod mini */ {
338 .firmware_revision = 0x0a2700,
339 .model_id = 0x000023,
340 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
341 },
342 /* iPod Photo */ {
343 .firmware_revision = 0x0a2700,
344 .model_id = 0x00007e,
345 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
346 }
277}; 347};
278 348
279/************************************** 349/**************************************
@@ -765,12 +835,17 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
765 835
766 /* Register the status FIFO address range. We could use the same FIFO 836 /* Register the status FIFO address range. We could use the same FIFO
767 * for targets at different nodes. However we need different FIFOs per 837 * for targets at different nodes. However we need different FIFOs per
768 * target in order to support multi-unit devices. */ 838 * target in order to support multi-unit devices.
839 * The FIFO is located out of the local host controller's physical range
840 * but, if possible, within the posted write area. Status writes will
841 * then be performed as unified transactions. This slightly reduces
842 * bandwidth usage, and some Prolific based devices seem to require it.
843 */
769 scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace( 844 scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace(
770 &sbp2_highlevel, ud->ne->host, &sbp2_ops, 845 &sbp2_highlevel, ud->ne->host, &sbp2_ops,
771 sizeof(struct sbp2_status_block), sizeof(quadlet_t), 846 sizeof(struct sbp2_status_block), sizeof(quadlet_t),
772 ~0ULL, ~0ULL); 847 0x010000000000ULL, CSR1212_ALL_SPACE_END);
773 if (!scsi_id->status_fifo_addr) { 848 if (scsi_id->status_fifo_addr == ~0ULL) {
774 SBP2_ERR("failed to allocate status FIFO address range"); 849 SBP2_ERR("failed to allocate status FIFO address range");
775 goto failed_alloc; 850 goto failed_alloc;
776 } 851 }
@@ -1450,7 +1525,8 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1450 struct csr1212_dentry *dentry; 1525 struct csr1212_dentry *dentry;
1451 u64 management_agent_addr; 1526 u64 management_agent_addr;
1452 u32 command_set_spec_id, command_set, unit_characteristics, 1527 u32 command_set_spec_id, command_set, unit_characteristics,
1453 firmware_revision, workarounds; 1528 firmware_revision;
1529 unsigned workarounds;
1454 int i; 1530 int i;
1455 1531
1456 SBP2_DEBUG_ENTER(); 1532 SBP2_DEBUG_ENTER();
@@ -1506,12 +1582,8 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1506 case SBP2_FIRMWARE_REVISION_KEY: 1582 case SBP2_FIRMWARE_REVISION_KEY:
1507 /* Firmware revision */ 1583 /* Firmware revision */
1508 firmware_revision = kv->value.immediate; 1584 firmware_revision = kv->value.immediate;
1509 if (force_inquiry_hack) 1585 SBP2_DEBUG("sbp2_firmware_revision = %x",
1510 SBP2_INFO("sbp2_firmware_revision = %x", 1586 (unsigned int)firmware_revision);
1511 (unsigned int)firmware_revision);
1512 else
1513 SBP2_DEBUG("sbp2_firmware_revision = %x",
1514 (unsigned int)firmware_revision);
1515 break; 1587 break;
1516 1588
1517 default: 1589 default:
@@ -1519,41 +1591,44 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1519 } 1591 }
1520 } 1592 }
1521 1593
1522 /* This is the start of our broken device checking. We try to hack 1594 workarounds = sbp2_default_workarounds;
1523 * around oddities and known defects. */ 1595 if (force_inquiry_hack) {
1524 workarounds = 0x0; 1596 SBP2_WARN("force_inquiry_hack is deprecated. "
1597 "Use parameter 'workarounds' instead.");
1598 workarounds |= SBP2_WORKAROUND_INQUIRY_36;
1599 }
1525 1600
1526 /* If the vendor id is 0xa0b8 (Symbios vendor id), then we have a 1601 if (!(workarounds & SBP2_WORKAROUND_OVERRIDE))
1527 * bridge with 128KB max transfer size limitation. For sanity, we 1602 for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
1528 * only voice this when the current max_sectors setting 1603 if (sbp2_workarounds_table[i].firmware_revision &&
1529 * exceeds the 128k limit. By default, that is not the case. 1604 sbp2_workarounds_table[i].firmware_revision !=
1530 * 1605 (firmware_revision & 0xffff00))
1531 * It would be really nice if we could detect this before the scsi 1606 continue;
1532 * host gets initialized. That way we can down-force the 1607 if (sbp2_workarounds_table[i].model_id &&
1533 * max_sectors to account for it. That is not currently 1608 sbp2_workarounds_table[i].model_id != ud->model_id)
1534 * possible. */ 1609 continue;
1535 if ((firmware_revision & 0xffff00) == 1610 workarounds |= sbp2_workarounds_table[i].workarounds;
1536 SBP2_128KB_BROKEN_FIRMWARE && 1611 break;
1537 (max_sectors * 512) > (128*1024)) {
1538 SBP2_WARN("Node " NODE_BUS_FMT ": Bridge only supports 128KB max transfer size.",
1539 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid));
1540 SBP2_WARN("WARNING: Current max_sectors setting is larger than 128KB (%d sectors)!",
1541 max_sectors);
1542 workarounds |= SBP2_BREAKAGE_128K_MAX_TRANSFER;
1543 }
1544
1545 /* Check for a blacklisted set of devices that require us to force
1546 * a 36 byte host inquiry. This can be overriden as a module param
1547 * (to force all hosts). */
1548 for (i = 0; i < ARRAY_SIZE(sbp2_broken_inquiry_list); i++) {
1549 if ((firmware_revision & 0xffff00) ==
1550 sbp2_broken_inquiry_list[i]) {
1551 SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround",
1552 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid));
1553 workarounds |= SBP2_BREAKAGE_INQUIRY_HACK;
1554 break; /* No need to continue. */
1555 } 1612 }
1556 } 1613
1614 if (workarounds)
1615 SBP2_INFO("Workarounds for node " NODE_BUS_FMT ": 0x%x "
1616 "(firmware_revision 0x%06x, vendor_id 0x%06x,"
1617 " model_id 0x%06x)",
1618 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1619 workarounds, firmware_revision,
1620 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
1621 ud->model_id);
1622
1623 /* We would need one SCSI host template for each target to adjust
1624 * max_sectors on the fly, therefore warn only. */
1625 if (workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
1626 (max_sectors * 512) > (128 * 1024))
1627 SBP2_WARN("Node " NODE_BUS_FMT ": Bridge only supports 128KB "
1628 "max transfer size. WARNING: Current max_sectors "
1629 "setting is larger than 128KB (%d sectors)",
1630 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1631 max_sectors);
1557 1632
1558 /* If this is a logical unit directory entry, process the parent 1633 /* If this is a logical unit directory entry, process the parent
1559 * to get the values. */ 1634 * to get the values. */
@@ -2447,19 +2522,25 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2447 2522
2448 scsi_id->sdev = sdev; 2523 scsi_id->sdev = sdev;
2449 2524
2450 if (force_inquiry_hack || 2525 if (scsi_id->workarounds & SBP2_WORKAROUND_INQUIRY_36)
2451 scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) {
2452 sdev->inquiry_len = 36; 2526 sdev->inquiry_len = 36;
2453 sdev->skip_ms_page_8 = 1;
2454 }
2455 return 0; 2527 return 0;
2456} 2528}
2457 2529
2458static int sbp2scsi_slave_configure(struct scsi_device *sdev) 2530static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2459{ 2531{
2532 struct scsi_id_instance_data *scsi_id =
2533 (struct scsi_id_instance_data *)sdev->host->hostdata[0];
2534
2460 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2535 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
2461 sdev->use_10_for_rw = 1; 2536 sdev->use_10_for_rw = 1;
2462 sdev->use_10_for_ms = 1; 2537 sdev->use_10_for_ms = 1;
2538
2539 if (sdev->type == TYPE_DISK &&
2540 scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
2541 sdev->skip_ms_page_8 = 1;
2542 if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
2543 sdev->fix_capacity = 1;
2463 return 0; 2544 return 0;
2464} 2545}
2465 2546
@@ -2603,7 +2684,9 @@ static int sbp2_module_init(void)
2603 scsi_driver_template.cmd_per_lun = 1; 2684 scsi_driver_template.cmd_per_lun = 1;
2604 } 2685 }
2605 2686
2606 /* Set max sectors (module load option). Default is 255 sectors. */ 2687 if (sbp2_default_workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
2688 (max_sectors * 512) > (128 * 1024))
2689 max_sectors = 128 * 1024 / 512;
2607 scsi_driver_template.max_sectors = max_sectors; 2690 scsi_driver_template.max_sectors = max_sectors;
2608 2691
2609 /* Register our high level driver with 1394 stack */ 2692 /* Register our high level driver with 1394 stack */