Tejun Heo wrote:
..
Right. Also, we need to snoop some passthrough commands and
revalidate/reconfigure when configuration is explicitly changed.
Once the sysfs attr's actually work, I'll probably re-do my hdparm
stuff to detect use them when available, avoiding the need for libata
to snoop passthrough commands. But Jeff may (or not) want to snoop anyway.
As a workaround for now, Ric is using the ugly hack attached here.
Cheers
--- linux/drivers/scsi/libata-scsi.c.orig 2006-05-15 14:20:27.000000000 -0400
+++ linux/drivers/scsi/libata-scsi.c 2006-05-17 17:50:11.000000000 -0400
@@ -2479,6 +2479,18 @@
goto invalid_fld;
/*
+ * Filter: detect changes to WCE on the drive
+ */
+ if (tf->command == ATA_CMD_SET_FEATURES && (tf->feature & 0x7f) == 2) {
+ extern void sd_set_WCE(struct device *, int);
+ struct scsi_device *sdev = qc->scsicmd->device;
+ struct device *dev = &sdev->sdev_gendev;
+ unsigned int wce = tf->feature == 2 ? 1 : 0;
+ qc->dev->id[85] = (qc->dev->id[85] & ~(1 << 5)) | (wce << 5);
+ sd_set_WCE(dev, wce);
+ }
+
+ /*
* Set flags so that all registers will be written,
* and pass on write indication (used for PIO/DMA
* setup.)
--- linux/drivers/scsi/sd.c.orig 2005-12-12 18:50:34.000000000 -0500
+++ linux/drivers/scsi/sd.c 2006-03-06 15:09:44.000000000 -0500
@@ -1828,5 +1828,12 @@
unregister_blkdev(sd_major(i), "sd");
}
+void sd_set_WCE (struct device *dev, int off_on)
+{
+ struct scsi_disk *sdkp = dev_get_drvdata(dev);
+ sdkp->WCE = off_on;
+}
+EXPORT_SYMBOL(sd_set_WCE);
+
module_init(init_sd);
module_exit(exit_sd);