Skip to content

Commit e10117d

Browse files
committed
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (26 commits) include/linux/libata.h: fix typo pata_bf54x: fix return type of bfin_set_devctl Drivers: ata: Makefile: replace the use of <module>-objs with <module>-y libahci: fix result_tf handling after an ATA PIO data-in command pata_sl82c105: implement sff_irq_check() method pata_sil680: implement sff_irq_check() method pata_pdc202xx_old: implement sff_irq_check() method pata_cmd640: implement sff_irq_check() method ata_piix: Add device ID for ICH4-L pata_sil680: make sil680_sff_exec_command() 'static' ata: Intel IDE-R support libata: reorder ata_queued_cmd to remove alignment padding on 64 bit builds libata: Signal that our SATL supports WRITE SAME(16) with UNMAP ata_piix: remove SIDPR locking libata: implement cross-port EH exclusion libata: add @ap to ata_wait_register() and introduce ata_msleep() ata_piix: implement LPM support libata: implement LPM support for port multipliers libata: reimplement link power management libata: implement sata_link_scr_lpm() and make ata_dev_set_feature() global ...
2 parents f3270b1 + 89692c0 commit e10117d

31 files changed

+1815
-630
lines changed

Documentation/ABI/testing/sysfs-ata

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
What: /sys/class/ata_...
2+
Date: August 2008
3+
Contact: Gwendal Grignou<[email protected]>
4+
Description:
5+
6+
Provide a place in sysfs for storing the ATA topology of the system. This allows
7+
retrieving various information about ATA objects.
8+
9+
Files under /sys/class/ata_port
10+
-------------------------------
11+
12+
For each port, a directory ataX is created where X is the ata_port_id of
13+
the port. The device parent is the ata host device.
14+
15+
idle_irq (read)
16+
17+
Number of IRQ received by the port while idle [some ata HBA only].
18+
19+
nr_pmp_links (read)
20+
21+
If a SATA Port Multiplier (PM) is connected, number of link behind it.
22+
23+
Files under /sys/class/ata_link
24+
-------------------------------
25+
26+
Behind each port, there is a ata_link. If there is a SATA PM in the
27+
topology, 15 ata_link objects are created.
28+
29+
If a link is behind a port, the directory name is linkX, where X is
30+
ata_port_id of the port.
31+
If a link is behind a PM, its name is linkX.Y where X is ata_port_id
32+
of the parent port and Y the PM port.
33+
34+
hw_sata_spd_limit
35+
36+
Maximum speed supported by the connected SATA device.
37+
38+
sata_spd_limit
39+
40+
Maximum speed imposed by libata.
41+
42+
sata_spd
43+
44+
Current speed of the link [1.5, 3Gps,...].
45+
46+
Files under /sys/class/ata_device
47+
---------------------------------
48+
49+
Behind each link, up to two ata device are created.
50+
The name of the directory is devX[.Y].Z where:
51+
- X is ata_port_id of the port where the device is connected,
52+
- Y the port of the PM if any, and
53+
- Z the device id: for PATA, there is usually 2 devices [0,1],
54+
only 1 for SATA.
55+
56+
class
57+
Device class. Can be "ata" for disk, "atapi" for packet device,
58+
"pmp" for PM, or "none" if no device was found behind the link.
59+
60+
dma_mode
61+
62+
Transfer modes supported by the device when in DMA mode.
63+
Mostly used by PATA device.
64+
65+
pio_mode
66+
67+
Transfer modes supported by the device when in PIO mode.
68+
Mostly used by PATA device.
69+
70+
xfer_mode
71+
72+
Current transfer mode.
73+
74+
id
75+
76+
Cached result of IDENTIFY command, as described in ATA8 7.16 and 7.17.
77+
Only valid if the device is not a PM.
78+
79+
gscr
80+
81+
Cached result of the dump of PM GSCR register.
82+
Valid registers are:
83+
0: SATA_PMP_GSCR_PROD_ID,
84+
1: SATA_PMP_GSCR_REV,
85+
2: SATA_PMP_GSCR_PORT_INFO,
86+
32: SATA_PMP_GSCR_ERROR,
87+
33: SATA_PMP_GSCR_ERROR_EN,
88+
64: SATA_PMP_GSCR_FEAT,
89+
96: SATA_PMP_GSCR_FEAT_EN,
90+
130: SATA_PMP_GSCR_SII_GPIO
91+
Only valid if the device is a PM.
92+
93+
spdn_cnt
94+
95+
Number of time libata decided to lower the speed of link due to errors.
96+
97+
ering
98+
99+
Formatted output of the error ring of the device.

drivers/ata/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o
9999
# Should be last libata driver
100100
obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o
101101

102-
libata-objs := libata-core.o libata-scsi.o libata-eh.o
102+
libata-y := libata-core.o libata-scsi.o libata-eh.o libata-transport.o
103103
libata-$(CONFIG_ATA_SFF) += libata-sff.o
104104
libata-$(CONFIG_SATA_PMP) += libata-pmp.o
105105
libata-$(CONFIG_ATA_ACPI) += libata-acpi.o

