* [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion
@ 2004-09-28 7:58 Jeremy Higdon
2004-09-28 10:48 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Higdon @ 2004-09-28 7:58 UTC (permalink / raw)
To: Emoore, linux-scsi
This patch lets you override the default queue depth for SCSI devices
attached through the mptfusion driver.
I moved some common code that I needed out of mpt_slave_configure()
into its own function.
signed-off-by: Jeremy Higdon <jeremy@sgi.com>
===== drivers/message/fusion/mptscsih.c 1.47 vs edited =====
--- 1.47/drivers/message/fusion/mptscsih.c 2004-09-03 02:08:35 -07:00
+++ edited/drivers/message/fusion/mptscsih.c 2004-09-28 00:51:07 -07:00
@@ -2887,6 +2887,40 @@
return;
}
+static void
+mptscsih_set_queue_depth(struct scsi_device *device, MPT_SCSI_HOST *hd, VirtDevice *pTarget, int qdepth)
+{
+ int max_depth;
+ int tagged;
+
+ if ( hd->is_spi ) {
+ if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
+ if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
+ max_depth = 1;
+ else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
+ && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
+ max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+ else
+ max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
+ } else {
+ /* error case - No Inq. Data */
+ max_depth = 1;
+ }
+ }
+ else
+ max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+
+ if (qdepth > max_depth)
+ qdepth = max_depth;
+ if (qdepth == 1)
+ tagged = 0;
+ else
+ tagged = MSG_SIMPLE_TAG;
+
+ scsi_adjust_queue_depth(device, tagged, qdepth);
+}
+
+
/*
* OS entry point to adjust the queue_depths on a per-device basis.
* Called once per device the bus scan. Use it to force the queue_depth
@@ -2936,24 +2970,7 @@
mptscsih_initTarget(hd, device->channel, device->id, device->lun,
device->inquiry, device->inquiry_len );
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_HIGH);
- if ( hd->is_spi ) {
- if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
- if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
- scsi_adjust_queue_depth(device, 0, 1);
- else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
- && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_HIGH);
- else
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_LOW);
- } else {
- /* error case - No Inq. Data */
- scsi_adjust_queue_depth(device, 0, 1);
- }
- }
+ mptscsih_set_queue_depth(device, hd, pTarget, MPT_SCSI_CMD_PER_DEV_HIGH);
dsprintk((MYIOC_s_INFO_FMT
"Queue depth=%d, tflags=%x\n",
@@ -2973,6 +2990,25 @@
return 0;
}
+static ssize_t
+mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+ int depth;
+ struct scsi_device *sdev = to_scsi_device(dev);
+ MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) sdev->host->hostdata;
+ VirtDevice *pTarget;
+
+ depth = simple_strtoul(buf, NULL, 0);
+ if (depth == 0)
+ return -EINVAL;
+ pTarget = hd->Targets[sdev->id];
+ if (pTarget == NULL)
+ return -EINVAL;
+ mptscsih_set_queue_depth(sdev, (MPT_SCSI_HOST *) sdev->host->hostdata,
+ pTarget, depth);
+ return count;
+}
+
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
@@ -3302,6 +3338,19 @@
return 1; /* currently means nothing really */
}
+static struct device_attribute mptscsih_queue_depth_attr = {
+ .attr = {
+ .name = "queue_depth",
+ .mode = S_IWUSR,
+ },
+ .store = mptscsih_store_queue_depth,
+};
+
+static struct device_attribute *mptscsih_dev_attrs[] = {
+ &mptscsih_queue_depth_attr,
+ NULL,
+};
+
static struct scsi_host_template driver_template = {
.proc_name = "mptscsih",
.proc_info = mptscsih_proc_info,
@@ -3322,6 +3371,7 @@
.max_sectors = 8192,
.cmd_per_lun = 7,
.use_clustering = ENABLE_CLUSTERING,
+ .sdev_attrs = mptscsih_dev_attrs,
};
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion
2004-09-28 7:58 [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion Jeremy Higdon
@ 2004-09-28 10:48 ` Christoph Hellwig
2004-09-28 11:43 ` Matthew Wilcox
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christoph Hellwig @ 2004-09-28 10:48 UTC (permalink / raw)
To: Jeremy Higdon; +Cc: Emoore, linux-scsi
Code looks good but some style nitpicks (often inherited from the original
code):
> +static void
> +mptscsih_set_queue_depth(struct scsi_device *device, MPT_SCSI_HOST *hd, VirtDevice *pTarget, int qdepth)
linebreaks after 80characters please.
> + if ( hd->is_spi ) {
if (hdis_spi) {
> + else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
> + && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
else if (!(pTarget->inq_data[0] & 0x1f) &&
(pTarget->minSyncFactor <= MPT_ULTRA160)
> + }
> + else
} else
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion
2004-09-28 10:48 ` Christoph Hellwig
@ 2004-09-28 11:43 ` Matthew Wilcox
2004-09-28 23:47 ` Jeremy Higdon
2004-09-29 0:14 ` Jeremy Higdon
2 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2004-09-28 11:43 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jeremy Higdon, Emoore, linux-scsi
On Tue, Sep 28, 2004 at 11:48:14AM +0100, Christoph Hellwig wrote:
> > + else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
> > + && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
>
>
> else if (!(pTarget->inq_data[0] & 0x1f) &&
> (pTarget->minSyncFactor <= MPT_ULTRA160)
I'm not sure about converting
if ((pTarget->inq_data[0] & 0x1f) == 0x00)
to
if (!(pTarget->inq_data[0] & 0x1f))
It really depends on the semantics -- in this case I think it's "this 5
bit field has the value 0", rather than "this field is not set". It's the
same reason I hate people using if (!strcmp()) -- it's not that strcmp()
failed, it's that it returned 0.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion
2004-09-28 10:48 ` Christoph Hellwig
2004-09-28 11:43 ` Matthew Wilcox
@ 2004-09-28 23:47 ` Jeremy Higdon
2004-09-29 0:14 ` Jeremy Higdon
2 siblings, 0 replies; 5+ messages in thread
From: Jeremy Higdon @ 2004-09-28 23:47 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Emoore, linux-scsi
On Tue, Sep 28, 2004 at 11:48:14AM +0100, Christoph Hellwig wrote:
>
> Code looks good but some style nitpicks (often inherited from the original
> code):
I cut and pasted, leaving original style intact. I was of the opinion
that I should not make style changes for one little piece of code.
I can add the line break.
jeremy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion
2004-09-28 10:48 ` Christoph Hellwig
2004-09-28 11:43 ` Matthew Wilcox
2004-09-28 23:47 ` Jeremy Higdon
@ 2004-09-29 0:14 ` Jeremy Higdon
2 siblings, 0 replies; 5+ messages in thread
From: Jeremy Higdon @ 2004-09-29 0:14 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Emoore, linux-scsi
New patch with some style issues fixed. I went ahead and moved the
logical "and" to the end of the line from the start of the next line.
I agreed with Matthew's reasoning on the comparison with 0.
Thanks for reviewing, Christoph.
signed-off-by: Jeremy Higdon <jeremy@sgi.com>
===== drivers/message/fusion/mptscsih.c 1.47 vs edited =====
--- 1.47/drivers/message/fusion/mptscsih.c 2004-09-03 02:08:35 -07:00
+++ edited/drivers/message/fusion/mptscsih.c 2004-09-28 16:58:39 -07:00
@@ -2887,6 +2887,40 @@
return;
}
+static void
+mptscsih_set_queue_depth(struct scsi_device *device, MPT_SCSI_HOST *hd,
+ VirtDevice *pTarget, int qdepth)
+{
+ int max_depth;
+ int tagged;
+
+ if ( hd->is_spi ) {
+ if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
+ if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
+ max_depth = 1;
+ else if (((pTarget->inq_data[0] & 0x1f) == 0x00) &&
+ (pTarget->minSyncFactor <= MPT_ULTRA160 ))
+ max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+ else
+ max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
+ } else {
+ /* error case - No Inq. Data */
+ max_depth = 1;
+ }
+ } else
+ max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+
+ if (qdepth > max_depth)
+ qdepth = max_depth;
+ if (qdepth == 1)
+ tagged = 0;
+ else
+ tagged = MSG_SIMPLE_TAG;
+
+ scsi_adjust_queue_depth(device, tagged, qdepth);
+}
+
+
/*
* OS entry point to adjust the queue_depths on a per-device basis.
* Called once per device the bus scan. Use it to force the queue_depth
@@ -2936,24 +2970,7 @@
mptscsih_initTarget(hd, device->channel, device->id, device->lun,
device->inquiry, device->inquiry_len );
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_HIGH);
- if ( hd->is_spi ) {
- if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
- if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
- scsi_adjust_queue_depth(device, 0, 1);
- else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
- && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_HIGH);
- else
- scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
- MPT_SCSI_CMD_PER_DEV_LOW);
- } else {
- /* error case - No Inq. Data */
- scsi_adjust_queue_depth(device, 0, 1);
- }
- }
+ mptscsih_set_queue_depth(device, hd, pTarget, MPT_SCSI_CMD_PER_DEV_HIGH);
dsprintk((MYIOC_s_INFO_FMT
"Queue depth=%d, tflags=%x\n",
@@ -2973,6 +2990,25 @@
return 0;
}
+static ssize_t
+mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+ int depth;
+ struct scsi_device *sdev = to_scsi_device(dev);
+ MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) sdev->host->hostdata;
+ VirtDevice *pTarget;
+
+ depth = simple_strtoul(buf, NULL, 0);
+ if (depth == 0)
+ return -EINVAL;
+ pTarget = hd->Targets[sdev->id];
+ if (pTarget == NULL)
+ return -EINVAL;
+ mptscsih_set_queue_depth(sdev, (MPT_SCSI_HOST *) sdev->host->hostdata,
+ pTarget, depth);
+ return count;
+}
+
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
@@ -3302,6 +3338,19 @@
return 1; /* currently means nothing really */
}
+static struct device_attribute mptscsih_queue_depth_attr = {
+ .attr = {
+ .name = "queue_depth",
+ .mode = S_IWUSR,
+ },
+ .store = mptscsih_store_queue_depth,
+};
+
+static struct device_attribute *mptscsih_dev_attrs[] = {
+ &mptscsih_queue_depth_attr,
+ NULL,
+};
+
static struct scsi_host_template driver_template = {
.proc_name = "mptscsih",
.proc_info = mptscsih_proc_info,
@@ -3322,6 +3371,7 @@
.max_sectors = 8192,
.cmd_per_lun = 7,
.use_clustering = ENABLE_CLUSTERING,
+ .sdev_attrs = mptscsih_dev_attrs,
};
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-09-29 0:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-28 7:58 [RFC PATCH 2.6.9-rc2] add ability to set device queue depth to mptfusion Jeremy Higdon
2004-09-28 10:48 ` Christoph Hellwig
2004-09-28 11:43 ` Matthew Wilcox
2004-09-28 23:47 ` Jeremy Higdon
2004-09-29 0:14 ` Jeremy Higdon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox