sbp2: update 36byte inquiry workaround (fix compatibility regression) Since about Linux 2.6.14, sbp2's inquiry workaround did not work anymore due to changes in the SCSI layer. Update it to become effective again. Testing one of the two known affected bridges has shown that skip_ms_page_8 is required as well. Also, make force_inquiry_hack tunable via /sys/module/sbp2/parameters. Signed-off-by: Stefan Richter --- drivers/ieee1394/sbp2.c | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-) Index: linux-2.6.16-rc2/drivers/ieee1394/sbp2.c =================================================================== --- linux-2.6.16-rc2.orig/drivers/ieee1394/sbp2.c 2006-02-11 22:04:50.000000000 +0100 +++ linux-2.6.16-rc2/drivers/ieee1394/sbp2.c 2006-02-11 22:05:33.000000000 +0100 @@ -137,15 +137,15 @@ MODULE_PARM_DESC(exclusive_login, "Exclu /* * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on * if your sbp2 device is not properly handling the SCSI inquiry command. - * This hack makes the inquiry look more like a typical MS Windows - * inquiry. + * This hack makes the inquiry look more like a typical MS Windows inquiry + * by enforcing 36 byte inquiry and avoiding access to mode_sense page 8. * * If force_inquiry_hack=1 is required for your device to work, * please submit the logged sbp2_firmware_revision value of this device to * the linux1394-devel mailing list. */ static int force_inquiry_hack; -module_param(force_inquiry_hack, int, 0444); +module_param(force_inquiry_hack, int, 0644); MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); /* @@ -265,18 +265,17 @@ static struct hpsb_protocol_driver sbp2_ }, }; - -/* List of device firmware's that require a forced 36 byte inquiry. */ +/* + * List of device firmwares that require the inquiry hack. + * Yields a few false positives but did not break other devices so far. + */ static u32 sbp2_broken_inquiry_list[] = { - 0x00002800, /* Stefan Richter */ + 0x00002800, /* Stefan Richter */ /* DViCO Momobay CX-1 */ 0x00000200 /* Andreas Plesch */ /* QPS Fire DVDBurner */ }; -#define NUM_BROKEN_INQUIRY_DEVS \ - (sizeof(sbp2_broken_inquiry_list)/sizeof(*sbp2_broken_inquiry_list)) - /************************************** * General utility functions **************************************/ @@ -1553,7 +1552,7 @@ static void sbp2_parse_unit_directory(st /* Check for a blacklisted set of devices that require us to force * a 36 byte host inquiry. This can be overriden as a module param * (to force all hosts). */ - for (i = 0; i < NUM_BROKEN_INQUIRY_DEVS; i++) { + for (i = 0; i < ARRAY_SIZE(sbp2_broken_inquiry_list); i++) { if ((firmware_revision & 0xffff00) == sbp2_broken_inquiry_list[i]) { SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround", @@ -1993,18 +1992,6 @@ static int sbp2_send_command(struct scsi } /* - * The scsi stack sends down a request_bufflen which does not match the - * length field in the scsi cdb. This causes some sbp2 devices to - * reject this inquiry command. Fix the request_bufflen. - */ - if (*cmd == INQUIRY) { - if (force_inquiry_hack || scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) - request_bufflen = cmd[4] = 0x24; - else - request_bufflen = cmd[4]; - } - - /* * Now actually fill in the comamnd orb and sbp2 s/g list */ sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, @@ -2460,7 +2447,16 @@ static void sbp2scsi_complete_command(st static int sbp2scsi_slave_alloc(struct scsi_device *sdev) { - ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; + struct scsi_id_instance_data *scsi_id = + (struct scsi_id_instance_data *)sdev->host->hostdata[0]; + + scsi_id->sdev = sdev; + + if (force_inquiry_hack || + scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) { + sdev->inquiry_len = 36; + sdev->skip_ms_page_8 = 1; + } return 0; }