Skip to content

Commit 0519359

Browse files
committed
Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: "Nothing too interesting. Mostly ahci and ahci_platform changes, many around power management" * 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (22 commits) ata: ahci_platform: enable to get and control reset ata: libahci_platform: add reset control support ata: add an extra argument to ahci_platform_get_resources() ata: sata_rcar: Add r8a77965 support ata: sata_rcar: exclude setting of PHY registers in Gen3 ata: sata_rcar: really mask all interrupts on Gen2 and later Revert "ata: ahci_platform: allow disabling of hotplug to save power" ata: libahci: Allow reconfigure of DEVSLP register ata: libahci: Correct setting of DEVSLP register ata: ahci: Enable DEVSLP by default on x86 with SLP_S0 ata: ahci: Support state with min power but Partial low power state Revert "ata: ahci_platform: convert kcalloc to devm_kcalloc" ata: sata_rcar: Add rudimentary Runtime PM support ata: sata_rcar: Provide a short-hand for &pdev->dev ata: Only output sg element mapped number in verbose debug ata: Guard ata_scsi_dump_cdb() by ATA_VERBOSE_DEBUG ata: ahci_platform: convert kcalloc to devm_kcalloc ata: ahci_platform: convert kzallloc to kcalloc ata: ahci_platform: correct parameter documentation for ahci_platform_shutdown libata: remove ata_sff_data_xfer_noirq() ...
2 parents 5967661 + 2d17f46 commit 0519359

35 files changed

+166
-126
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ compatible:
2929
Optional properties:
3030
- dma-coherent : Present if dma operations are coherent
3131
- clocks : a list of phandle + clock specifier pairs
32+
- resets : a list of phandle + reset specifier pairs
3233
- target-supply : regulator for SATA target power
3334
- phys : reference to the SATA PHY node
3435
- phy-names : must be "sata-phy"

Documentation/devicetree/bindings/ata/sata_rcar.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Required properties:
88
- "renesas,sata-r8a7791" for R-Car M2-W
99
- "renesas,sata-r8a7793" for R-Car M2-N
1010
- "renesas,sata-r8a7795" for R-Car H3
11+
- "renesas,sata-r8a77965" for R-Car M3-N
1112
- "renesas,rcar-gen2-sata" for a generic R-Car Gen2 compatible device
1213
- "renesas,rcar-gen3-sata" for a generic R-Car Gen3 compatible device
1314
- "renesas,rcar-sata" is deprecated

Documentation/driver-api/libata.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ PIO data read/write
118118
All bmdma-style drivers must implement this hook. This is the low-level
119119
operation that actually copies the data bytes during a PIO data
120120
transfer. Typically the driver will choose one of
121-
:c:func:`ata_sff_data_xfer_noirq`, :c:func:`ata_sff_data_xfer`, or
122-
:c:func:`ata_sff_data_xfer32`.
121+
:c:func:`ata_sff_data_xfer`, or :c:func:`ata_sff_data_xfer32`.
123122

124123
ATA command execute
125124
~~~~~~~~~~~~~~~~~~~

drivers/ata/ahci.c

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static int marvell_enable = 1;
610610
module_param(marvell_enable, int, 0644);
611611
MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
612612

613-
static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY;
613+
static int mobile_lpm_policy = -1;
614614
module_param(mobile_lpm_policy, int, 0644);
615615
MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");
616616

@@ -1604,6 +1604,37 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
16041604
return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
16051605
}
16061606

1607+
static void ahci_update_initial_lpm_policy(struct ata_port *ap,
1608+
struct ahci_host_priv *hpriv)
1609+
{
1610+
int policy = CONFIG_SATA_MOBILE_LPM_POLICY;
1611+
1612+
1613+
/* Ignore processing for non mobile platforms */
1614+
if (!(hpriv->flags & AHCI_HFLAG_IS_MOBILE))
1615+
return;
1616+
1617+
/* user modified policy via module param */
1618+
if (mobile_lpm_policy != -1) {
1619+
policy = mobile_lpm_policy;
1620+
goto update_policy;
1621+
}
1622+
1623+
#ifdef CONFIG_ACPI
1624+
if (policy > ATA_LPM_MED_POWER &&
1625+
(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) {
1626+
if (hpriv->cap & HOST_CAP_PART)
1627+
policy = ATA_LPM_MIN_POWER_WITH_PARTIAL;
1628+
else if (hpriv->cap & HOST_CAP_SSC)
1629+
policy = ATA_LPM_MIN_POWER;
1630+
}
1631+
#endif
1632+
1633+
update_policy:
1634+
if (policy >= ATA_LPM_UNKNOWN && policy <= ATA_LPM_MIN_POWER)
1635+
ap->target_lpm_policy = policy;
1636+
}
1637+
16071638
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
16081639
{
16091640
unsigned int board_id = ent->driver_data;
@@ -1807,10 +1838,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
18071838
if (ap->flags & ATA_FLAG_EM)
18081839
ap->em_message_type = hpriv->em_msg_type;
18091840

1810-
if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) &&
1811-
mobile_lpm_policy >= ATA_LPM_UNKNOWN &&
1812-
mobile_lpm_policy <= ATA_LPM_MIN_POWER)
1813-
ap->target_lpm_policy = mobile_lpm_policy;
1841+
ahci_update_initial_lpm_policy(ap, hpriv);
18141842

