Commit 256414de authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev:
  [PATCH] sata_mv: three bug fixes
  [PATCH] libata: ata_dev_init_params() fixes
  [PATCH] libata: Fix interesting use of "extern" and also some bracketing
  [PATCH] libata: Simplex and other mode filtering logic
  [PATCH] libata - ATA is both ATA and CFA
  [PATCH] libata: Add ->set_mode hook for odd drivers
  [PATCH] libata: BMDMA handling updates
  [PATCH] libata: kill trailing whitespace
  [PATCH] libata: add FIXME above ata_dev_xfermask()
  [PATCH] libata: cosmetic changes in ata_bus_softreset()
  [PATCH] libata: kill E.D.D.
parents 63e8d911 55d8ca4f
...@@ -120,14 +120,27 @@ void (*dev_config) (struct ata_port *, struct ata_device *); ...@@ -120,14 +120,27 @@ void (*dev_config) (struct ata_port *, struct ata_device *);
<programlisting> <programlisting>
void (*set_piomode) (struct ata_port *, struct ata_device *); void (*set_piomode) (struct ata_port *, struct ata_device *);
void (*set_dmamode) (struct ata_port *, struct ata_device *); void (*set_dmamode) (struct ata_port *, struct ata_device *);
void (*post_set_mode) (struct ata_port *ap); void (*post_set_mode) (struct ata_port *);
unsigned int (*mode_filter) (struct ata_port *, struct ata_device *, unsigned int);
</programlisting> </programlisting>
<para> <para>
Hooks called prior to the issue of SET FEATURES - XFER MODE Hooks called prior to the issue of SET FEATURES - XFER MODE
command. dev->pio_mode is guaranteed to be valid when command. The optional ->mode_filter() hook is called when libata
->set_piomode() is called, and dev->dma_mode is guaranteed to be has built a mask of the possible modes. This is passed to the
valid when ->set_dmamode() is called. ->post_set_mode() is ->mode_filter() function which should return a mask of valid modes
after filtering those unsuitable due to hardware limits. It is not
valid to use this interface to add modes.
</para>
<para>
dev->pio_mode and dev->dma_mode are guaranteed to be valid when
->set_piomode() and when ->set_dmamode() is called. The timings for
any other drive sharing the cable will also be valid at this point.
That is the library records the decisions for the modes of each
drive on a channel before it attempts to set any of them.
</para>
<para>
->post_set_mode() is
called unconditionally, after the SET FEATURES - XFER MODE called unconditionally, after the SET FEATURES - XFER MODE
command completes successfully. command completes successfully.
</para> </para>
...@@ -230,6 +243,32 @@ void (*dev_select)(struct ata_port *ap, unsigned int device); ...@@ -230,6 +243,32 @@ void (*dev_select)(struct ata_port *ap, unsigned int device);
</sect2> </sect2>
<sect2><title>Private tuning method</title>
<programlisting>
void (*set_mode) (struct ata_port *ap);
</programlisting>
<para>
By default libata performs drive and controller tuning in
accordance with the ATA timing rules and also applies blacklists
and cable limits. Some controllers need special handling and have
custom tuning rules, typically raid controllers that use ATA
commands but do not actually do drive timing.
</para>
<warning>
<para>
This hook should not be used to replace the standard controller
tuning logic when a controller has quirks. Replacing the default
tuning logic in that case would bypass handling for drive and
bridge quirks that may be important to data reliability. If a
controller needs to filter the mode selection it should use the
mode_filter hook instead.
</para>
</warning>
</sect2>
<sect2><title>Reset ATA bus</title> <sect2><title>Reset ATA bus</title>
<programlisting> <programlisting>
void (*phy_reset) (struct ata_port *ap); void (*phy_reset) (struct ata_port *ap);
......
...@@ -703,6 +703,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ...@@ -703,6 +703,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
struct ata_probe_ent *probe_ent = struct ata_probe_ent *probe_ent =
ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
int p = 0; int p = 0;
unsigned long bmdma;
if (!probe_ent) if (!probe_ent)
return NULL; return NULL;
...@@ -716,7 +717,12 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ...@@ -716,7 +717,12 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
probe_ent->port[p].altstatus_addr = probe_ent->port[p].altstatus_addr =
probe_ent->port[p].ctl_addr = probe_ent->port[p].ctl_addr =
pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4); bmdma = pci_resource_start(pdev, 4);
if (bmdma) {
if (inb(bmdma + 2) & 0x80)
probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
probe_ent->port[p].bmdma_addr = bmdma;
}
ata_std_ports(&probe_ent->port[p]); ata_std_ports(&probe_ent->port[p]);
p++; p++;
} }
...@@ -726,7 +732,13 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ...@@ -726,7 +732,13 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
probe_ent->port[p].altstatus_addr = probe_ent->port[p].altstatus_addr =
probe_ent->port[p].ctl_addr = probe_ent->port[p].ctl_addr =
pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS; pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4) + 8; bmdma = pci_resource_start(pdev, 4);
if (bmdma) {
bmdma += 8;
if(inb(bmdma + 2) & 0x80)
probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
probe_ent->port[p].bmdma_addr = bmdma;
}
ata_std_ports(&probe_ent->port[p]); ata_std_ports(&probe_ent->port[p]);
p++; p++;
} }
...@@ -740,6 +752,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, ...@@ -740,6 +752,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
struct ata_port_info *port, int port_num) struct ata_port_info *port, int port_num)
{ {
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
unsigned long bmdma;
probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
if (!probe_ent) if (!probe_ent)
...@@ -766,8 +779,13 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, ...@@ -766,8 +779,13 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
break; break;
} }
probe_ent->port[0].bmdma_addr = bmdma = pci_resource_start(pdev, 4);
pci_resource_start(pdev, 4) + 8 * port_num; if (bmdma != 0) {
bmdma += 8 * port_num;
probe_ent->port[0].bmdma_addr = bmdma;
if (inb(bmdma + 2) & 0x80)
probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
}
ata_std_ports(&probe_ent->port[0]); ata_std_ports(&probe_ent->port[0]);
return probe_ent; return probe_ent;
......
This diff is collapsed.
...@@ -1010,7 +1010,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc) ...@@ -1010,7 +1010,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff); pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff);
pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
pp->sg_tbl[i].flags_size = cpu_to_le32(len); pp->sg_tbl[i].flags_size = cpu_to_le32(len & 0xffff);
sg_len -= len; sg_len -= len;
addr += len; addr += len;
...@@ -1350,7 +1350,6 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1350,7 +1350,6 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
{ {
void __iomem *mmio = host_set->mmio_base; void __iomem *mmio = host_set->mmio_base;
void __iomem *hc_mmio = mv_hc_base(mmio, hc); void __iomem *hc_mmio = mv_hc_base(mmio, hc);
struct ata_port *ap;
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u32 hc_irq_cause; u32 hc_irq_cause;
int shift, port, port0, hard_port, handled; int shift, port, port0, hard_port, handled;
...@@ -1373,25 +1372,32 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1373,25 +1372,32 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) {
u8 ata_status = 0; u8 ata_status = 0;
ap = host_set->ports[port]; struct ata_port *ap = host_set->ports[port];
struct mv_port_priv *pp = ap->private_data;
hard_port = port & MV_PORT_MASK; /* range 0-3 */ hard_port = port & MV_PORT_MASK; /* range 0-3 */
handled = 0; /* ensure ata_status is set if handled++ */ handled = 0; /* ensure ata_status is set if handled++ */
if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) { /* Note that DEV_IRQ might happen spuriously during EDMA,
/* new CRPB on the queue; just one at a time until NCQ * and should be ignored in such cases. We could mask it,
* but it's pretty rare and may not be worth the overhead.
*/ */
if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
/* EDMA: check for response queue interrupt */
if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) {
ata_status = mv_get_crpb_status(ap); ata_status = mv_get_crpb_status(ap);
handled++; handled = 1;
} else if ((DEV_IRQ << hard_port) & hc_irq_cause) { }
/* received ATA IRQ; read the status reg to clear INTRQ } else {
*/ /* PIO: check for device (drive) interrupt */
if ((DEV_IRQ << hard_port) & hc_irq_cause) {
ata_status = readb((void __iomem *) ata_status = readb((void __iomem *)
ap->ioaddr.status_addr); ap->ioaddr.status_addr);
handled++; handled = 1;
}
} }
if (ap && if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))
(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))
continue; continue;
err_mask = ac_err_mask(ata_status); err_mask = ac_err_mask(ata_status);
...@@ -1403,12 +1409,12 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1403,12 +1409,12 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
if ((PORT0_ERR << shift) & relevant) { if ((PORT0_ERR << shift) & relevant) {
mv_err_intr(ap); mv_err_intr(ap);
err_mask |= AC_ERR_OTHER; err_mask |= AC_ERR_OTHER;
handled++; handled = 1;
} }
if (handled && ap) { if (handled) {
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
if (NULL != qc) { if (qc && (qc->flags & ATA_QCFLAG_ACTIVE)) {
VPRINTK("port %u IRQ found for qc, " VPRINTK("port %u IRQ found for qc, "
"ata_status 0x%x\n", port,ata_status); "ata_status 0x%x\n", port,ata_status);
/* mark qc status appropriately */ /* mark qc status appropriately */
......
...@@ -160,8 +160,10 @@ enum { ...@@ -160,8 +160,10 @@ enum {
ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */
/* host set flags */
ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */
/* various lengths of time */ /* various lengths of time */
ATA_TMOUT_EDD = 5 * HZ, /* heuristic */
ATA_TMOUT_PIO = 30 * HZ, ATA_TMOUT_PIO = 30 * HZ,
ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */
ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */
...@@ -279,6 +281,7 @@ struct ata_probe_ent { ...@@ -279,6 +281,7 @@ struct ata_probe_ent {
unsigned long irq; unsigned long irq;
unsigned int irq_flags; unsigned int irq_flags;
unsigned long host_flags; unsigned long host_flags;
unsigned long host_set_flags;
void __iomem *mmio_base; void __iomem *mmio_base;
void *private_data; void *private_data;
}; };
...@@ -291,6 +294,9 @@ struct ata_host_set { ...@@ -291,6 +294,9 @@ struct ata_host_set {
unsigned int n_ports; unsigned int n_ports;
void *private_data; void *private_data;
const struct ata_port_operations *ops; const struct ata_port_operations *ops;
unsigned long flags;
int simplex_claimed; /* Keep seperate in case we
ever need to do this locked */
struct ata_port * ports[0]; struct ata_port * ports[0];
}; };
...@@ -420,6 +426,7 @@ struct ata_port_operations { ...@@ -420,6 +426,7 @@ struct ata_port_operations {
void (*set_piomode) (struct ata_port *, struct ata_device *); void (*set_piomode) (struct ata_port *, struct ata_device *);
void (*set_dmamode) (struct ata_port *, struct ata_device *); void (*set_dmamode) (struct ata_port *, struct ata_device *);
unsigned long (*mode_filter) (const struct ata_port *, struct ata_device *, unsigned long);
void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf); void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
...@@ -430,6 +437,7 @@ struct ata_port_operations { ...@@ -430,6 +437,7 @@ struct ata_port_operations {
void (*dev_select)(struct ata_port *ap, unsigned int device); void (*dev_select)(struct ata_port *ap, unsigned int device);
void (*phy_reset) (struct ata_port *ap); /* obsolete */ void (*phy_reset) (struct ata_port *ap); /* obsolete */
void (*set_mode) (struct ata_port *ap);
int (*probe_reset) (struct ata_port *ap, unsigned int *classes); int (*probe_reset) (struct ata_port *ap, unsigned int *classes);
void (*post_set_mode) (struct ata_port *ap); void (*post_set_mode) (struct ata_port *ap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment