Skip to contentSkip to conversation

Add sysfs queue depth override to qla2xxx

RFC PATCH In review Jeremy Higdon 2 participants 4 messages Sep 27, 2004 – Sep 28, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Add sysfs queue depth override to qla2xxx

This patch is to QLA2xxx version 8.00.00b15-k, and it allows users to override the default driver queue depth for a target by making the queue_depth sysfs attribute writeable.

I based this on the code in the 53c700 driver.

Andrew, please apply if it looks correct to you and James.

Let me know if you'd like me to regenerate against a different qla2xxx version.

thanks

Jeremy

===== drivers/scsi/qla2xxx/qla_os.c 1.41 vs edited =====

drivers/scsi/qla2xxx/qla_os.c +32 -0
@@ -159,6 +159,20 @@
 
 static int qla2x00_proc_info(struct Scsi_Host *, char *, char **,
     off_t, int, int);
+static ssize_t qla2xxx_store_queue_depth(struct device *dev, const char *buf, size_t count);
+
+static struct device_attribute qla2xxx_queue_depth_attr = {
+	.attr = {
+		.name =		"queue_depth",
+		.mode =		S_IWUSR,
+	},
+	.store = qla2xxx_store_queue_depth,
+};
+
+static struct device_attribute *qla2xxx_dev_attrs[] = {
+	&qla2xxx_queue_depth_attr,
+	NULL,
+};
 
 static struct scsi_host_template qla2x00_driver_template = {
 	.module			= THIS_MODULE,
@@ -184,6 +198,8 @@
 	 * which equates to 0x800000 sectors.
 	 */
 	.max_sectors		= 0xFFFF,
+
+	.sdev_attrs		= qla2xxx_dev_attrs,
 };
 
 static struct scsi_transport_template *qla2xxx_transport_template = NULL;
@@ -1797,6 +1813,22 @@
 	}
 
 	return (0);
+}
+
+static ssize_t
+qla2xxx_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+	int			 depth;
+	struct scsi_device	*sdev = to_scsi_device(dev);
+
+	if (sdev->tagged_supported) {
+		depth = simple_strtoul(buf, NULL, 0);
+		if (depth > ql2xmaxqdepth)
+			return -EINVAL;
+		scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth);
+		return count;
+	}
+	return 1;
 }
 
 /**
#1 lore raw
Quoted 6 lines · Jeremy Higdon

This patch is to QLA2xxx version 8.00.00b15-k, and it allows users to override the default driver queue depth for a target by making the queue_depth sysfs attribute writeable.

I based this on the code in the 53c700 driver.

Quoted 8 lines

Andrew, please apply if it looks correct to you and James.

Let me know if you'd like me to regenerate against a different qla2xxx version.

thanks

Jeremy

#2 lore raw
In reply to Jeremy Higdon
Quoted 6 lines · Jeremy Higdon

This patch is to QLA2xxx version 8.00.00b15-k, and it allows users to override the default driver queue depth for a target by making the queue_depth sysfs attribute writeable.

I based this on the code in the 53c700 driver.

Quoted 8 lines

Andrew, please apply if it looks correct to you and James.

Let me know if you'd like me to regenerate against a different qla2xxx version.

thanks

Jeremy

Found a bug in the patch. It returned an incorrect count if tagged_supported was not true.

===== drivers/scsi/qla2xxx/qla_os.c 1.41 vs edited =====

drivers/scsi/qla2xxx/qla_os.c +31 -0
@@ -159,6 +159,20 @@
 
 static int qla2x00_proc_info(struct Scsi_Host *, char *, char **,
     off_t, int, int);
+static ssize_t qla2xxx_store_queue_depth(struct device *dev, const char *buf, size_t count);
+
+static struct device_attribute qla2xxx_queue_depth_attr = {
+	.attr = {
+		.name =		"queue_depth",
+		.mode =		S_IWUSR,
+	},
+	.store = qla2xxx_store_queue_depth,
+};
+
+static struct device_attribute *qla2xxx_dev_attrs[] = {
+	&qla2xxx_queue_depth_attr,
+	NULL,
+};
 
 static struct scsi_host_template qla2x00_driver_template = {
 	.module			= THIS_MODULE,
@@ -184,6 +198,8 @@
 	 * which equates to 0x800000 sectors.
 	 */
 	.max_sectors		= 0xFFFF,
+
+	.sdev_attrs		= qla2xxx_dev_attrs,
 };
 
 static struct scsi_transport_template *qla2xxx_transport_template = NULL;
@@ -1797,6 +1813,21 @@
 	}
 
 	return (0);
+}
+
+static ssize_t
+qla2xxx_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+	int			 depth;
+	struct scsi_device	*sdev = to_scsi_device(dev);
+
+	if (sdev->tagged_supported) {
+		depth = simple_strtoul(buf, NULL, 0);
+		if (depth > ql2xmaxqdepth)
+			depth = ql2xmaxqdepth;
+		scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth);
+	}
+	return count;
 }
 
 /**
#3 lore raw
Quoted 12 lines · Jeremy Higdon
Quoted 11 lines · Jeremy Higdon

This patch is to QLA2xxx version 8.00.00b15-k, and it allows users to override the default driver queue depth for a target by making the queue_depth sysfs attribute writeable.

I based this on the code in the 53c700 driver.

Andrew, please apply if it looks correct to you and James.

Let me know if you'd like me to regenerate against a different qla2xxx version.

Quoted 6 lines
Quoted 3 lines

thanks

Jeremy

Found a bug in the patch. It returned an incorrect count if tagged_supported was not true.

I haven't had time to check yet, but I believe I remember queue depth being also a parameter that has to be communicated to the card's firmware for the sizing of an internal queue. Could you check ... and if that is the case, we'll have to communicate this change to the card as well.

James