18151843
/* disabled/not-implemented port */
18161844
if (!(hpriv->port_map & (1 << i)))

drivers/ata/ahci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ struct ahci_host_priv {
350350
u32 em_msg_type; /* EM message type */
351351
bool got_runtime_pm; /* Did we do pm_runtime_get? */
352352
struct clk *clks[AHCI_MAX_CLKS]; /* Optional */
353+
struct reset_control *rsts; /* Optional */
353354
struct regulator **target_pwrs; /* Optional */
354355
/*
355356
* If platform uses PHYs. There is a 1:1 relation between the port number and

drivers/ata/ahci_brcm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
425425

426426
brcm_sata_phys_enable(priv);
427427

428-
hpriv = ahci_platform_get_resources(pdev);
428+
hpriv = ahci_platform_get_resources(pdev, 0);
429429
if (IS_ERR(hpriv))
430430
return PTR_ERR(hpriv);
431431
hpriv->plat_data = priv;

drivers/ata/ahci_ceva.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int ceva_ahci_probe(struct platform_device *pdev)
213213

214214
cevapriv->ahci_pdev = pdev;
215215

216-
hpriv = ahci_platform_get_resources(pdev);
216+
hpriv = ahci_platform_get_resources(pdev, 0);
217217
if (IS_ERR(hpriv))
218218
return PTR_ERR(hpriv);
219219

drivers/ata/ahci_da850.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int ahci_da850_probe(struct platform_device *pdev)
171171
u32 mpy;
172172
int rc;
173173

174-
hpriv = ahci_platform_get_resources(pdev);
174+
hpriv = ahci_platform_get_resources(pdev, 0);
175175
if (IS_ERR(hpriv))
176176
return PTR_ERR(hpriv);
177177

drivers/ata/ahci_dm816.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int ahci_dm816_probe(struct platform_device *pdev)
148148
struct ahci_host_priv *hpriv;
149149
int rc;
150150

151-
hpriv = ahci_platform_get_resources(pdev);
151+
hpriv = ahci_platform_get_resources(pdev, 0);
152152
if (IS_ERR(hpriv))
153153
return PTR_ERR(hpriv);
154154

drivers/ata/ahci_imx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ static int imx_ahci_probe(struct platform_device *pdev)
11271127
return ret;
11281128
}
11291129

1130-
hpriv = ahci_platform_get_resources(pdev);
1130+
hpriv = ahci_platform_get_resources(pdev, 0);
11311131
if (IS_ERR(hpriv))
11321132
return PTR_ERR(hpriv);
11331133

drivers/ata/ahci_mtk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int mtk_ahci_probe(struct platform_device *pdev)
142142
if (!plat)
143143
return -ENOMEM;
144144

145-
hpriv = ahci_platform_get_resources(pdev);
145+
hpriv = ahci_platform_get_resources(pdev, 0);
146146
if (IS_ERR(hpriv))
147147
return PTR_ERR(hpriv);
148148

drivers/ata/ahci_mvebu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int ahci_mvebu_probe(struct platform_device *pdev)
158158
const struct mbus_dram_target_info *dram;
159159
int rc;
160160

161-
hpriv = ahci_platform_get_resources(pdev);
161+
hpriv = ahci_platform_get_resources(pdev, 0);
162162
if (IS_ERR(hpriv))
163163
return PTR_ERR(hpriv);
164164

drivers/ata/ahci_platform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int ahci_probe(struct platform_device *pdev)
4343
struct ahci_host_priv *hpriv;
4444
int rc;
4545

46-
hpriv = ahci_platform_get_resources(pdev);
46+
hpriv = ahci_platform_get_resources(pdev,
47+
AHCI_PLATFORM_GET_RESETS);
4748
if (IS_ERR(hpriv))
4849
return PTR_ERR(hpriv);
4950

drivers/ata/ahci_qoriq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int ahci_qoriq_probe(struct platform_device *pdev)
250250
struct resource *res;
251251
int rc;
252252

253-
hpriv = ahci_platform_get_resources(pdev);
253+
hpriv = ahci_platform_get_resources(pdev, 0);
254254
if (IS_ERR(hpriv))
255255
return PTR_ERR(hpriv);
256256

drivers/ata/ahci_seattle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int ahci_seattle_probe(struct platform_device *pdev)
164164
int rc;
165165
struct ahci_host_priv *hpriv;
166166

167-
hpriv = ahci_platform_get_resources(pdev);
167+
hpriv = ahci_platform_get_resources(pdev, 0);
168168
if (IS_ERR(hpriv))
169169
return PTR_ERR(hpriv);
170170

drivers/ata/ahci_st.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int st_ahci_probe(struct platform_device *pdev)
156156
if (!drv_data)
157157
return -ENOMEM;
158158

159-
hpriv = ahci_platform_get_resources(pdev);
159+
hpriv = ahci_platform_get_resources(pdev, 0);
160160
if (IS_ERR(hpriv))
161161
return PTR_ERR(hpriv);
162162
hpriv->plat_data = drv_data;

drivers/ata/ahci_sunxi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int ahci_sunxi_probe(struct platform_device *pdev)
181181
struct ahci_host_priv *hpriv;
182182
int rc;
183183

184-
hpriv = ahci_platform_get_resources(pdev);
184+
hpriv = ahci_platform_get_resources(pdev, 0);
185185
if (IS_ERR(hpriv))
186186
return PTR_ERR(hpriv);
187187

drivers/ata/ahci_tegra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static int tegra_ahci_probe(struct platform_device *pdev)
494494
int ret;
495495
unsigned int i;
496496

497-
hpriv = ahci_platform_get_resources(pdev);
497+
hpriv = ahci_platform_get_resources(pdev, 0);
498498
if (IS_ERR(hpriv))
499499
return PTR_ERR(hpriv);
500500

drivers/ata/ahci_xgene.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static int xgene_ahci_probe(struct platform_device *pdev)
759759
&xgene_ahci_v2_port_info };
760760
int rc;
761761

762-
hpriv = ahci_platform_get_resources(pdev);
762+
hpriv = ahci_platform_get_resources(pdev, 0);
763763
if (IS_ERR(hpriv))
764764
return PTR_ERR(hpriv);
765765

drivers/ata/libahci.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
801801
cmd |= PORT_CMD_ALPE;
802802
if (policy == ATA_LPM_MIN_POWER)
803803
cmd |= PORT_CMD_ASP;
804+
else if (policy == ATA_LPM_MIN_POWER_WITH_PARTIAL)
805+
cmd &= ~PORT_CMD_ASP;
804806

805807
/* write out new cmd value */
806808
writel(cmd, port_mmio + PORT_CMD);
@@ -811,7 +813,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
811813
if ((hpriv->cap2 & HOST_CAP2_SDS) &&
812814
(hpriv->cap2 & HOST_CAP2_SADM) &&
813815
(link->device->flags & ATA_DFLAG_DEVSLP)) {
814-
if (policy == ATA_LPM_MIN_POWER)
816+
if (policy == ATA_LPM_MIN_POWER ||
817+
policy == ATA_LPM_MIN_POWER_WITH_PARTIAL)
815818
ahci_set_aggressive_devslp(ap, true);
816819
else
817820
ahci_set_aggressive_devslp(ap, false);
@@ -2107,7 +2110,7 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
21072110
struct ahci_host_priv *hpriv = ap->host->private_data;
21082111
void __iomem *port_mmio = ahci_port_base(ap);
21092112
struct ata_device *dev = ap->link.device;
2110-
u32 devslp, dm, dito, mdat, deto;
2113+
u32 devslp, dm, dito, mdat, deto, dito_conf;
21112114
int rc;
21122115
unsigned int err_mask;
21132116

@@ -2131,20 +2134,22 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
21312134
return;
21322135
}
21332136

2134-
/* device sleep was already enabled */
2135-
if (devslp & PORT_DEVSLP_ADSE)
2137+
dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET;
2138+
dito = devslp_idle_timeout / (dm + 1);
2139+
if (dito > 0x3ff)
2140+
dito = 0x3ff;
2141+
2142+
dito_conf = (devslp >> PORT_DEVSLP_DITO_OFFSET) & 0x3FF;
2143+
2144+
/* device sleep was already enabled and same dito */
2145+
if ((devslp & PORT_DEVSLP_ADSE) && (dito_conf == dito))
21362146
return;
21372147

21382148
/* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */
21392149
rc = hpriv->stop_engine(ap);
21402150
if (rc)
21412151
return;
21422152

2143-
dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET;
2144-
dito = devslp_idle_timeout / (dm + 1);
2145-
if (dito > 0x3ff)
2146-
dito = 0x3ff;
2147-
21482153
/* Use the nominal value 10 ms if the read MDAT is zero,
21492154
* the nominal value of DETO is 20 ms.
21502155
*/
@@ -2162,6 +2167,8 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
21622167
deto = 20;
21632168
}
21642169

2170+
/* Make dito, mdat, deto bits to 0s */
2171+
devslp &= ~GENMASK_ULL(24, 2);
21652172
devslp |= ((dito << PORT_DEVSLP_DITO_OFFSET) |
21662173
(mdat << PORT_DEVSLP_MDAT_OFFSET) |
21672174
(deto << PORT_DEVSLP_DETO_OFFSET) |
@@ -2439,6 +2446,8 @@ static void ahci_port_stop(struct ata_port *ap)
24392446
* re-enabling INTx.
24402447
*/
24412448
writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT);
2449+
2450+
ahci_rpm_put_port(ap);
24422451
}
24432452

24442453
void ahci_print_info(struct ata_host *host, const char *scc_s)

0 commit comments

Comments
 (0)