Commit 6e9d6b8e authored by Linus Torvalds's avatar Linus Torvalds

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

parents d3f8cf48 a9524a76
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -192,7 +193,6 @@ static void ahci_port_stop(struct ata_port *ap); ...@@ -192,7 +193,6 @@ static void ahci_port_stop(struct ata_port *ap);
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
static void ahci_qc_prep(struct ata_queued_cmd *qc); static void ahci_qc_prep(struct ata_queued_cmd *qc);
static u8 ahci_check_status(struct ata_port *ap); static u8 ahci_check_status(struct ata_port *ap);
static u8 ahci_check_err(struct ata_port *ap);
static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
static void ahci_remove_one (struct pci_dev *pdev); static void ahci_remove_one (struct pci_dev *pdev);
...@@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = { ...@@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = {
.check_status = ahci_check_status, .check_status = ahci_check_status,
.check_altstatus = ahci_check_status, .check_altstatus = ahci_check_status,
.check_err = ahci_check_err,
.dev_select = ata_noop_dev_select, .dev_select = ata_noop_dev_select,
.tf_read = ahci_tf_read, .tf_read = ahci_tf_read,
...@@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap) ...@@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap)
return readl(mmio + PORT_TFDATA) & 0xFF; return readl(mmio + PORT_TFDATA) & 0xFF;
} }
static u8 ahci_check_err(struct ata_port *ap)
{
void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF;
}
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
{ {
struct ahci_port_priv *pp = ap->private_data; struct ahci_port_priv *pp = ap->private_data;
...@@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap) ...@@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap)
* not being called from the SCSI EH. * not being called from the SCSI EH.
*/ */
qc->scsidone = scsi_finish_command; qc->scsidone = scsi_finish_command;
ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER);
} }
spin_unlock_irqrestore(&host_set->lock, flags); spin_unlock_irqrestore(&host_set->lock, flags);
...@@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) ...@@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
if (status & PORT_IRQ_FATAL) { if (status & PORT_IRQ_FATAL) {
ahci_intr_error(ap, status); ahci_intr_error(ap, status);
if (qc) if (qc)
ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER);
} }
return 1; return 1;
...@@ -683,10 +675,10 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * ...@@ -683,10 +675,10 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
if (!ahci_host_intr(ap, qc)) if (!ahci_host_intr(ap, qc))
if (ata_ratelimit()) { if (ata_ratelimit()) {
struct pci_dev *pdev = struct pci_dev *pdev =
to_pci_dev(ap->host_set->dev); to_pci_dev(ap->host_set->dev);
printk(KERN_WARNING dev_printk(KERN_WARNING, &pdev->dev,
"ahci(%s): unhandled interrupt on port %u\n", "unhandled interrupt on port %u\n",
pci_name(pdev), i); i);
} }
VPRINTK("port %u\n", i); VPRINTK("port %u\n", i);
...@@ -694,10 +686,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * ...@@ -694,10 +686,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
VPRINTK("port %u (no irq)\n", i); VPRINTK("port %u (no irq)\n", i);
if (ata_ratelimit()) { if (ata_ratelimit()) {
struct pci_dev *pdev = struct pci_dev *pdev =
to_pci_dev(ap->host_set->dev); to_pci_dev(ap->host_set->dev);
printk(KERN_WARNING dev_printk(KERN_WARNING, &pdev->dev,
"ahci(%s): interrupt on disabled port %u\n", "interrupt on disabled port %u\n", i);
pci_name(pdev), i);
} }
} }
...@@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) ...@@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
tmp = readl(mmio + HOST_CTL); tmp = readl(mmio + HOST_CTL);
if (tmp & HOST_RESET) { if (tmp & HOST_RESET) {
printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev), tmp); "controller reset failed (0x%x)\n", tmp);
return -EIO; return -EIO;
} }
...@@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) ...@@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
if (rc) { if (rc) {
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev)); "64-bit DMA enable failed\n");
return rc; return rc;
} }
} }
} else { } else {
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev)); "32-bit DMA enable failed\n");
return rc; return rc;
} }
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev)); "32-bit consistent DMA enable failed\n");
return rc; return rc;
} }
} }
...@@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) ...@@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
else else
scc_s = "unknown"; scc_s = "unknown";
printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x " dev_printk(KERN_INFO, &pdev->dev,
"AHCI %02x%02x.%02x%02x "
"%u slots %u ports %s Gbps 0x%x impl %s mode\n" "%u slots %u ports %s Gbps 0x%x impl %s mode\n"
, ,
pci_name(pdev),
(vers >> 24) & 0xff, (vers >> 24) & 0xff,
(vers >> 16) & 0xff, (vers >> 16) & 0xff,
...@@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) ...@@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
impl, impl,
scc_s); scc_s);
printk(KERN_INFO DRV_NAME "(%s) flags: " dev_printk(KERN_INFO, &pdev->dev,
"flags: "
"%s%s%s%s%s%s" "%s%s%s%s%s%s"
"%s%s%s%s%s%s%s\n" "%s%s%s%s%s%s%s\n"
, ,
pci_name(pdev),
cap & (1 << 31) ? "64bit " : "", cap & (1 << 31) ? "64bit " : "",
cap & (1 << 30) ? "ncq " : "", cap & (1 << 30) ? "ncq " : "",
...@@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
VPRINTK("ENTER\n"); VPRINTK("ENTER\n");
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int printed_version; static int printed_version;
struct ata_port_info *port_info[2]; struct ata_port_info *port_info[2];
unsigned int combined = 0, n_ports = 1; unsigned int combined = 0;
unsigned int pata_chan = 0, sata_chan = 0; unsigned int pata_chan = 0, sata_chan = 0;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
/* no hotplugging support (FIXME) */ /* no hotplugging support (FIXME) */
if (!in_module_init) if (!in_module_init)
return -ENODEV; return -ENODEV;
port_info[0] = &piix_port_info[ent->driver_data]; port_info[0] = &piix_port_info[ent->driver_data];
port_info[1] = NULL; port_info[1] = &piix_port_info[ent->driver_data];
if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
u8 tmp; u8 tmp;
...@@ -670,12 +672,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -670,12 +672,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
port_info[sata_chan] = &piix_port_info[ent->driver_data]; port_info[sata_chan] = &piix_port_info[ent->driver_data];
port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS; port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS;
port_info[pata_chan] = &piix_port_info[ich5_pata]; port_info[pata_chan] = &piix_port_info[ich5_pata];
n_ports++;
printk(KERN_WARNING DRV_NAME ": combined mode detected\n"); dev_printk(KERN_WARNING, &pdev->dev,
"combined mode detected (p=%u, s=%u)\n",
pata_chan, sata_chan);
} }
return ata_pci_init_one(pdev, port_info, n_ports); return ata_pci_init_one(pdev, port_info, 2);
} }
static int __init piix_init(void) static int __init piix_init(void)
......
...@@ -372,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) ...@@ -372,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf)
struct ata_ioports *ioaddr = &ap->ioaddr; struct ata_ioports *ioaddr = &ap->ioaddr;
tf->command = ata_check_status(ap); tf->command = ata_check_status(ap);
tf->feature = ata_chk_err(ap); tf->feature = inb(ioaddr->error_addr);
tf->nsect = inb(ioaddr->nsect_addr); tf->nsect = inb(ioaddr->nsect_addr);
tf->lbal = inb(ioaddr->lbal_addr); tf->lbal = inb(ioaddr->lbal_addr);
tf->lbam = inb(ioaddr->lbam_addr); tf->lbam = inb(ioaddr->lbam_addr);
...@@ -406,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) ...@@ -406,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf)
struct ata_ioports *ioaddr = &ap->ioaddr; struct ata_ioports *ioaddr = &ap->ioaddr;
tf->command = ata_check_status(ap); tf->command = ata_check_status(ap);
tf->feature = ata_chk_err(ap); tf->feature = readb((void __iomem *)ioaddr->error_addr);
tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); tf->nsect = readb((void __iomem *)ioaddr->nsect_addr);
tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); tf->lbal = readb((void __iomem *)ioaddr->lbal_addr);
tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); tf->lbam = readb((void __iomem *)ioaddr->lbam_addr);
...@@ -526,30 +526,6 @@ u8 ata_altstatus(struct ata_port *ap) ...@@ -526,30 +526,6 @@ u8 ata_altstatus(struct ata_port *ap)
} }
/**
* ata_chk_err - Read device error reg
* @ap: port where the device is
*
* Reads ATA taskfile error register for
* currently-selected device and return its value.
*
* Note: may NOT be used as the check_err() entry in
* ata_port_operations.
*
* LOCKING:
* Inherited from caller.
*/
u8 ata_chk_err(struct ata_port *ap)
{
if (ap->ops->check_err)
return ap->ops->check_err(ap);
if (ap->flags & ATA_FLAG_MMIO) {
return readb((void __iomem *) ap->ioaddr.error_addr);
}
return inb(ap->ioaddr.error_addr);
}
/** /**
* ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
* @tf: Taskfile to convert * @tf: Taskfile to convert
...@@ -902,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) ...@@ -902,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
memset(&tf, 0, sizeof(tf)); memset(&tf, 0, sizeof(tf));
err = ata_chk_err(ap);
ap->ops->tf_read(ap, &tf); ap->ops->tf_read(ap, &tf);
err = tf.feature;
dev->class = ATA_DEV_NONE; dev->class = ATA_DEV_NONE;
...@@ -1140,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1140,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
unsigned int major_version; unsigned int major_version;
u16 tmp; u16 tmp;
unsigned long xfer_modes; unsigned long xfer_modes;
u8 status;
unsigned int using_edd; unsigned int using_edd;
DECLARE_COMPLETION(wait); DECLARE_COMPLETION(wait);
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
...@@ -1194,8 +1169,11 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1194,8 +1169,11 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
else else
wait_for_completion(&wait); wait_for_completion(&wait);
status = ata_chk_status(ap); spin_lock_irqsave(&ap->host_set->lock, flags);
if (status & ATA_ERR) { ap->ops->tf_read(ap, &qc->tf);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (qc->tf.command & ATA_ERR) {
/* /*
* arg! EDD works for all test cases, but seems to return * arg! EDD works for all test cases, but seems to return
* the ATA signature for some ATAPI devices. Until the * the ATA signature for some ATAPI devices. Until the
...@@ -1208,7 +1186,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1208,7 +1186,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
* to have this problem. * to have this problem.
*/ */
if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) {
u8 err = ata_chk_err(ap); u8 err = qc->tf.feature;
if (err & ATA_ABORTED) { if (err & ATA_ABORTED) {
dev->class = ATA_DEV_ATAPI; dev->class = ATA_DEV_ATAPI;
qc->cursg = 0; qc->cursg = 0;
...@@ -2685,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) ...@@ -2685,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
* None. (grabs host lock) * None. (grabs host lock)
*/ */
void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
unsigned long flags; unsigned long flags;
...@@ -2693,7 +2671,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) ...@@ -2693,7 +2671,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
spin_lock_irqsave(&ap->host_set->lock, flags); spin_lock_irqsave(&ap->host_set->lock, flags);
ap->flags &= ~ATA_FLAG_NOINTR; ap->flags &= ~ATA_FLAG_NOINTR;
ata_irq_on(ap); ata_irq_on(ap);
ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, err_mask);
spin_unlock_irqrestore(&ap->host_set->lock, flags); spin_unlock_irqrestore(&ap->host_set->lock, flags);
} }
...@@ -2790,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap) ...@@ -2790,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap)
ap->hsm_task_state = HSM_ST_IDLE; ap->hsm_task_state = HSM_ST_IDLE;
ata_poll_qc_complete(qc, drv_stat); ata_poll_qc_complete(qc, 0);
/* another command may start at this point */ /* another command may start at this point */
...@@ -3158,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap) ...@@ -3158,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap)
static void ata_pio_error(struct ata_port *ap) static void ata_pio_error(struct ata_port *ap)
{ {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u8 drv_stat;
printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL); assert(qc != NULL);
drv_stat = ata_chk_status(ap);
printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n",
ap->id, drv_stat);
ap->hsm_task_state = HSM_ST_IDLE; ap->hsm_task_state = HSM_ST_IDLE;
ata_poll_qc_complete(qc, drv_stat | ATA_ERR); ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
} }
static void ata_pio_task(void *_data) static void ata_pio_task(void *_data)
...@@ -3292,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) ...@@ -3292,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
ap->id, qc->tf.command, drv_stat, host_stat); ap->id, qc->tf.command, drv_stat, host_stat);
/* complete taskfile transaction */ /* complete taskfile transaction */
ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, ac_err_mask(drv_stat));
break; break;
} }
...@@ -3397,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, ...@@ -3397,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
return qc; return qc;
} }
int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
{ {
return 0; return 0;
} }
...@@ -3456,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) ...@@ -3456,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
* spin_lock_irqsave(host_set lock) * spin_lock_irqsave(host_set lock)
*/ */
void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
{ {
int rc; int rc;
...@@ -3473,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) ...@@ -3473,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
qc->flags &= ~ATA_QCFLAG_ACTIVE; qc->flags &= ~ATA_QCFLAG_ACTIVE;
/* call completion callback */ /* call completion callback */
rc = qc->complete_fn(qc, drv_stat); rc = qc->complete_fn(qc, err_mask);
/* if callback indicates not to complete command (non-zero), /* if callback indicates not to complete command (non-zero),
* return immediately * return immediately
...@@ -3911,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap, ...@@ -3911,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
ap->ops->irq_clear(ap); ap->ops->irq_clear(ap);
/* complete taskfile transaction */ /* complete taskfile transaction */
ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status));
break; break;
default: default:
...@@ -4006,7 +3981,7 @@ static void atapi_packet_task(void *_data) ...@@ -4006,7 +3981,7 @@ static void atapi_packet_task(void *_data)
/* sleep-wait for BSY to clear */ /* sleep-wait for BSY to clear */
DPRINTK("busy wait\n"); DPRINTK("busy wait\n");
if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB))
goto err_out; goto err_out_status;
/* make sure DRQ is set */ /* make sure DRQ is set */
status = ata_chk_status(ap); status = ata_chk_status(ap);
...@@ -4043,8 +4018,10 @@ static void atapi_packet_task(void *_data) ...@@ -4043,8 +4018,10 @@ static void atapi_packet_task(void *_data)
return; return;
err_out_status:
status = ata_chk_status(ap);
err_out: err_out:
ata_poll_qc_complete(qc, ATA_ERR); ata_poll_qc_complete(qc, __ac_err_mask(status));
} }
...@@ -4550,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ...@@ -4550,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
return probe_ent; return probe_ent;
} }
static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num) static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num)
{ {
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
if (!probe_ent) if (!probe_ent)
return NULL; return NULL;
...@@ -4701,9 +4678,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, ...@@ -4701,9 +4678,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
if (legacy_mode) { if (legacy_mode) {
if (legacy_mode & (1 << 0)) if (legacy_mode & (1 << 0))
probe_ent = ata_pci_init_legacy_port(pdev, port, 0); probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0);
if (legacy_mode & (1 << 1)) if (legacy_mode & (1 << 1))
probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1);
} else { } else {
if (n_ports == 2) if (n_ports == 2)
probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
...@@ -4867,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis); ...@@ -4867,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis);
EXPORT_SYMBOL_GPL(ata_tf_from_fis); EXPORT_SYMBOL_GPL(ata_tf_from_fis);
EXPORT_SYMBOL_GPL(ata_check_status); EXPORT_SYMBOL_GPL(ata_check_status);
EXPORT_SYMBOL_GPL(ata_altstatus); EXPORT_SYMBOL_GPL(ata_altstatus);
EXPORT_SYMBOL_GPL(ata_chk_err);
EXPORT_SYMBOL_GPL(ata_exec_command); EXPORT_SYMBOL_GPL(ata_exec_command);
EXPORT_SYMBOL_GPL(ata_port_start); EXPORT_SYMBOL_GPL(ata_port_start);
EXPORT_SYMBOL_GPL(ata_port_stop); EXPORT_SYMBOL_GPL(ata_port_stop);
......
...@@ -560,7 +560,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) ...@@ -560,7 +560,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
* Use ata_to_sense_error() to map status register bits * Use ata_to_sense_error() to map status register bits
* onto sense key, asc & ascq. * onto sense key, asc & ascq.
*/ */
if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
ata_to_sense_error(qc->ap->id, tf->command, tf->feature, ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
&sb[1], &sb[2], &sb[3]); &sb[1], &sb[2], &sb[3]);
sb[1] &= 0x0f; sb[1] &= 0x0f;
...@@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) ...@@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
* Use ata_to_sense_error() to map status register bits * Use ata_to_sense_error() to map status register bits
* onto sense key, asc & ascq. * onto sense key, asc & ascq.
*/ */
if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
ata_to_sense_error(qc->ap->id, tf->command, tf->feature, ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
&sb[2], &sb[12], &sb[13]); &sb[2], &sb[12], &sb[13]);
sb[2] &= 0x0f; sb[2] &= 0x0f;
...@@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) ...@@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
sb[0] = 0x70; sb[0] = 0x70;
sb[7] = 0x0a; sb[7] = 0x0a;
if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { if (tf->flags & ATA_TFLAG_LBA48) {
/* TODO: find solution for LBA48 descriptors */
}
else if (tf->flags & ATA_TFLAG_LBA) {
/* A small (28b) LBA will fit in the 32b info field */ /* A small (28b) LBA will fit in the 32b info field */
sb[0] |= 0x80; /* set valid bit */ sb[0] |= 0x80; /* set valid bit */
sb[3] = tf->device & 0x0f; sb[3] = tf->device & 0x0f;
...@@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) ...@@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
sb[5] = tf->lbam; sb[5] = tf->lbam;
sb[6] = tf->lbal; sb[6] = tf->lbal;
} }
else {
/* TODO: C/H/S */
}
} }
/** /**
...@@ -1199,10 +1207,12 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm ...@@ -1199,10 +1207,12 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
return 1; return 1;
} }
static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) static int ata_scsi_qc_complete(struct ata_queued_cmd *qc,
unsigned int err_mask)
{ {
struct scsi_cmnd *cmd = qc->scsicmd; struct scsi_cmnd *cmd = qc->scsicmd;
int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); u8 *cdb = cmd->cmnd;
int need_sense = (err_mask != 0);
/* For ATA pass thru (SAT) commands, generate a sense block if /* For ATA pass thru (SAT) commands, generate a sense block if
* user mandated it or if there's an error. Note that if we * user mandated it or if there's an error. Note that if we
...@@ -1211,8 +1221,8 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) ...@@ -1211,8 +1221,8 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
* whether the command completed successfully or not. If there * whether the command completed successfully or not. If there
* was no error, SK, ASC and ASCQ will all be zero. * was no error, SK, ASC and ASCQ will all be zero.
*/ */
if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
((cmd->cmnd[2] & 0x20) || need_sense)) { ((cdb[2] & 0x20) || need_sense)) {
ata_gen_ata_desc_sense(qc); ata_gen_ata_desc_sense(qc);
} else { } else {
if (!need_sense) { if (!need_sense) {
...@@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, ...@@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
DPRINTK("EXIT\n"); DPRINTK("EXIT\n");
} }
static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
{ {
struct scsi_cmnd *cmd = qc->scsicmd; struct scsi_cmnd *cmd = qc->scsicmd;
VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ)))
/* FIXME: not quite right; we don't want the
* translation of taskfile registers into
* a sense descriptors, since that's only
* correct for ATA, not ATAPI
*/
ata_gen_ata_desc_sense(qc);
else if (unlikely(drv_stat & ATA_ERR)) { if (unlikely(err_mask & AC_ERR_DEV)) {
DPRINTK("request check condition\n"); DPRINTK("request check condition\n");
/* FIXME: command completion with check condition /* FIXME: command completion with check condition
...@@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) ...@@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
return 1; return 1;
} }
else if (unlikely(err_mask))
/* FIXME: not quite right; we don't want the
* translation of taskfile registers into
* a sense descriptors, since that's only
* correct for ATA, not ATAPI
*/
ata_gen_ata_desc_sense(qc);
else { else {
u8 *scsicmd = cmd->cmnd; u8 *scsicmd = cmd->cmnd;
......
...@@ -39,7 +39,7 @@ struct ata_scsi_args { ...@@ -39,7 +39,7 @@ struct ata_scsi_args {
/* libata-core.c */ /* libata-core.c */
extern int atapi_enabled; extern int atapi_enabled;
extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat); extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
struct ata_device *dev); struct ata_device *dev);
extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -451,7 +452,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) ...@@ -451,7 +452,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
struct adma_port_priv *pp; struct adma_port_priv *pp;
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
void __iomem *chan = ADMA_REGS(mmio_base, port_no); void __iomem *chan = ADMA_REGS(mmio_base, port_no);
u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); u8 status = readb(chan + ADMA_STATUS);
if (status == 0) if (status == 0)
continue; continue;
...@@ -464,11 +465,14 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) ...@@ -464,11 +465,14 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
continue; continue;
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
if (qc && (!(qc->tf.ctl & ATA_NIEN))) { if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
unsigned int err_mask = 0;
if ((status & (aPERR | aPSD | aUIRQ))) if ((status & (aPERR | aPSD | aUIRQ)))
drv_stat = ATA_ERR; err_mask = AC_ERR_OTHER;
else if (pp->pkt[0] != cDONE) else if (pp->pkt[0] != cDONE)
drv_stat = ATA_ERR; err_mask = AC_ERR_OTHER;
ata_qc_complete(qc, drv_stat);
ata_qc_complete(qc, err_mask);
} }
} }
return handled; return handled;
...@@ -498,7 +502,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) ...@@ -498,7 +502,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
/* complete taskfile transaction */ /* complete taskfile transaction */
pp->state = adma_state_idle; pp->state = adma_state_idle;
ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status));
handled = 1; handled = 1;
} }
} }
...@@ -623,16 +627,14 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) ...@@ -623,16 +627,14 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): 32-bit DMA enable failed\n", "32-bit DMA enable failed\n");
pci_name(pdev));
return rc; return rc;
} }
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): 32-bit consistent DMA enable failed\n", "32-bit consistent DMA enable failed\n");
pci_name(pdev));
return rc; return rc;
} }
return 0; return 0;
...@@ -648,7 +650,7 @@ static int adma_ata_init_one(struct pci_dev *pdev, ...@@ -648,7 +650,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
int rc, port_no; int rc, port_no;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -258,7 +259,6 @@ struct mv_host_priv { ...@@ -258,7 +259,6 @@ struct mv_host_priv {
static void mv_irq_clear(struct ata_port *ap); static void mv_irq_clear(struct ata_port *ap);
static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
static u8 mv_check_err(struct ata_port *ap);
static void mv_phy_reset(struct ata_port *ap); static void mv_phy_reset(struct ata_port *ap);
static void mv_host_stop(struct ata_host_set *host_set); static void mv_host_stop(struct ata_host_set *host_set);
static int mv_port_start(struct ata_port *ap); static int mv_port_start(struct ata_port *ap);
...@@ -296,7 +296,6 @@ static const struct ata_port_operations mv_ops = { ...@@ -296,7 +296,6 @@ static const struct ata_port_operations mv_ops = {
.tf_load = ata_tf_load, .tf_load = ata_tf_load,
.tf_read = ata_tf_read, .tf_read = ata_tf_read,
.check_status = ata_check_status, .check_status = ata_check_status,
.check_err = mv_check_err,
.exec_command = ata_exec_command, .exec_command = ata_exec_command,
.dev_select = ata_std_dev_select, .dev_select = ata_std_dev_select,
...@@ -1067,6 +1066,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1067,6 +1066,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
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;
unsigned int err_mask;
u8 ata_status = 0; u8 ata_status = 0;
if (hc == 0) { if (hc == 0) {
...@@ -1102,15 +1102,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1102,15 +1102,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
handled++; handled++;
} }
err_mask = ac_err_mask(ata_status);
shift = port << 1; /* (port * 2) */ shift = port << 1; /* (port * 2) */
if (port >= MV_PORTS_PER_HC) { if (port >= MV_PORTS_PER_HC) {
shift++; /* skip bit 8 in the HC Main IRQ reg */ shift++; /* skip bit 8 in the HC Main IRQ reg */
} }
if ((PORT0_ERR << shift) & relevant) { if ((PORT0_ERR << shift) & relevant) {
mv_err_intr(ap); mv_err_intr(ap);
/* OR in ATA_ERR to ensure libata knows we took one */ err_mask |= AC_ERR_OTHER;
ata_status = readb((void __iomem *)
ap->ioaddr.status_addr) | ATA_ERR;
handled++; handled++;
} }
...@@ -1120,7 +1120,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, ...@@ -1120,7 +1120,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
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 */
ata_qc_complete(qc, ata_status); ata_qc_complete(qc, err_mask);
} }
} }
} }
...@@ -1184,22 +1184,6 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance, ...@@ -1184,22 +1184,6 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
/**
* mv_check_err - Return the error shadow register to caller.
* @ap: ATA channel to manipulate
*
* Marvell requires DMA to be stopped before accessing shadow
* registers. So we do that, then return the needed register.
*
* LOCKING:
* Inherited from caller. FIXME: protect mv_stop_dma with lock?
*/
static u8 mv_check_err(struct ata_port *ap)
{
mv_stop_dma(ap); /* can't read shadow regs if DMA on */
return readb((void __iomem *) ap->ioaddr.error_addr);
}
/** /**
* mv_phy_reset - Perform eDMA reset followed by COMRESET * mv_phy_reset - Perform eDMA reset followed by COMRESET
* @ap: ATA channel to manipulate * @ap: ATA channel to manipulate
...@@ -1312,7 +1296,7 @@ static void mv_eng_timeout(struct ata_port *ap) ...@@ -1312,7 +1296,7 @@ static void mv_eng_timeout(struct ata_port *ap)
*/ */
spin_lock_irqsave(&ap->host_set->lock, flags); spin_lock_irqsave(&ap->host_set->lock, flags);
qc->scsidone = scsi_finish_command; qc->scsidone = scsi_finish_command;
ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER);
spin_unlock_irqrestore(&ap->host_set->lock, flags); spin_unlock_irqrestore(&ap->host_set->lock, flags);
} }
} }
...@@ -1454,9 +1438,9 @@ static void mv_print_info(struct ata_probe_ent *probe_ent) ...@@ -1454,9 +1438,9 @@ static void mv_print_info(struct ata_probe_ent *probe_ent)
else else
scc_s = "unknown"; scc_s = "unknown";
printk(KERN_INFO DRV_NAME dev_printk(KERN_INFO, &pdev->dev,
"(%s) %u slots %u ports %s mode IRQ via %s\n", "%u slots %u ports %s mode IRQ via %s\n",
pci_name(pdev), (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports,
scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
} }
...@@ -1477,9 +1461,8 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1477,9 +1461,8 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
void __iomem *mmio_base; void __iomem *mmio_base;
int pci_dev_busy = 0, rc; int pci_dev_busy = 0, rc;
if (!printed_version++) { if (!printed_version++)
printk(KERN_INFO DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
}
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) { if (rc) {
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -383,7 +384,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -383,7 +384,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENODEV; return -ENODEV;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -399,7 +400,8 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -399,7 +400,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
case ATA_PROT_DMA: case ATA_PROT_DMA:
case ATA_PROT_NODATA: case ATA_PROT_NODATA:
printk(KERN_ERR "ata%u: command timeout\n", ap->id); printk(KERN_ERR "ata%u: command timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); drv_stat = ata_wait_idle(ap);
ata_qc_complete(qc, __ac_err_mask(drv_stat));
break; break;
default: default:
...@@ -408,7 +410,7 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -408,7 +410,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
ap->id, qc->tf.command, drv_stat); ap->id, qc->tf.command, drv_stat);
ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, ac_err_mask(drv_stat));
break; break;
} }
...@@ -420,24 +422,21 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -420,24 +422,21 @@ static void pdc_eng_timeout(struct ata_port *ap)
static inline unsigned int pdc_host_intr( struct ata_port *ap, static inline unsigned int pdc_host_intr( struct ata_port *ap,
struct ata_queued_cmd *qc) struct ata_queued_cmd *qc)
{ {
u8 status; unsigned int handled = 0, err_mask = 0;
unsigned int handled = 0, have_err = 0;
u32 tmp; u32 tmp;
void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
tmp = readl(mmio); tmp = readl(mmio);
if (tmp & PDC_ERR_MASK) { if (tmp & PDC_ERR_MASK) {
have_err = 1; err_mask = AC_ERR_DEV;
pdc_reset_port(ap); pdc_reset_port(ap);
} }
switch (qc->tf.protocol) { switch (qc->tf.protocol) {
case ATA_PROT_DMA: case ATA_PROT_DMA:
case ATA_PROT_NODATA: case ATA_PROT_NODATA:
status = ata_wait_idle(ap); err_mask |= ac_err_mask(ata_wait_idle(ap));
if (have_err) ata_qc_complete(qc, err_mask);
status |= ATA_ERR;
ata_qc_complete(qc, status);
handled = 1; handled = 1;
break; break;
...@@ -635,7 +634,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -635,7 +634,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
int rc; int rc;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
/* /*
* If this driver happens to only be useful on Apple's K2, then * If this driver happens to only be useful on Apple's K2, then
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -400,11 +401,12 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) ...@@ -400,11 +401,12 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
if (qc && (!(qc->tf.ctl & ATA_NIEN))) { if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
switch (sHST) { switch (sHST) {
case 0: /* sucessful CPB */ case 0: /* successful CPB */
case 3: /* device error */ case 3: /* device error */
pp->state = qs_state_idle; pp->state = qs_state_idle;
qs_enter_reg_mode(qc->ap); qs_enter_reg_mode(qc->ap);
ata_qc_complete(qc, sDST); ata_qc_complete(qc,
ac_err_mask(sDST));
break; break;
default: default:
break; break;
...@@ -441,7 +443,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) ...@@ -441,7 +443,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
/* complete taskfile transaction */ /* complete taskfile transaction */
pp->state = qs_state_idle; pp->state = qs_state_idle;
ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status));
handled = 1; handled = 1;
} }
} }
...@@ -599,25 +601,22 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) ...@@ -599,25 +601,22 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
if (rc) { if (rc) {
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): 64-bit DMA enable failed\n", "64-bit DMA enable failed\n");
pci_name(pdev));
return rc; return rc;
} }
} }
} else { } else {
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): 32-bit DMA enable failed\n", "32-bit DMA enable failed\n");
pci_name(pdev));
return rc; return rc;
} }
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): 32-bit consistent DMA enable failed\n", "32-bit consistent DMA enable failed\n");
pci_name(pdev));
return rc; return rc;
} }
} }
...@@ -634,7 +633,7 @@ static int qs_ata_init_one(struct pci_dev *pdev, ...@@ -634,7 +633,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
int rc, port_no; int rc, port_no;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -386,7 +387,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -386,7 +387,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
u8 cls; u8 cls;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
/* /*
* If this driver happens to only be useful on Apple's K2, then * If this driver happens to only be useful on Apple's K2, then
...@@ -463,8 +464,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -463,8 +464,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
writeb(cls, mmio_base + SIL_FIFO_W3); writeb(cls, mmio_base + SIL_FIFO_W3);
} }
} else } else
printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n", dev_printk(KERN_WARNING, &pdev->dev,
pci_name(pdev)); "cache line size not set. Driver may not function\n");
if (ent->driver_data == sil_3114) { if (ent->driver_data == sil_3114) {
irq_mask = SIL_MASK_4PORT; irq_mask = SIL_MASK_4PORT;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/device.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include "scsi.h" #include "scsi.h"
#include <linux/libata.h> #include <linux/libata.h>
...@@ -225,7 +226,6 @@ struct sil24_host_priv { ...@@ -225,7 +226,6 @@ struct sil24_host_priv {
}; };
static u8 sil24_check_status(struct ata_port *ap); static u8 sil24_check_status(struct ata_port *ap);
static u8 sil24_check_err(struct ata_port *ap);
static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val);
static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
...@@ -280,7 +280,6 @@ static const struct ata_port_operations sil24_ops = { ...@@ -280,7 +280,6 @@ static const struct ata_port_operations sil24_ops = {
.check_status = sil24_check_status, .check_status = sil24_check_status,
.check_altstatus = sil24_check_status, .check_altstatus = sil24_check_status,
.check_err = sil24_check_err,
.dev_select = ata_noop_dev_select, .dev_select = ata_noop_dev_select,
.tf_read = sil24_tf_read, .tf_read = sil24_tf_read,
...@@ -363,12 +362,6 @@ static u8 sil24_check_status(struct ata_port *ap) ...@@ -363,12 +362,6 @@ static u8 sil24_check_status(struct ata_port *ap)
return pp->tf.command; return pp->tf.command;
} }
static u8 sil24_check_err(struct ata_port *ap)
{
struct sil24_port_priv *pp = ap->private_data;
return pp->tf.feature;
}
static int sil24_scr_map[] = { static int sil24_scr_map[] = {
[SCR_CONTROL] = 0, [SCR_CONTROL] = 0,
[SCR_STATUS] = 1, [SCR_STATUS] = 1,
...@@ -506,7 +499,7 @@ static void sil24_eng_timeout(struct ata_port *ap) ...@@ -506,7 +499,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
if (!qc) { if (!qc) {
printk(KERN_ERR "ata%u: BUG: tiemout without command\n", printk(KERN_ERR "ata%u: BUG: timeout without command\n",
ap->id); ap->id);
return; return;
} }
...@@ -520,7 +513,7 @@ static void sil24_eng_timeout(struct ata_port *ap) ...@@ -520,7 +513,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
*/ */
printk(KERN_ERR "ata%u: command timeout\n", ap->id); printk(KERN_ERR "ata%u: command timeout\n", ap->id);
qc->scsidone = scsi_finish_command; qc->scsidone = scsi_finish_command;
ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER);
sil24_reset_controller(ap); sil24_reset_controller(ap);
} }
...@@ -531,6 +524,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) ...@@ -531,6 +524,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
struct sil24_port_priv *pp = ap->private_data; struct sil24_port_priv *pp = ap->private_data;
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
u32 irq_stat, cmd_err, sstatus, serror; u32 irq_stat, cmd_err, sstatus, serror;
unsigned int err_mask;
irq_stat = readl(port + PORT_IRQ_STAT); irq_stat = readl(port + PORT_IRQ_STAT);
writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */
...@@ -558,17 +552,18 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) ...@@ -558,17 +552,18 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
* Device is reporting error, tf registers are valid. * Device is reporting error, tf registers are valid.
*/ */
sil24_update_tf(ap); sil24_update_tf(ap);
err_mask = ac_err_mask(pp->tf.command);
} else { } else {
/* /*
* Other errors. libata currently doesn't have any * Other errors. libata currently doesn't have any
* mechanism to report these errors. Just turn on * mechanism to report these errors. Just turn on
* ATA_ERR. * ATA_ERR.
*/ */
pp->tf.command = ATA_ERR; err_mask = AC_ERR_OTHER;
} }
if (qc) if (qc)
ata_qc_complete(qc, pp->tf.command); ata_qc_complete(qc, err_mask);
sil24_reset_controller(ap); sil24_reset_controller(ap);
} }
...@@ -593,7 +588,7 @@ static inline void sil24_host_intr(struct ata_port *ap) ...@@ -593,7 +588,7 @@ static inline void sil24_host_intr(struct ata_port *ap)
sil24_update_tf(ap); sil24_update_tf(ap);
if (qc) if (qc)
ata_qc_complete(qc, pp->tf.command); ata_qc_complete(qc, ac_err_mask(pp->tf.command));
} else } else
sil24_error_intr(ap, slot_stat); sil24_error_intr(ap, slot_stat);
} }
...@@ -696,7 +691,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -696,7 +691,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
int i, rc; int i, rc;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
...@@ -756,14 +751,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -756,14 +751,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
*/ */
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev)); "32-bit DMA enable failed\n");
goto out_free; goto out_free;
} }
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) { if (rc) {
printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev)); "32-bit consistent DMA enable failed\n");
goto out_free; goto out_free;
} }
...@@ -799,9 +794,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -799,9 +794,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
break; break;
} }
if (tmp & PORT_CS_PORT_RST) if (tmp & PORT_CS_PORT_RST)
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): failed to clear port RST\n", "failed to clear port RST\n");
pci_name(pdev));
} }
/* Zero error counters. */ /* Zero error counters. */
...@@ -830,9 +824,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -830,9 +824,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* Reset itself */ /* Reset itself */
if (__sil24_reset_controller(port)) if (__sil24_reset_controller(port))
printk(KERN_ERR DRV_NAME dev_printk(KERN_ERR, &pdev->dev,
"(%s): failed to reset controller\n", "failed to reset controller\n");
pci_name(pdev));
} }
/* Turn on interrupts */ /* Turn on interrupts */
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -237,6 +238,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) ...@@ -237,6 +238,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int printed_version;
struct ata_probe_ent *probe_ent = NULL; struct ata_probe_ent *probe_ent = NULL;
int rc; int rc;
u32 genctl; u32 genctl;
...@@ -245,6 +247,9 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -245,6 +247,9 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
u8 pmr; u8 pmr;
u8 port2_start; u8 port2_start;
if (!printed_version++)
dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
return rc; return rc;
...@@ -288,16 +293,18 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -288,16 +293,18 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
pci_read_config_byte(pdev, SIS_PMR, &pmr); pci_read_config_byte(pdev, SIS_PMR, &pmr);
if (ent->device != 0x182) { if (ent->device != 0x182) {
if ((pmr & SIS_PMR_COMBINED) == 0) { if ((pmr & SIS_PMR_COMBINED) == 0) {
printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in SATA mode\n"); dev_printk(KERN_INFO, &pdev->dev,
"Detected SiS 180/181 chipset in SATA mode\n");
port2_start = 64; port2_start = 64;
} }
else { else {
printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in combined mode\n"); dev_printk(KERN_INFO, &pdev->dev,
"Detected SiS 180/181 chipset in combined mode\n");
port2_start=0; port2_start=0;
} }
} }
else { else {
printk(KERN_INFO "sata_sis: Detected SiS 182 chipset\n"); dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182 chipset\n");
port2_start = 0x20; port2_start = 0x20;
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -362,7 +363,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -362,7 +363,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
int i; int i;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
/* /*
* If this driver happens to only be useful on Apple's K2, then * If this driver happens to only be useful on Apple's K2, then
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -718,7 +719,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -718,7 +719,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
/* get drive status; clear intr; complete txn */ /* get drive status; clear intr; complete txn */
ata_qc_complete(qc, ata_wait_idle(ap)); ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
pdc20621_pop_hdma(qc); pdc20621_pop_hdma(qc);
} }
...@@ -756,7 +757,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -756,7 +757,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
/* get drive status; clear intr; complete txn */ /* get drive status; clear intr; complete txn */
ata_qc_complete(qc, ata_wait_idle(ap)); ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
pdc20621_pop_hdma(qc); pdc20621_pop_hdma(qc);
} }
handled = 1; handled = 1;
...@@ -766,7 +767,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -766,7 +767,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status));
handled = 1; handled = 1;
} else { } else {
...@@ -881,7 +882,7 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -881,7 +882,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
case ATA_PROT_DMA: case ATA_PROT_DMA:
case ATA_PROT_NODATA: case ATA_PROT_NODATA:
printk(KERN_ERR "ata%u: command timeout\n", ap->id); printk(KERN_ERR "ata%u: command timeout\n", ap->id);
ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap)));
break; break;
default: default:
...@@ -890,7 +891,7 @@ static void pdc_eng_timeout(struct ata_port *ap) ...@@ -890,7 +891,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
ap->id, qc->tf.command, drv_stat); ap->id, qc->tf.command, drv_stat);
ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, ac_err_mask(drv_stat));
break; break;
} }
...@@ -1385,7 +1386,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * ...@@ -1385,7 +1386,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
int rc; int rc;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
/* /*
* If this driver happens to only be useful on Apple's K2, then * If this driver happens to only be useful on Apple's K2, then
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -178,12 +179,16 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) ...@@ -178,12 +179,16 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int printed_version;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
struct ata_port_info *ppi; struct ata_port_info *ppi;
int rc; int rc;
unsigned int board_idx = (unsigned int) ent->driver_data; unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0; int pci_dev_busy = 0;
if (!printed_version++)
dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
return rc; return rc;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -259,15 +260,15 @@ static void svia_configure(struct pci_dev *pdev) ...@@ -259,15 +260,15 @@ static void svia_configure(struct pci_dev *pdev)
u8 tmp8; u8 tmp8;
pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8);
printk(KERN_INFO DRV_NAME "(%s): routed to hard irq line %d\n", dev_printk(KERN_INFO, &pdev->dev, "routed to hard irq line %d\n",
pci_name(pdev),
(int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f);
/* make sure SATA channels are enabled */ /* make sure SATA channels are enabled */
pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8);
if ((tmp8 & ALL_PORTS) != ALL_PORTS) { if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channels (0x%x)\n", dev_printk(KERN_DEBUG, &pdev->dev,
pci_name(pdev), (int) tmp8); "enabling SATA channels (0x%x)\n",
(int) tmp8);
tmp8 |= ALL_PORTS; tmp8 |= ALL_PORTS;
pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8);
} }
...@@ -275,8 +276,9 @@ static void svia_configure(struct pci_dev *pdev) ...@@ -275,8 +276,9 @@ static void svia_configure(struct pci_dev *pdev)
/* make sure interrupts for each channel sent to us */ /* make sure interrupts for each channel sent to us */
pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8);
if ((tmp8 & ALL_PORTS) != ALL_PORTS) { if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel interrupts (0x%x)\n", dev_printk(KERN_DEBUG, &pdev->dev,
pci_name(pdev), (int) tmp8); "enabling SATA channel interrupts (0x%x)\n",
(int) tmp8);
tmp8 |= ALL_PORTS; tmp8 |= ALL_PORTS;
pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); pci_write_config_byte(pdev, SATA_INT_GATE, tmp8);
} }
...@@ -284,8 +286,9 @@ static void svia_configure(struct pci_dev *pdev) ...@@ -284,8 +286,9 @@ static void svia_configure(struct pci_dev *pdev)
/* make sure native mode is enabled */ /* make sure native mode is enabled */
pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8);
if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) {
printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel native mode (0x%x)\n", dev_printk(KERN_DEBUG, &pdev->dev,
pci_name(pdev), (int) tmp8); "enabling SATA channel native mode (0x%x)\n",
(int) tmp8);
tmp8 |= NATIVE_MODE_ALL; tmp8 |= NATIVE_MODE_ALL;
pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8);
} }
...@@ -303,7 +306,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -303,7 +306,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
u8 tmp8; u8 tmp8;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
...@@ -318,8 +321,9 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -318,8 +321,9 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if (board_id == vt6420) { if (board_id == vt6420) {
pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8);
if (tmp8 & SATA_2DEV) { if (tmp8 & SATA_2DEV) {
printk(KERN_ERR DRV_NAME "(%s): SATA master/slave not supported (0x%x)\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev), (int) tmp8); "SATA master/slave not supported (0x%x)\n",
(int) tmp8);
rc = -EIO; rc = -EIO;
goto err_out_regions; goto err_out_regions;
} }
...@@ -332,10 +336,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -332,10 +336,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++)
if ((pci_resource_start(pdev, i) == 0) || if ((pci_resource_start(pdev, i) == 0) ||
(pci_resource_len(pdev, i) < bar_sizes[i])) { (pci_resource_len(pdev, i) < bar_sizes[i])) {
printk(KERN_ERR DRV_NAME "(%s): invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", dev_printk(KERN_ERR, &pdev->dev,
pci_name(pdev), i, "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n",
pci_resource_start(pdev, i), i,
pci_resource_len(pdev, i)); pci_resource_start(pdev, i),
pci_resource_len(pdev, i));
rc = -ENODEV; rc = -ENODEV;
goto err_out_regions; goto err_out_regions;
} }
...@@ -353,8 +358,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -353,8 +358,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent = vt6421_init_probe_ent(pdev); probe_ent = vt6421_init_probe_ent(pdev);
if (!probe_ent) { if (!probe_ent) {
printk(KERN_ERR DRV_NAME "(%s): out of memory\n", dev_printk(KERN_ERR, &pdev->dev, "out of memory\n");
pci_name(pdev));
rc = -ENOMEM; rc = -ENOMEM;
goto err_out_regions; goto err_out_regions;
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/device.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <linux/libata.h> #include <linux/libata.h>
...@@ -295,7 +296,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d ...@@ -295,7 +296,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
int rc; int rc;
if (!printed_version++) if (!printed_version++)
printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
rc = pci_enable_device(pdev); rc = pci_enable_device(pdev);
if (rc) if (rc)
......
...@@ -172,6 +172,13 @@ enum hsm_task_states { ...@@ -172,6 +172,13 @@ enum hsm_task_states {
HSM_ST_ERR, HSM_ST_ERR,
}; };
enum ata_completion_errors {
AC_ERR_OTHER = (1 << 0),
AC_ERR_DEV = (1 << 1),
AC_ERR_ATA_BUS = (1 << 2),
AC_ERR_HOST_BUS = (1 << 3),
};
/* forward declarations */ /* forward declarations */
struct scsi_device; struct scsi_device;
struct ata_port_operations; struct ata_port_operations;
...@@ -179,7 +186,7 @@ struct ata_port; ...@@ -179,7 +186,7 @@ struct ata_port;
struct ata_queued_cmd; struct ata_queued_cmd;
/* typedefs */ /* typedefs */
typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat); typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, unsigned int err_mask);
struct ata_ioports { struct ata_ioports {
unsigned long cmd_addr; unsigned long cmd_addr;
...@@ -347,7 +354,6 @@ struct ata_port_operations { ...@@ -347,7 +354,6 @@ struct ata_port_operations {
void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf); void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf);
u8 (*check_status)(struct ata_port *ap); u8 (*check_status)(struct ata_port *ap);
u8 (*check_altstatus)(struct ata_port *ap); u8 (*check_altstatus)(struct ata_port *ap);
u8 (*check_err)(struct ata_port *ap);
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); void (*phy_reset) (struct ata_port *ap);
...@@ -434,7 +440,6 @@ extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); ...@@ -434,7 +440,6 @@ extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
extern u8 ata_check_status(struct ata_port *ap); extern u8 ata_check_status(struct ata_port *ap);
extern u8 ata_altstatus(struct ata_port *ap); extern u8 ata_altstatus(struct ata_port *ap);
extern u8 ata_chk_err(struct ata_port *ap);
extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
extern int ata_port_start (struct ata_port *ap); extern int ata_port_start (struct ata_port *ap);
extern void ata_port_stop (struct ata_port *ap); extern void ata_port_stop (struct ata_port *ap);
...@@ -455,7 +460,7 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); ...@@ -455,7 +460,7 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc);
extern void ata_bmdma_stop(struct ata_queued_cmd *qc); extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
extern u8 ata_bmdma_status(struct ata_port *ap); extern u8 ata_bmdma_status(struct ata_port *ap);
extern void ata_bmdma_irq_clear(struct ata_port *ap); extern void ata_bmdma_irq_clear(struct ata_port *ap);
extern void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat); extern void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask);
extern void ata_eng_timeout(struct ata_port *ap); extern void ata_eng_timeout(struct ata_port *ap);
extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd, extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd,
void (*done)(struct scsi_cmnd *)); void (*done)(struct scsi_cmnd *));
...@@ -718,4 +723,21 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) ...@@ -718,4 +723,21 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
ata_id_has_flush_ext(dev->id); ata_id_has_flush_ext(dev->id);
} }
static inline unsigned int ac_err_mask(u8 status)
{
if (status & ATA_BUSY)
return AC_ERR_ATA_BUS;
if (status & (ATA_ERR | ATA_DF))
return AC_ERR_DEV;
return 0;
}
static inline unsigned int __ac_err_mask(u8 status)
{
unsigned int mask = ac_err_mask(status);
if (mask == 0)
return AC_ERR_OTHER;
return mask;
}
#endif /* __LINUX_LIBATA_H__ */ #endif /* __LINUX_LIBATA_H__ */
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