Skip to content

Commit 7b5ca22

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: ata_piix: The Sony TZ90 needs the cable type hardcoding ata_piix: ICH7 does not support correct MWDMA timings Avoid world-writable sysfs files in libata driver. libata: fix suspend/resume for ATA SEMB devices libata: clear ering on resume pata_pdc202xx_old: fix UDMA33 handling sata_mv: use new sata phy register settings for new devices libata: fix attach error handling
2 parents 2b79bc4 + 124a6ee commit 7b5ca22

6 files changed

Lines changed: 120 additions & 15 deletions

File tree

‎drivers/ata/ata_piix.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
* ICH2 spec c #20 - IDE PRD must not cross a 64K boundary
7373
* and must be dword aligned
7474
* ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3
75+
* ICH7 errata #16 - MWDMA1 timings are incorrect
7576
*
7677
* Should have been BIOS fixed:
7778
* 450NX: errata #19 - DMA hangs on old 450NX
@@ -94,7 +95,7 @@
9495
#include <linux/dmi.h>
9596

9697
#define DRV_NAME "ata_piix"
97-
#define DRV_VERSION "2.12"
98+
#define DRV_VERSION "2.13"
9899

99100
enum {
100101
PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
@@ -136,6 +137,7 @@ enum piix_controller_ids {
136137
ich_pata_33, /* ICH up to UDMA 33 only */
137138
ich_pata_66, /* ICH up to 66 Mhz */
138139
ich_pata_100, /* ICH up to UDMA 100 */
140+
ich_pata_100_nomwdma1, /* ICH up to UDMA 100 but with no MWDMA1*/
139141
ich5_sata,
140142
ich6_sata,
141143
ich6m_sata,
@@ -216,8 +218,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
216218
/* ICH6 (and 6) (i915) UDMA 100 */
217219
{ 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
218220
/* ICH7/7-R (i945, i975) UDMA 100*/
219-
{ 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
220-
{ 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
221+
{ 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100_nomwdma1 },
222+
{ 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100_nomwdma1 },
221223
/* ICH8 Mobile PATA Controller */
222224
{ 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
223225

@@ -487,6 +489,15 @@ static struct ata_port_info piix_port_info[] = {
487489
.port_ops = &ich_pata_ops,
488490
},
489491

492+
[ich_pata_100_nomwdma1] =
493+
{
494+
.flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
495+
.pio_mask = ATA_PIO4,
496+
.mwdma_mask = ATA_MWDMA2_ONLY,
497+
.udma_mask = ATA_UDMA5,
498+
.port_ops = &ich_pata_ops,
499+
},
500+
490501
[ich5_sata] =
491502
{
492503
.flags = PIIX_SATA_FLAGS,
@@ -594,6 +605,7 @@ static const struct ich_laptop ich_laptop[] = {
594605
{ 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */
595606
{ 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */
596607
{ 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */
608+
{ 0x27df, 0x104d, 0x900e }, /* ICH7 on Sony TZ-90 */
597609
/* end marker */
598610
{ 0, }
599611
};

‎drivers/ata/libata-core.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4091,7 +4091,9 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
40914091

40924092
/* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */
40934093
if (ata_class_enabled(new_class) &&
4094-
new_class != ATA_DEV_ATA && new_class != ATA_DEV_ATAPI) {
4094+
new_class != ATA_DEV_ATA &&
4095+
new_class != ATA_DEV_ATAPI &&
4096+
new_class != ATA_DEV_SEMB) {
40954097
ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n",
40964098
dev->class, new_class);
40974099
rc = -ENODEV;

‎drivers/ata/libata-eh.c‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,13 +2783,24 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
27832783
} else if (dev->class == ATA_DEV_UNKNOWN &&
27842784
ehc->tries[dev->devno] &&
27852785
ata_class_enabled(ehc->classes[dev->devno])) {
2786+
/* Temporarily set dev->class, it will be
2787+
* permanently set once all configurations are
2788+
* complete. This is necessary because new
2789+
* device configuration is done in two
2790+
* separate loops.
2791+
*/
27862792
dev->class = ehc->classes[dev->devno];
27872793

27882794
if (dev->class == ATA_DEV_PMP)
27892795
rc = sata_pmp_attach(dev);
27902796
else
27912797
rc = ata_dev_read_id(dev, &dev->class,
27922798
readid_flags, dev->id);
2799+
2800+
/* read_id might have changed class, store and reset */
2801+
ehc->classes[dev->devno] = dev->class;
2802+
dev->class = ATA_DEV_UNKNOWN;
2803+
27932804
switch (rc) {
27942805
case 0:
27952806
/* clear error info accumulated during probe */
@@ -2799,13 +2810,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
27992810
case -ENOENT:
28002811
/* IDENTIFY was issued to non-existent
28012812
* device. No need to reset. Just
2802-
* thaw and kill the device.
2813+
* thaw and ignore the device.
28032814
*/
28042815
ata_eh_thaw_port(ap);
2805-
dev->class = ATA_DEV_UNKNOWN;
28062816
break;
28072817
default:
2808-
dev->class = ATA_DEV_UNKNOWN;
28092818
goto err;
28102819
}
28112820
}
@@ -2826,11 +2835,15 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
28262835
dev->class == ATA_DEV_PMP)
28272836
continue;
28282837

2838+
dev->class = ehc->classes[dev->devno];
2839+
28292840
ehc->i.flags |= ATA_EHI_PRINTINFO;
28302841
rc = ata_dev_configure(dev);
28312842
ehc->i.flags &= ~ATA_EHI_PRINTINFO;
2832-
if (rc)
2843+
if (rc) {
2844+
dev->class = ATA_DEV_UNKNOWN;
28332845
goto err;
2846+
}
28342847

28352848
spin_lock_irqsave(ap->lock, flags);
28362849
ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
@@ -3494,6 +3507,8 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
34943507
*/
34953508
static void ata_eh_handle_port_resume(struct ata_port *ap)
34963509
{
3510+
struct ata_link *link;
3511+
struct ata_device *dev;
34973512
unsigned long flags;
34983513
int rc = 0;
34993514

@@ -3508,6 +3523,17 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
35083523

35093524
WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
35103525

3526+
/*
3527+
* Error timestamps are in jiffies which doesn't run while
3528+
* suspended and PHY events during resume isn't too uncommon.
3529+
* When the two are combined, it can lead to unnecessary speed
3530+
* downs if the machine is suspended and resumed repeatedly.
3531+
* Clear error history.
3532+
*/
3533+
ata_for_each_link(link, ap, HOST_FIRST)
3534+
ata_for_each_dev(dev, link, ALL)
3535+
ata_ering_clear(&dev->ering);
3536+
35113537
ata_acpi_set_state(ap, PMSG_ON);
35123538

35133539
if (ap->ops->port_resume)

‎drivers/ata/libata-scsi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ ata_scsi_em_message_show(struct device *dev, struct device_attribute *attr,
313313
return ap->ops->em_show(ap, buf);
314314
return -EINVAL;
315315
}
316-
DEVICE_ATTR(em_message, S_IRUGO | S_IWUGO,
316+
DEVICE_ATTR(em_message, S_IRUGO | S_IWUSR,
317317
ata_scsi_em_message_show, ata_scsi_em_message_store);
318318
EXPORT_SYMBOL_GPL(dev_attr_em_message);
319319

@@ -366,7 +366,7 @@ ata_scsi_activity_store(struct device *dev, struct device_attribute *attr,
366366
}
367367
return -EINVAL;
368368
}
369-
DEVICE_ATTR(sw_activity, S_IWUGO | S_IRUGO, ata_scsi_activity_show,
369+
DEVICE_ATTR(sw_activity, S_IWUSR | S_IRUGO, ata_scsi_activity_show,
370370
ata_scsi_activity_store);
371371
EXPORT_SYMBOL_GPL(dev_attr_sw_activity);
372372

‎drivers/ata/pata_pdc202xx_old.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer
33
* (C) 2005 Red Hat Inc
44
* Alan Cox <alan@lxorguk.ukuu.org.uk>
5-
* (C) 2007 Bartlomiej Zolnierkiewicz
5+
* (C) 2007,2009 Bartlomiej Zolnierkiewicz
66
*
77
* Based in part on linux/drivers/ide/pci/pdc202xx_old.c
88
*
@@ -158,7 +158,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
158158
u32 len;
159159

160160
/* Check we keep host level locking here */
161-
if (adev->dma_mode >= XFER_UDMA_2)
161+
if (adev->dma_mode > XFER_UDMA_2)
162162
iowrite8(ioread8(clock) | sel66, clock);
163163
else
164164
iowrite8(ioread8(clock) & ~sel66, clock);
@@ -212,7 +212,7 @@ static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc)
212212
iowrite8(ioread8(clock) & ~sel66, clock);
213213
}
214214
/* Flip back to 33Mhz for PIO */
215-
if (adev->dma_mode >= XFER_UDMA_2)
215+
if (adev->dma_mode > XFER_UDMA_2)
216216
iowrite8(ioread8(clock) & ~sel66, clock);
217217
ata_bmdma_stop(qc);
218218
pdc202xx_set_piomode(ap, adev);

‎drivers/ata/sata_mv.c‎

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ enum {
293293
FISCFG_WAIT_DEV_ERR = (1 << 8), /* wait for host on DevErr */
294294
FISCFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */
295295

296+
PHY_MODE9_GEN2 = 0x398,
297+
PHY_MODE9_GEN1 = 0x39c,
298+
PHYCFG_OFS = 0x3a0, /* only in 65n devices */
299+
296300
MV5_PHY_MODE = 0x74,
297301
MV5_LTMODE = 0x30,
298302
MV5_PHY_CTL = 0x0C,
@@ -609,6 +613,8 @@ static int mv_soc_reset_hc(struct mv_host_priv *hpriv,
609613
static void mv_soc_reset_flash(struct mv_host_priv *hpriv,
610614
void __iomem *mmio);
611615
static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio);
616+
static void mv_soc_65n_phy_errata(struct mv_host_priv *hpriv,
617+
void __iomem *mmio, unsigned int port);
612618
static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio);
613619
static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
614620
unsigned int port_no);
@@ -807,6 +813,14 @@ static const struct mv_hw_ops mv_soc_ops = {
807813
.reset_bus = mv_soc_reset_bus,
808814
};
809815

816+
static const struct mv_hw_ops mv_soc_65n_ops = {
817+
.phy_errata = mv_soc_65n_phy_errata,
818+
.enable_leds = mv_soc_enable_leds,
819+
.reset_hc = mv_soc_reset_hc,
820+
.reset_flash = mv_soc_reset_flash,
821+
.reset_bus = mv_soc_reset_bus,
822+
};
823+
810824
/*
811825
* Functions
812826
*/
@@ -3397,6 +3411,53 @@ static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio)
33973411
return;
33983412
}
33993413

3414+
static void mv_soc_65n_phy_errata(struct mv_host_priv *hpriv,
3415+
void __iomem *mmio, unsigned int port)
3416+
{
3417+
void __iomem *port_mmio = mv_port_base(mmio, port);
3418+
u32 reg;
3419+
3420+
reg = readl(port_mmio + PHY_MODE3);
3421+
reg &= ~(0x3 << 27); /* SELMUPF (bits 28:27) to 1 */
3422+
reg |= (0x1 << 27);
3423+
reg &= ~(0x3 << 29); /* SELMUPI (bits 30:29) to 1 */
3424+
reg |= (0x1 << 29);
3425+
writel(reg, port_mmio + PHY_MODE3);
3426+
3427+
reg = readl(port_mmio + PHY_MODE4);
3428+
reg &= ~0x1; /* SATU_OD8 (bit 0) to 0, reserved bit 16 must be set */
3429+
reg |= (0x1 << 16);
3430+
writel(reg, port_mmio + PHY_MODE4);
3431+
3432+
reg = readl(port_mmio + PHY_MODE9_GEN2);
3433+
reg &= ~0xf; /* TXAMP[3:0] (bits 3:0) to 8 */
3434+
reg |= 0x8;
3435+
reg &= ~(0x1 << 14); /* TXAMP[4] (bit 14) to 0 */
3436+
writel(reg, port_mmio + PHY_MODE9_GEN2);
3437+
3438+
reg = readl(port_mmio + PHY_MODE9_GEN1);
3439+
reg &= ~0xf; /* TXAMP[3:0] (bits 3:0) to 8 */
3440+
reg |= 0x8;
3441+
reg &= ~(0x1 << 14); /* TXAMP[4] (bit 14) to 0 */
3442+
writel(reg, port_mmio + PHY_MODE9_GEN1);
3443+
}
3444+
3445+
/**
3446+
* soc_is_65 - check if the soc is 65 nano device
3447+
*
3448+
* Detect the type of the SoC, this is done by reading the PHYCFG_OFS
3449+
* register, this register should contain non-zero value and it exists only
3450+
* in the 65 nano devices, when reading it from older devices we get 0.
3451+
*/
3452+
static bool soc_is_65n(struct mv_host_priv *hpriv)
3453+
{
3454+
void __iomem *port0_mmio = mv_port_base(hpriv->base, 0);
3455+
3456+
if (readl(port0_mmio + PHYCFG_OFS))
3457+
return true;
3458+
return false;
3459+
}
3460+
34003461
static void mv_setup_ifcfg(void __iomem *port_mmio, int want_gen2i)
34013462
{
34023463
u32 ifcfg = readl(port_mmio + SATA_IFCFG);
@@ -3737,7 +3798,10 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
37373798
}
37383799
break;
37393800
case chip_soc:
3740-
hpriv->ops = &mv_soc_ops;
3801+
if (soc_is_65n(hpriv))
3802+
hpriv->ops = &mv_soc_65n_ops;
3803+
else
3804+
hpriv->ops = &mv_soc_ops;
37413805
hp_flags |= MV_HP_FLAG_SOC | MV_HP_GEN_IIE |
37423806
MV_HP_ERRATA_60X1C0;
37433807
break;
@@ -3800,7 +3864,8 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
38003864
n_hc = mv_get_hc_count(host->ports[0]->flags);
38013865

38023866
for (port = 0; port < host->n_ports; port++)
3803-
hpriv->ops->read_preamp(hpriv, port, mmio);
3867+
if (hpriv->ops->read_preamp)
3868+
hpriv->ops->read_preamp(hpriv, port, mmio);
38043869

38053870
rc = hpriv->ops->reset_hc(hpriv, mmio, n_hc);
38063871
if (rc)

0 commit comments

Comments
 (0)