aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-10 07:23:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-10 07:23:11 -0400
commitd9428f09763d307a6d2220c4bbb01d8fc5c55b52 (patch)
treebe02ed22b6630d6a40706b2e09cc8b13fa3e3e7c
parent0cf744bc7ae8e0072159a901f6e1a159bbc30ffa (diff)
parent37017ac6849e772e67dd187ba2fbd056c4afa533 (diff)
Merge branch 'for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata update from Tejun Heo: "AHCI is getting per-port irq handling and locks for better scalability. The gain is not huge but measureable with multiple high iops devices connected to the same host; however, the value of threaded IRQ handling seems negligible for AHCI and it likely will revert to non-threaded handling soon. Another noteworthy change is George Spelvin's "libata: Un-break ATA blacklist". During 3.17 devel cycle, the libata blacklist glob matching got generalized and rewritten; unfortunately, the patch forgot to swap arguments to match the new match function and ended up breaking blacklist matching completely. It got noticed only a couple days ago so it couldn't make for-3.17-fixes either. :( Other than the above two, nothing too interesting - the usual cleanup churns and device-specific changes" * 'for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (22 commits) pata_serverworks: disable 64-KB DMA transfers on Broadcom OSB4 IDE Controller libata: Un-break ATA blacklist AHCI: Do not acquire ata_host::lock from single IRQ handler AHCI: Optimize single IRQ interrupt processing AHCI: Do not read HOST_IRQ_STAT reg in multi-MSI mode AHCI: Make few function names more descriptive AHCI: Move host activation code into ahci_host_activate() AHCI: Move ahci_host_activate() function to libahci.c AHCI: Pass SCSI host template as arg to ahci_host_activate() ata: pata_imx: Use the SIMPLE_DEV_PM_OPS() macro AHCI: Cleanup checking of multiple MSIs/SLM modes libata-sff: Fix controllers with no ctl port ahci_xgene: Fix the error print invalid resource for APM X-Gene SoC AHCI SATA Host Controller driver. libata: change ata_<foo>_printk routines to return void ata: qcom: Add device tree bindings information ahci-platform: Bump max number of clocks to 5 ahci: ahci_p5wdh_workaround - constify DMI table libahci_platform: Staticize ahci_platform_<en/dis>able_phys() pata_platform: Remove useless irq_flags field pata_of_platform: Remove "electra-ide" quirk ...
-rw-r--r--Documentation/devicetree/bindings/ata/qcom-sata.txt48
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537e.c3
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537u.c3
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c3
-rw-r--r--arch/blackfin/mach-bf537/boards/tcm_bf537.c3
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c3
-rw-r--r--drivers/ata/acard-ahci.c3
-rw-r--r--drivers/ata/ahci.c82
-rw-r--r--drivers/ata/ahci.h10
-rw-r--r--drivers/ata/ahci_platform.c18
-rw-r--r--drivers/ata/ahci_xgene.c10
-rw-r--r--drivers/ata/libahci.c195
-rw-r--r--drivers/ata/libahci_platform.c32
-rw-r--r--drivers/ata/libata-core.c41
-rw-r--r--drivers/ata/libata-sff.c20
-rw-r--r--drivers/ata/pata_imx.c9
-rw-r--r--drivers/ata/pata_of_platform.c24
-rw-r--r--drivers/ata/pata_platform.c4
-rw-r--r--drivers/ata/pata_serverworks.c13
-rw-r--r--drivers/ata/sata_highbank.c3
-rw-r--r--include/linux/ahci_platform.h13
-rw-r--r--include/linux/ata_platform.h5
-rw-r--r--include/linux/libata.h12
23 files changed, 259 insertions, 298 deletions
diff --git a/Documentation/devicetree/bindings/ata/qcom-sata.txt b/Documentation/devicetree/bindings/ata/qcom-sata.txt
new file mode 100644
index 000000000000..094de91cd9fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/qcom-sata.txt
@@ -0,0 +1,48 @@
1* Qualcomm AHCI SATA Controller
2
3SATA nodes are defined to describe on-chip Serial ATA controllers.
4Each SATA controller should have its own node.
5
6Required properties:
7- compatible : compatible list, must contain "generic-ahci"
8- interrupts : <interrupt mapping for SATA IRQ>
9- reg : <registers mapping>
10- phys : Must contain exactly one entry as specified
11 in phy-bindings.txt
12- phy-names : Must be "sata-phy"
13
14Required properties for "qcom,ipq806x-ahci" compatible:
15- clocks : Must contain an entry for each entry in clock-names.
16- clock-names : Shall be:
17 "slave_iface" - Fabric port AHB clock for SATA
18 "iface" - AHB clock
19 "core" - core clock
20 "rxoob" - RX out-of-band clock
21 "pmalive" - Power Module Alive clock
22- assigned-clocks : Shall be:
23 SATA_RXOOB_CLK
24 SATA_PMALIVE_CLK
25- assigned-clock-rates : Shall be:
26 100Mhz (100000000) for SATA_RXOOB_CLK
27 100Mhz (100000000) for SATA_PMALIVE_CLK
28
29Example:
30 sata@29000000 {
31 compatible = "qcom,ipq806x-ahci", "generic-ahci";
32 reg = <0x29000000 0x180>;
33
34 interrupts = <0 209 0x0>;
35
36 clocks = <&gcc SFAB_SATA_S_H_CLK>,
37 <&gcc SATA_H_CLK>,
38 <&gcc SATA_A_CLK>,
39 <&gcc SATA_RXOOB_CLK>,
40 <&gcc SATA_PMALIVE_CLK>;
41 clock-names = "slave_iface", "iface", "core",
42 "rxoob", "pmalive";
43 assigned-clocks = <&gcc SATA_RXOOB_CLK>, <&gcc SATA_PMALIVE_CLK>;
44 assigned-clock-rates = <100000000>, <100000000>;
45
46 phys = <&sata_phy>;
47 phy-names = "sata-phy";
48 };
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537e.c b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
index 1e7290ef3525..1e1014df5e9e 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537e.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
@@ -733,7 +733,6 @@ static struct platform_device bfin_mac_device = {
733 733
734static struct pata_platform_info bfin_pata_platform_data = { 734static struct pata_platform_info bfin_pata_platform_data = {
735 .ioport_shift = 2, 735 .ioport_shift = 2,
736 .irq_type = IRQF_TRIGGER_HIGH,
737}; 736};
738 737
739static struct resource bfin_pata_resources[] = { 738static struct resource bfin_pata_resources[] = {
@@ -750,7 +749,7 @@ static struct resource bfin_pata_resources[] = {
750 { 749 {
751 .start = PATA_INT, 750 .start = PATA_INT,
752 .end = PATA_INT, 751 .end = PATA_INT,
753 .flags = IORESOURCE_IRQ, 752 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
754 }, 753 },
755}; 754};
756 755
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
index c7495dc74690..d056db9e5592 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537u.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
@@ -587,7 +587,6 @@ static struct platform_device bfin_mac_device = {
587 587
588static struct pata_platform_info bfin_pata_platform_data = { 588static struct pata_platform_info bfin_pata_platform_data = {
589 .ioport_shift = 2, 589 .ioport_shift = 2,
590 .irq_type = IRQF_TRIGGER_HIGH,
591}; 590};
592 591
593static struct resource bfin_pata_resources[] = { 592static struct resource bfin_pata_resources[] = {
@@ -604,7 +603,7 @@ static struct resource bfin_pata_resources[] = {
604 { 603 {
605 .start = PATA_INT, 604 .start = PATA_INT,
606 .end = PATA_INT, 605 .end = PATA_INT,
607 .flags = IORESOURCE_IRQ, 606 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
608 }, 607 },
609}; 608};
610 609
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index de19b8a56007..88a19fc9844d 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -2462,7 +2462,6 @@ static struct platform_device bfin_sport0_device = {
2462#define PATA_INT IRQ_PF5 2462#define PATA_INT IRQ_PF5
2463static struct pata_platform_info bfin_pata_platform_data = { 2463static struct pata_platform_info bfin_pata_platform_data = {
2464 .ioport_shift = 1, 2464 .ioport_shift = 1,
2465 .irq_flags = IRQF_TRIGGER_HIGH,
2466}; 2465};
2467 2466
2468static struct resource bfin_pata_resources[] = { 2467static struct resource bfin_pata_resources[] = {
@@ -2479,7 +2478,7 @@ static struct resource bfin_pata_resources[] = {
2479 { 2478 {
2480 .start = PATA_INT, 2479 .start = PATA_INT,
2481 .end = PATA_INT, 2480 .end = PATA_INT,
2482 .flags = IORESOURCE_IRQ, 2481 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
2483 }, 2482 },
2484}; 2483};
2485#elif defined(CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE) 2484#elif defined(CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE)
diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
index 6b988ad653d8..ed309c9a62b6 100644
--- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
@@ -589,7 +589,6 @@ static struct platform_device bfin_mac_device = {
589 589
590static struct pata_platform_info bfin_pata_platform_data = { 590static struct pata_platform_info bfin_pata_platform_data = {
591 .ioport_shift = 2, 591 .ioport_shift = 2,
592 .irq_type = IRQF_TRIGGER_HIGH,
593}; 592};
594 593
595static struct resource bfin_pata_resources[] = { 594static struct resource bfin_pata_resources[] = {
@@ -606,7 +605,7 @@ static struct resource bfin_pata_resources[] = {
606 { 605 {
607 .start = PATA_INT, 606 .start = PATA_INT,
608 .end = PATA_INT, 607 .end = PATA_INT,
609 .flags = IORESOURCE_IRQ, 608 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
610 }, 609 },
611}; 610};
612 611
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
index e862f7823e68..c6db52ba3a06 100644
--- a/arch/blackfin/mach-bf561/boards/cm_bf561.c
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -354,7 +354,6 @@ static struct platform_device bfin_sir0_device = {
354 354
355static struct pata_platform_info bfin_pata_platform_data = { 355static struct pata_platform_info bfin_pata_platform_data = {
356 .ioport_shift = 2, 356 .ioport_shift = 2,
357 .irq_type = IRQF_TRIGGER_HIGH,
358}; 357};
359 358
360static struct resource bfin_pata_resources[] = { 359static struct resource bfin_pata_resources[] = {
@@ -371,7 +370,7 @@ static struct resource bfin_pata_resources[] = {
371 { 370 {
372 .start = PATA_INT, 371 .start = PATA_INT,
373 .end = PATA_INT, 372 .end = PATA_INT,
374 .flags = IORESOURCE_IRQ, 373 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
375 }, 374 },
376}; 375};
377 376
diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c
index 25d0ac32e721..c962886d7e71 100644
--- a/drivers/ata/acard-ahci.c
+++ b/drivers/ata/acard-ahci.c
@@ -498,8 +498,7 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id
498 acard_ahci_pci_print_info(host); 498 acard_ahci_pci_print_info(host);
499 499
500 pci_set_master(pdev); 500 pci_set_master(pdev);
501 return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED, 501 return ahci_host_activate(host, pdev->irq, &acard_ahci_sht);
502 &acard_ahci_sht);
503} 502}
504 503
505module_pci_driver(acard_ahci_pci_driver); 504module_pci_driver(acard_ahci_pci_driver);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a0cc0edafc78..5f039f191067 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -790,7 +790,7 @@ static void ahci_pci_print_info(struct ata_host *host)
790 */ 790 */
791static void ahci_p5wdh_workaround(struct ata_host *host) 791static void ahci_p5wdh_workaround(struct ata_host *host)
792{ 792{
793 static struct dmi_system_id sysids[] = { 793 static const struct dmi_system_id sysids[] = {
794 { 794 {
795 .ident = "P5W DH Deluxe", 795 .ident = "P5W DH Deluxe",
796 .matches = { 796 .matches = {
@@ -1221,6 +1221,9 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
1221 goto single_msi; 1221 goto single_msi;
1222 } 1222 }
1223 1223
1224 if (nvec > 1)
1225 hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1226
1224 return nvec; 1227 return nvec;
1225 1228
1226single_msi: 1229single_msi:
@@ -1233,71 +1236,6 @@ intx:
1233 return 0; 1236 return 0;
1234} 1237}
1235 1238
1236/**
1237 * ahci_host_activate - start AHCI host, request IRQs and register it
1238 * @host: target ATA host
1239 * @irq: base IRQ number to request
1240 * @n_msis: number of MSIs allocated for this host
1241 * @irq_handler: irq_handler used when requesting IRQs
1242 * @irq_flags: irq_flags used when requesting IRQs
1243 *
1244 * Similar to ata_host_activate, but requests IRQs according to AHCI-1.1
1245 * when multiple MSIs were allocated. That is one MSI per port, starting
1246 * from @irq.
1247 *
1248 * LOCKING:
1249 * Inherited from calling layer (may sleep).
1250 *
1251 * RETURNS:
1252 * 0 on success, -errno otherwise.
1253 */
1254int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
1255{
1256 int i, rc;
1257
1258 /* Sharing Last Message among several ports is not supported */
1259 if (n_msis < host->n_ports)
1260 return -EINVAL;
1261
1262 rc = ata_host_start(host);
1263 if (rc)
1264 return rc;
1265
1266 for (i = 0; i < host->n_ports; i++) {
1267 struct ahci_port_priv *pp = host->ports[i]->private_data;
1268
1269 /* Do not receive interrupts sent by dummy ports */
1270 if (!pp) {
1271 disable_irq(irq + i);
1272 continue;
1273 }
1274
1275 rc = devm_request_threaded_irq(host->dev, irq + i,
1276 ahci_hw_interrupt,
1277 ahci_thread_fn, IRQF_SHARED,
1278 pp->irq_desc, host->ports[i]);
1279 if (rc)
1280 goto out_free_irqs;
1281 }
1282
1283 for (i = 0; i < host->n_ports; i++)
1284 ata_port_desc(host->ports[i], "irq %d", irq + i);
1285
1286 rc = ata_host_register(host, &ahci_sht);
1287 if (rc)
1288 goto out_free_all_irqs;
1289
1290 return 0;
1291
1292out_free_all_irqs:
1293 i = host->n_ports;
1294out_free_irqs:
1295 for (i--; i >= 0; i--)
1296 devm_free_irq(host->dev, irq + i, host->ports[i]);
1297
1298 return rc;
1299}
1300
1301static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1239static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1302{ 1240{
1303 unsigned int board_id = ent->driver_data; 1241 unsigned int board_id = ent->driver_data;
@@ -1306,7 +1244,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1306 struct device *dev = &pdev->dev; 1244 struct device *dev = &pdev->dev;
1307 struct ahci_host_priv *hpriv; 1245 struct ahci_host_priv *hpriv;
1308 struct ata_host *host; 1246 struct ata_host *host;
1309 int n_ports, n_msis, i, rc; 1247 int n_ports, i, rc;
1310 int ahci_pci_bar = AHCI_PCI_BAR_STANDARD; 1248 int ahci_pci_bar = AHCI_PCI_BAR_STANDARD;
1311 1249
1312 VPRINTK("ENTER\n"); 1250 VPRINTK("ENTER\n");
@@ -1459,9 +1397,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1459 */ 1397 */
1460 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); 1398 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
1461 1399
1462 n_msis = ahci_init_interrupts(pdev, n_ports, hpriv); 1400 ahci_init_interrupts(pdev, n_ports, hpriv);
1463 if (n_msis > 1)
1464 hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1465 1401
1466 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); 1402 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
1467 if (!host) 1403 if (!host)
@@ -1513,11 +1449,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1513 1449
1514 pci_set_master(pdev); 1450 pci_set_master(pdev);
1515 1451
1516 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI) 1452 return ahci_host_activate(host, pdev->irq, &ahci_sht);
1517 return ahci_host_activate(host, pdev->irq, n_msis);
1518
1519 return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
1520 &ahci_sht);
1521} 1453}
1522 1454
1523module_pci_driver(ahci_pci_driver); 1455module_pci_driver(ahci_pci_driver);
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 59ae0ee00149..40f0e34f17af 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -53,7 +53,7 @@
53 53
54enum { 54enum {
55 AHCI_MAX_PORTS = 32, 55 AHCI_MAX_PORTS = 32,
56 AHCI_MAX_CLKS = 4, 56 AHCI_MAX_CLKS = 5,
57 AHCI_MAX_SG = 168, /* hardware max is 64K */ 57 AHCI_MAX_SG = 168, /* hardware max is 64K */
58 AHCI_DMA_BOUNDARY = 0xffffffff, 58 AHCI_DMA_BOUNDARY = 0xffffffff,
59 AHCI_MAX_CMDS = 32, 59 AHCI_MAX_CMDS = 32,
@@ -304,7 +304,7 @@ struct ahci_port_priv {
304 unsigned int ncq_saw_d2h:1; 304 unsigned int ncq_saw_d2h:1;
305 unsigned int ncq_saw_dmas:1; 305 unsigned int ncq_saw_dmas:1;
306 unsigned int ncq_saw_sdb:1; 306 unsigned int ncq_saw_sdb:1;
307 u32 intr_status; /* interrupts to handle */ 307 atomic_t intr_status; /* interrupts to handle */
308 spinlock_t lock; /* protects parent ata_port */ 308 spinlock_t lock; /* protects parent ata_port */
309 u32 intr_mask; /* interrupts to enable */ 309 u32 intr_mask; /* interrupts to enable */
310 bool fbs_supported; /* set iff FBS is supported */ 310 bool fbs_supported; /* set iff FBS is supported */
@@ -388,11 +388,9 @@ int ahci_port_resume(struct ata_port *ap);
388void ahci_set_em_messages(struct ahci_host_priv *hpriv, 388void ahci_set_em_messages(struct ahci_host_priv *hpriv,
389 struct ata_port_info *pi); 389 struct ata_port_info *pi);
390int ahci_reset_em(struct ata_host *host); 390int ahci_reset_em(struct ata_host *host);
391irqreturn_t ahci_interrupt(int irq, void *dev_instance);
392irqreturn_t ahci_hw_interrupt(int irq, void *dev_instance);
393irqreturn_t ahci_thread_fn(int irq, void *dev_instance);
394void ahci_print_info(struct ata_host *host, const char *scc_s); 391void ahci_print_info(struct ata_host *host, const char *scc_s);
395int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis); 392int ahci_host_activate(struct ata_host *host, int irq,
393 struct scsi_host_template *sht);
396void ahci_error_handler(struct ata_port *ap); 394void ahci_error_handler(struct ata_port *ap);
397 395
398static inline void __iomem *__ahci_port_base(struct ata_host *host, 396static inline void __iomem *__ahci_port_base(struct ata_host *host,
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index f61ddb9146d6..06f1d59fa678 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -32,7 +32,6 @@ static const struct ata_port_info ahci_port_info = {
32static int ahci_probe(struct platform_device *pdev) 32static int ahci_probe(struct platform_device *pdev)
33{ 33{
34 struct device *dev = &pdev->dev; 34 struct device *dev = &pdev->dev;
35 struct ahci_platform_data *pdata = dev_get_platdata(dev);
36 struct ahci_host_priv *hpriv; 35 struct ahci_host_priv *hpriv;
37 int rc; 36 int rc;
38 37
@@ -44,29 +43,14 @@ static int ahci_probe(struct platform_device *pdev)
44 if (rc) 43 if (rc)
45 return rc; 44 return rc;
46 45
47 /*
48 * Some platforms might need to prepare for mmio region access,
49 * which could be done in the following init call. So, the mmio
50 * region shouldn't be accessed before init (if provided) has
51 * returned successfully.
52 */
53 if (pdata && pdata->init) {
54 rc = pdata->init(dev, hpriv->mmio);
55 if (rc)
56 goto disable_resources;
57 }
58
59 if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) 46 if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
60 hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; 47 hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
61 48
62 rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info); 49 rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info);
63 if (rc) 50 if (rc)
64 goto pdata_exit; 51 goto disable_resources;
65 52
66 return 0; 53 return 0;
67pdata_exit:
68 if (pdata && pdata->exit)
69 pdata->exit(dev);
70disable_resources: 54disable_resources:
71 ahci_platform_disable_resources(hpriv); 55 ahci_platform_disable_resources(hpriv);
72 return rc; 56 return rc;
diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c
index f03aab187f4d..0f8538f238b6 100644
--- a/drivers/ata/ahci_xgene.c
+++ b/drivers/ata/ahci_xgene.c
@@ -434,7 +434,7 @@ static int xgene_ahci_mux_select(struct xgene_ahci_context *ctx)
434 u32 val; 434 u32 val;
435 435
436 /* Check for optional MUX resource */ 436 /* Check for optional MUX resource */
437 if (IS_ERR(ctx->csr_mux)) 437 if (!ctx->csr_mux)
438 return 0; 438 return 0;
439 439
440 val = readl(ctx->csr_mux + SATA_ENET_CONFIG_REG); 440 val = readl(ctx->csr_mux + SATA_ENET_CONFIG_REG);
@@ -484,7 +484,13 @@ static int xgene_ahci_probe(struct platform_device *pdev)
484 484
485 /* Retrieve the optional IP mux resource */ 485 /* Retrieve the optional IP mux resource */
486 res = platform_get_resource(pdev, IORESOURCE_MEM, 4); 486 res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
487 ctx->csr_mux = devm_ioremap_resource(dev, res); 487 if (res) {
488 void __iomem *csr = devm_ioremap_resource(dev, res);
489 if (IS_ERR(csr))
490 return PTR_ERR(csr);
491
492 ctx->csr_mux = csr;
493 }
488 494
489 dev_dbg(dev, "VAddr 0x%p Mmio VAddr 0x%p\n", ctx->csr_core, 495 dev_dbg(dev, "VAddr 0x%p Mmio VAddr 0x%p\n", ctx->csr_core,
490 hpriv->mmio); 496 hpriv->mmio);
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index b784e9de426a..5eb61c9e63da 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1778,30 +1778,28 @@ static void ahci_handle_port_interrupt(struct ata_port *ap,
1778 } 1778 }
1779} 1779}
1780 1780
1781static void ahci_port_intr(struct ata_port *ap) 1781static void ahci_update_intr_status(struct ata_port *ap)
1782{ 1782{
1783 void __iomem *port_mmio = ahci_port_base(ap); 1783 void __iomem *port_mmio = ahci_port_base(ap);
1784 struct ahci_port_priv *pp = ap->private_data;
1784 u32 status; 1785 u32 status;
1785 1786
1786 status = readl(port_mmio + PORT_IRQ_STAT); 1787 status = readl(port_mmio + PORT_IRQ_STAT);
1787 writel(status, port_mmio + PORT_IRQ_STAT); 1788 writel(status, port_mmio + PORT_IRQ_STAT);
1788 1789
1789 ahci_handle_port_interrupt(ap, port_mmio, status); 1790 atomic_or(status, &pp->intr_status);
1790} 1791}
1791 1792
1792irqreturn_t ahci_thread_fn(int irq, void *dev_instance) 1793static irqreturn_t ahci_port_thread_fn(int irq, void *dev_instance)
1793{ 1794{
1794 struct ata_port *ap = dev_instance; 1795 struct ata_port *ap = dev_instance;
1795 struct ahci_port_priv *pp = ap->private_data; 1796 struct ahci_port_priv *pp = ap->private_data;
1796 void __iomem *port_mmio = ahci_port_base(ap); 1797 void __iomem *port_mmio = ahci_port_base(ap);
1797 unsigned long flags;
1798 u32 status; 1798 u32 status;
1799 1799
1800 spin_lock_irqsave(&ap->host->lock, flags); 1800 status = atomic_xchg(&pp->intr_status, 0);
1801 status = pp->intr_status; 1801 if (!status)
1802 if (status) 1802 return IRQ_NONE;
1803 pp->intr_status = 0;
1804 spin_unlock_irqrestore(&ap->host->lock, flags);
1805 1803
1806 spin_lock_bh(ap->lock); 1804 spin_lock_bh(ap->lock);
1807 ahci_handle_port_interrupt(ap, port_mmio, status); 1805 ahci_handle_port_interrupt(ap, port_mmio, status);
@@ -1809,47 +1807,13 @@ irqreturn_t ahci_thread_fn(int irq, void *dev_instance)
1809 1807
1810 return IRQ_HANDLED; 1808 return IRQ_HANDLED;
1811} 1809}
1812EXPORT_SYMBOL_GPL(ahci_thread_fn);
1813
1814static void ahci_hw_port_interrupt(struct ata_port *ap)
1815{
1816 void __iomem *port_mmio = ahci_port_base(ap);
1817 struct ahci_port_priv *pp = ap->private_data;
1818 u32 status;
1819
1820 status = readl(port_mmio + PORT_IRQ_STAT);
1821 writel(status, port_mmio + PORT_IRQ_STAT);
1822 1810
1823 pp->intr_status |= status; 1811irqreturn_t ahci_thread_fn(int irq, void *dev_instance)
1824}
1825
1826irqreturn_t ahci_hw_interrupt(int irq, void *dev_instance)
1827{ 1812{
1828 struct ata_port *ap_this = dev_instance; 1813 struct ata_host *host = dev_instance;
1829 struct ahci_port_priv *pp = ap_this->private_data;
1830 struct ata_host *host = ap_this->host;
1831 struct ahci_host_priv *hpriv = host->private_data; 1814 struct ahci_host_priv *hpriv = host->private_data;
1832 void __iomem *mmio = hpriv->mmio; 1815 u32 irq_masked = hpriv->port_map;
1833 unsigned int i; 1816 unsigned int i;
1834 u32 irq_stat, irq_masked;
1835
1836 VPRINTK("ENTER\n");
1837
1838 spin_lock(&host->lock);
1839
1840 irq_stat = readl(mmio + HOST_IRQ_STAT);
1841
1842 if (!irq_stat) {
1843 u32 status = pp->intr_status;
1844
1845 spin_unlock(&host->lock);
1846
1847 VPRINTK("EXIT\n");
1848
1849 return status ? IRQ_WAKE_THREAD : IRQ_NONE;
1850 }
1851
1852 irq_masked = irq_stat & hpriv->port_map;
1853 1817
1854 for (i = 0; i < host->n_ports; i++) { 1818 for (i = 0; i < host->n_ports; i++) {
1855 struct ata_port *ap; 1819 struct ata_port *ap;
@@ -1859,7 +1823,7 @@ irqreturn_t ahci_hw_interrupt(int irq, void *dev_instance)
1859 1823
1860 ap = host->ports[i]; 1824 ap = host->ports[i];
1861 if (ap) { 1825 if (ap) {
1862 ahci_hw_port_interrupt(ap); 1826 ahci_port_thread_fn(irq, ap);
1863 VPRINTK("port %u\n", i); 1827 VPRINTK("port %u\n", i);
1864 } else { 1828 } else {
1865 VPRINTK("port %u (no irq)\n", i); 1829 VPRINTK("port %u (no irq)\n", i);
@@ -1869,17 +1833,29 @@ irqreturn_t ahci_hw_interrupt(int irq, void *dev_instance)
1869 } 1833 }
1870 } 1834 }
1871 1835
1872 writel(irq_stat, mmio + HOST_IRQ_STAT); 1836 return IRQ_HANDLED;
1837}
1873 1838
1874 spin_unlock(&host->lock); 1839static irqreturn_t ahci_multi_irqs_intr(int irq, void *dev_instance)
1840{
1841 struct ata_port *ap = dev_instance;
1842 void __iomem *port_mmio = ahci_port_base(ap);
1843 struct ahci_port_priv *pp = ap->private_data;
1844 u32 status;
1845
1846 VPRINTK("ENTER\n");
1847
1848 status = readl(port_mmio + PORT_IRQ_STAT);
1849 writel(status, port_mmio + PORT_IRQ_STAT);
1850
1851 atomic_or(status, &pp->intr_status);
1875 1852
1876 VPRINTK("EXIT\n"); 1853 VPRINTK("EXIT\n");
1877 1854
1878 return IRQ_WAKE_THREAD; 1855 return IRQ_WAKE_THREAD;
1879} 1856}
1880EXPORT_SYMBOL_GPL(ahci_hw_interrupt);
1881 1857
1882irqreturn_t ahci_interrupt(int irq, void *dev_instance) 1858static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
1883{ 1859{
1884 struct ata_host *host = dev_instance; 1860 struct ata_host *host = dev_instance;
1885 struct ahci_host_priv *hpriv; 1861 struct ahci_host_priv *hpriv;
@@ -1899,8 +1875,6 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance)
1899 1875
1900 irq_masked = irq_stat & hpriv->port_map; 1876 irq_masked = irq_stat & hpriv->port_map;
1901 1877
1902 spin_lock(&host->lock);
1903
1904 for (i = 0; i < host->n_ports; i++) { 1878 for (i = 0; i < host->n_ports; i++) {
1905 struct ata_port *ap; 1879 struct ata_port *ap;
1906 1880
@@ -1909,7 +1883,7 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance)
1909 1883
1910 ap = host->ports[i]; 1884 ap = host->ports[i];
1911 if (ap) { 1885 if (ap) {
1912 ahci_port_intr(ap); 1886 ahci_update_intr_status(ap);
1913 VPRINTK("port %u\n", i); 1887 VPRINTK("port %u\n", i);
1914 } else { 1888 } else {
1915 VPRINTK("port %u (no irq)\n", i); 1889 VPRINTK("port %u (no irq)\n", i);
@@ -1932,13 +1906,10 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance)
1932 */ 1906 */
1933 writel(irq_stat, mmio + HOST_IRQ_STAT); 1907 writel(irq_stat, mmio + HOST_IRQ_STAT);
1934 1908
1935 spin_unlock(&host->lock);
1936
1937 VPRINTK("EXIT\n"); 1909 VPRINTK("EXIT\n");
1938 1910
1939 return IRQ_RETVAL(handled); 1911 return handled ? IRQ_WAKE_THREAD : IRQ_NONE;
1940} 1912}
1941EXPORT_SYMBOL_GPL(ahci_interrupt);
1942 1913
1943unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) 1914unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1944{ 1915{
@@ -2349,13 +2320,8 @@ static int ahci_port_start(struct ata_port *ap)
2349 */ 2320 */
2350 pp->intr_mask = DEF_PORT_IRQ; 2321 pp->intr_mask = DEF_PORT_IRQ;
2351 2322
2352 /* 2323 spin_lock_init(&pp->lock);
2353 * Switch to per-port locking in case each port has its own MSI vector. 2324 ap->lock = &pp->lock;
2354 */
2355 if ((hpriv->flags & AHCI_HFLAG_MULTI_MSI)) {
2356 spin_lock_init(&pp->lock);
2357 ap->lock = &pp->lock;
2358 }
2359 2325
2360 ap->private_data = pp; 2326 ap->private_data = pp;
2361 2327
@@ -2472,6 +2438,105 @@ void ahci_set_em_messages(struct ahci_host_priv *hpriv,
2472} 2438}
2473EXPORT_SYMBOL_GPL(ahci_set_em_messages); 2439EXPORT_SYMBOL_GPL(ahci_set_em_messages);
2474 2440
2441static int ahci_host_activate_multi_irqs(struct ata_host *host, int irq,
2442 struct scsi_host_template *sht)
2443{
2444 int i, rc;
2445
2446 rc = ata_host_start(host);
2447 if (rc)
2448 return rc;
2449
2450 for (i = 0; i < host->n_ports; i++) {
2451 struct ahci_port_priv *pp = host->ports[i]->private_data;
2452
2453 /* Do not receive interrupts sent by dummy ports */
2454 if (!pp) {
2455 disable_irq(irq + i);
2456 continue;
2457 }
2458
2459 rc = devm_request_threaded_irq(host->dev, irq + i,
2460 ahci_multi_irqs_intr,
2461 ahci_port_thread_fn, IRQF_SHARED,
2462 pp->irq_desc, host->ports[i]);
2463 if (rc)
2464 goto out_free_irqs;
2465 }
2466
2467 for (i = 0; i < host->n_ports; i++)
2468 ata_port_desc(host->ports[i], "irq %d", irq + i);
2469
2470 rc = ata_host_register(host, sht);
2471 if (rc)
2472 goto out_free_all_irqs;
2473
2474 return 0;
2475
2476out_free_all_irqs:
2477 i = host->n_ports;
2478out_free_irqs:
2479 for (i--; i >= 0; i--)
2480 devm_free_irq(host->dev, irq + i, host->ports[i]);
2481
2482 return rc;
2483}
2484
2485static int ahci_host_activate_single_irq(struct ata_host *host, int irq,
2486 struct scsi_host_template *sht)
2487{
2488 int i, rc;
2489
2490 rc = ata_host_start(host);
2491 if (rc)
2492 return rc;
2493
2494 rc = devm_request_threaded_irq(host->dev, irq, ahci_single_irq_intr,
2495 ahci_thread_fn, IRQF_SHARED,
2496 dev_driver_string(host->dev), host);
2497 if (rc)
2498 return rc;
2499
2500 for (i = 0; i < host->n_ports; i++)
2501 ata_port_desc(host->ports[i], "irq %d", irq);
2502
2503 rc = ata_host_register(host, sht);
2504 if (rc)
2505 devm_free_irq(host->dev, irq, host);
2506
2507 return rc;
2508}
2509
2510/**
2511 * ahci_host_activate - start AHCI host, request IRQs and register it
2512 * @host: target ATA host
2513 * @irq: base IRQ number to request
2514 * @sht: scsi_host_template to use when registering the host
2515 *
2516 * Similar to ata_host_activate, but requests IRQs according to AHCI-1.1
2517 * when multiple MSIs were allocated. That is one MSI per port, starting
2518 * from @irq.
2519 *
2520 * LOCKING:
2521 * Inherited from calling layer (may sleep).
2522 *
2523 * RETURNS:
2524 * 0 on success, -errno otherwise.
2525 */
2526int ahci_host_activate(struct ata_host *host, int irq,
2527 struct scsi_host_template *sht)
2528{
2529 struct ahci_host_priv *hpriv = host->private_data;
2530 int rc;
2531
2532 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI)
2533 rc = ahci_host_activate_multi_irqs(host, irq, sht);
2534 else
2535 rc = ahci_host_activate_single_irq(host, irq, sht);
2536 return rc;
2537}
2538EXPORT_SYMBOL_GPL(ahci_host_activate);
2539
2475MODULE_AUTHOR("Jeff Garzik"); 2540MODULE_AUTHOR("Jeff Garzik");
2476MODULE_DESCRIPTION("Common AHCI SATA low-level routines"); 2541MODULE_DESCRIPTION("Common AHCI SATA low-level routines");
2477MODULE_LICENSE("GPL"); 2542MODULE_LICENSE("GPL");
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index 5b92c290e6c6..0b03f9056692 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -49,7 +49,7 @@ static struct scsi_host_template ahci_platform_sht = {
49 * RETURNS: 49 * RETURNS:
50 * 0 on success otherwise a negative error code 50 * 0 on success otherwise a negative error code
51 */ 51 */
52int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 52static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
53{ 53{
54 int rc, i; 54 int rc, i;
55 55
@@ -77,7 +77,6 @@ disable_phys:
77 } 77 }
78 return rc; 78 return rc;
79} 79}
80EXPORT_SYMBOL_GPL(ahci_platform_enable_phys);
81 80
82/** 81/**
83 * ahci_platform_disable_phys - Disable PHYs 82 * ahci_platform_disable_phys - Disable PHYs
@@ -85,7 +84,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_phys);
85 * 84 *
86 * This function disables all PHYs found in hpriv->phys. 85 * This function disables all PHYs found in hpriv->phys.
87 */ 86 */
88void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 87static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
89{ 88{
90 int i; 89 int i;
91 90
@@ -97,7 +96,6 @@ void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
97 phy_exit(hpriv->phys[i]); 96 phy_exit(hpriv->phys[i]);
98 } 97 }
99} 98}
100EXPORT_SYMBOL_GPL(ahci_platform_disable_phys);
101 99
102/** 100/**
103 * ahci_platform_enable_clks - Enable platform clocks 101 * ahci_platform_enable_clks - Enable platform clocks
@@ -495,20 +493,14 @@ int ahci_platform_init_host(struct platform_device *pdev,
495 ahci_init_controller(host); 493 ahci_init_controller(host);
496 ahci_print_info(host, "platform"); 494 ahci_print_info(host, "platform");
497 495
498 return ata_host_activate(host, irq, ahci_interrupt, IRQF_SHARED, 496 return ahci_host_activate(host, irq, &ahci_platform_sht);
499 &ahci_platform_sht);
500} 497}
501EXPORT_SYMBOL_GPL(ahci_platform_init_host); 498EXPORT_SYMBOL_GPL(ahci_platform_init_host);
502 499
503static void ahci_host_stop(struct ata_host *host) 500static void ahci_host_stop(struct ata_host *host)
504{ 501{
505 struct device *dev = host->dev;
506 struct ahci_platform_data *pdata = dev_get_platdata(dev);
507 struct ahci_host_priv *hpriv = host->private_data; 502 struct ahci_host_priv *hpriv = host->private_data;
508 503
509 if (pdata && pdata->exit)
510 pdata->exit(dev);
511
512 ahci_platform_disable_resources(hpriv); 504 ahci_platform_disable_resources(hpriv);
513} 505}
514 506
@@ -592,7 +584,6 @@ EXPORT_SYMBOL_GPL(ahci_platform_resume_host);
592 */ 584 */
593int ahci_platform_suspend(struct device *dev) 585int ahci_platform_suspend(struct device *dev)
594{ 586{
595 struct ahci_platform_data *pdata = dev_get_platdata(dev);
596 struct ata_host *host = dev_get_drvdata(dev); 587 struct ata_host *host = dev_get_drvdata(dev);
597 struct ahci_host_priv *hpriv = host->private_data; 588 struct ahci_host_priv *hpriv = host->private_data;
598 int rc; 589 int rc;
@@ -601,19 +592,9 @@ int ahci_platform_suspend(struct device *dev)
601 if (rc) 592 if (rc)
602 return rc; 593 return rc;
603 594
604 if (pdata && pdata->suspend) {
605 rc = pdata->suspend(dev);
606 if (rc)
607 goto resume_host;
608 }
609
610 ahci_platform_disable_resources(hpriv); 595 ahci_platform_disable_resources(hpriv);
611 596
612 return 0; 597 return 0;
613
614resume_host:
615 ahci_platform_resume_host(dev);
616 return rc;
617} 598}
618EXPORT_SYMBOL_GPL(ahci_platform_suspend); 599EXPORT_SYMBOL_GPL(ahci_platform_suspend);
619 600
@@ -629,7 +610,6 @@ EXPORT_SYMBOL_GPL(ahci_platform_suspend);
629 */ 610 */
630int ahci_platform_resume(struct device *dev) 611int ahci_platform_resume(struct device *dev)
631{ 612{
632 struct ahci_platform_data *pdata = dev_get_platdata(dev);
633 struct ata_host *host = dev_get_drvdata(dev); 613 struct ata_host *host = dev_get_drvdata(dev);
634 struct ahci_host_priv *hpriv = host->private_data; 614 struct ahci_host_priv *hpriv = host->private_data;
635 int rc; 615 int rc;
@@ -638,12 +618,6 @@ int ahci_platform_resume(struct device *dev)
638 if (rc) 618 if (rc)
639 return rc; 619 return rc;
640 620
641 if (pdata && pdata->resume) {
642 rc = pdata->resume(dev);
643 if (rc)
644 goto disable_resources;
645 }
646
647 rc = ahci_platform_resume_host(dev); 621 rc = ahci_platform_resume_host(dev);
648 if (rc) 622 if (rc)
649 goto disable_resources; 623 goto disable_resources;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f3e7b9f894cd..c5ba15af87d3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4261,10 +4261,10 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev)
4261 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); 4261 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
4262 4262
4263 while (ad->model_num) { 4263 while (ad->model_num) {
4264 if (glob_match(model_num, ad->model_num)) { 4264 if (glob_match(ad->model_num, model_num)) {
4265 if (ad->model_rev == NULL) 4265 if (ad->model_rev == NULL)
4266 return ad->horkage; 4266 return ad->horkage;
4267 if (glob_match(model_rev, ad->model_rev)) 4267 if (glob_match(ad->model_rev, model_rev))
4268 return ad->horkage; 4268 return ad->horkage;
4269 } 4269 }
4270 ad++; 4270 ad++;
@@ -6227,7 +6227,7 @@ int ata_host_activate(struct ata_host *host, int irq,
6227 } 6227 }
6228 6228
6229 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags, 6229 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags,
6230 dev_driver_string(host->dev), host); 6230 dev_name(host->dev), host);
6231 if (rc) 6231 if (rc)
6232 return rc; 6232 return rc;
6233 6233
@@ -6772,32 +6772,28 @@ const struct ata_port_info ata_dummy_port_info = {
6772/* 6772/*
6773 * Utility print functions 6773 * Utility print functions
6774 */ 6774 */
6775int ata_port_printk(const struct ata_port *ap, const char *level, 6775void ata_port_printk(const struct ata_port *ap, const char *level,
6776 const char *fmt, ...) 6776 const char *fmt, ...)
6777{ 6777{
6778 struct va_format vaf; 6778 struct va_format vaf;
6779 va_list args; 6779 va_list args;
6780 int r;
6781 6780
6782 va_start(args, fmt); 6781 va_start(args, fmt);
6783 6782
6784 vaf.fmt = fmt; 6783 vaf.fmt = fmt;
6785 vaf.va = &args; 6784 vaf.va = &args;
6786 6785
6787 r = printk("%sata%u: %pV", level, ap->print_id, &vaf); 6786 printk("%sata%u: %pV", level, ap->print_id, &vaf);
6788 6787
6789 va_end(args); 6788 va_end(args);
6790
6791 return r;
6792} 6789}
6793EXPORT_SYMBOL(ata_port_printk); 6790EXPORT_SYMBOL(ata_port_printk);
6794 6791
6795int ata_link_printk(const struct ata_link *link, const char *level, 6792void ata_link_printk(const struct ata_link *link, const char *level,
6796 const char *fmt, ...) 6793 const char *fmt, ...)
6797{ 6794{
6798 struct va_format vaf; 6795 struct va_format vaf;
6799 va_list args; 6796 va_list args;
6800 int r;
6801 6797
6802 va_start(args, fmt); 6798 va_start(args, fmt);
6803 6799
@@ -6805,37 +6801,32 @@ int ata_link_printk(const struct ata_link *link, const char *level,
6805 vaf.va = &args; 6801 vaf.va = &args;
6806 6802
6807 if (sata_pmp_attached(link->ap) || link->ap->slave_link) 6803 if (sata_pmp_attached(link->ap) || link->ap->slave_link)
6808 r = printk("%sata%u.%02u: %pV", 6804 printk("%sata%u.%02u: %pV",
6809 level, link->ap->print_id, link->pmp, &vaf); 6805 level, link->ap->print_id, link->pmp, &vaf);
6810 else 6806 else
6811 r = printk("%sata%u: %pV", 6807 printk("%sata%u: %pV",
6812 level, link->ap->print_id, &vaf); 6808 level, link->ap->print_id, &vaf);
6813 6809
6814 va_end(args); 6810 va_end(args);
6815
6816 return r;
6817} 6811}
6818EXPORT_SYMBOL(ata_link_printk); 6812EXPORT_SYMBOL(ata_link_printk);
6819 6813
6820int ata_dev_printk(const struct ata_device *dev, const char *level, 6814void ata_dev_printk(const struct ata_device *dev, const char *level,
6821 const char *fmt, ...) 6815 const char *fmt, ...)
6822{ 6816{
6823 struct va_format vaf; 6817 struct va_format vaf;
6824 va_list args; 6818 va_list args;
6825 int r;
6826 6819
6827 va_start(args, fmt); 6820 va_start(args, fmt);
6828 6821
6829 vaf.fmt = fmt; 6822 vaf.fmt = fmt;
6830 vaf.va = &args; 6823 vaf.va = &args;
6831 6824
6832 r = printk("%sata%u.%02u: %pV", 6825 printk("%sata%u.%02u: %pV",
6833 level, dev->link->ap->print_id, dev->link->pmp + dev->devno, 6826 level, dev->link->ap->print_id, dev->link->pmp + dev->devno,
6834 &vaf); 6827 &vaf);
6835 6828
6836 va_end(args); 6829 va_end(args);
6837
6838 return r;
6839} 6830}
6840EXPORT_SYMBOL(ata_dev_printk); 6831EXPORT_SYMBOL(ata_dev_printk);
6841 6832
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 1121153f1ecd..db90aa35cb71 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -2008,13 +2008,15 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask,
2008 2008
2009 DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); 2009 DPRINTK("ata%u: bus reset via SRST\n", ap->print_id);
2010 2010
2011 /* software reset. causes dev0 to be selected */ 2011 if (ap->ioaddr.ctl_addr) {
2012 iowrite8(ap->ctl, ioaddr->ctl_addr); 2012 /* software reset. causes dev0 to be selected */
2013 udelay(20); /* FIXME: flush */ 2013 iowrite8(ap->ctl, ioaddr->ctl_addr);
2014 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr); 2014 udelay(20); /* FIXME: flush */
2015 udelay(20); /* FIXME: flush */ 2015 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
2016 iowrite8(ap->ctl, ioaddr->ctl_addr); 2016 udelay(20); /* FIXME: flush */
2017 ap->last_ctl = ap->ctl; 2017 iowrite8(ap->ctl, ioaddr->ctl_addr);
2018 ap->last_ctl = ap->ctl;
2019 }
2018 2020
2019 /* wait the port to become ready */ 2021 /* wait the port to become ready */
2020 return ata_sff_wait_after_reset(&ap->link, devmask, deadline); 2022 return ata_sff_wait_after_reset(&ap->link, devmask, deadline);
@@ -2215,10 +2217,6 @@ void ata_sff_error_handler(struct ata_port *ap)
2215 2217
2216 spin_unlock_irqrestore(ap->lock, flags); 2218 spin_unlock_irqrestore(ap->lock, flags);
2217 2219
2218 /* ignore ata_sff_softreset if ctl isn't accessible */
2219 if (softreset == ata_sff_softreset && !ap->ioaddr.ctl_addr)
2220 softreset = NULL;
2221
2222 /* ignore built-in hardresets if SCR access is not available */ 2220 /* ignore built-in hardresets if SCR access is not available */
2223 if ((hardreset == sata_std_hardreset || 2221 if ((hardreset == sata_std_hardreset ||
2224 hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link)) 2222 hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link))
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index af424573c2ff..989ff5ac69ec 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -221,13 +221,10 @@ static int pata_imx_resume(struct device *dev)
221 221
222 return 0; 222 return 0;
223} 223}
224
225static const struct dev_pm_ops pata_imx_pm_ops = {
226 .suspend = pata_imx_suspend,
227 .resume = pata_imx_resume,
228};
229#endif 224#endif
230 225
226static SIMPLE_DEV_PM_OPS(pata_imx_pm_ops, pata_imx_suspend, pata_imx_resume);
227
231static const struct of_device_id imx_pata_dt_ids[] = { 228static const struct of_device_id imx_pata_dt_ids[] = {
232 { 229 {
233 .compatible = "fsl,imx27-pata", 230 .compatible = "fsl,imx27-pata",
@@ -244,9 +241,7 @@ static struct platform_driver pata_imx_driver = {
244 .name = DRV_NAME, 241 .name = DRV_NAME,
245 .of_match_table = imx_pata_dt_ids, 242 .of_match_table = imx_pata_dt_ids,
246 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
247#ifdef CONFIG_PM_SLEEP
248 .pm = &pata_imx_pm_ops, 244 .pm = &pata_imx_pm_ops,
249#endif
250 }, 245 },
251}; 246};
252 247
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index a7e95a54c782..64965398914a 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -35,25 +35,14 @@ static int pata_of_platform_probe(struct platform_device *ofdev)
35 return -EINVAL; 35 return -EINVAL;
36 } 36 }
37 37
38 if (of_device_is_compatible(dn, "electra-ide")) { 38 ret = of_address_to_resource(dn, 1, &ctl_res);
39 /* Altstatus is really at offset 0x3f6 from the primary window 39 if (ret) {
40 * on electra-ide. Adjust ctl_res and io_res accordingly. 40 dev_err(&ofdev->dev, "can't get CTL address from "
41 */ 41 "device tree\n");
42 ctl_res = io_res; 42 return -EINVAL;
43 ctl_res.start = ctl_res.start+0x3f6;
44 io_res.end = ctl_res.start-1;
45 } else {
46 ret = of_address_to_resource(dn, 1, &ctl_res);
47 if (ret) {
48 dev_err(&ofdev->dev, "can't get CTL address from "
49 "device tree\n");
50 return -EINVAL;
51 }
52 } 43 }
53 44
54 irq_res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0); 45 irq_res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0);
55 if (irq_res)
56 irq_res->flags = 0;
57 46
58 prop = of_get_property(dn, "reg-shift", NULL); 47 prop = of_get_property(dn, "reg-shift", NULL);
59 if (prop) 48 if (prop)
@@ -79,8 +68,7 @@ static int pata_of_platform_probe(struct platform_device *ofdev)
79 68
80static struct of_device_id pata_of_platform_match[] = { 69static struct of_device_id pata_of_platform_match[] = {
81 { .compatible = "ata-generic", }, 70 { .compatible = "ata-generic", },
82 { .compatible = "electra-ide", }, 71 { },
83 {},
84}; 72};
85MODULE_DEVICE_TABLE(of, pata_of_platform_match); 73MODULE_DEVICE_TABLE(of, pata_of_platform_match);
86 74
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index a5579b55e332..f8cff3e247c5 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -118,7 +118,7 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res,
118 */ 118 */
119 if (irq_res && irq_res->start > 0) { 119 if (irq_res && irq_res->start > 0) {
120 irq = irq_res->start; 120 irq = irq_res->start;
121 irq_flags = irq_res->flags; 121 irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
122 } 122 }
123 123
124 /* 124 /*
@@ -213,8 +213,6 @@ static int pata_platform_probe(struct platform_device *pdev)
213 * And the IRQ 213 * And the IRQ
214 */ 214 */
215 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 215 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
216 if (irq_res)
217 irq_res->flags = pp_info ? pp_info->irq_flags : 0;
218 216
219 return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res, 217 return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,
220 pp_info ? pp_info->ioport_shift : 0, 218 pp_info ? pp_info->ioport_shift : 0,
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index fc5f31d4828e..57de02123c4c 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -251,12 +251,18 @@ static void serverworks_set_dmamode(struct ata_port *ap, struct ata_device *adev
251 pci_write_config_byte(pdev, 0x54, ultra_cfg); 251 pci_write_config_byte(pdev, 0x54, ultra_cfg);
252} 252}
253 253
254static struct scsi_host_template serverworks_sht = { 254static struct scsi_host_template serverworks_osb4_sht = {
255 ATA_BMDMA_SHT(DRV_NAME),
256 .sg_tablesize = LIBATA_DUMB_MAX_PRD,
257};
258
259static struct scsi_host_template serverworks_csb_sht = {
255 ATA_BMDMA_SHT(DRV_NAME), 260 ATA_BMDMA_SHT(DRV_NAME),
256}; 261};
257 262
258static struct ata_port_operations serverworks_osb4_port_ops = { 263static struct ata_port_operations serverworks_osb4_port_ops = {
259 .inherits = &ata_bmdma_port_ops, 264 .inherits = &ata_bmdma_port_ops,
265 .qc_prep = ata_bmdma_dumb_qc_prep,
260 .cable_detect = serverworks_cable_detect, 266 .cable_detect = serverworks_cable_detect,
261 .mode_filter = serverworks_osb4_filter, 267 .mode_filter = serverworks_osb4_filter,
262 .set_piomode = serverworks_set_piomode, 268 .set_piomode = serverworks_set_piomode,
@@ -265,6 +271,7 @@ static struct ata_port_operations serverworks_osb4_port_ops = {
265 271
266static struct ata_port_operations serverworks_csb_port_ops = { 272static struct ata_port_operations serverworks_csb_port_ops = {
267 .inherits = &serverworks_osb4_port_ops, 273 .inherits = &serverworks_osb4_port_ops,
274 .qc_prep = ata_bmdma_qc_prep,
268 .mode_filter = serverworks_csb_filter, 275 .mode_filter = serverworks_csb_filter,
269}; 276};
270 277
@@ -404,6 +411,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
404 } 411 }
405 }; 412 };
406 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; 413 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
414 struct scsi_host_template *sht = &serverworks_csb_sht;
407 int rc; 415 int rc;
408 416
409 rc = pcim_enable_device(pdev); 417 rc = pcim_enable_device(pdev);
@@ -417,6 +425,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
417 /* Select non UDMA capable OSB4 if we can't do fixups */ 425 /* Select non UDMA capable OSB4 if we can't do fixups */
418 if (rc < 0) 426 if (rc < 0)
419 ppi[0] = &info[1]; 427 ppi[0] = &info[1];
428 sht = &serverworks_osb4_sht;
420 } 429 }
421 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ 430 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
422 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || 431 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
@@ -433,7 +442,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
433 ppi[1] = &ata_dummy_port_info; 442 ppi[1] = &ata_dummy_port_info;
434 } 443 }
435 444
436 return ata_pci_bmdma_init_one(pdev, ppi, &serverworks_sht, NULL, 0); 445 return ata_pci_bmdma_init_one(pdev, ppi, sht, NULL, 0);
437} 446}
438 447
439#ifdef CONFIG_PM_SLEEP 448#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index da3bc2709c63..ce2b99a1ed70 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -568,8 +568,7 @@ static int ahci_highbank_probe(struct platform_device *pdev)
568 ahci_init_controller(host); 568 ahci_init_controller(host);
569 ahci_print_info(host, "platform"); 569 ahci_print_info(host, "platform");
570 570
571 rc = ata_host_activate(host, irq, ahci_interrupt, 0, 571 rc = ahci_host_activate(host, irq, &ahci_highbank_platform_sht);
572 &ahci_highbank_platform_sht);
573 if (rc) 572 if (rc)
574 goto err0; 573 goto err0;
575 574
diff --git a/include/linux/ahci_platform.h b/include/linux/ahci_platform.h
index 09a947e8bc87..642d6ae4030c 100644
--- a/include/linux/ahci_platform.h
+++ b/include/linux/ahci_platform.h
@@ -22,19 +22,6 @@ struct ata_port_info;
22struct ahci_host_priv; 22struct ahci_host_priv;
23struct platform_device; 23struct platform_device;
24 24
25/*
26 * Note ahci_platform_data is deprecated, it is only kept around for use
27 * by the old da850 and spear13xx ahci code.
28 * New drivers should instead declare their own platform_driver struct, and
29 * use ahci_platform* functions in their own probe, suspend and resume methods.
30 */
31struct ahci_platform_data {
32 int (*init)(struct device *dev, void __iomem *addr);
33 void (*exit)(struct device *dev);
34 int (*suspend)(struct device *dev);
35 int (*resume)(struct device *dev);
36};
37
38int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); 25int ahci_platform_enable_clks(struct ahci_host_priv *hpriv);
39void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); 26void ahci_platform_disable_clks(struct ahci_host_priv *hpriv);
40int ahci_platform_enable_resources(struct ahci_host_priv *hpriv); 27int ahci_platform_enable_resources(struct ahci_host_priv *hpriv);
diff --git a/include/linux/ata_platform.h b/include/linux/ata_platform.h
index b9fde17f767c..5c618a084225 100644
--- a/include/linux/ata_platform.h
+++ b/include/linux/ata_platform.h
@@ -8,11 +8,6 @@ struct pata_platform_info {
8 * spacing used by ata_std_ports(). 8 * spacing used by ata_std_ports().
9 */ 9 */
10 unsigned int ioport_shift; 10 unsigned int ioport_shift;
11 /*
12 * Indicate platform specific irq types and initial
13 * IRQ flags when call request_irq()
14 */
15 unsigned int irq_flags;
16}; 11};
17 12
18extern int __pata_platform_probe(struct device *dev, 13extern int __pata_platform_probe(struct device *dev,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 92abb497ab14..bd5fefeaf548 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1404,14 +1404,14 @@ static inline int sata_srst_pmp(struct ata_link *link)
1404 * printk helpers 1404 * printk helpers
1405 */ 1405 */
1406__printf(3, 4) 1406__printf(3, 4)
1407int ata_port_printk(const struct ata_port *ap, const char *level, 1407void ata_port_printk(const struct ata_port *ap, const char *level,
1408 const char *fmt, ...); 1408 const char *fmt, ...);
1409__printf(3, 4) 1409__printf(3, 4)
1410int ata_link_printk(const struct ata_link *link, const char *level, 1410void ata_link_printk(const struct ata_link *link, const char *level,
1411 const char *fmt, ...); 1411 const char *fmt, ...);
1412__printf(3, 4) 1412__printf(3, 4)
1413int ata_dev_printk(const struct ata_device *dev, const char *level, 1413void ata_dev_printk(const struct ata_device *dev, const char *level,
1414 const char *fmt, ...); 1414 const char *fmt, ...);
1415 1415
1416#define ata_port_err(ap, fmt, ...) \ 1416#define ata_port_err(ap, fmt, ...) \
1417 ata_port_printk(ap, KERN_ERR, fmt, ##__VA_ARGS__) 1417 ata_port_printk(ap, KERN_ERR, fmt, ##__VA_ARGS__)