libata: make gtf_filter per-dev
authorTejun Heo <tj@kernel.org>
Tue, 15 Sep 2009 19:17:28 +0000 (04:17 +0900)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 6 Oct 2009 04:26:27 +0000 (00:26 -0400)
Add ->gtf_filter to ata_device and set it to ata_acpi_gtf_filter when
initializing ata_link.  This is to allow quirks which apply different
gtf filters.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/libata-acpi.c
drivers/ata/libata-core.c
drivers/ata/libata.h
include/linux/libata.h

index 960c6a7caa83396c414a310eec6f5b47cb57f569..b0882cddfd4cae52856cabeb487ecc51c8cc81a3 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <acpi/acpi_bus.h>
 
-static unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT;
+unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT;
 module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644);
 MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-activate)");
 
@@ -603,10 +603,11 @@ static void ata_acpi_gtf_to_tf(struct ata_device *dev,
        tf->command = gtf->tf[6];       /* 0x1f7 */
 }
 
-static int ata_acpi_filter_tf(const struct ata_taskfile *tf,
+static int ata_acpi_filter_tf(struct ata_device *dev,
+                             const struct ata_taskfile *tf,
                              const struct ata_taskfile *ptf)
 {
-       if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_SETXFER) {
+       if (dev->gtf_filter & ATA_ACPI_FILTER_SETXFER) {
                /* libata doesn't use ACPI to configure transfer mode.
                 * It will only confuse device configuration.  Skip.
                 */
@@ -615,7 +616,7 @@ static int ata_acpi_filter_tf(const struct ata_taskfile *tf,
                        return 1;
        }
 
-       if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_LOCK) {
+       if (dev->gtf_filter & ATA_ACPI_FILTER_LOCK) {
                /* BIOS writers, sorry but we don't wanna lock
                 * features unless the user explicitly said so.
                 */
@@ -640,18 +641,18 @@ static int ata_acpi_filter_tf(const struct ata_taskfile *tf,
        if (tf->command == ATA_CMD_SET_FEATURES &&
            tf->feature == SETFEATURES_SATA_ENABLE) {
                /* inhibit enabling DIPM */
-               if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_DIPM &&
+               if (dev->gtf_filter & ATA_ACPI_FILTER_DIPM &&
                    tf->nsect == SATA_DIPM)
                        return 1;
 
                /* inhibit FPDMA non-zero offset */
-               if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_FPDMA_OFFSET &&
+               if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_OFFSET &&
                    (tf->nsect == SATA_FPDMA_OFFSET ||
                     tf->nsect == SATA_FPDMA_IN_ORDER))
                        return 1;
 
                /* inhibit FPDMA auto activation */
-               if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_FPDMA_AA &&
+               if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_AA &&
                    tf->nsect == SATA_FPDMA_AA)
                        return 1;
        }
@@ -705,7 +706,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,
                pptf = &ptf;
        }
 
-       if (!ata_acpi_filter_tf(&tf, pptf)) {
+       if (!ata_acpi_filter_tf(dev, &tf, pptf)) {
                rtf = tf;
                err_mask = ata_exec_internal(dev, &rtf, NULL,
                                             DMA_NONE, NULL, 0, 0);
index 0ddaf43d68c68dd89e2b36409487bf57b5f54686..b525a0981348dfd16aa04ac2db5077a00c84a9a8 100644 (file)
@@ -5591,6 +5591,9 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
 
                dev->link = link;
                dev->devno = dev - link->device;
+#ifdef CONFIG_ATA_ACPI
+               dev->gtf_filter = ata_acpi_gtf_filter;
+#endif
                ata_dev_init(dev);
        }
 }
index be8e2628f82cd7805fe1c42220eab28ffa835a62..823e630963627f75e807a3af793457c8cbf84d6f 100644 (file)
@@ -118,6 +118,8 @@ extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm);
 
 /* libata-acpi.c */
 #ifdef CONFIG_ATA_ACPI
+extern unsigned int ata_acpi_gtf_filter;
+
 extern void ata_acpi_associate_sata_port(struct ata_port *ap);
 extern void ata_acpi_associate(struct ata_host *host);
 extern void ata_acpi_dissociate(struct ata_host *host);
index aa52794d2a03e007178d48edbb15b9de7597c4b1..87698640c091e1d91379ea01050242ec884645da 100644 (file)
@@ -598,6 +598,7 @@ struct ata_device {
 #ifdef CONFIG_ATA_ACPI
        acpi_handle             acpi_handle;
        union acpi_object       *gtf_cache;
+       unsigned int            gtf_filter;
 #endif
        /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
        u64                     n_sectors;      /* size of device, if ATA */