From 3100d49d3cd236443faae9d81137c81b22d36003 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sun, 16 Sep 2012 20:53:43 +0200 Subject: sata_promise: fix hardreset lockdep error sata_promise's pdc_hard_reset_port() needs to serialize because it flips a port-specific bit in controller register that's shared by all ports. The code takes the ata host lock for this, but that's broken because an interrupt may arrive on our irq during the hard reset sequence, and that too will take the ata host lock. With lockdep enabled a big nasty warning is seen. Fixed by adding private state to the ata host structure, containing a second lock used only for serializing the hard reset sequences. This eliminated the lockdep warnings both on my test rig and on the original reporter's machine. Signed-off-by: Mikael Pettersson Tested-by: Adko Branil Cc: stable@vger.kernel.org Signed-off-by: Jeff Garzik --- drivers/ata/sata_promise.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 489c81768321..fb0dd87f8893 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c @@ -147,6 +147,10 @@ struct pdc_port_priv { dma_addr_t pkt_dma; }; +struct pdc_host_priv { + spinlock_t hard_reset_lock; +}; + static int pdc_sata_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); static int pdc_sata_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); @@ -801,9 +805,10 @@ static void pdc_hard_reset_port(struct ata_port *ap) void __iomem *host_mmio = ap->host->iomap[PDC_MMIO_BAR]; void __iomem *pcictl_b1_mmio = host_mmio + PDC_PCI_CTL + 1; unsigned int ata_no = pdc_ata_port_to_ata_no(ap); + struct pdc_host_priv *hpriv = ap->host->private_data; u8 tmp; - spin_lock(&ap->host->lock); + spin_lock(&hpriv->hard_reset_lock); tmp = readb(pcictl_b1_mmio); tmp &= ~(0x10 << ata_no); @@ -814,7 +819,7 @@ static void pdc_hard_reset_port(struct ata_port *ap) writeb(tmp, pcictl_b1_mmio); readb(pcictl_b1_mmio); /* flush */ - spin_unlock(&ap->host->lock); + spin_unlock(&hpriv->hard_reset_lock); } static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class, @@ -1182,6 +1187,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev, const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; const struct ata_port_info *ppi[PDC_MAX_PORTS]; struct ata_host *host; + struct pdc_host_priv *hpriv; void __iomem *host_mmio; int n_ports, i, rc; int is_sataii_tx4; @@ -1218,6 +1224,11 @@ static int pdc_ata_init_one(struct pci_dev *pdev, dev_err(&pdev->dev, "failed to allocate host\n"); return -ENOMEM; } + hpriv = devm_kzalloc(&pdev->dev, sizeof *hpriv, GFP_KERNEL); + if (!hpriv) + return -ENOMEM; + spin_lock_init(&hpriv->hard_reset_lock); + host->private_data = hpriv; host->iomap = pcim_iomap_table(pdev); is_sataii_tx4 = pdc_is_sataii_tx4(pi->flags); -- cgit v1.2.3 From d9904344fc4052fbe7e4dc137eba0dcdadf326bd Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 18 Sep 2012 17:48:01 +0200 Subject: ata_piix: reenable MS Virtual PC guests An earlier commit cd006086fa5d91414d8ff9ff2b78fbb593878e3c ("ata_piix: defer disks to the Hyper-V drivers by default") broke MS Virtual PC guests. Hyper-V guests and Virtual PC guests have nearly identical DMI info. As a result the driver does currently ignore the emulated hardware in Virtual PC guests and defers the handling to hv_blkvsc. Since Virtual PC does not offer paravirtualized drivers no disks will be found in the guest. One difference in the DMI info is the product version. This patch adds a match for MS Virtual PC 2007 and "unignores" the emulated hardware. This was reported for openSuSE 12.1 in bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=737532 Here is a detailed list of DMI info from example guests: hwinfo --bios: virtual pc guest: System Info: #1 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "VS2005R2" Serial: "3178-9905-1533-4840-9282-0569-59" UUID: undefined, but settable Wake-up: 0x06 (Power Switch) Board Info: #2 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "5.0" Serial: "3178-9905-1533-4840-9282-0569-59" Chassis Info: #3 Manufacturer: "Microsoft Corporation" Version: "5.0" Serial: "3178-9905-1533-4840-9282-0569-59" Asset Tag: "7188-3705-6309-9738-9645-0364-00" Type: 0x03 (Desktop) Bootup State: 0x03 (Safe) Power Supply State: 0x03 (Safe) Thermal State: 0x01 (Other) Security Status: 0x01 (Other) win2k8 guest: System Info: #1 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "7.0" Serial: "9106-3420-9819-5495-1514-2075-48" UUID: undefined, but settable Wake-up: 0x06 (Power Switch) Board Info: #2 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "7.0" Serial: "9106-3420-9819-5495-1514-2075-48" Chassis Info: #3 Manufacturer: "Microsoft Corporation" Version: "7.0" Serial: "9106-3420-9819-5495-1514-2075-48" Asset Tag: "7076-9522-6699-1042-9501-1785-77" Type: 0x03 (Desktop) Bootup State: 0x03 (Safe) Power Supply State: 0x03 (Safe) Thermal State: 0x01 (Other) Security Status: 0x01 (Other) win2k12 guest: System Info: #1 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "7.0" Serial: "8179-1954-0187-0085-3868-2270-14" UUID: undefined, but settable Wake-up: 0x06 (Power Switch) Board Info: #2 Manufacturer: "Microsoft Corporation" Product: "Virtual Machine" Version: "7.0" Serial: "8179-1954-0187-0085-3868-2270-14" Chassis Info: #3 Manufacturer: "Microsoft Corporation" Version: "7.0" Serial: "8179-1954-0187-0085-3868-2270-14" Asset Tag: "8374-0485-4557-6331-0620-5845-25" Type: 0x03 (Desktop) Bootup State: 0x03 (Safe) Power Supply State: 0x03 (Safe) Thermal State: 0x01 (Other) Security Status: 0x01 (Other) Signed-off-by: Olaf Hering Signed-off-by: Jeff Garzik --- drivers/ata/ata_piix.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index ef773e12af79..bec35f491cb9 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -1585,12 +1585,31 @@ static void piix_ignore_devices_quirk(struct ata_host *host) }, { } /* terminate list */ }; - const struct dmi_system_id *dmi = dmi_first_match(ignore_hyperv); + static const struct dmi_system_id allow_virtual_pc[] = { + { + /* In MS Virtual PC guests the DMI ident is nearly + * identical to a Hyper-V guest. One difference is the + * product version which is used here to identify + * a Virtual PC guest. This entry allows ata_piix to + * drive the emulated hardware. + */ + .ident = "MS Virtual PC 2007", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, + "Microsoft Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), + DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"), + }, + }, + { } /* terminate list */ + }; + const struct dmi_system_id *ignore = dmi_first_match(ignore_hyperv); + const struct dmi_system_id *allow = dmi_first_match(allow_virtual_pc); - if (dmi && prefer_ms_hyperv) { + if (ignore && !allow && prefer_ms_hyperv) { host->flags |= ATA_HOST_IGNORE_ATA; dev_info(host->dev, "%s detected, ATA device ignore set\n", - dmi->ident); + ignore->ident); } #endif } -- cgit v1.2.3 From abf8f2b877846573f0e6498883fe43f08be5696d Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 9 Oct 2012 17:53:12 +0200 Subject: pata_cs5536: add quirk for broken udma I am working on a device which uses the cs5536 pata driver. There are some broken hardware revisions out in the field, which can be detected via DMI. On older versions with an embedded BIOS I used libata.dma=0 to disable dma completely. Now we are switching to a coreboot/seabios based BIOS where we have DMI support and so I think its a good idea to get rid of all those hacky kernel parameters as the same image is used other devices where libata.dma=0 is not a good idea. Signed-off-by: Christian Gmeiner Signed-off-by: Jeff Garzik --- drivers/ata/pata_cs5536.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c index dec1b6c4b351..0448860a2077 100644 --- a/drivers/ata/pata_cs5536.c +++ b/drivers/ata/pata_cs5536.c @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef CONFIG_X86_32 #include @@ -80,6 +81,21 @@ enum { IDE_ETC_UDMA_MASK = 0xc0, }; +/* Some Bachmann OT200 devices have a non working UDMA support due a + * missing resistor. + */ +static const struct dmi_system_id udma_quirk_dmi_table[] = { + { + .ident = "Bachmann electronic OT200", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Bachmann electronic"), + DMI_MATCH(DMI_PRODUCT_NAME, "OT200"), + DMI_MATCH(DMI_PRODUCT_VERSION, "1") + }, + }, + { } +}; + static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) { if (unlikely(use_msr)) { @@ -242,9 +258,23 @@ static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &cs5536_port_ops, }; - const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + static const struct ata_port_info no_udma_info = { + .flags = ATA_FLAG_SLAVE_POSS, + .pio_mask = ATA_PIO4, + .port_ops = &cs5536_port_ops, + }; + + + const struct ata_port_info *ppi[2]; u32 cfg; + if (dmi_check_system(udma_quirk_dmi_table)) + ppi[0] = &no_udma_info; + else + ppi[0] = &info; + + ppi[1] = &ata_dummy_port_info; + if (use_msr) printk(KERN_ERR DRV_NAME ": Using MSR regs instead of PCI\n"); -- cgit v1.2.3 From 8b34f2cc99df7275652ac6b522a767d750a02b3a Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 22 Oct 2012 16:55:50 +0800 Subject: pata_rdc: remove unused variable in rdc_init_one() The variable port_flags is initialized but never used otherwise, so remove the unused variable. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/pata_rdc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_rdc.c b/drivers/ata/pata_rdc.c index 32a3499e83e7..e71f998dd90d 100644 --- a/drivers/ata/pata_rdc.c +++ b/drivers/ata/pata_rdc.c @@ -327,7 +327,6 @@ static int __devinit rdc_init_one(struct pci_dev *pdev, struct device *dev = &pdev->dev; struct ata_port_info port_info[2]; const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; - unsigned long port_flags; struct ata_host *host; struct rdc_host_priv *hpriv; int rc; @@ -337,8 +336,6 @@ static int __devinit rdc_init_one(struct pci_dev *pdev, port_info[0] = rdc_port_info; port_info[1] = rdc_port_info; - port_flags = port_info[0].flags; - /* enable device and prepare host */ rc = pcim_enable_device(pdev); if (rc) -- cgit v1.2.3 From 7f0658d37f2d9a3a251f5b0bf1877eb9ec593f04 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 22 Oct 2012 16:58:30 +0800 Subject: sata_inic162x: remove unused variable in inic_scr_read() The variable addr is initialized but never used otherwise, so remove the unused variable. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/sata_inic162x.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index dc35f4d42b8b..1e6827c89429 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c @@ -273,12 +273,10 @@ static void inic_reset_port(void __iomem *port_base) static int inic_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val) { void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR; - void __iomem *addr; if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) return -EINVAL; - addr = scr_addr + scr_map[sc_reg] * 4; *val = readl(scr_addr + scr_map[sc_reg] * 4); /* this controller has stuck DIAG.N, ignore it */ -- cgit v1.2.3 From 10083d7ac038da3062e6a496d883728afb388892 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 22 Oct 2012 17:02:23 +0800 Subject: sata_sil24: remove unused variable from sata_sil24.c The variable addr is initialized but never used otherwise, so remove the unused variable. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/sata_sil24.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index a5f2a563a26a..59f0d630d634 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c @@ -506,8 +506,6 @@ static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val) void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { - void __iomem *addr; - addr = scr_addr + sil24_scr_map[sc_reg] * 4; *val = readl(scr_addr + sil24_scr_map[sc_reg] * 4); return 0; } @@ -519,8 +517,6 @@ static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val) void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { - void __iomem *addr; - addr = scr_addr + sil24_scr_map[sc_reg] * 4; writel(val, scr_addr + sil24_scr_map[sc_reg] * 4); return 0; } -- cgit v1.2.3 From 7c26deab5abfb86f6c71f1bbf685072cbc0e5fea Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Thu, 25 Oct 2012 21:19:12 +0400 Subject: sata_sx4: pdc20621_{ata|host}_sg() do not need 'tf' parameter ... because those functions don't use this parameter. While at it, correctly align 'total_len' parameter. Signed-off-by: Sergei Shtylyov Signed-off-by: Jeff Garzik --- drivers/ata/sata_sx4.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index 122605593166..7b7127a58f51 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c @@ -315,9 +315,8 @@ static int pdc_port_start(struct ata_port *ap) return 0; } -static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, - unsigned int portno, - unsigned int total_len) +static inline void pdc20621_ata_sg(u8 *buf, unsigned int portno, + unsigned int total_len) { u32 addr; unsigned int dw = PDC_DIMM_APKT_PRD >> 2; @@ -337,9 +336,8 @@ static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, buf32[dw], buf32[dw + 1]); } -static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, - unsigned int portno, - unsigned int total_len) +static inline void pdc20621_host_sg(u8 *buf, unsigned int portno, + unsigned int total_len) { u32 addr; unsigned int dw = PDC_DIMM_HPKT_PRD >> 2; @@ -486,10 +484,10 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) /* * Build ATA, host DMA packets */ - pdc20621_host_sg(&qc->tf, &pp->dimm_buf[0], portno, total_len); + pdc20621_host_sg(&pp->dimm_buf[0], portno, total_len); pdc20621_host_pkt(&qc->tf, &pp->dimm_buf[0], portno); - pdc20621_ata_sg(&qc->tf, &pp->dimm_buf[0], portno, total_len); + pdc20621_ata_sg(&pp->dimm_buf[0], portno, total_len); i = pdc20621_ata_pkt(&qc->tf, qc->dev->devno, &pp->dimm_buf[0], portno); if (qc->tf.flags & ATA_TFLAG_LBA48) -- cgit v1.2.3 From 121650a55535e4a3f152a30ee42f26e815eff714 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Thu, 1 Nov 2012 20:59:28 +0300 Subject: sata_highbank: use ATA_BUSY ahci_highbank_hardreset() uses bare number for the BSY bit of the ATA status register, despite it is #define'd in Signed-off-by: Sergei Shtylyov Signed-off-by: Jeff Garzik --- drivers/ata/sata_highbank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c index 400bf1c3e982..75c0f3cc4a8a 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c @@ -213,7 +213,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class, /* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init(link->device, &tf); - tf.command = 0x80; + tf.command = ATA_BUSY; ata_tf_to_fis(&tf, 0, 0, d2h_fis); do { -- cgit v1.2.3 From 52bd4978c61bc23e619a4287a3d30814c97b5d4e Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Thu, 1 Nov 2012 18:28:36 +0300 Subject: pata_arasan_cf: declare/use more local variables in arasan_cf_dma_start() 'acdev->qc', 'acdev->qc->ap', and 'acdev->qc->tf' expressions are used multiple times in this function, so it makes sense to use the local variables for them. Signed-off-by: Sergei Shtylyov Acked-by: Viresh Kumar Signed-off-by: Jeff Garzik --- drivers/ata/pata_arasan_cf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index 371fd2c698b7..9764e80f9320 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c @@ -674,13 +674,16 @@ void arasan_cf_error_handler(struct ata_port *ap) static void arasan_cf_dma_start(struct arasan_cf_dev *acdev) { + struct ata_queued_cmd *qc = acdev->qc; + struct ata_port *ap = qc->ap; + struct ata_taskfile *tf = &qc->tf; u32 xfer_ctr = readl(acdev->vbase + XFER_CTR) & ~XFER_DIR_MASK; - u32 write = acdev->qc->tf.flags & ATA_TFLAG_WRITE; + u32 write = tf->flags & ATA_TFLAG_WRITE; xfer_ctr |= write ? XFER_WRITE : XFER_READ; writel(xfer_ctr, acdev->vbase + XFER_CTR); - acdev->qc->ap->ops->sff_exec_command(acdev->qc->ap, &acdev->qc->tf); + ap->ops->sff_exec_command(ap, tf); ata_sff_queue_work(&acdev->work); } -- cgit v1.2.3 From a52f514c911978dee418f19d1d0103e3bc25fa62 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 28 Oct 2012 01:05:40 -0700 Subject: ata: Convert dev_printk(KERN_ to dev_( dev_ calls take less code than dev_printk(KERN_ and reducing object size is good. Coalesce formats for easier grep. Signed-off-by: Joe Perches Signed-off-by: Jeff Garzik --- drivers/ata/pata_cmd64x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 7ba01415b676..2949cfc2dd31 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c @@ -474,14 +474,14 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) /* check for enabled ports */ pci_read_config_byte(pdev, CNTRL, ®); if (!port_ok) - dev_printk(KERN_NOTICE, &pdev->dev, "Mobility Bridge detected, ignoring CNTRL port enable/disable\n"); + dev_notice(&pdev->dev, "Mobility Bridge detected, ignoring CNTRL port enable/disable\n"); if (port_ok && cntrl_ch0_ok && !(reg & CNTRL_CH0)) { - dev_printk(KERN_NOTICE, &pdev->dev, "Primary port is disabled\n"); + dev_notice(&pdev->dev, "Primary port is disabled\n"); ppi[0] = &ata_dummy_port_info; } if (port_ok && !(reg & CNTRL_CH1)) { - dev_printk(KERN_NOTICE, &pdev->dev, "Secondary port is disabled\n"); + dev_notice(&pdev->dev, "Secondary port is disabled\n"); ppi[1] = &ata_dummy_port_info; } -- cgit v1.2.3 From 0d0cdb028f9d9771e2b346038707734121f906e3 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Mon, 26 Nov 2012 13:55:25 +0800 Subject: libata: restore acpi disable functionality Commit 66fa7f215 "libata-acpi: improve ACPI disabling" introdcued the behaviour of disabling ATA ACPI if ata_acpi_on_devcfg failed the 2nd time, but commit 30dcf76ac dropped this behaviour and this caused problem for Dimitris Damigos, where his laptop can not resume correctly. The bugzilla page for it is: https://bugzilla.kernel.org/show_bug.cgi?id=49331 The problem is, ata_dev_push_id will fail the 2nd time it is invoked, and due to disabling ACPI code is dropped, ata_acpi_on_devcfg which calls ata_dev_push_id will keep failing and eventually made the device disabled. This patch restores the original behaviour, if acpi failed the 2nd time, disable acpi functionality for the device(and we do not event need to add a debug message for this as it is still there ;-). Reported-by: Dimitris Damigos Signed-off-by: Aaron Lu Cc: Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 4 ++++ include/linux/libata.h | 1 + 2 files changed, 5 insertions(+) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 5b0ba3f20edc..ef01ac07502e 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -76,6 +76,9 @@ acpi_handle ata_dev_acpi_handle(struct ata_device *dev) acpi_integer adr; struct ata_port *ap = dev->link->ap; + if (dev->flags & ATA_DFLAG_ACPI_DISABLED) + return NULL; + if (ap->flags & ATA_FLAG_ACPI_SATA) { if (!sata_pmp_attached(ap)) adr = SATA_ADR(ap->port_no, NO_PORT_MULT); @@ -945,6 +948,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev) return rc; } + dev->flags |= ATA_DFLAG_ACPI_DISABLED; ata_dev_warn(dev, "ACPI: failed the second time, disabled\n"); /* We can safely continue if no _GTF command has been executed diff --git a/include/linux/libata.h b/include/linux/libata.h index 77eeeda2b6e2..e931c9ad1078 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -163,6 +163,7 @@ enum { ATA_DFLAG_DA = (1 << 26), /* device supports Device Attention */ ATA_DFLAG_DEVSLP = (1 << 27), /* device supports Device Sleep */ + ATA_DFLAG_ACPI_DISABLED = (1 << 28), /* ACPI for the device is disabled */ ATA_DEV_UNKNOWN = 0, /* unknown device */ ATA_DEV_ATA = 1, /* ATA device */ -- cgit v1.2.3 From de90cd71f68e947d3bd6c3f2ef5731ead010a768 Mon Sep 17 00:00:00 2001 From: Shane Huang Date: Sun, 18 Nov 2012 04:44:41 +0800 Subject: libata: check SATA_SETTINGS log with HW Feature Ctrl NCQ capability was used to check availability of SATA Settings page from Identify Device Data Log, which contains DevSlp timing variables. It does not work on some HDDs and leads to error messages. IDENTIFY word 78 bit 5(Hardware Feature Control) should be used. Quoting SATA spec 3.1: If Hardware Feature Control is supported, then: a) IDENTIFY DEVICE data word 78 bit 5 (see 13.2.1.18) shall be set to one; b) the SET FEATURES Select Hardware Feature Control subcommand shall be supported (see 13.3.8); c) page 08h of the Identify Device Data log (see 13.7.7) shall be supported; This patch is not tested on SATA HDD with DevSlp supported. Reported-by: Borislav Petkov Signed-off-by: Shane Huang Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 3 +-- include/linux/ata.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f46fbd3bd3fb..caffe73c1e4a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2330,9 +2330,8 @@ int ata_dev_configure(struct ata_device *dev) /* Obtain SATA Settings page from Identify Device Data Log, * which contains DevSlp timing variables etc. - * Exclude old devices with ata_id_has_ncq() */ - if (ata_id_has_ncq(dev->id)) { + if (ata_id_has_hw_feature_ctrl(dev->id)) { err_mask = ata_read_log_page(dev, ATA_LOG_SATA_ID_DEV_DATA, ATA_LOG_SATA_SETTINGS, diff --git a/include/linux/ata.h b/include/linux/ata.h index 408da9502177..18cbb93fdbca 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -593,6 +593,7 @@ static inline int ata_is_data(u8 prot) #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4)) #define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)) +#define ata_id_has_hw_feature_ctrl(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 5)) static inline bool ata_id_has_hipm(const u16 *id) { -- cgit v1.2.3 From f295be25a0e7baeda1e338aeb84e16b727b78c7e Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 30 Nov 2012 11:56:04 +0100 Subject: ata_piix: re-order code and remove prototypes Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Kyungmin Park Signed-off-by: Jeff Garzik --- drivers/ata/ata_piix.c | 419 +++++++++++++++++++++++-------------------------- 1 file changed, 198 insertions(+), 221 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index bec35f491cb9..acffcf0b3ad3 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -164,28 +164,6 @@ struct piix_host_priv { void __iomem *sidpr; }; -static int piix_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent); -static void piix_remove_one(struct pci_dev *pdev); -static int piix_pata_prereset(struct ata_link *link, unsigned long deadline); -static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev); -static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev); -static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev); -static int ich_pata_cable_detect(struct ata_port *ap); -static u8 piix_vmw_bmdma_status(struct ata_port *ap); -static int piix_sidpr_scr_read(struct ata_link *link, - unsigned int reg, u32 *val); -static int piix_sidpr_scr_write(struct ata_link *link, - unsigned int reg, u32 val); -static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, - unsigned hints); -static bool piix_irq_check(struct ata_port *ap); -static int piix_port_start(struct ata_port *ap); -#ifdef CONFIG_PM -static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); -static int piix_pci_device_resume(struct pci_dev *pdev); -#endif - static unsigned int in_module_init = 1; static const struct pci_device_id piix_pci_tbl[] = { @@ -342,64 +320,6 @@ static const struct pci_device_id piix_pci_tbl[] = { { } /* terminate list */ }; -static struct pci_driver piix_pci_driver = { - .name = DRV_NAME, - .id_table = piix_pci_tbl, - .probe = piix_init_one, - .remove = piix_remove_one, -#ifdef CONFIG_PM - .suspend = piix_pci_device_suspend, - .resume = piix_pci_device_resume, -#endif -}; - -static struct scsi_host_template piix_sht = { - ATA_BMDMA_SHT(DRV_NAME), -}; - -static struct ata_port_operations piix_sata_ops = { - .inherits = &ata_bmdma32_port_ops, - .sff_irq_check = piix_irq_check, - .port_start = piix_port_start, -}; - -static struct ata_port_operations piix_pata_ops = { - .inherits = &piix_sata_ops, - .cable_detect = ata_cable_40wire, - .set_piomode = piix_set_piomode, - .set_dmamode = piix_set_dmamode, - .prereset = piix_pata_prereset, -}; - -static struct ata_port_operations piix_vmw_ops = { - .inherits = &piix_pata_ops, - .bmdma_status = piix_vmw_bmdma_status, -}; - -static struct ata_port_operations ich_pata_ops = { - .inherits = &piix_pata_ops, - .cable_detect = ich_pata_cable_detect, - .set_dmamode = ich_set_dmamode, -}; - -static struct device_attribute *piix_sidpr_shost_attrs[] = { - &dev_attr_link_power_management_policy, - NULL -}; - -static struct scsi_host_template piix_sidpr_sht = { - ATA_BMDMA_SHT(DRV_NAME), - .shost_attrs = piix_sidpr_shost_attrs, -}; - -static struct ata_port_operations piix_sidpr_sata_ops = { - .inherits = &piix_sata_ops, - .hardreset = sata_std_hardreset, - .scr_read = piix_sidpr_scr_read, - .scr_write = piix_sidpr_scr_write, - .set_lpm = piix_sidpr_set_lpm, -}; - static const struct piix_map_db ich5_map_db = { .mask = 0x7, .port_enable = 0x3, @@ -504,147 +424,6 @@ static const struct piix_map_db *piix_map_db_table[] = { [ich8_sata_snb] = &ich8_map_db, }; -static struct ata_port_info piix_port_info[] = { - [piix_pata_mwdma] = /* PIIX3 MWDMA only */ - { - .flags = PIIX_PATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ - .port_ops = &piix_pata_ops, - }, - - [piix_pata_33] = /* PIIX4 at 33MHz */ - { - .flags = PIIX_PATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ - .udma_mask = ATA_UDMA2, - .port_ops = &piix_pata_ops, - }, - - [ich_pata_33] = /* ICH0 - ICH at 33Mhz*/ - { - .flags = PIIX_PATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, /* Check: maybe MWDMA0 is ok */ - .udma_mask = ATA_UDMA2, - .port_ops = &ich_pata_ops, - }, - - [ich_pata_66] = /* ICH controllers up to 66MHz */ - { - .flags = PIIX_PATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, /* MWDMA0 is broken on chip */ - .udma_mask = ATA_UDMA4, - .port_ops = &ich_pata_ops, - }, - - [ich_pata_100] = - { - .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, - .udma_mask = ATA_UDMA5, - .port_ops = &ich_pata_ops, - }, - - [ich_pata_100_nomwdma1] = - { - .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2_ONLY, - .udma_mask = ATA_UDMA5, - .port_ops = &ich_pata_ops, - }, - - [ich5_sata] = - { - .flags = PIIX_SATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [ich6_sata] = - { - .flags = PIIX_SATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [ich6m_sata] = - { - .flags = PIIX_SATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [ich8_sata] = - { - .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [ich8_2port_sata] = - { - .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [tolapai_sata] = - { - .flags = PIIX_SATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [ich8m_apple_sata] = - { - .flags = PIIX_SATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - - [piix_pata_vmw] = - { - .flags = PIIX_PATA_FLAGS, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ - .udma_mask = ATA_UDMA2, - .port_ops = &piix_vmw_ops, - }, - - /* - * some Sandybridge chipsets have broken 32 mode up to now, - * see https://bugzilla.kernel.org/show_bug.cgi?id=40592 - */ - [ich8_sata_snb] = - { - .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR | PIIX_FLAG_PIO16, - .pio_mask = ATA_PIO4, - .mwdma_mask = ATA_MWDMA2, - .udma_mask = ATA_UDMA6, - .port_ops = &piix_sata_ops, - }, - -}; - static struct pci_bits piix_enable_bits[] = { { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */ @@ -1261,6 +1040,193 @@ static u8 piix_vmw_bmdma_status(struct ata_port *ap) return ata_bmdma_status(ap) & ~ATA_DMA_ERR; } +static struct scsi_host_template piix_sht = { + ATA_BMDMA_SHT(DRV_NAME), +}; + +static struct ata_port_operations piix_sata_ops = { + .inherits = &ata_bmdma32_port_ops, + .sff_irq_check = piix_irq_check, + .port_start = piix_port_start, +}; + +static struct ata_port_operations piix_pata_ops = { + .inherits = &piix_sata_ops, + .cable_detect = ata_cable_40wire, + .set_piomode = piix_set_piomode, + .set_dmamode = piix_set_dmamode, + .prereset = piix_pata_prereset, +}; + +static struct ata_port_operations piix_vmw_ops = { + .inherits = &piix_pata_ops, + .bmdma_status = piix_vmw_bmdma_status, +}; + +static struct ata_port_operations ich_pata_ops = { + .inherits = &piix_pata_ops, + .cable_detect = ich_pata_cable_detect, + .set_dmamode = ich_set_dmamode, +}; + +static struct device_attribute *piix_sidpr_shost_attrs[] = { + &dev_attr_link_power_management_policy, + NULL +}; + +static struct scsi_host_template piix_sidpr_sht = { + ATA_BMDMA_SHT(DRV_NAME), + .shost_attrs = piix_sidpr_shost_attrs, +}; + +static struct ata_port_operations piix_sidpr_sata_ops = { + .inherits = &piix_sata_ops, + .hardreset = sata_std_hardreset, + .scr_read = piix_sidpr_scr_read, + .scr_write = piix_sidpr_scr_write, + .set_lpm = piix_sidpr_set_lpm, +}; + +static struct ata_port_info piix_port_info[] = { + [piix_pata_mwdma] = /* PIIX3 MWDMA only */ + { + .flags = PIIX_PATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ + .port_ops = &piix_pata_ops, + }, + + [piix_pata_33] = /* PIIX4 at 33MHz */ + { + .flags = PIIX_PATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ + .udma_mask = ATA_UDMA2, + .port_ops = &piix_pata_ops, + }, + + [ich_pata_33] = /* ICH0 - ICH at 33Mhz*/ + { + .flags = PIIX_PATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, /* Check: maybe MWDMA0 is ok */ + .udma_mask = ATA_UDMA2, + .port_ops = &ich_pata_ops, + }, + + [ich_pata_66] = /* ICH controllers up to 66MHz */ + { + .flags = PIIX_PATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, /* MWDMA0 is broken on chip */ + .udma_mask = ATA_UDMA4, + .port_ops = &ich_pata_ops, + }, + + [ich_pata_100] = + { + .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, + .udma_mask = ATA_UDMA5, + .port_ops = &ich_pata_ops, + }, + + [ich_pata_100_nomwdma1] = + { + .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2_ONLY, + .udma_mask = ATA_UDMA5, + .port_ops = &ich_pata_ops, + }, + + [ich5_sata] = + { + .flags = PIIX_SATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [ich6_sata] = + { + .flags = PIIX_SATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [ich6m_sata] = + { + .flags = PIIX_SATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [ich8_sata] = + { + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [ich8_2port_sata] = + { + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [tolapai_sata] = + { + .flags = PIIX_SATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [ich8m_apple_sata] = + { + .flags = PIIX_SATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + + [piix_pata_vmw] = + { + .flags = PIIX_PATA_FLAGS, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ + .udma_mask = ATA_UDMA2, + .port_ops = &piix_vmw_ops, + }, + + /* + * some Sandybridge chipsets have broken 32 mode up to now, + * see https://bugzilla.kernel.org/show_bug.cgi?id=40592 + */ + [ich8_sata_snb] = + { + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR | PIIX_FLAG_PIO16, + .pio_mask = ATA_PIO4, + .mwdma_mask = ATA_MWDMA2, + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, +}; + #define AHCI_PCI_BAR 5 #define AHCI_GLOBAL_CTL 0x04 #define AHCI_ENABLE (1 << 31) @@ -1746,6 +1712,17 @@ static void piix_remove_one(struct pci_dev *pdev) ata_pci_remove_one(pdev); } +static struct pci_driver piix_pci_driver = { + .name = DRV_NAME, + .id_table = piix_pci_tbl, + .probe = piix_init_one, + .remove = piix_remove_one, +#ifdef CONFIG_PM + .suspend = piix_pci_device_suspend, + .resume = piix_pci_device_resume, +#endif +}; + static int __init piix_init(void) { int rc; -- cgit v1.2.3 From 5416912af75de9cba5d1c75b99a7888b0bbbd2fb Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Mon, 3 Dec 2012 11:35:02 +0800 Subject: libata: set dma_mode to 0xff in reset ata_device->dma_mode's initial value is zero, which is not a valid dma mode, but ata_dma_enabled will return true for this value. This patch sets dma_mode to 0xff in reset function, so that ata_dma_enabled will not return true for this case, or it will cause problem for pata_acpi. The corrsponding bugzilla page is at: https://bugzilla.kernel.org/show_bug.cgi?id=49151 Reported-by: Phillip Wood Signed-off-by: Aaron Lu Tested-by: Szymon Janc Tested-by: Dutra Julio Acked-by: Alan Cox Cc: Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 1 + drivers/ata/libata-eh.c | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index caffe73c1e4a..583f26d6d455 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2559,6 +2559,7 @@ int ata_bus_probe(struct ata_port *ap) * bus as we may be talking too fast. */ dev->pio_mode = XFER_PIO_0; + dev->dma_mode = 0xff; /* If the controller has a pio mode setup function * then use it to set the chipset to rights. Don't diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e60437cd0d19..bf039b0e97b7 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2657,6 +2657,7 @@ int ata_eh_reset(struct ata_link *link, int classify, * bus as we may be talking too fast. */ dev->pio_mode = XFER_PIO_0; + dev->dma_mode = 0xff; /* If the controller has a pio mode setup function * then use it to set the chipset to rights. Don't -- cgit v1.2.3 From 941c77fd0f2f6f5964a3f9fba4e8779714faf832 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:15 -0700 Subject: ahci_platform: enable hotplug unbinding platform_driver_probe() should be used for registering this driver only if we want to "...remove its run-once probe() infrastructure from memory after the driver has bound to the device." However, we may want to leave the probe infrastructure in place in order to support binding/unbinding a device dynamically. This is useful, for instance, as a power management mechanism, where a device can be totally powered down when unbound (whereas with runtime power management, powering down the SATA core would incur unacceptable loss of functionality). Thus, convert this driver to use platform_driver_register(). Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/ahci_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index b7078afddb74..c598fd7cbf3f 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -75,7 +75,7 @@ static struct scsi_host_template ahci_platform_sht = { AHCI_SHT("ahci_platform"), }; -static int __init ahci_probe(struct platform_device *pdev) +static int __devinit ahci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ahci_platform_data *pdata = dev_get_platdata(dev); @@ -326,6 +326,7 @@ static const struct of_device_id ahci_of_match[] = { MODULE_DEVICE_TABLE(of, ahci_of_match); static struct platform_driver ahci_driver = { + .probe = ahci_probe, .remove = __devexit_p(ahci_remove), .driver = { .name = "ahci", @@ -338,7 +339,7 @@ static struct platform_driver ahci_driver = { static int __init ahci_init(void) { - return platform_driver_probe(&ahci_driver, ahci_probe); + return platform_driver_register(&ahci_driver); } module_init(ahci_init); -- cgit v1.2.3 From 9a99e4768a6dcfa50d1cda1b2f55c9ea5c4213cc Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:16 -0700 Subject: ahci_platform: convert to module_platform_driver The ahci_platform driver can now use the module_platform_driver() macro. Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/ahci_platform.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index c598fd7cbf3f..fbbfa2bccbcd 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -336,18 +336,7 @@ static struct platform_driver ahci_driver = { }, .id_table = ahci_devtype, }; - -static int __init ahci_init(void) -{ - return platform_driver_register(&ahci_driver); -} -module_init(ahci_init); - -static void __exit ahci_exit(void) -{ - platform_driver_unregister(&ahci_driver); -} -module_exit(ahci_exit); +module_platform_driver(ahci_driver); MODULE_DESCRIPTION("AHCI SATA platform driver"); MODULE_AUTHOR("Anton Vorontsov "); -- cgit v1.2.3 From 1896b15eddb4ff7266bccf3efa981885ecf80ab1 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:17 -0700 Subject: ahci_platform: perform platform exit in host_stop() hook AHCI platform devices may provide an exit() routine, via ahci_platform_data, that powers off the SATA core. Such a routine should be executed from the ata_port_operations host_stop() hook. That way, the ATA subsystem can perform any last-minute hardware cleanup (via devres, for example), then trigger the power-off at the appropriate time. This patch fixes bus errors triggered during module removal or device unbinding, seen on an SoC SATA core. Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/ahci_platform.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index fbbfa2bccbcd..5aa4309d4481 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -25,6 +25,8 @@ #include #include "ahci.h" +static void ahci_host_stop(struct ata_host *host); + enum ahci_type { AHCI, /* standard platform ahci */ IMX53_AHCI, /* ahci on i.mx53 */ @@ -47,6 +49,15 @@ static struct platform_device_id ahci_devtype[] = { }; MODULE_DEVICE_TABLE(platform, ahci_devtype); +struct ata_port_operations ahci_platform_ops = { + .inherits = &ahci_ops, + .host_stop = ahci_host_stop, +}; + +struct ata_port_operations ahci_platform_retry_srst_ops = { + .inherits = &ahci_pmp_retry_srst_ops, + .host_stop = ahci_host_stop, +}; static const struct ata_port_info ahci_port_info[] = { /* by features */ @@ -54,20 +65,20 @@ static const struct ata_port_info ahci_port_info[] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, [IMX53_AHCI] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_pmp_retry_srst_ops, + .port_ops = &ahci_platform_retry_srst_ops, }, [STRICT_AHCI] = { AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE), .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, }; @@ -221,12 +232,19 @@ free_clk: static int __devexit ahci_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ahci_platform_data *pdata = dev_get_platdata(dev); struct ata_host *host = dev_get_drvdata(dev); - struct ahci_host_priv *hpriv = host->private_data; ata_host_detach(host); + return 0; +} + +static void ahci_host_stop(struct ata_host *host) +{ + struct device *dev = host->dev; + struct ahci_platform_data *pdata = dev_get_platdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + if (pdata && pdata->exit) pdata->exit(dev); @@ -234,8 +252,6 @@ static int __devexit ahci_remove(struct platform_device *pdev) clk_disable_unprepare(hpriv->clk); clk_put(hpriv->clk); } - - return 0; } #ifdef CONFIG_PM_SLEEP -- cgit v1.2.3 From b7db04d9264fca4b00e949da7b3180c50e243fca Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 12:29:32 -0700 Subject: libata: implement ata_platform_remove_one() This relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata. Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 583f26d6d455..8e3f4a90c088 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "libata.h" #include "libata-transport.h" @@ -6382,6 +6383,26 @@ int ata_pci_device_resume(struct pci_dev *pdev) #endif /* CONFIG_PCI */ +/** + * ata_platform_remove_one - Platform layer callback for device removal + * @pdev: Platform device that was removed + * + * Platform layer indicates to libata via this hook that hot-unplug or + * module unload event has occurred. Detach all ports. Resource + * release is handled via devres. + * + * LOCKING: + * Inherited from platform layer (may sleep). + */ +int ata_platform_remove_one(struct platform_device *pdev) +{ + struct ata_host *host = platform_get_drvdata(pdev); + + ata_host_detach(host); + + return 0; +} + static int __init ata_parse_force_one(char **cur, struct ata_force_ent *force_ent, const char **reason) @@ -6877,6 +6898,8 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume); #endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +EXPORT_SYMBOL_GPL(ata_platform_remove_one); + EXPORT_SYMBOL_GPL(__ata_ehi_push_desc); EXPORT_SYMBOL_GPL(ata_ehi_push_desc); EXPORT_SYMBOL_GPL(ata_ehi_clear_desc); diff --git a/include/linux/libata.h b/include/linux/libata.h index e931c9ad1078..83ba0ab2c915 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1115,6 +1115,10 @@ extern int ata_pci_device_resume(struct pci_dev *pdev); #endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +struct platform_device; + +extern int ata_platform_remove_one(struct platform_device *pdev); + /* * ACPI - drivers/ata/libata-acpi.c */ -- cgit v1.2.3 From 83291d65cbeadda2bd600b6c500df7046dcd6fa9 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:19 -0700 Subject: ahci_platform: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/ahci_platform.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 5aa4309d4481..1d90690d85f7 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -229,16 +229,6 @@ free_clk: return rc; } -static int __devexit ahci_remove(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct ata_host *host = dev_get_drvdata(dev); - - ata_host_detach(host); - - return 0; -} - static void ahci_host_stop(struct ata_host *host) { struct device *dev = host->dev; @@ -343,7 +333,7 @@ MODULE_DEVICE_TABLE(of, ahci_of_match); static struct platform_driver ahci_driver = { .probe = ahci_probe, - .remove = __devexit_p(ahci_remove), + .remove = ata_platform_remove_one, .driver = { .name = "ahci", .owner = THIS_MODULE, -- cgit v1.2.3 From 58d0ff2f05d6915c455b5fe7c404e299fe34993b Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:20 -0700 Subject: pata_ixp4xx_cf: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_ixp4xx_cf.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index badb1789a918..0566e67b5e12 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c @@ -187,22 +187,13 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev) return ata_host_activate(host, irq, ata_sff_interrupt, 0, &ixp4xx_sht); } -static __devexit int ixp4xx_pata_remove(struct platform_device *dev) -{ - struct ata_host *host = platform_get_drvdata(dev); - - ata_host_detach(host); - - return 0; -} - static struct platform_driver ixp4xx_pata_platform_driver = { .driver = { .name = DRV_NAME, .owner = THIS_MODULE, }, .probe = ixp4xx_pata_probe, - .remove = __devexit_p(ixp4xx_pata_remove), + .remove = ata_platform_remove_one, }; module_platform_driver(ixp4xx_pata_platform_driver); -- cgit v1.2.3 From 37e1b022bf1c54daf6849deffb65322299493702 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:21 -0700 Subject: pata_mpc52xx: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_mpc52xx.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index d2c102fd4330..ec67f54dc56f 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c @@ -663,18 +663,6 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv, &mpc52xx_ata_sht); } -static struct mpc52xx_ata_priv * -mpc52xx_ata_remove_one(struct device *dev) -{ - struct ata_host *host = dev_get_drvdata(dev); - struct mpc52xx_ata_priv *priv = host->private_data; - - ata_host_detach(host); - - return priv; -} - - /* ======================================================================== */ /* OF Platform driver */ /* ======================================================================== */ @@ -815,11 +803,12 @@ mpc52xx_ata_probe(struct platform_device *op) static int mpc52xx_ata_remove(struct platform_device *op) { - struct mpc52xx_ata_priv *priv; + struct ata_host *host = platform_get_drvdata(op); + struct mpc52xx_ata_priv *priv = host->private_data; int task_irq; /* Deregister the ATA interface */ - priv = mpc52xx_ata_remove_one(&op->dev); + ata_platform_remove_one(op); /* Clean up DMA */ task_irq = bcom_get_task_irq(priv->dmatsk); -- cgit v1.2.3 From 3e7068da1194543fb4841072838b967e576adc55 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:22 -0700 Subject: pata_of_platform: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_of_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c index 1654dc27e7f8..cd0f9da08637 100644 --- a/drivers/ata/pata_of_platform.c +++ b/drivers/ata/pata_of_platform.c @@ -76,11 +76,6 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev) reg_shift, pio_mask); } -static int __devexit pata_of_platform_remove(struct platform_device *ofdev) -{ - return __pata_platform_remove(&ofdev->dev); -} - static struct of_device_id pata_of_platform_match[] = { { .compatible = "ata-generic", }, { .compatible = "electra-ide", }, @@ -95,7 +90,7 @@ static struct platform_driver pata_of_platform_driver = { .of_match_table = pata_of_platform_match, }, .probe = pata_of_platform_probe, - .remove = __devexit_p(pata_of_platform_remove), + .remove = ata_platform_remove_one, }; module_platform_driver(pata_of_platform_driver); -- cgit v1.2.3 From ccd1196a924a0fd64132297a121794c347f52d3a Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:23 -0700 Subject: pata_platform: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index f1848aeda783..449aa29931bc 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c @@ -242,14 +242,9 @@ static int __devinit pata_platform_probe(struct platform_device *pdev) pio_mask); } -static int __devexit pata_platform_remove(struct platform_device *pdev) -{ - return __pata_platform_remove(&pdev->dev); -} - static struct platform_driver pata_platform_driver = { .probe = pata_platform_probe, - .remove = __devexit_p(pata_platform_remove), + .remove = ata_platform_remove_one, .driver = { .name = DRV_NAME, .owner = THIS_MODULE, -- cgit v1.2.3 From 156f34d26a74c6ea060fb43d898f17509ed8e18a Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:24 -0700 Subject: pata_platform: remove unused remove function All users of __pata_platform_remove() have been converted to utilize the common ata_platform_remove_one(). Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_platform.c | 17 ----------------- include/linux/ata_platform.h | 2 -- 2 files changed, 19 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 449aa29931bc..f4372d0c7ce6 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c @@ -178,23 +178,6 @@ int __devinit __pata_platform_probe(struct device *dev, } EXPORT_SYMBOL_GPL(__pata_platform_probe); -/** - * __pata_platform_remove - unplug a platform interface - * @dev: device - * - * A platform bus ATA device has been unplugged. Perform the needed - * cleanup. Also called on module unload for any active devices. - */ -int __pata_platform_remove(struct device *dev) -{ - struct ata_host *host = dev_get_drvdata(dev); - - ata_host_detach(host); - - return 0; -} -EXPORT_SYMBOL_GPL(__pata_platform_remove); - static int __devinit pata_platform_probe(struct platform_device *pdev) { struct resource *io_res; diff --git a/include/linux/ata_platform.h b/include/linux/ata_platform.h index b856a2a590d9..fe9989636b62 100644 --- a/include/linux/ata_platform.h +++ b/include/linux/ata_platform.h @@ -22,8 +22,6 @@ extern int __devinit __pata_platform_probe(struct device *dev, unsigned int ioport_shift, int __pio_mask); -extern int __devexit __pata_platform_remove(struct device *dev); - /* * Marvell SATA private data */ -- cgit v1.2.3 From 56c1d3b77fc83939ab530b8a871e00176fc5b583 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 2 Nov 2012 00:46:25 -0700 Subject: pata_palmld: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_palmld.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c index 5ff31b68135c..f9f79fc04a8f 100644 --- a/drivers/ata/pata_palmld.c +++ b/drivers/ata/pata_palmld.c @@ -111,9 +111,7 @@ err1: static __devexit int palmld_pata_remove(struct platform_device *dev) { - struct ata_host *host = platform_get_drvdata(dev); - - ata_host_detach(host); + ata_platform_remove_one(dev); /* power down the HDD */ gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); -- cgit v1.2.3 From e2ec1817484d7448af2d8bf8a8acb144f87d5238 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 3 Dec 2012 10:34:39 -0800 Subject: sata_highbank: utilize common ata_platform_remove_one() Signed-off-by: Brian Norris Acked-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/sata_highbank.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c index 75c0f3cc4a8a..dc7d78eecb19 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c @@ -368,16 +368,6 @@ err0: return rc; } -static int __devexit ahci_highbank_remove(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct ata_host *host = dev_get_drvdata(dev); - - ata_host_detach(host); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int ahci_highbank_suspend(struct device *dev) { @@ -432,7 +422,7 @@ SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, ahci_highbank_suspend, ahci_highbank_resume); static struct platform_driver ahci_highbank_driver = { - .remove = __devexit_p(ahci_highbank_remove), + .remove = ata_platform_remove_one, .driver = { .name = "highbank-ahci", .owner = THIS_MODULE, -- cgit v1.2.3 From 1645bf1b51e5788a18cb6af7cfbb221ee17a6e8b Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 3 Dec 2012 10:34:40 -0800 Subject: pata_octeon_cf: perform host detach, removal on exit This driver does not detach and remove its ata_host properly on device removal. Add the common .remove helper. Note: I do not know this driver well enough to ensure this is the right thing to do. Merge this patch with caution. Signed-off-by: Brian Norris Acked-by: Tejun Heo Cc: David Daney Signed-off-by: Jeff Garzik --- drivers/ata/pata_octeon_cf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c index 1d61d5d278fa..d8df93b2a028 100644 --- a/drivers/ata/pata_octeon_cf.c +++ b/drivers/ata/pata_octeon_cf.c @@ -921,6 +921,7 @@ free_cf_port: static struct platform_driver octeon_cf_driver = { .probe = octeon_cf_probe, + .remove = ata_platform_remove_one, .driver = { .name = DRV_NAME, .owner = THIS_MODULE, -- cgit v1.2.3 From 04a3f5b7d2961a05b428abc75b30e2dc85f88ac6 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 3 Dec 2012 10:34:41 -0800 Subject: libata: use pci_get_drvdata() helper Signed-off-by: Brian Norris Acked-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 8e3f4a90c088..47d59616fe3d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6287,8 +6287,7 @@ void ata_host_detach(struct ata_host *host) */ void ata_pci_remove_one(struct pci_dev *pdev) { - struct device *dev = &pdev->dev; - struct ata_host *host = dev_get_drvdata(dev); + struct ata_host *host = pci_get_drvdata(pdev); ata_host_detach(host); } @@ -6357,7 +6356,7 @@ int ata_pci_device_do_resume(struct pci_dev *pdev) int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) { - struct ata_host *host = dev_get_drvdata(&pdev->dev); + struct ata_host *host = pci_get_drvdata(pdev); int rc = 0; rc = ata_host_suspend(host, mesg); @@ -6371,7 +6370,7 @@ int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) int ata_pci_device_resume(struct pci_dev *pdev) { - struct ata_host *host = dev_get_drvdata(&pdev->dev); + struct ata_host *host = pci_get_drvdata(pdev); int rc; rc = ata_pci_device_do_resume(pdev); -- cgit v1.2.3 From 84043ac26ed120826db8e6198531da888c6e57b0 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 3 Dec 2012 10:34:42 -0800 Subject: pata_of_platform: fix compile error I failed to include , causing this error: drivers/ata/pata_of_platform.c:93: error: 'ata_platform_remove_one' undeclared here (not in a function) Signed-off-by: Brian Norris Signed-off-by: Jeff Garzik --- drivers/ata/pata_of_platform.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c index cd0f9da08637..e5b234c370fa 100644 --- a/drivers/ata/pata_of_platform.c +++ b/drivers/ata/pata_of_platform.c @@ -14,6 +14,7 @@ #include #include #include +#include static int __devinit pata_of_platform_probe(struct platform_device *ofdev) { -- cgit v1.2.3 From 8349e5aeaadd160b7cce554a62a05be4b2d894aa Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 14 Dec 2012 09:34:01 -0500 Subject: Revert "libata: check SATA_SETTINGS log with HW Feature Ctrl" This reverts commit de90cd71f68e947d3bd6c3f2ef5731ead010a768. Shane Huang writes: Please suspend this patch because I just received two new DevSlp drives but found word 78 bit 5 is _not_ set. I'm checking with the drive vendor whether he gave me the wrong information. If bit 5 is not the necessary and sufficient condition, I will implement another patch to replace ata_device->sata_settings into ->devslp_timing. Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 3 ++- include/linux/ata.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 47d59616fe3d..9e8b99af400d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2331,8 +2331,9 @@ int ata_dev_configure(struct ata_device *dev) /* Obtain SATA Settings page from Identify Device Data Log, * which contains DevSlp timing variables etc. + * Exclude old devices with ata_id_has_ncq() */ - if (ata_id_has_hw_feature_ctrl(dev->id)) { + if (ata_id_has_ncq(dev->id)) { err_mask = ata_read_log_page(dev, ATA_LOG_SATA_ID_DEV_DATA, ATA_LOG_SATA_SETTINGS, diff --git a/include/linux/ata.h b/include/linux/ata.h index 18cbb93fdbca..408da9502177 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -593,7 +593,6 @@ static inline int ata_is_data(u8 prot) #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4)) #define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)) -#define ata_id_has_hw_feature_ctrl(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 5)) static inline bool ata_id_has_hipm(const u16 *id) { -- cgit v1.2.3 From 11ace0c1defc4d1fe78afd29319bedef36da7078 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 14 Dec 2012 09:35:51 -0500 Subject: Revert "pata_octeon_cf: perform host detach, removal on exit" This reverts commit 1645bf1b51e5788a18cb6af7cfbb221ee17a6e8b. Brian Norris writes: > David Daney writes: > I can seem to find it. Without knowing what that does, I would be inclined > to NACK the whole thing. A NACK is probably the right thing. I was mostly converting a few other drivers which used some simple, common patterns to use my new common code, but this driver was missing it altogether. It looks like there may be bigger issues, though, as you point out. > This patch is likely to be incomplete as the driver is also missing the > module_exit() things. > > It might be simpler to just make the driver "bool" instead of "tristate" in > the Kconfig. As noted earlier, I don't have much interest in this driver. I agree that there are some other issues with the driver; I think it leaks memory if it is ever allowed to unload, for one. Feel free to submit an alternative patch to prevent this driver from being built as a module. Signed-off-by: Jeff Garzik --- drivers/ata/pata_octeon_cf.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c index d8df93b2a028..1d61d5d278fa 100644 --- a/drivers/ata/pata_octeon_cf.c +++ b/drivers/ata/pata_octeon_cf.c @@ -921,7 +921,6 @@ free_cf_port: static struct platform_driver octeon_cf_driver = { .probe = octeon_cf_probe, - .remove = ata_platform_remove_one, .driver = { .name = DRV_NAME, .owner = THIS_MODULE, -- cgit v1.2.3 From 071d3ad37485a82e0543a503272c45cdd32053dd Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 5 Dec 2012 23:44:20 -0800 Subject: ahci_platform: make structs static These structs are used only for ahci_platform.c, so they should be static. Thanks to Fengguang for the (automated) suggestion. Signed-off-by: Brian Norris Cc: Fengguang Wu Signed-off-by: Jeff Garzik --- drivers/ata/ahci_platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 1d90690d85f7..1cc467bdb63d 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -49,12 +49,12 @@ static struct platform_device_id ahci_devtype[] = { }; MODULE_DEVICE_TABLE(platform, ahci_devtype); -struct ata_port_operations ahci_platform_ops = { +static struct ata_port_operations ahci_platform_ops = { .inherits = &ahci_ops, .host_stop = ahci_host_stop, }; -struct ata_port_operations ahci_platform_retry_srst_ops = { +static struct ata_port_operations ahci_platform_retry_srst_ops = { .inherits = &ahci_pmp_retry_srst_ops, .host_stop = ahci_host_stop, }; @@ -323,7 +323,7 @@ disable_unprepare_clk: } #endif -SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); +static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); static const struct of_device_id ahci_of_match[] = { { .compatible = "snps,spear-ahci", }, -- cgit v1.2.3 From 99da09fcc561b56664b3c4184b5caf4e94449e98 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 3 Dec 2012 23:30:55 -0500 Subject: ARM: ep93xx: convert ata__printk() to ata__() Using ata__() instead of ata__printk(). Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/pata_ep93xx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c index e056406d6a11..3982cef91f3c 100644 --- a/drivers/ata/pata_ep93xx.c +++ b/drivers/ata/pata_ep93xx.c @@ -822,8 +822,7 @@ static int ep93xx_pata_softreset(struct ata_link *al, unsigned int *classes, rc = ep93xx_pata_bus_softreset(ap, devmask, deadline); /* if link is ocuppied, -ENODEV too is an error */ if (rc && (rc != -ENODEV || sata_scr_valid(al))) { - ata_link_printk(al, KERN_ERR, "SRST failed (errno=%d)\n", - rc); + ata_link_err(al, "SRST failed (errno=%d)\n", rc); return rc; } @@ -857,8 +856,7 @@ static void ep93xx_pata_drain_fifo(struct ata_queued_cmd *qc) /* Can become DEBUG later */ if (count) - ata_port_printk(ap, KERN_DEBUG, - "drained %d bytes to clear DRQ.\n", count); + ata_port_dbg(ap, "drained %d bytes to clear DRQ.\n", count); } -- cgit v1.2.3 From 22c8be31446fabae7e5448ebddc65db59187608e Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 3 Dec 2012 23:38:58 -0500 Subject: pata_imx: convert ata_dev_printk() to ata_dev_info() Using ata_dev_info() instead of ata_dev_printk(). Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/pata_imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index 87bb05b3cafc..7d40b526ef11 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -60,7 +60,7 @@ static int pata_imx_set_mode(struct ata_link *link, struct ata_device **unused) val &= ~PATA_IMX_ATA_CTRL_IORDY_EN; __raw_writel(val, priv->host_regs + PATA_IMX_ATA_CONTROL); - ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); + ata_dev_info(dev, "configured for PIO\n"); } return 0; } -- cgit v1.2.3 From 39f80acb9fe5adff216bde33c554e4bf5f6eec12 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 3 Dec 2012 23:39:31 -0500 Subject: ahci: convert ata_link_printk() to ata_link_warn() Using ata_link_warn() instead of ata_link_printk(). Signed-off-by: Wei Yongjun Signed-off-by: Jeff Garzik --- drivers/ata/libahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 4201e535a8c8..320712a7b9ea 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -1384,7 +1384,7 @@ int ahci_pmp_retry_softreset(struct ata_link *link, unsigned int *class, if (rc == -EIO) { irq_sts = readl(port_mmio + PORT_IRQ_STAT); if (irq_sts & PORT_IRQ_BAD_PMP) { - ata_link_printk(link, KERN_WARNING, + ata_link_warn(link, "applying PMP SRST workaround " "and retrying\n"); rc = ahci_do_softreset(link, class, 0, deadline, -- cgit v1.2.3 From 26cd4d65deba587f3cf2329b6869ce02bcbe68ec Mon Sep 17 00:00:00 2001 From: Xiaotian Feng Date: Thu, 13 Dec 2012 16:12:18 +0800 Subject: [libata] fix Null pointer dereference on disk error Following oops were observed when disk error happened: [ 4272.896937] sd 0:0:0:0: [sda] Unhandled error code [ 4272.896939] sd 0:0:0:0: [sda] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK [ 4272.896942] sd 0:0:0:0: [sda] CDB: Read(10): 28 00 00 5a de a7 00 00 08 00 [ 4272.896951] end_request: I/O error, dev sda, sector 5955239 [ 4291.574947] BUG: unable to handle kernel NULL pointer dereference at (null) [ 4291.658305] IP: [] ahci_activity_show+0x1/0x40 [ 4291.730090] PGD 76dbbc067 PUD 6c4fba067 PMD 0 [ 4291.783408] Oops: 0000 [#1] SMP [ 4291.822100] last sysfs file: /sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/sw_activity [ 4291.934235] CPU 9 [ 4291.958301] Pid: 27942, comm: hwinfo ...... ata_scsi_find_dev could return NULL, so ata_scsi_activity_{show,store} should check if atadev is NULL. Signed-off-by: Xiaotian Feng Cc: James Bottomley Cc: stable@kernel.org Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index a6df6a351d6e..7c337e754dab 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -309,7 +309,8 @@ ata_scsi_activity_show(struct device *dev, struct device_attribute *attr, struct ata_port *ap = ata_shost_to_port(sdev->host); struct ata_device *atadev = ata_scsi_find_dev(ap, sdev); - if (ap->ops->sw_activity_show && (ap->flags & ATA_FLAG_SW_ACTIVITY)) + if (atadev && ap->ops->sw_activity_show && + (ap->flags & ATA_FLAG_SW_ACTIVITY)) return ap->ops->sw_activity_show(atadev, buf); return -EINVAL; } @@ -324,7 +325,8 @@ ata_scsi_activity_store(struct device *dev, struct device_attribute *attr, enum sw_activity val; int rc; - if (ap->ops->sw_activity_store && (ap->flags & ATA_FLAG_SW_ACTIVITY)) { + if (atadev && ap->ops->sw_activity_store && + (ap->flags & ATA_FLAG_SW_ACTIVITY)) { val = simple_strtoul(buf, NULL, 0); switch (val) { case OFF: case BLINK_ON: case BLINK_OFF: -- cgit v1.2.3 From 72d5f2da2c3717f1be484d97e35d67dde0efb4c0 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 14 Dec 2012 09:43:39 -0500 Subject: sata_dwc_460ex: remove file exec bit (chmod 0755 -> 0644) Signed-off-by: Jeff Garzik --- drivers/ata/sata_dwc_460ex.c | 1 + 1 file changed, 1 insertion(+) mode change 100755 => 100644 drivers/ata/sata_dwc_460ex.c (limited to 'drivers/ata') diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c old mode 100755 new mode 100644 index 937aeb34b310..2e391730e8be --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c @@ -43,6 +43,7 @@ /* These two are defined in "libata.h" */ #undef DRV_NAME #undef DRV_VERSION + #define DRV_NAME "sata-dwc" #define DRV_VERSION "1.3" -- cgit v1.2.3