Skip to content

Commit fcab86a

Browse files
committed
Merge branch 'for-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: - ahci grew runtime power management support so that the controller can be turned off if no devices are attached. - sata_via isn't dead yet. It got hotplug support and more refined workaround for certain WD drives. - Misc cleanups. There's a merge from for-4.5-fixes to avoid confusing conflicts in ahci PCI ID table. * 'for-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: ata: ahci_xgene: dereferencing uninitialized pointer in probe AHCI: Remove obsolete Intel Lewisburg SATA RAID device IDs ata: sata_rcar: Use ARCH_RENESAS sata_via: Implement hotplug for VT6421 sata_via: Apply WD workaround only when needed on VT6421 ahci: Add runtime PM support for the host controller ahci: Add functions to manage runtime PM of AHCI ports ahci: Convert driver to use modern PM hooks ahci: Cache host controller version scsi: Drop runtime PM usage count after host is added scsi: Set request queue runtime PM status back to active on resume block: Add blk_set_runtime_active() ata: ahci_mvebu: add support for Armada 3700 variant libata: fix unbalanced spin_lock_irqsave/spin_unlock_irq() in ata_scsi_park_show() libata: support AHCI on OCTEON platform
2 parents ef504fa + 8134233 commit fcab86a

File tree

18 files changed

+475
-57
lines changed

18 files changed

+475
-57
lines changed

Documentation/devicetree/bindings/ata/ahci-platform.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Required properties:
1111
- compatible : compatible string, one of:
1212
- "allwinner,sun4i-a10-ahci"
1313
- "hisilicon,hisi-ahci"
14+
- "cavium,octeon-7130-ahci"
1415
- "ibm,476gtr-ahci"
1516
- "marvell,armada-380-ahci"
1617
- "snps,dwc-ahci"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
* UCTL SATA controller glue
2+
3+
UCTL is the bridge unit between the I/O interconnect (an internal bus)
4+
and the SATA AHCI host controller (UAHC). It performs the following functions:
5+
- provides interfaces for the applications to access the UAHC AHCI
6+
registers on the CN71XX I/O space.
7+
- provides a bridge for UAHC to fetch AHCI command table entries and data
8+
buffers from Level 2 Cache.
9+
- posts interrupts to the CIU.
10+
- contains registers that:
11+
- control the behavior of the UAHC
12+
- control the clock/reset generation to UAHC
13+
- control endian swapping for all UAHC registers and DMA accesses
14+
15+
Properties:
16+
17+
- compatible: "cavium,octeon-7130-sata-uctl"
18+
19+
Compatibility with the cn7130 SOC.
20+
21+
- reg: The base address of the UCTL register bank.
22+
23+
- #address-cells, #size-cells, ranges and dma-ranges must be present and hold
24+
suitable values to map all child nodes.
25+
26+
Example:
27+
28+
uctl@118006c000000 {
29+
compatible = "cavium,octeon-7130-sata-uctl";
30+
reg = <0x11800 0x6c000000 0x0 0x100>;
31+
ranges; /* Direct mapping */
32+
dma-ranges;
33+
#address-cells = <2>;
34+
#size-cells = <2>;
35+
36+
sata: sata@16c0000000000 {
37+
compatible = "cavium,octeon-7130-ahci";
38+
reg = <0x16c00 0x00000000 0x0 0x200>;
39+
interrupt-parent = <&cibsata>;
40+
interrupts = <2 4>; /* Bit: 2, level */
41+
};
42+
};

arch/mips/include/asm/octeon/cvmx.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ static inline void cvmx_write_csr(uint64_t csr_addr, uint64_t val)
275275
cvmx_read64(CVMX_MIO_BOOT_BIST_STAT);
276276
}
277277

278+
static inline void cvmx_writeq_csr(void __iomem *csr_addr, uint64_t val)
279+
{
280+
cvmx_write_csr((__force uint64_t)csr_addr, val);
281+
}
282+
278283
static inline void cvmx_write_io(uint64_t io_addr, uint64_t val)
279284
{
280285
cvmx_write64(io_addr, val);
@@ -287,6 +292,10 @@ static inline uint64_t cvmx_read_csr(uint64_t csr_addr)
287292
return val;
288293
}
289294

