From: Miquel van Smoorenburg <miquels@cistron.nl>

Make 3w-xxxx.c queue_depth sysfs parameter writable, adjust initial queue
nr_requests to 2*queue_depth

Signed-off-by: Miquel van Smoorenburg <miquels@cistron.nl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/scsi/3w-xxxx.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff -puN drivers/scsi/3w-xxxx.c~3w-xxxxc-queue-depth drivers/scsi/3w-xxxx.c
--- 25/drivers/scsi/3w-xxxx.c~3w-xxxxc-queue-depth	2004-09-02 15:52:32.601238736 -0700
+++ 25-akpm/drivers/scsi/3w-xxxx.c	2004-09-02 15:52:32.608237672 -0700
@@ -184,6 +184,8 @@
    1.26.00.039 - Fix bug in tw_chrdev_ioctl() polling code.
                  Fix data_buffer_length usage in tw_chrdev_ioctl().
                  Update contact information.
+   1.02.00.XXX - Miquel van Smoorenburg - make queue_depth sysfs parameter
+                 writable, adjust initial queue nr_requests to 2*queue_depth
 */
 
 #include <linux/module.h>
@@ -3388,8 +3390,6 @@ int tw_slave_configure(Scsi_Device *SDpt
 {
 	int max_cmds;
 
-	dprintk(KERN_WARNING "3w-xxxx: tw_slave_configure()\n");
-
 	if (cmds_per_lun) {
 		max_cmds = cmds_per_lun;
 		if (max_cmds > TW_MAX_CMDS_PER_LUN)
@@ -3399,6 +3399,10 @@ int tw_slave_configure(Scsi_Device *SDpt
 	}
 	scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, max_cmds);
 
+	/* make sure blockdev queue depth is at least 2 * scsi depth */
+	if (SDptr->request_queue->nr_requests < 2 * max_cmds)
+		SDptr->request_queue->nr_requests = 2 * max_cmds;
+
 	return 0;
 } /* End tw_slave_configure() */
 
@@ -3482,6 +3486,34 @@ void tw_unmask_command_interrupt(TW_Devi
 	outl(control_reg_value, control_reg_addr);
 } /* End tw_unmask_command_interrupt() */
 
+static ssize_t
+tw_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+	int depth;
+
+	struct scsi_device *SDp = to_scsi_device(dev);
+	if (sscanf(buf, "%d", &depth) != 1)
+		return -EINVAL;
+	if (depth < 1 || depth > TW_MAX_CMDS_PER_LUN)
+		return -EINVAL;
+	scsi_adjust_queue_depth(SDp, MSG_ORDERED_TAG, depth);
+
+	return count;
+}
+
+static struct device_attribute tw_queue_depth_attr = {
+	.attr = {
+		.name =		"queue_depth",
+		.mode =		S_IWUSR,
+	},
+	.store = tw_store_queue_depth,
+};
+
+static struct device_attribute *tw_dev_attrs[] = {
+	&tw_queue_depth_attr,
+	NULL,
+};
+
 static Scsi_Host_Template driver_template = {
 	.proc_name		= "3w-xxxx",
 	.proc_info		= tw_scsi_proc_info,
@@ -3499,6 +3531,7 @@ static Scsi_Host_Template driver_templat
 	.max_sectors		= TW_MAX_SECTORS,
 	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,	
 	.use_clustering		= ENABLE_CLUSTERING,
+	.sdev_attrs		= tw_dev_attrs,
 	.emulated		= 1
 };
 #include "scsi_module.c"
_