drivers/ata/ahci.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,9 +1208,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
12081208
ata_port_pbar_desc(ap, AHCI_PCI_BAR,
12091209
0x100 + ap->port_no * 0x80, "port");
12101210

1211-
/* set initial link pm policy */
1212-
ap->pm_policy = NOT_AVAILABLE;
1213-
12141211
/* set enclosure management message type */
12151212
if (ap->flags & ATA_FLAG_EM)
12161213
ap->em_message_type = hpriv->em_msg_type;

drivers/ata/ahci.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ enum {
7272
AHCI_CMD_RESET = (1 << 8),
7373
AHCI_CMD_CLR_BUSY = (1 << 10),
7474

75+
RX_FIS_PIO_SETUP = 0x20, /* offset of PIO Setup FIS data */
7576
RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
7677
RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
7778
RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
@@ -201,7 +202,6 @@ enum {
201202
AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */
202203
AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */
203204
AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */
204-
AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */
205205
AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
206206
AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */
207207
AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */
@@ -216,7 +216,7 @@ enum {
216216
AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
217217
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
218218
ATA_FLAG_ACPI_SATA | ATA_FLAG_AN |
219-
ATA_FLAG_IPM,
219+
ATA_FLAG_LPM,
220220

221221
ICH_MAP = 0x90, /* ICH MAP register */
222222

drivers/ata/ahci_platform.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ static int __init ahci_probe(struct platform_device *pdev)
129129
ata_port_desc(ap, "mmio %pR", mem);
130130
ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80);
131131

132-
/* set initial link pm policy */
133-
ap->pm_policy = NOT_AVAILABLE;
134-
135132
/* set enclosure management message type */
136133
if (ap->flags & ATA_FLAG_EM)
137134
ap->em_message_type = hpriv->em_msg_type;

drivers/ata/ata_generic.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
enum {
3636
ATA_GEN_CLASS_MATCH = (1 << 0),
3737
ATA_GEN_FORCE_DMA = (1 << 1),
38+
ATA_GEN_INTEL_IDER = (1 << 2),
3839
};
3940

4041
/**
@@ -108,6 +109,49 @@ static struct ata_port_operations generic_port_ops = {
108109

109110
static int all_generic_ide; /* Set to claim all devices */
110111

112+
/**
113+
* is_intel_ider - identify intel IDE-R devices
114+
* @dev: PCI device
115+
*
116+
* Distinguish Intel IDE-R controller devices from other Intel IDE
117+
* devices. IDE-R devices have no timing registers and are in
118+
* most respects virtual. They should be driven by the ata_generic
119+
* driver.
120+
*
121+
* IDE-R devices have PCI offset 0xF8.L as zero, later Intel ATA has
122+
* it non zero. All Intel ATA has 0x40 writable (timing), but it is
123+
* not writable on IDE-R devices (this is guaranteed).
124+
*/
125+
126+
static int is_intel_ider(struct pci_dev *dev)
127+
{
128+
/* For Intel IDE the value at 0xF8 is only zero on IDE-R
129+
interfaces */
130+
u32 r;
131+
u16 t;
132+
133+
/* Check the manufacturing ID, it will be zero for IDE-R */
134+
pci_read_config_dword(dev, 0xF8, &r);
135+
/* Not IDE-R: punt so that ata_(old)piix gets it */
136+
if (r != 0)
137+
return 0;
138+
/* 0xF8 will also be zero on some early Intel IDE devices
139+
but they will have a sane timing register */
140+
pci_read_config_word(dev, 0x40, &t);
141+
if (t != 0)
142+
return 0;
143+
/* Finally check if the timing register is writable so that
144+
we eliminate any early devices hot-docked in a docking
145+
station */
146+
pci_write_config_word(dev, 0x40, 1);
147+
pci_read_config_word(dev, 0x40, &t);
148+
if (t) {
149+
pci_write_config_word(dev, 0x40, 0);
150+
return 0;
151+
}
152+
return 1;
153+
}
154+
111155
/**
112156
* ata_generic_init - attach generic IDE
113157
* @dev: PCI device found
@@ -134,6 +178,10 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
134178
if ((id->driver_data & ATA_GEN_CLASS_MATCH) && all_generic_ide == 0)
135179
return -ENODEV;
136180

181+
if (id->driver_data & ATA_GEN_INTEL_IDER)
182+
if (!is_intel_ider(dev))
183+
return -ENODEV;
184+
137185
/* Devices that need care */
138186
if (dev->vendor == PCI_VENDOR_ID_UMC &&
139187
dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
@@ -186,7 +234,11 @@ static struct pci_device_id ata_generic[] = {
186234
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
187235
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), },
188236
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), },
189-
#endif
237+
#endif
238+
/* Intel, IDE class device */
239+
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
240+
PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL,
241+
.driver_data = ATA_GEN_INTEL_IDER },
190242
/* Must come last. If you add entries adjust this table appropriately */
191243
{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL),
192244
.driver_data = ATA_GEN_CLASS_MATCH },

