* [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)
@ 2006-06-12 4:01 zhao, forrest
2006-06-12 4:18 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: zhao, forrest @ 2006-06-12 4:01 UTC (permalink / raw)
To: jeff; +Cc: linux-ide
This patch makes libata "Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE
command" and clean the things up(e.g. revalidate and rescan).
Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
---
It's against #upstream
drivers/scsi/libata-core.c | 1 +
drivers/scsi/libata-eh.c | 3 +++
drivers/scsi/libata-scsi.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/scsi/libata.h | 1 +
include/linux/ata.h | 3 +++
5 files changed, 44 insertions(+), 0 deletions(-)
f36bb7625e283ba15b02af220bae0682f33d883f
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 40d1612..aaed5e5 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -5185,6 +5185,7 @@ static void ata_host_init(struct ata_por
INIT_WORK(&ap->port_task, NULL, NULL);
INIT_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap);
+ INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan, ap);
INIT_LIST_HEAD(&ap->eh_done_q);
init_waitqueue_head(&ap->eh_wait_q);
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 6285257..f82799e 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -1554,6 +1554,9 @@ static int ata_eh_revalidate_and_attach(
if (rc)
break;
+ /* schedule the scsi_rescan_device() here */
+ queue_work(ata_aux_wq, &(ap->scsi_rescan_task));
+
ehc->i.action &= ~ATA_EH_REVALIDATE;
} else if (dev->class == ATA_DEV_UNKNOWN &&
ehc->tries[dev->devno] &&
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 5f90d8e..45a49be 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1306,6 +1306,17 @@ static void ata_scsi_qc_complete(struct
u8 *cdb = cmd->cmnd;
int need_sense = (qc->err_mask != 0);
+ /* We snoop the SET_FEATURES - Write Cache ON/OFF command, and
+ * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
+ * cache
+ */
+ if (!need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) &&
+ ((qc->tf.feature == SETFEATURES_WC_ON) ||
+ (qc->tf.feature == SETFEATURES_WC_OFF))) {
+ qc->ap->eh_info.action |= ATA_EH_REVALIDATE;
+ ata_port_schedule_eh(qc->ap);
+ }
+
/* For ATA pass thru (SAT) commands, generate a sense block if
* user mandated it or if there's an error. Note that if we
* generate because the user forced us to, a check condition
@@ -2992,3 +3003,28 @@ static int ata_scsi_user_scan(struct Scs
return rc;
}
+
+/**
+ * ata_scsi_dev_rescan - initiate scsi_rescan_device()
+ * @data: Pointer to ATA port to perform scsi_rescan_device()
+ *
+ * After ATA pass thru (SAT) commands are executed successfully,
+ * libata need to propagate the changes to SCSI layer.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep).
+ */
+void ata_scsi_dev_rescan(void *data)
+{
+ struct ata_port *ap = data;
+ struct ata_device *dev;
+ unsigned int i;
+
+ for (i = 0; i < ATA_MAX_DEVICES; i++) {
+ dev = &ap->device[i];
+
+ if (ata_dev_enabled(dev))
+ scsi_rescan_device(&(dev->sdev->sdev_gendev));
+ }
+}
+
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 1dd496f..bdd4888 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -104,6 +104,7 @@ extern void ata_scsi_rbuf_fill(struct at
unsigned int (*actor) (struct ata_scsi_args *args,
u8 *rbuf, unsigned int buflen));
extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
+extern void ata_scsi_dev_rescan(void *data);
/* libata-eh.c */
extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index c494e1c..3671af8 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -181,6 +181,9 @@ enum {
XFER_PIO_0 = 0x08,
XFER_PIO_SLOW = 0x00,
+ SETFEATURES_WC_ON = 0x02, /* Enable write cache */
+ SETFEATURES_WC_OFF = 0x82, /* Disable write cache */
+
/* ATAPI stuff */
ATAPI_PKT_DMA = (1 << 0),
ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
--
1.2.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)
2006-06-12 4:01 [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5) zhao, forrest
@ 2006-06-12 4:18 ` Jeff Garzik
2006-06-12 4:21 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2006-06-12 4:18 UTC (permalink / raw)
To: zhao, forrest; +Cc: linux-ide
zhao, forrest wrote:
> This patch makes libata "Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE
> command" and clean the things up(e.g. revalidate and rescan).
>
> Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
applied
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)
2006-06-12 4:18 ` Jeff Garzik
@ 2006-06-12 4:21 ` Jeff Garzik
2006-06-12 4:23 ` zhao, forrest
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2006-06-12 4:21 UTC (permalink / raw)
To: zhao, forrest; +Cc: linux-ide
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
Jeff Garzik wrote:
> zhao, forrest wrote:
>> This patch makes libata "Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE
>> command" and clean the things up(e.g. revalidate and rescan).
>>
>> Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
>
> applied
Um... please make sure all your patches build!
I had to apply the attached patch to get it to work.
Jeff
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 331 bytes --]
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 39e6b77..61eea57 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -522,6 +522,7 @@ struct ata_port {
struct work_struct port_task;
struct work_struct hotplug_task;
+ struct work_struct scsi_rescan_task;
unsigned int hsm_task_state;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)
2006-06-12 4:21 ` Jeff Garzik
@ 2006-06-12 4:23 ` zhao, forrest
2006-06-12 4:43 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: zhao, forrest @ 2006-06-12 4:23 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-ide
On Mon, 2006-06-12 at 00:21 -0400, Jeff Garzik wrote:
> Jeff Garzik wrote:
> > zhao, forrest wrote:
> >> This patch makes libata "Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE
> >> command" and clean the things up(e.g. revalidate and rescan).
> >>
> >> Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
> >
> > applied
>
> Um... please make sure all your patches build!
>
> I had to apply the attached patch to get it to work.
>
> Jeff
>
>
>
> Plain text document attachment (patch)
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index 39e6b77..61eea57 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -522,6 +522,7 @@ struct ata_port {
>
> struct work_struct port_task;
> struct work_struct hotplug_task;
> + struct work_struct scsi_rescan_task;
>
> unsigned int hsm_task_state;
Oh, sorry for that. I had tested the patch before sending it out.
But don't know why this line is missing. Do I need to re-send the whole
patch?
BTW. the disk of my develop machine for SATA was corrupted 10 minutes
ago after I applied the AHCI suspend/resume patch against #upstream, I
had to recover it painfully. Haven't expected that it can cause such bad
damage :(
Forrest
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)
2006-06-12 4:23 ` zhao, forrest
@ 2006-06-12 4:43 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2006-06-12 4:43 UTC (permalink / raw)
To: zhao, forrest; +Cc: linux-ide
zhao, forrest wrote:
> On Mon, 2006-06-12 at 00:21 -0400, Jeff Garzik wrote:
>> Jeff Garzik wrote:
>>> zhao, forrest wrote:
>>>> This patch makes libata "Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE
>>>> command" and clean the things up(e.g. revalidate and rescan).
>>>>
>>>> Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
>>> applied
>> Um... please make sure all your patches build!
>>
>> I had to apply the attached patch to get it to work.
>>
>> Jeff
>>
>>
>>
>> Plain text document attachment (patch)
>> diff --git a/include/linux/libata.h b/include/linux/libata.h
>> index 39e6b77..61eea57 100644
>> --- a/include/linux/libata.h
>> +++ b/include/linux/libata.h
>> @@ -522,6 +522,7 @@ struct ata_port {
>>
>> struct work_struct port_task;
>> struct work_struct hotplug_task;
>> + struct work_struct scsi_rescan_task;
>>
>> unsigned int hsm_task_state;
>
> Oh, sorry for that. I had tested the patch before sending it out.
> But don't know why this line is missing. Do I need to re-send the whole
> patch?
Nope, I applied it, then applied a build fix.
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-12 4:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-12 4:01 [PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5) zhao, forrest
2006-06-12 4:18 ` Jeff Garzik
2006-06-12 4:21 ` Jeff Garzik
2006-06-12 4:23 ` zhao, forrest
2006-06-12 4:43 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).