295+
static inline uint64_t cvmx_readq_csr(void __iomem *csr_addr)
296+
{
297+
return cvmx_read_csr((__force uint64_t) csr_addr);
298+
}
290299

291300
static inline void cvmx_send_single(uint64_t data)
292301
{

block/blk-core.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,30 @@ void blk_post_runtime_resume(struct request_queue *q, int err)
35293529
spin_unlock_irq(q->queue_lock);
35303530
}
35313531
EXPORT_SYMBOL(blk_post_runtime_resume);
3532+
3533+
/**
3534+
* blk_set_runtime_active - Force runtime status of the queue to be active
3535+
* @q: the queue of the device
3536+
*
3537+
* If the device is left runtime suspended during system suspend the resume
3538+
* hook typically resumes the device and corrects runtime status
3539+
* accordingly. However, that does not affect the queue runtime PM status
3540+
* which is still "suspended". This prevents processing requests from the
3541+
* queue.
3542+
*
3543+
* This function can be used in driver's resume hook to correct queue
3544+
* runtime PM status and re-enable peeking requests from the queue. It
3545+
* should be called before first request is added to the queue.
3546+
*/
3547+
void blk_set_runtime_active(struct request_queue *q)
3548+
{
3549+
spin_lock_irq(q->queue_lock);
3550+
q->rpm_status = RPM_ACTIVE;
3551+
pm_runtime_mark_last_busy(q->dev);
3552+
pm_request_autosuspend(q->dev);
3553+
spin_unlock_irq(q->queue_lock);
3554+
}
3555+
EXPORT_SYMBOL(blk_set_runtime_active);
35323556
#endif
35333557

35343558
int __init blk_dev_init(void)

drivers/ata/Kconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ config AHCI_MVEBU
151151

152152
If unsure, say N.
153153

154+
config AHCI_OCTEON
155+
tristate "Cavium Octeon Soc Serial ATA"
156+
depends on SATA_AHCI_PLATFORM && CAVIUM_OCTEON_SOC
157+
default y
158+
help
159+
This option enables support for Cavium Octeon SoC Serial ATA.
160+
161+
If unsure, say N.
162+
154163
config AHCI_SUNXI
155164
tristate "Allwinner sunxi AHCI SATA support"
156165
depends on ARCH_SUNXI
@@ -355,7 +364,7 @@ config SATA_PROMISE
355364

356365
config SATA_RCAR
357366
tristate "Renesas R-Car SATA support"
358-
depends on ARCH_SHMOBILE || COMPILE_TEST
367+
depends on ARCH_RENESAS || COMPILE_TEST
359368
help
360369
This option enables support for Renesas R-Car Serial ATA.
361370

drivers/ata/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o
1515
obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o
1616
obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o
1717
obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o libahci.o libahci_platform.o
18+
obj-$(CONFIG_AHCI_OCTEON) += ahci_octeon.o
1819
obj-$(CONFIG_AHCI_SUNXI) += ahci_sunxi.o libahci.o libahci_platform.o
1920
obj-$(CONFIG_AHCI_ST) += ahci_st.o libahci.o libahci_platform.o
2021
obj-$(CONFIG_AHCI_TEGRA) += ahci_tegra.o libahci.o libahci_platform.o

drivers/ata/ahci.c

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum board_ids {
8585
};
8686

8787
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
88+
static void ahci_remove_one(struct pci_dev *dev);
8889
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
8990
unsigned long deadline);
9091
static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
@@ -94,9 +95,13 @@ static bool is_mcp89_apple(struct pci_dev *pdev);
9495
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
9596
unsigned long deadline);
9697
#ifdef CONFIG_PM
97-
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
98-
static int ahci_pci_device_resume(struct pci_dev *pdev);
98+
static int ahci_pci_device_runtime_suspend(struct device *dev);
99+
static int ahci_pci_device_runtime_resume(struct device *dev);
100+
#ifdef CONFIG_PM_SLEEP
101+
static int ahci_pci_device_suspend(struct device *dev);
102+
static int ahci_pci_device_resume(struct device *dev);
99103
#endif
104+
#endif /* CONFIG_PM */
100105

