Skip to content

Commit cc3e5af

Browse files
committed
Merge tag 'ata-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata fixes from Damien Le Moal: - Fix link power management transitions to disallow unsupported states (Niklas) - A small string handling fix for the sata_mv driver (Christophe) - Clear port pending interrupts before reset, as per AHCI specifications (Szuying). Followup fixes for this one are to not clear ATA_PFLAG_EH_PENDING in ata_eh_reset() to allow EH to continue on with other actions recorded with error interrupts triggered before EH completes. And an additional fix to avoid thawing a port twice in EH (Niklas) - Small code style fixes in the pata_parport driver to silence the build bot as it keeps complaining about bad indentation (me) - A fix for the recent CDL code to avoid fetching sense data for successful commands when not necessary for correct operation (Niklas) * tag 'ata-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: ata: libata-core: fetch sense data for successful commands iff CDL enabled ata: libata-eh: do not thaw the port twice in ata_eh_reset() ata: libata-eh: do not clear ATA_PFLAG_EH_PENDING in ata_eh_reset() ata: pata_parport: Fix code style issues ata: libahci: clear pending interrupt status ata: sata_mv: Fix incorrect string length computation in mv_dump_mem() ata: libata: disallow dev-initiated LPM transitions to unsupported states
2 parents cce67b6 + 5e35a9a commit cc3e5af

File tree

8 files changed

+63
-40
lines changed

8 files changed

+63
-40
lines changed

drivers/ata/ahci.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,15 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
18831883
else
18841884
dev_info(&pdev->dev, "SSS flag set, parallel bus scan disabled\n");
18851885

1886+
if (!(hpriv->cap & HOST_CAP_PART))
1887+
host->flags |= ATA_HOST_NO_PART;
1888+
1889+
if (!(hpriv->cap & HOST_CAP_SSC))
1890+
host->flags |= ATA_HOST_NO_SSC;
1891+
1892+
if (!(hpriv->cap2 & HOST_CAP2_SDS))
1893+
host->flags |= ATA_HOST_NO_DEVSLP;
1894+
18861895
if (pi.flags & ATA_FLAG_EM)
18871896
ahci_reset_em(host);
18881897

drivers/ata/libahci.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
12561256
return sprintf(buf, "%d\n", emp->blink_policy);
12571257
}
12581258

1259+
static void ahci_port_clear_pending_irq(struct ata_port *ap)
1260+
{
1261+
struct ahci_host_priv *hpriv = ap->host->private_data;
1262+
void __iomem *port_mmio = ahci_port_base(ap);
1263+
u32 tmp;
1264+
1265+
/* clear SError */
1266+
tmp = readl(port_mmio + PORT_SCR_ERR);
1267+
dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
1268+
writel(tmp, port_mmio + PORT_SCR_ERR);
1269+
1270+
/* clear port IRQ */
1271+
tmp = readl(port_mmio + PORT_IRQ_STAT);
1272+
dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
1273+
if (tmp)
1274+
writel(tmp, port_mmio + PORT_IRQ_STAT);
1275+
1276+
writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
1277+
}
1278+
12591279
static void ahci_port_init(struct device *dev, struct ata_port *ap,
12601280
int port_no, void __iomem *mmio,
12611281
void __iomem *port_mmio)
@@ -1270,18 +1290,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
12701290
if (rc)
12711291
dev_warn(dev, "%s (%d)\n", emsg, rc);
12721292

1273-
/* clear SError */
1274-
tmp = readl(port_mmio + PORT_SCR_ERR);
1275-
dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
1276-
writel(tmp, port_mmio + PORT_SCR_ERR);
1277-
1278-
/* clear port IRQ */
1279-
tmp = readl(port_mmio + PORT_IRQ_STAT);
1280-
dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
1281-
if (tmp)
1282-
writel(tmp, port_mmio + PORT_IRQ_STAT);
1283-
1284-
writel(1 << port_no, mmio + HOST_IRQ_STAT);
1293+
ahci_port_clear_pending_irq(ap);
12851294

12861295
/* mark esata ports */
12871296
tmp = readl(port_mmio + PORT_CMD);
@@ -1603,6 +1612,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
16031612
tf.status = ATA_BUSY;
16041613
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
16051614

1615+
ahci_port_clear_pending_irq(ap);
1616+
16061617
rc = sata_link_hardreset(link, timing, deadline, online,
16071618
ahci_check_ready);
16081619

