Skip to content

Commit 8f75446

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: libata: ahci_start_engine compliant to AHCI spec ata: pata_at91.c bugfix for initial_timing initialisation ata: pata_at91.c bugfix for high master clock ahci: AHCI-mode SATA patch for Intel Panther Point DeviceIDs ata_piix: IDE-mode SATA patch for Intel Panther Point DeviceIDs libata: Pioneer DVR-216D can't do SETXFER ahci: don't enable port irq before handler is registered libata: Implement ATA_FLAG_NO_DIPM and apply it to mcp65 libata: Kill unused ATA_DFLAG_{H|D}IPM flags ahci: EM supported message type sysfs attribute
2 parents 1f91f48 + 270dac3 commit 8f75446

8 files changed

Lines changed: 103 additions & 11 deletions

File tree

‎drivers/ata/ahci.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static const struct ata_port_info ahci_port_info[] = {
150150
{
151151
AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP |
152152
AHCI_HFLAG_YES_NCQ),
153-
.flags = AHCI_FLAG_COMMON,
153+
.flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
154154
.pio_mask = ATA_PIO4,
155155
.udma_mask = ATA_UDMA6,
156156
.port_ops = &ahci_ops,
@@ -261,6 +261,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
261261
{ PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */
262262
{ PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
263263
{ PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
264+
{ PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
265+
{ PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point AHCI */
266+
{ PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
267+
{ PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
268+
{ PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
269+
{ PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
264270

265271
/* JMicron 360/1/3/5/6, match class to avoid IDE function */
266272
{ PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,

‎drivers/ata/ahci.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ enum {
229229
EM_CTL_ALHD = (1 << 26), /* Activity LED */
230230
EM_CTL_XMT = (1 << 25), /* Transmit Only */
231231
EM_CTL_SMB = (1 << 24), /* Single Message Buffer */
232+
EM_CTL_SGPIO = (1 << 19), /* SGPIO messages supported */
233+
EM_CTL_SES = (1 << 18), /* SES-2 messages supported */
234+
EM_CTL_SAFTE = (1 << 17), /* SAF-TE messages supported */
235+
EM_CTL_LED = (1 << 16), /* LED messages supported */
232236

233237
/* em message type */
234238
EM_MSG_TYPE_LED = (1 << 0), /* LED */

‎drivers/ata/ata_piix.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ static const struct pci_device_id piix_pci_tbl[] = {
309309
{ 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
310310
/* SATA Controller IDE (PBG) */
311311
{ 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
312+
/* SATA Controller IDE (Panther Point) */
313+
{ 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
314+
/* SATA Controller IDE (Panther Point) */
315+
{ 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
316+
/* SATA Controller IDE (Panther Point) */
317+
{ 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
318+
/* SATA Controller IDE (Panther Point) */
319+
{ 0x8086, 0x1e09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
312320
{ } /* terminate list */
313321
};
314322

‎drivers/ata/libahci.c‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ static ssize_t ahci_read_em_buffer(struct device *dev,
109109
static ssize_t ahci_store_em_buffer(struct device *dev,
110110
struct device_attribute *attr,
111111
const char *buf, size_t size);
112+
static ssize_t ahci_show_em_supported(struct device *dev,
113+
struct device_attribute *attr, char *buf);
112114

113115
static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
114116
static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
115117
static DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
116118
static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
117119
static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO,
118120
ahci_read_em_buffer, ahci_store_em_buffer);
121+
static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);
119122

120123
struct device_attribute *ahci_shost_attrs[] = {
121124
&dev_attr_link_power_management_policy,
@@ -126,6 +129,7 @@ struct device_attribute *ahci_shost_attrs[] = {
126129
&dev_attr_ahci_host_version,
127130
&dev_attr_ahci_port_cmd,
128131
&dev_attr_em_buffer,
132+
&dev_attr_em_message_supported,
129133
NULL
130134
};
131135
EXPORT_SYMBOL_GPL(ahci_shost_attrs);
@@ -343,6 +347,24 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
343347
return size;
344348
}
345349

350+
static ssize_t ahci_show_em_supported(struct device *dev,
351+
struct device_attribute *attr, char *buf)
352+
{
353+
struct Scsi_Host *shost = class_to_shost(dev);
354+
struct ata_port *ap = ata_shost_to_port(shost);
355+
struct ahci_host_priv *hpriv = ap->host->private_data;
356+
void __iomem *mmio = hpriv->mmio;
357+
u32 em_ctl;
358+
359+
em_ctl = readl(mmio + HOST_EM_CTL);
360+
361+
return sprintf(buf, "%s%s%s%s\n",
362+
em_ctl & EM_CTL_LED ? "led " : "",
363+
em_ctl & EM_CTL_SAFTE ? "saf-te " : "",
364+
em_ctl & EM_CTL_SES ? "ses-2 " : "",
365+
em_ctl & EM_CTL_SGPIO ? "sgpio " : "");
366+
}
367+
346368
/**
347369
* ahci_save_initial_config - Save and fixup initial config values
348370
* @dev: target AHCI device
@@ -539,6 +561,27 @@ void ahci_start_engine(struct ata_port *ap)
539561
{
540562
void __iomem *port_mmio = ahci_port_base(ap);
541563
u32 tmp;
564+
u8 status;
565+
566+
status = readl(port_mmio + PORT_TFDATA) & 0xFF;
567+
568+
/*
569+
* At end of section 10.1 of AHCI spec (rev 1.3), it states
570+
* Software shall not set PxCMD.ST to 1 until it is determined
571+
* that a functoinal device is present on the port as determined by
572+
* PxTFD.STS.BSY=0, PxTFD.STS.DRQ=0 and PxSSTS.DET=3h
573+
*
574+
* Even though most AHCI host controllers work without this check,
575+
* specific controller will fail under this condition
576+
*/
577+
if (status & (ATA_BUSY | ATA_DRQ))
578+
return;
579+
else {
580+
ahci_scr_read(&ap->link, SCR_STATUS, &tmp);
581+
582+
if ((tmp & 0xf) != 0x3)
583+
return;
584+
}
542585

543586
/* start DMA */
544587
tmp = readl(port_mmio + PORT_CMD);
@@ -1897,7 +1940,17 @@ static void ahci_pmp_attach(struct ata_port *ap)
18971940
ahci_enable_fbs(ap);
18981941

18991942
pp->intr_mask |= PORT_IRQ_BAD_PMP;
1900-
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
1943+
1944+
/*
1945+
* We must not change the port interrupt mask register if the
1946+
* port is marked frozen, the value in pp->intr_mask will be
1947+
* restored later when the port is thawed.
1948+
*
1949+
* Note that during initialization, the port is marked as
1950+
* frozen since the irq handler is not yet registered.
1951+
*/
1952+
if (!(ap->pflags & ATA_PFLAG_FROZEN))
1953+
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
19011954
}
19021955

19031956
static void ahci_pmp_detach(struct ata_port *ap)
@@ -1913,7 +1966,10 @@ static void ahci_pmp_detach(struct ata_port *ap)
19131966
writel(cmd, port_mmio + PORT_CMD);
19141967

19151968
pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
1916-
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
1969+
1970+
/* see comment above in ahci_pmp_attach() */
1971+
if (!(ap->pflags & ATA_PFLAG_FROZEN))
1972+
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
19171973
}
19181974

19191975
int ahci_port_resume(struct ata_port *ap)

‎drivers/ata/libata-core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4139,6 +4139,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
41394139
*/
41404140
{ "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER },
41414141
{ "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER },
4142+
{ "PIONEER DVD-RW DVR-216D", "1.08", ATA_HORKAGE_NOSETXFER },
41424143

41434144
/* End Marker */
41444145
{ }
@@ -5480,7 +5481,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
54805481
if (!ap)
54815482
return NULL;
54825483

5483-
ap->pflags |= ATA_PFLAG_INITIALIZING;
5484+
ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
54845485
ap->lock = &host->lock;
54855486
ap->print_id = -1;
54865487
ap->host = host;

‎drivers/ata/libata-eh.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,6 +3316,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
33163316
struct ata_eh_context *ehc = &link->eh_context;
33173317
struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL;
33183318
enum ata_lpm_policy old_policy = link->lpm_policy;
3319+
bool no_dipm = ap->flags & ATA_FLAG_NO_DIPM;
33193320
unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM;
33203321
unsigned int err_mask;
33213322
int rc;
@@ -3332,7 +3333,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
33323333
*/
33333334
ata_for_each_dev(dev, link, ENABLED) {
33343335
bool hipm = ata_id_has_hipm(dev->id);
3335-
bool dipm = ata_id_has_dipm(dev->id);
3336+
bool dipm = ata_id_has_dipm(dev->id) && !no_dipm;
33363337

33373338
/* find the first enabled and LPM enabled devices */
33383339
if (!link_dev)
@@ -3389,7 +3390,8 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
33893390

33903391
/* host config updated, enable DIPM if transitioning to MIN_POWER */
33913392
ata_for_each_dev(dev, link, ENABLED) {
3392-
if (policy == ATA_LPM_MIN_POWER && ata_id_has_dipm(dev->id)) {
3393+
if (policy == ATA_LPM_MIN_POWER && !no_dipm &&
3394+
ata_id_has_dipm(dev->id)) {
33933395
err_mask = ata_dev_set_feature(dev,
33943396
SETFEATURES_SATA_ENABLE, SATA_DIPM);
33953397
if (err_mask && err_mask != AC_ERR_DEV) {

‎drivers/ata/pata_at91.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333

3434

3535
#define DRV_NAME "pata_at91"
36-
#define DRV_VERSION "0.1"
36+
#define DRV_VERSION "0.2"
3737

3838
#define CF_IDE_OFFSET 0x00c00000
3939
#define CF_ALT_IDE_OFFSET 0x00e00000
4040
#define CF_IDE_RES_SIZE 0x08
41+
#define NCS_RD_PULSE_LIMIT 0x3f /* maximal value for pulse bitfields */
4142

4243
struct at91_ide_info {
4344
unsigned long mode;
@@ -49,8 +50,18 @@ struct at91_ide_info {
4950
void __iomem *alt_addr;
5051
};
5152

52-
static const struct ata_timing initial_timing =
53-
{XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};
53+
static const struct ata_timing initial_timing = {
54+
.mode = XFER_PIO_0,
55+
.setup = 70,
56+
.act8b = 290,
57+
.rec8b = 240,
58+
.cyc8b = 600,
59+
.active = 165,
60+
.recover = 150,
61+
.dmack_hold = 0,
62+
.cycle = 600,
63+
.udma = 0
64+
};
5465

5566
static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz)
5667
{
@@ -109,6 +120,11 @@ static void set_smc_timing(struct device *dev,
109120
/* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
110121
ncs_read_setup = 1;
111122
ncs_read_pulse = read_cycle - 2;
123+
if (ncs_read_pulse > NCS_RD_PULSE_LIMIT) {
124+
ncs_read_pulse = NCS_RD_PULSE_LIMIT;
125+
dev_warn(dev, "ncs_read_pulse limited to maximal value %lu\n",
126+
ncs_read_pulse);
127+
}
112128

113129
/* Write timings same as read timings */
114130
write_cycle = read_cycle;

‎include/linux/libata.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ enum {
137137
ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */
138138
ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */
139139
ATA_DFLAG_AN = (1 << 7), /* AN configured */
140-
ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */
141-
ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */
142140
ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */
143141
ATA_DFLAG_CFG_MASK = (1 << 12) - 1,
144142

@@ -198,6 +196,7 @@ enum {
198196
* management */
199197
ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
200198
* led */
199+
ATA_FLAG_NO_DIPM = (1 << 23), /* host not happy with DIPM */
201200

202201
/* bits 24:31 of ap->flags are reserved for LLD specific flags */
203202

0 commit comments

Comments
 (0)