101106
static struct scsi_host_template ahci_sht = {
102107
AHCI_SHT("ahci"),
@@ -371,15 +376,11 @@ static const struct pci_device_id ahci_pci_tbl[] = {
371376
{ PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
372377
{ PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Lewisburg RAID*/
373378
{ PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
374-
{ PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
375379
{ PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
376-
{ PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
377380
{ PCI_VDEVICE(INTEL, 0xa1d2), board_ahci }, /* Lewisburg RAID*/
378381
{ PCI_VDEVICE(INTEL, 0xa1d6), board_ahci }, /* Lewisburg RAID*/
379382
{ PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
380-
{ PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
381383
{ PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
382-
{ PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
383384
{ PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
384385
{ PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
385386

@@ -563,16 +564,20 @@ static const struct pci_device_id ahci_pci_tbl[] = {
563564
{ } /* terminate list */
564565
};
565566

567+
static const struct dev_pm_ops ahci_pci_pm_ops = {
568+
SET_SYSTEM_SLEEP_PM_OPS(ahci_pci_device_suspend, ahci_pci_device_resume)
569+
SET_RUNTIME_PM_OPS(ahci_pci_device_runtime_suspend,
570+
ahci_pci_device_runtime_resume, NULL)
571+
};
566572

567573
static struct pci_driver ahci_pci_driver = {
568574
.name = DRV_NAME,
569575
.id_table = ahci_pci_tbl,
570576
.probe = ahci_init_one,
571-
.remove = ata_pci_remove_one,
572-
#ifdef CONFIG_PM
573-
.suspend = ahci_pci_device_suspend,
574-
.resume = ahci_pci_device_resume,
575-
#endif
577+
.remove = ahci_remove_one,
578+
.driver = {
579+
.pm = &ahci_pci_pm_ops,
580+
},
576581
};
577582

578583
#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
@@ -801,42 +806,66 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
801806

802807

803808
#ifdef CONFIG_PM
804-
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
809+
static void ahci_pci_disable_interrupts(struct ata_host *host)
805810
{
806-
struct ata_host *host = pci_get_drvdata(pdev);
807811
struct ahci_host_priv *hpriv = host->private_data;
808812
void __iomem *mmio = hpriv->mmio;
809813
u32 ctl;
810814

811-
if (mesg.event & PM_EVENT_SUSPEND &&
812-
hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
813-
dev_err(&pdev->dev,
814-
"BIOS update required for suspend/resume\n");
815-
return -EIO;
816-
}
815+
/* AHCI spec rev1.1 section 8.3.3:
816+
* Software must disable interrupts prior to requesting a
817+
* transition of the HBA to D3 state.
818+
*/
819+
ctl = readl(mmio + HOST_CTL);
820+
ctl &= ~HOST_IRQ_EN;
821+
writel(ctl, mmio + HOST_CTL);
822+
readl(mmio + HOST_CTL); /* flush */
823+
}
817824

818-
if (mesg.event & PM_EVENT_SLEEP) {
819-
/* AHCI spec rev1.1 section 8.3.3:
820-
* Software must disable interrupts prior to requesting a
821-
* transition of the HBA to D3 state.
822-
*/
823-
ctl = readl(mmio + HOST_CTL);
824-
ctl &= ~HOST_IRQ_EN;
825-
writel(ctl, mmio + HOST_CTL);
826-
readl(mmio + HOST_CTL); /* flush */
827-
}
825+
static int ahci_pci_device_runtime_suspend(struct device *dev)
826+
{
827+
struct pci_dev *pdev = to_pci_dev(dev);
828+
struct ata_host *host = pci_get_drvdata(pdev);
828829

829-
return ata_pci_device_suspend(pdev, mesg);
830+
ahci_pci_disable_interrupts(host);
831+
return 0;
830832
}
831833

832-
static int ahci_pci_device_resume(struct pci_dev *pdev)
834+
static int ahci_pci_device_runtime_resume(struct device *dev)
833835
{
836+
struct pci_dev *pdev = to_pci_dev(dev);
834837
struct ata_host *host = pci_get_drvdata(pdev);
835838
int rc;
836839

837-
rc = ata_pci_device_do_resume(pdev);
840+
rc = ahci_pci_reset_controller(host);
838841
if (rc)
839842
return rc;
843+
ahci_pci_init_controller(host);
844+
return 0;
845+
}
846+
847+
#ifdef CONFIG_PM_SLEEP
848+
static int ahci_pci_device_suspend(struct device *dev)
849+
{
850+
struct pci_dev *pdev = to_pci_dev(dev);
851+
struct ata_host *host = pci_get_drvdata(pdev);
852+
struct ahci_host_priv *hpriv = host->private_data;
853+
854+
if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
855+
dev_err(&pdev->dev,
856+
"BIOS update required for suspend/resume\n");
857+
return -EIO;
858+
}
859+
860+
ahci_pci_disable_interrupts(host);
861+
return ata_host_suspend(host, PMSG_SUSPEND);
862+
}
863+
864+
static int ahci_pci_device_resume(struct device *dev)
865+
{
866+
struct pci_dev *pdev = to_pci_dev(dev);
867+
struct ata_host *host = pci_get_drvdata(pdev);
868+
int rc;
840869

841870
/* Apple BIOS helpfully mangles the registers on resume */
842871
if (is_mcp89_apple(pdev))
@@ -856,6 +885,8 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
856885
}
857886
#endif
858887

888+
#endif /* CONFIG_PM */
889+
859890
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
860891
{
861892
int rc;
@@ -1718,7 +1749,18 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
17181749

17191750
pci_set_master(pdev);
17201751

1721-
return ahci_host_activate(host, &ahci_sht);
1752+
rc = ahci_host_activate(host, &ahci_sht);
1753+
if (rc)
1754+
return rc;
1755+
1756+
pm_runtime_put_noidle(&pdev->dev);
1757+
return 0;
1758+
}
1759+
1760+
static void ahci_remove_one(struct pci_dev *pdev)
1761+
{
1762+
pm_runtime_get_noresume(&pdev->dev);
1763+
ata_pci_remove_one(pdev);
17221764
}
17231765

17241766
module_pci_driver(ahci_pci_driver);

drivers/ata/ahci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ struct ahci_host_priv {
335335
void __iomem * mmio; /* bus-independent mem map */
336336
u32 cap; /* cap to use */
337337
u32 cap2; /* cap2 to use */
338+
u32 version; /* cached version */
338339
u32 port_map; /* port map to use */
339340
u32 saved_cap; /* saved initial cap */
340341
u32 saved_cap2; /* saved initial cap2 */

drivers/ata/ahci_mvebu.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ static int ahci_mvebu_probe(struct platform_device *pdev)
112112
if (rc)
113113
return rc;
114114

115-
dram = mv_mbus_dram_info();
116-
if (!dram)
117-
return -ENODEV;
115+
if (of_device_is_compatible(pdev->dev.of_node,
116+
"marvell,armada-380-ahci")) {
117+
dram = mv_mbus_dram_info();
118+
if (!dram)
119+
return -ENODEV;
118120

119-
ahci_mvebu_mbus_config(hpriv, dram);
120-
ahci_mvebu_regret_option(hpriv);
121+
ahci_mvebu_mbus_config(hpriv, dram);
122+
ahci_mvebu_regret_option(hpriv);
123+
}
121124

122125
rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info,
123126
&ahci_platform_sht);
@@ -133,6 +136,7 @@ static int ahci_mvebu_probe(struct platform_device *pdev)
133136

134137
static const struct of_device_id ahci_mvebu_of_match[] = {
135138
{ .compatible = "marvell,armada-380-ahci", },
139+
{ .compatible = "marvell,armada-3700-ahci", },
136140
{ },
137141
};
138142
MODULE_DEVICE_TABLE(of, ahci_mvebu_of_match);

0 commit comments

Comments
 (0)