drivers/ata/ata_piix.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ struct piix_map_db {
158158
struct piix_host_priv {
159159
const int *map;
160160
u32 saved_iocfg;
161-
spinlock_t sidpr_lock; /* FIXME: remove once locking in EH is fixed */
162161
void __iomem *sidpr;
163162
};
164163

@@ -175,6 +174,8 @@ static int piix_sidpr_scr_read(struct ata_link *link,
175174
unsigned int reg, u32 *val);
176175
static int piix_sidpr_scr_write(struct ata_link *link,
177176
unsigned int reg, u32 val);
177+
static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
178+
unsigned hints);
178179
static bool piix_irq_check(struct ata_port *ap);
179180
#ifdef CONFIG_PM
180181
static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
@@ -209,6 +210,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
209210
{ 0x8086, 0x248A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
210211
/* Intel ICH3 (E7500/1) UDMA 100 */
211212
{ 0x8086, 0x248B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
213+
/* Intel ICH4-L */
214+
{ 0x8086, 0x24C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
212215
/* Intel ICH4 (i845GV, i845E, i852, i855) UDMA 100 */
213216
{ 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
214217
{ 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
@@ -348,11 +351,22 @@ static struct ata_port_operations ich_pata_ops = {
348351
.set_dmamode = ich_set_dmamode,
349352
};
350353

354+
static struct device_attribute *piix_sidpr_shost_attrs[] = {
355+
&dev_attr_link_power_management_policy,
356+
NULL
357+
};
358+
359+
static struct scsi_host_template piix_sidpr_sht = {
360+
ATA_BMDMA_SHT(DRV_NAME),
361+
.shost_attrs = piix_sidpr_shost_attrs,
362+
};
363+
351364
static struct ata_port_operations piix_sidpr_sata_ops = {
352365
.inherits = &piix_sata_ops,
353366
.hardreset = sata_std_hardreset,
354367
.scr_read = piix_sidpr_scr_read,
355368
.scr_write = piix_sidpr_scr_write,
369+
.set_lpm = piix_sidpr_set_lpm,
356370
};
357371

358372
static const struct piix_map_db ich5_map_db = {
@@ -956,34 +970,34 @@ static int piix_sidpr_scr_read(struct ata_link *link,
956970
unsigned int reg, u32 *val)
957971
{
958972
struct piix_host_priv *hpriv = link->ap->host->private_data;
959-
unsigned long flags;
960973

961974
if (reg >= ARRAY_SIZE(piix_sidx_map))
962975
return -EINVAL;
963976

964-
spin_lock_irqsave(&hpriv->sidpr_lock, flags);
965977
piix_sidpr_sel(link, reg);
966978
*val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA);
967-
spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
968979
return 0;
969980
}
970981

971982
static int piix_sidpr_scr_write(struct ata_link *link,
972983
unsigned int reg, u32 val)
973984
{
974985
struct piix_host_priv *hpriv = link->ap->host->private_data;
975-
unsigned long flags;
976986

977987
if (reg >= ARRAY_SIZE(piix_sidx_map))
978988
return -EINVAL;
979989

980-
spin_lock_irqsave(&hpriv->sidpr_lock, flags);
981990
piix_sidpr_sel(link, reg);
982991
iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA);
983-
spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
984992
return 0;
985993
}
986994

995+
static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
996+
unsigned hints)
997+
{
998+
return sata_link_scr_lpm(link, policy, false);
999+
}
1000+
9871001
static bool piix_irq_check(struct ata_port *ap)
9881002
{
9891003
if (unlikely(!ap->ioaddr.bmdma_addr))
@@ -1543,6 +1557,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
15431557
struct device *dev = &pdev->dev;
15441558
struct ata_port_info port_info[2];
15451559
const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
1560+
struct scsi_host_template *sht = &piix_sht;
15461561
unsigned long port_flags;
15471562
struct ata_host *host;
15481563
struct piix_host_priv *hpriv;
@@ -1577,7 +1592,6 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
15771592
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
15781593
if (!hpriv)
15791594
return -ENOMEM;
1580-
spin_lock_init(&hpriv->sidpr_lock);
15811595

15821596
/* Save IOCFG, this will be used for cable detection, quirk
15831597
* detection and restoration on detach. This is necessary
@@ -1612,6 +1626,8 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
16121626
rc = piix_init_sidpr(host);
16131627
if (rc)
16141628
return rc;
1629+
if (host->ports[0]->ops == &piix_sidpr_sata_ops)
1630+
sht = &piix_sidpr_sht;
16151631
}
16161632

16171633
/* apply IOCFG bit18 quirk */
@@ -1638,7 +1654,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
16381654
host->flags |= ATA_HOST_PARALLEL_SCAN;
16391655

16401656
pci_set_master(pdev);
1641-
return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, &piix_sht);
1657+
return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
16421658
}
16431659

16441660
static void piix_remove_one(struct pci_dev *pdev)

0 commit comments

Comments
 (0)