Skip to contentSkip to conversation

Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command

PATCH In review zhao, forrest 3 participants 3 messages Jun 12, 2006

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

PATCH v5 1/1 Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command

OK. I ported it to latest #upstream

drivers/scsi/libata-core.c +1 -0
index 40d1612..aaed5e5 100644
@@ -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);
 
drivers/scsi/libata-eh.c +3 -0
index 6285257..f82799e 100644
@@ -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] &&
drivers/scsi/libata-scsi.c +36 -0
index 5f90d8e..45a49be 100644
@@ -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));
+	}
+}
+
drivers/scsi/libata.h +0 -0
index 1dd496f..bdd4888 100644
@@ -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);

include/linux/ata.h +3 -0
index c494e1c..3671af8 100644
@@ -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 lore raw
Quoted 4 lines · forrest

OK. I ported it to latest #upstream

The patch looks good to me, but can you repost it with proper header message? If Jeff applies your patch w/ git-applymbox, "OK. I ported it to latest #upstream" will end up as the commit message body, which isn't so descriptive. Please write what the patch does above Signed-off-by. You can write 'ported to latest #upstream' kind of message below Signed-off-by separated w/ '---'. For example.

Subject: [PATCH] libata: Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command (v5)

[Explain what the patch does.]

Signed-off-by [....]

---

OK. I ported it to latest #upstream

[If the patch touches a lot of files, including diffstat -p1 result here would be nice.]

drivers/scsi/libata-core.c +0 -0
index 11df827..7efe991 100644
@@ -69,6 +69,8 @@ static void ata_dev_xfermask(struct ata_

....

Signature · 1 line
tejun
#2 lore raw
In reply to zhao, forrest
Quoted 3 lines · forrest

OK. I ported it to latest #upstream

Patch content looks OK, but

1) "OK. I ported it to latest #upstream" is not a good description :) I use the git-applymbox script to apply the patch, and the full technical patch description is copied from your email's message body directly into the Linux kernel changelog.

The appropriate place for comments like "OK. I ported it to latest #upstream" is following the "---" description terminator line. See Tejun's patches for an example :)

2) Both git-applymbox(1) and patch(1) fail to apply the patch:

[jgarzik@pretzel libata-dev]$ git-applymbox /g/tmp/mbox ~/info/signoff.txt 1 patch(es) to process.

Applying 'Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command'

fatal: corrupt patch at line 84

[jgarzik@pretzel libata-dev]$ patch -sp1 < /g/tmp/mbox
patch: **** malformed patch at line 144: *args,