From bdfa2e7e5a46d7dcd9ff127fdf198faf90f0e215 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 5 Mar 2013 10:39:47 +0900 Subject: pata_at32: use module_platform_driver_probe() This patch uses module_platform_driver_probe() macro which makes the code smaller and simpler. Signed-off-by: Jingoo Han Signed-off-by: Jeff Garzik --- drivers/ata/pata_at32.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c index 36f189c7ee8..8d493b4a096 100644 --- a/drivers/ata/pata_at32.c +++ b/drivers/ata/pata_at32.c @@ -393,18 +393,7 @@ static struct platform_driver pata_at32_driver = { }, }; -static int __init pata_at32_init(void) -{ - return platform_driver_probe(&pata_at32_driver, pata_at32_probe); -} - -static void __exit pata_at32_exit(void) -{ - platform_driver_unregister(&pata_at32_driver); -} - -module_init(pata_at32_init); -module_exit(pata_at32_exit); +module_platform_driver_probe(pata_at32_driver, pata_at32_probe); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("AVR32 SMC/CFC PATA Driver"); -- cgit v1.2.3 From e0044c9822ab7b60b493bc135ec258227a082b5a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 11 Mar 2013 14:41:51 +0300 Subject: pata_legacy: bogus clock in opti82c46x_set_piomode() "sysclk" is used as an index into a 4 element array. My static checker complains because it can be out of bounds. From the context, it looks like there is a right bit shift missing. Signed-off-by: Dan Carpenter Signed-off-by: Jeff Garzik --- drivers/ata/pata_legacy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 4fe9d2138d4..be816428b43 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c @@ -542,7 +542,7 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev) u8 sysclk; /* Get the clock */ - sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */ + sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6; /* BIOS set */ /* Enter configuration mode */ ioread16(ap->ioaddr.error_addr); -- cgit v1.2.3 From b1cbe7d6214042a6f08da7295757023938bcfdac Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghiu Date: Sat, 16 Mar 2013 16:32:11 +0200 Subject: pata_octeon_cf: Use resource_size function Use resource_size function instead of explicit computation. Patch found using coccinelle. Signed-off-by: Alexandru Gheorghiu Signed-off-by: Jeff Garzik --- drivers/ata/pata_octeon_cf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c index ff2e57f3b59..e73bef3093d 100644 --- a/drivers/ata/pata_octeon_cf.c +++ b/drivers/ata/pata_octeon_cf.c @@ -926,7 +926,7 @@ static int octeon_cf_probe(struct platform_device *pdev) goto free_cf_port; } cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start, - res_cs1->end - res_cs1->start + 1); + resource_size(res_cs1)); if (!cs1) goto free_cf_port; -- cgit v1.2.3 From b1a72d600a5acb93c1831865d72a6a90bfd7bcbf Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 19 Mar 2013 10:14:26 +0900 Subject: sata_highbank: make ahci_highbank_pm_ops static Make ahci_highbank_pm_ops static because ahci_highbank_pm_ops is not exported. Signed-off-by: Jingoo Han 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 5dba77ccaa0..b1ab7d8c396 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c @@ -418,7 +418,7 @@ static int ahci_highbank_resume(struct device *dev) } #endif -SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, +static SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, ahci_highbank_suspend, ahci_highbank_resume); static struct platform_driver ahci_highbank_driver = { -- cgit v1.2.3 From 7381fe73749bc3c1f914b3389891d7d22be7e0f1 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Tue, 5 Mar 2013 12:12:04 +0800 Subject: libata-acpi: remove redundent code for power resource handling With commit: bc9b6407bd6df3ab7189e5622816bbc11ae9d2d8 ACPI / PM: Rework the handling of devices depending on power resources The ACPI core now takes care of the power resources an acpi device depends on in that when the power resources are turned on, any devices that are bound to or in the dependent list of this acpi device will be runtime resumed. So there is no need for ata acpi code to duplicate this effort, and thus, the ata_acpi_(un)register_power_resource functions are no longer needed. The above commit thinks the scsi device is not bound to the acpi device, so needs to be added to the dependent list. But actually, it is. So there is no need to add it to the dependent list, or it will be runtime resumed twice(though this wouldn't cause any problem). This patch fixes it, and as a result, the ata_acpi_(un)register_power_resource and ata_acpi_(un)bind functions are removed. Signed-off-by: Aaron Lu Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 33 --------------------------------- drivers/ata/libata-scsi.c | 6 ++++-- 2 files changed, 4 insertions(+), 35 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 8a52dab412e..1c33f78040c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "libata.h" @@ -1020,38 +1019,6 @@ void ata_acpi_on_disable(struct ata_device *dev) ata_acpi_clear_gtf(dev); } -static void ata_acpi_register_power_resource(struct ata_device *dev) -{ - struct scsi_device *sdev = dev->sdev; - acpi_handle handle; - - handle = ata_dev_acpi_handle(dev); - if (handle) - acpi_dev_pm_add_dependent(handle, &sdev->sdev_gendev); -} - -static void ata_acpi_unregister_power_resource(struct ata_device *dev) -{ - struct scsi_device *sdev = dev->sdev; - acpi_handle handle; - - handle = ata_dev_acpi_handle(dev); - if (handle) - acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev); -} - -void ata_acpi_bind(struct ata_device *dev) -{ - ata_acpi_register_power_resource(dev); - if (zpodd_dev_enabled(dev)) - dev_pm_qos_expose_flags(&dev->sdev->sdev_gendev, 0); -} - -void ata_acpi_unbind(struct ata_device *dev) -{ - ata_acpi_unregister_power_resource(dev); -} - static int compat_pci_ata(struct ata_port *ap) { struct device *dev = ap->tdev.parent; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index ff44787e5a4..fe759cafc67 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include "libata.h" @@ -3668,7 +3669,9 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) if (!IS_ERR(sdev)) { dev->sdev = sdev; scsi_device_put(sdev); - ata_acpi_bind(dev); + if (zpodd_dev_enabled(dev)) + dev_pm_qos_expose_flags( + &sdev->sdev_gendev, 0); } else { dev->sdev = NULL; } @@ -3767,7 +3770,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev) if (zpodd_dev_enabled(dev)) zpodd_exit(dev); - ata_acpi_unbind(dev); /* clearing dev->sdev is protected by host lock */ sdev = dev->sdev; -- cgit v1.2.3 From 7551c40d908b2f6c08eb13571be1f9cfd7228689 Mon Sep 17 00:00:00 2001 From: Qiang Liu Date: Mon, 4 Mar 2013 15:20:23 +0800 Subject: fsl/sata: create a sysfs entry for rx water mark Support config RX WATER MARK via sysfs when running at run-time; A wrokaround for fix the exception happened to some WD HDD, found on WD3000HLFS-01G6U1, WD3000HLFS-01G6U0, some SSD disks. The read performance is also regression (about 30%) when use default value. According to the latest documents, 0x10 is the default value of RX WATER MARK, but exception/performance issue happened to some disks mentioned above. The exception log as below when testing read performance with IOZone: ata1.00: exception Emask 0x0 SAct 0x7 SErr 0x800000 action 0x6 frozen ata1: SError: { LinkSeq } ata1.00: failed command: READ FPDMA QUEUED ata1.00: cmd 60/00:00:ff:2c:14/01:00:02:00:00/40 tag 0 ncq 131072 in res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout) ata1.00: status: { DRDY } ata1.00: failed command: READ FPDMA QUEUED ata1.00: cmd 60/00:08:ff:2d:14/01:00:02:00:00/40 tag 1 ncq 131072 in res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout) ata1.00: status: { DRDY } ata1.00: failed command: WRITE FPDMA QUEUED ata1.00: cmd 61/10:10:af:08:6e/00:00:12:00:00/40 tag 2 ncq 8192 out res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout) ata1.00: status: { DRDY } ata1: hard resetting link ata1: Hardreset failed, not off-lined 0 ata1: Signature Update detected @ 504 msecs ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata1.00: configured for UDMA/133 ata1.00: device reported invalid CHS sector 0 ata1.00: device reported invalid CHS sector 0 ata1.00: device reported invalid CHS sector 0 ata1: EH complete The exception/performance can be resolved when RX WATER MARK value is 0x16. Signed-off-by: Qiang Liu Signed-off-by: Jeff Garzik --- drivers/ata/sata_fsl.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index 608f82fed63..d314c1dad06 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c @@ -285,6 +285,7 @@ struct sata_fsl_host_priv { int irq; int data_snoop; struct device_attribute intr_coalescing; + struct device_attribute rx_watermark; }; static void fsl_sata_set_irq_coalescing(struct ata_host *host, @@ -343,6 +344,48 @@ static ssize_t fsl_sata_intr_coalescing_store(struct device *dev, return strlen(buf); } +static ssize_t fsl_sata_rx_watermark_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + unsigned int rx_watermark; + unsigned long flags; + struct ata_host *host = dev_get_drvdata(dev); + struct sata_fsl_host_priv *host_priv = host->private_data; + void __iomem *csr_base = host_priv->csr_base; + + spin_lock_irqsave(&host->lock, flags); + rx_watermark = ioread32(csr_base + TRANSCFG); + rx_watermark &= 0x1f; + + spin_unlock_irqrestore(&host->lock, flags); + return sprintf(buf, "%d\n", rx_watermark); +} + +static ssize_t fsl_sata_rx_watermark_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int rx_watermark; + unsigned long flags; + struct ata_host *host = dev_get_drvdata(dev); + struct sata_fsl_host_priv *host_priv = host->private_data; + void __iomem *csr_base = host_priv->csr_base; + u32 temp; + + if (sscanf(buf, "%d", &rx_watermark) != 1) { + printk(KERN_ERR "fsl-sata: wrong parameter format.\n"); + return -EINVAL; + } + + spin_lock_irqsave(&host->lock, flags); + temp = ioread32(csr_base + TRANSCFG); + temp &= 0xffffffe0; + iowrite32(temp | rx_watermark, csr_base + TRANSCFG); + + spin_unlock_irqrestore(&host->lock, flags); + return strlen(buf); +} + static inline unsigned int sata_fsl_tag(unsigned int tag, void __iomem *hcr_base) { @@ -1500,6 +1543,17 @@ static int sata_fsl_probe(struct platform_device *ofdev) if (retval) goto error_exit_with_cleanup; + host_priv->rx_watermark.show = fsl_sata_rx_watermark_show; + host_priv->rx_watermark.store = fsl_sata_rx_watermark_store; + sysfs_attr_init(&host_priv->rx_watermark.attr); + host_priv->rx_watermark.attr.name = "rx_watermark"; + host_priv->rx_watermark.attr.mode = S_IRUGO | S_IWUSR; + retval = device_create_file(host->dev, &host_priv->rx_watermark); + if (retval) { + device_remove_file(&ofdev->dev, &host_priv->intr_coalescing); + goto error_exit_with_cleanup; + } + return 0; error_exit_with_cleanup: @@ -1522,6 +1576,7 @@ static int sata_fsl_remove(struct platform_device *ofdev) struct sata_fsl_host_priv *host_priv = host->private_data; device_remove_file(&ofdev->dev, &host_priv->intr_coalescing); + device_remove_file(&ofdev->dev, &host_priv->rx_watermark); ata_host_detach(host); -- cgit v1.2.3 From 2de1d5e159ccf317a9285a0dfaa6e4262500d7dd Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 4 Apr 2013 14:56:36 +0530 Subject: sata_rcar: Convert to devm_ioremap_resource() Use the newly introduced devm_ioremap_resource() instead of devm_request_and_ioremap() which provides more consistent error handling. Signed-off-by: Sachin Kamat Acked-by: Sergei Shtylyov Signed-off-by: Jeff Garzik --- drivers/ata/sata_rcar.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index caf33f620c3..4799868bd73 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -17,6 +17,7 @@ #include #include #include +#include #define DRV_NAME "sata_rcar" @@ -799,9 +800,9 @@ static int sata_rcar_probe(struct platform_device *pdev) host->private_data = priv; - priv->base = devm_request_and_ioremap(&pdev->dev, mem); - if (!priv->base) { - ret = -EADDRNOTAVAIL; + priv->base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(priv->base)) { + ret = PTR_ERR(priv->base); goto cleanup; } -- cgit v1.2.3 From 50f5a3415c2fc494e2bd80fc9e80cc62d64cbc3c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 4 Apr 2013 11:25:04 +0200 Subject: pata_imx: Use devm_clk_get To make the error path a bit simpler. Signed-off-by: Sascha Hauer Signed-off-by: Jeff Garzik --- drivers/ata/pata_imx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index 40849445a9d..af893dda852 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -112,7 +112,7 @@ static int pata_imx_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - priv->clk = clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "Failed to get clock\n"); return PTR_ERR(priv->clk); @@ -163,7 +163,7 @@ static int pata_imx_probe(struct platform_device *pdev) free_priv: clk_disable_unprepare(priv->clk); - clk_put(priv->clk); + return -ENOMEM; } @@ -177,7 +177,6 @@ static int pata_imx_remove(struct platform_device *pdev) __raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN); clk_disable_unprepare(priv->clk); - clk_put(priv->clk); return 0; } -- cgit v1.2.3 From ff540d029af1a5744fbf7c9b837801e46f683556 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 4 Apr 2013 11:25:05 +0200 Subject: pata_imx: cleanup error path - rename free_priv label to 'err' since priv is allocated with devm_* and not freed here. - add missing 'goto err' in case ata_host_activate fails - add 'ret' variable to return correct error value instead of hardcoded -ENOMEM in error case. Signed-off-by: Sascha Hauer Signed-off-by: Jeff Garzik --- drivers/ata/pata_imx.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index af893dda852..f243496c374 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -98,6 +98,7 @@ static int pata_imx_probe(struct platform_device *pdev) struct pata_imx_priv *priv; int irq = 0; struct resource *io_res; + int ret; io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (io_res == NULL) @@ -121,8 +122,10 @@ static int pata_imx_probe(struct platform_device *pdev) clk_prepare_enable(priv->clk); host = ata_host_alloc(&pdev->dev, 1); - if (!host) - goto free_priv; + if (!host) { + ret = -ENOMEM; + goto err; + } host->private_data = priv; ap = host->ports[0]; @@ -135,7 +138,8 @@ static int pata_imx_probe(struct platform_device *pdev) resource_size(io_res)); if (!priv->host_regs) { dev_err(&pdev->dev, "failed to map IO/CTL base\n"); - goto free_priv; + ret = -EBUSY; + goto err; } ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA; @@ -158,13 +162,17 @@ static int pata_imx_probe(struct platform_device *pdev) priv->host_regs + PATA_IMX_ATA_INT_EN); /* activate */ - return ata_host_activate(host, irq, ata_sff_interrupt, 0, + ret = ata_host_activate(host, irq, ata_sff_interrupt, 0, &pata_imx_sht); -free_priv: + if (ret) + goto err; + + return 0; +err: clk_disable_unprepare(priv->clk); - return -ENOMEM; + return ret; } static int pata_imx_remove(struct platform_device *pdev) -- cgit v1.2.3 From 51b5539c033cf5a6a7889b3cb56c122713c80423 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 4 Apr 2013 11:25:06 +0200 Subject: pata_imx: use void __iomem * for regs regs is returned from ioremap, so add a __iomem. Also, make it void * instead of u8 *. Signed-off-by: Sascha Hauer 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 f243496c374..adbb01d8362 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -37,7 +37,7 @@ struct pata_imx_priv { struct clk *clk; /* timings/interrupt/control regs */ - u8 *host_regs; + void __iomem *host_regs; u32 ata_ctl; }; -- cgit v1.2.3 From b9d15db2b815fd5368fb993471463829fd6d1eec Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 4 Apr 2013 11:25:07 +0200 Subject: pata_imx: add devicetree support Not much to do here, only the compatible entries have to be added. Signed-off-by: Sascha Hauer Signed-off-by: Jeff Garzik --- drivers/ata/pata_imx.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/ata') diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index adbb01d8362..aa3d166e02e 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -230,11 +230,20 @@ static const struct dev_pm_ops pata_imx_pm_ops = { }; #endif +static const struct of_device_id imx_pata_dt_ids[] = { + { + .compatible = "fsl,imx27-pata", + }, { + /* sentinel */ + } +}; + static struct platform_driver pata_imx_driver = { .probe = pata_imx_probe, .remove = pata_imx_remove, .driver = { .name = DRV_NAME, + .of_match_table = imx_pata_dt_ids, .owner = THIS_MODULE, #ifdef CONFIG_PM .pm = &pata_imx_pm_ops, -- cgit v1.2.3 From 3f1317a2be018d03435d48645df6d17eaa2a8421 Mon Sep 17 00:00:00 2001 From: Baruch Even Date: Fri, 5 Apr 2013 19:11:45 +0300 Subject: [libata] SCSI: really use SATL version in VPD As per c78968bb by Jeff Garzik ([libata] SCSI: simulator version, not device version, belongs in VPD) We need to provide the SATL driver version and not the disk firmware version but the code overwrites the driver version with the disk version. Signed-off-by: Baruch Even Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index fe759cafc67..dd310b27b24 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2127,7 +2127,6 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) memcpy(&rbuf[8], "linux ", 8); memcpy(&rbuf[16], "libata ", 16); memcpy(&rbuf[32], DRV_VERSION, 4); - ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); /* we don't store the ATA device signature, so we fake it */ -- cgit v1.2.3 From d66af4df0837f21bf267305dc5ccab2d29e24d86 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Sat, 27 Apr 2013 09:33:07 +0800 Subject: [libata] acpi: make ata_ap_acpi_handle not block Since commit 30dcf76acc, ata_ap_acpi_handle will always do a namespace walk, which requires acquiring an acpi namespace mutex. This made it impossible to be used when calling path has held a spinlock. For example, it can occur in the following code path for pata_acpi: ata_scsi_queuecmd (ap->lock is acquired) __ata_scsi_queuecmd ata_scsi_translate ata_qc_issue pacpi_qc_issue ata_acpi_stm ata_ap_acpi_handle acpi_get_child acpi_walk_namespace acpi_ut_acquire_mutex (acquire mutex while holding lock) This caused scheduling while atomic bug, as reported in bug #56781. Actually, ata_ap_acpi_handle doesn't have to walk the namespace every time it is called, it can simply return the bound acpi handle on the corresponding SCSI host. The reason previously it is not done this way is, ata_ap_acpi_handle is used in the binding function ata_acpi_bind_host by ata_acpi_gtm when the handle is not bound to the SCSI host yet. Since we already have the ATA port's handle in its binding function, we can simply use it instead of calling ata_ap_acpi_handle there. So introduce a new function __ata_acpi_gtm, where it will receive an acpi handle param in addition to the ATA port which is solely used for debug statement. With this change, we can make ata_ap_acpi_handle simply return the bound handle for SCSI host instead of walking the acpi namespace now. Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=56781 Reported-and-tested-by: Cc: Signed-off-by: Aaron Lu Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 1c33f78040c..f6d80e34231 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -60,7 +60,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap) if (ap->flags & ATA_FLAG_ACPI_SATA) return NULL; - return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no); + return ap->scsi_host ? + DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL; } EXPORT_SYMBOL(ata_ap_acpi_handle); @@ -239,28 +240,15 @@ void ata_acpi_dissociate(struct ata_host *host) } } -/** - * ata_acpi_gtm - execute _GTM - * @ap: target ATA port - * @gtm: out parameter for _GTM result - * - * Evaluate _GTM and store the result in @gtm. - * - * LOCKING: - * EH context. - * - * RETURNS: - * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. - */ -int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) +static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle, + struct ata_acpi_gtm *gtm) { struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; union acpi_object *out_obj; acpi_status status; int rc = 0; - status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL, - &output); + status = acpi_evaluate_object(handle, "_GTM", NULL, &output); rc = -ENOENT; if (status == AE_NOT_FOUND) @@ -294,6 +282,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) return rc; } +/** + * ata_acpi_gtm - execute _GTM + * @ap: target ATA port + * @gtm: out parameter for _GTM result + * + * Evaluate _GTM and store the result in @gtm. + * + * LOCKING: + * EH context. + * + * RETURNS: + * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. + */ +int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) +{ + if (ata_ap_acpi_handle(ap)) + return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm); + else + return -EINVAL; +} + EXPORT_SYMBOL_GPL(ata_acpi_gtm); /** @@ -1047,7 +1056,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle) if (!*handle) return -ENODEV; - if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) + if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0) ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; return 0; -- cgit v1.2.3 From 19ccee765f8030c1e36720b6bcb7e8bd8262af5c Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Sat, 27 Apr 2013 09:37:53 +0800 Subject: ACPI/libata: Restore libata.noacpi support This patch restores libata.noacpi support to libata-acpi.c. There are broken optional control methods for ATA controller devices in the real world. The libata.noacpi has been used for a long time as a workaround to deal with issues caused by the broken ASL codes. 1. The "noacpi" option is introduced by the following commit: commit 11ef697b37e3c85ce1ac21f7711babf1f5b12784 Date: Thu, 28 Sep 2006 11:29:01 -0700 Subject: libata: ACPI and _GTF support 2. The "noacpi" option is renamed to "libata_noacpi" by the following commit: commit d7d0dad62a641c156386288a747c1a2f6bb2e42d Date: Wed, 28 Mar 2007 01:57:37 -0400 Subject: [libata] Disable ACPI by default; fix namespace problems 3. Some of its logics are changed over time - becomes relying on the "acpi_handle" bound to the ATA devices since this commit: commit fafbae87db88a73b166d3bc3294d209207f27056 Date: Tue, 15 May 2007 03:28:16 +0900 Subject: libata-acpi: implement ata_acpi_associate() 4. The option is deleted by the following commit: commit 30dcf76acc695cbd2fa919e294670fe9552e16e7 Date: Mon, 25 Jun 2012 16:13:04 +0800 Subject: libata: migrate ACPI code over to new bindings But the libata.noacpi setup is still left in the kernel without codes to implement it. So the deletion introduces a regression to the Linux. This patch disables ATA_ACPI support at runtime by stopping acpi binding on the ATA devices to fix this regression. This patch is tested by booting a SATA x86-64 kernel or a PATA x86 kernel with or without "libata.noacpi=1" kernel command line argument. Signed-off-by: Lv Zheng Signed-off-by: Aaron Lu Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index f6d80e34231..87f2f395d79 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -77,7 +77,7 @@ 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) + if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED) return NULL; if (ap->flags & ATA_FLAG_ACPI_SATA) { @@ -1047,7 +1047,7 @@ static int compat_pci_ata(struct ata_port *ap) static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle) { - if (ap->flags & ATA_FLAG_ACPI_SATA) + if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA) return -ENODEV; *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent), -- cgit v1.2.3 From 2cc1144a31f76d4a9fb48bec5d6ba1359f980813 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Tue, 30 Apr 2013 18:57:18 +0200 Subject: sata_highbank: Rename proc_name to the module name mkinitrd looks at /sys/class/scsi_host/host$hostnum/proc_name to find the module name of a disk driver. Current name is "highbank-ahci" but the module is "sata_highbank". Rename it to match the module name. Cc: Rob Herring Cc: Alexander Graf Cc: v3.7.. Signed-off-by: Robert Richter 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 b1ab7d8c396..b20aa96b958 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c @@ -251,7 +251,7 @@ static const struct ata_port_info ahci_highbank_port_info = { }; static struct scsi_host_template ahci_highbank_platform_sht = { - AHCI_SHT("highbank-ahci"), + AHCI_SHT("sata_highbank"), }; static const struct of_device_id ahci_of_match[] = { -- cgit v1.2.3