drivers/ata/libata-core.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4783,11 +4783,8 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
47834783
* been aborted by the device due to a limit timeout using the policy
47844784
* 0xD. For these commands, invoke EH to get the command sense data.
47854785
*/
4786-
if (qc->result_tf.status & ATA_SENSE &&
4787-
((ata_is_ncq(qc->tf.protocol) &&
4788-
dev->flags & ATA_DFLAG_CDL_ENABLED) ||
4789-
(!ata_is_ncq(qc->tf.protocol) &&
4790-
ata_id_sense_reporting_enabled(dev->id)))) {
4786+
if (qc->flags & ATA_QCFLAG_HAS_CDL &&
4787+
qc->result_tf.status & ATA_SENSE) {
47914788
/*
47924789
* Tell SCSI EH to not overwrite scmd->result even if this
47934790
* command is finished with result SAM_STAT_GOOD.

drivers/ata/libata-eh.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,23 +2796,13 @@ int ata_eh_reset(struct ata_link *link, int classify,
27962796
}
27972797
}
27982798

2799-
/*
2800-
* Some controllers can't be frozen very well and may set spurious
2801-
* error conditions during reset. Clear accumulated error
2802-
* information and re-thaw the port if frozen. As reset is the
2803-
* final recovery action and we cross check link onlineness against
2804-
* device classification later, no hotplug event is lost by this.
2805-
*/
2799+
/* clear cached SError */
28062800
spin_lock_irqsave(link->ap->lock, flags);
2807-
memset(&link->eh_info, 0, sizeof(link->eh_info));
2801+
link->eh_info.serror = 0;
28082802
if (slave)
2809-
memset(&slave->eh_info, 0, sizeof(link->eh_info));
2810-
ap->pflags &= ~ATA_PFLAG_EH_PENDING;
2803+
slave->eh_info.serror = 0;
28112804
spin_unlock_irqrestore(link->ap->lock, flags);
28122805

2813-
if (ata_port_is_frozen(ap))
2814-
ata_eh_thaw_port(ap);
2815-
28162806
/*
28172807
* Make sure onlineness and classification result correspond.
28182808
* Hotplug could have happened during reset and some

drivers/ata/libata-sata.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,23 @@ int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
396396
case ATA_LPM_MED_POWER_WITH_DIPM:
397397
case ATA_LPM_MIN_POWER_WITH_PARTIAL:
398398
case ATA_LPM_MIN_POWER:
399-
if (ata_link_nr_enabled(link) > 0)
400-
/* no restrictions on LPM transitions */
399+
if (ata_link_nr_enabled(link) > 0) {
400+
/* assume no restrictions on LPM transitions */
401401
scontrol &= ~(0x7 << 8);
402-
else {
402+
403+
/*
404+
* If the controller does not support partial, slumber,
405+
* or devsleep, then disallow these transitions.
406+
*/
407+
if (link->ap->host->flags & ATA_HOST_NO_PART)
408+
scontrol |= (0x1 << 8);
409+
410+
if (link->ap->host->flags & ATA_HOST_NO_SSC)
411+
scontrol |= (0x2 << 8);
412+
413+
if (link->ap->host->flags & ATA_HOST_NO_DEVSLP)
414+
scontrol |= (0x4 << 8);
415+
} else {
403416
/* empty port, power off */
404417
scontrol &= ~0xf;
405418
scontrol |= (0x1 << 2);

drivers/ata/pata_parport/comm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int comm_read_regr(struct pi_adapter *pi, int cont, int regr)
3737
{
3838
int l, h, r;
3939

40-
r = regr + cont_map[cont];
40+
r = regr + cont_map[cont];
4141

4242
switch (pi->mode) {
4343
case 0:
@@ -90,7 +90,6 @@ static void comm_connect(struct pi_adapter *pi)
9090
}
9191

9292
static void comm_disconnect(struct pi_adapter *pi)
93-
9493
{
9594
w2(0); w2(0); w2(0); w2(4);
9695
w0(pi->saved_r0);
@@ -172,12 +171,12 @@ static void comm_write_block(struct pi_adapter *pi, char *buf, int count)
172171
w4l(swab16(((u16 *)buf)[2 * k]) |
173172
swab16(((u16 *)buf)[2 * k + 1]) << 16);
174173
break;
175-
}
174+
}
176175
}
177176

178177
static void comm_log_adapter(struct pi_adapter *pi)
179-
180-
{ char *mode_string[5] = { "4-bit", "8-bit", "EPP-8", "EPP-16", "EPP-32" };
178+
{
179+
char *mode_string[5] = { "4-bit", "8-bit", "EPP-8", "EPP-16", "EPP-32" };
181180

182181
dev_info(&pi->dev,
183182
"DataStor Commuter at 0x%x, mode %d (%s), delay %d\n",

drivers/ata/sata_mv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,8 @@ static void mv_dump_mem(struct device *dev, void __iomem *start, unsigned bytes)
12551255

12561256
for (b = 0; b < bytes; ) {
12571257
for (w = 0, o = 0; b < bytes && w < 4; w++) {
1258-
o += snprintf(linebuf + o, sizeof(linebuf) - o,
1259-
"%08x ", readl(start + b));
1258+
o += scnprintf(linebuf + o, sizeof(linebuf) - o,
1259+
"%08x ", readl(start + b));
12601260
b += sizeof(u32);
12611261
}
12621262
dev_dbg(dev, "%s: %p: %s\n",

include/linux/libata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ enum {
222222
ATA_HOST_PARALLEL_SCAN = (1 << 2), /* Ports on this host can be scanned in parallel */
223223
ATA_HOST_IGNORE_ATA = (1 << 3), /* Ignore ATA devices on this host. */
224224

225+
ATA_HOST_NO_PART = (1 << 4), /* Host does not support partial */
226+
ATA_HOST_NO_SSC = (1 << 5), /* Host does not support slumber */
227+
ATA_HOST_NO_DEVSLP = (1 << 6), /* Host does not support devslp */
228+
225229
/* bits 24:31 of host->flags are reserved for LLD specific flags */
226230

227231
/* various lengths of time */

0 commit comments

Comments
 (0)