Loading drivers/scsi/ahci.c +23 −32 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/dma-mapping.h> #include <linux/device.h> #include "scsi.h" #include <scsi/scsi_host.h> #include <linux/libata.h> Loading Loading @@ -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_qc_prep(struct ata_queued_cmd *qc); 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 void ahci_remove_one (struct pci_dev *pdev); Loading Loading @@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = { .check_status = ahci_check_status, .check_altstatus = ahci_check_status, .check_err = ahci_check_err, .dev_select = ata_noop_dev_select, .tf_read = ahci_tf_read, Loading Loading @@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap) 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) { struct ahci_port_priv *pp = ap->private_data; Loading Loading @@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap) * not being called from the SCSI EH. */ 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); Loading Loading @@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) if (status & PORT_IRQ_FATAL) { ahci_intr_error(ap, status); if (qc) ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER); } return 1; Loading Loading @@ -684,9 +676,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * if (ata_ratelimit()) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); printk(KERN_WARNING "ahci(%s): unhandled interrupt on port %u\n", pci_name(pdev), i); dev_printk(KERN_WARNING, &pdev->dev, "unhandled interrupt on port %u\n", i); } VPRINTK("port %u\n", i); Loading @@ -695,9 +687,8 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * if (ata_ratelimit()) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); printk(KERN_WARNING "ahci(%s): interrupt on disabled port %u\n", pci_name(pdev), i); dev_printk(KERN_WARNING, &pdev->dev, "interrupt on disabled port %u\n", i); } } Loading Loading @@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) tmp = readl(mmio + HOST_CTL); if (tmp & HOST_RESET) { printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", pci_name(pdev), tmp); dev_printk(KERN_ERR, &pdev->dev, "controller reset failed (0x%x)\n", tmp); return -EIO; } Loading Loading @@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) if (rc) { rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "64-bit DMA enable failed\n"); return rc; } } } else { rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "32-bit DMA enable failed\n"); return rc; } rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "32-bit consistent DMA enable failed\n"); return rc; } } Loading Loading @@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) else 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" , pci_name(pdev), (vers >> 24) & 0xff, (vers >> 16) & 0xff, Loading @@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) impl, 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\n" , pci_name(pdev), cap & (1 << 31) ? "64bit " : "", cap & (1 << 30) ? "ncq " : "", Loading Loading @@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) VPRINTK("ENTER\n"); 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); if (rc) Loading drivers/scsi/ata_piix.c +9 −6 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <linux/init.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/device.h> #include "scsi.h" #include <scsi/scsi_host.h> #include <linux/libata.h> Loading Loading @@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; 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; 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) */ if (!in_module_init) return -ENODEV; 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) { u8 tmp; Loading Loading @@ -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]->host_flags |= ATA_FLAG_SLAVE_POSS; 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) Loading drivers/scsi/libata-core.c +28 −52 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) struct ata_ioports *ioaddr = &ap->ioaddr; 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->lbal = inb(ioaddr->lbal_addr); tf->lbam = inb(ioaddr->lbam_addr); Loading Loading @@ -406,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) struct ata_ioports *ioaddr = &ap->ioaddr; 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->lbal = readb((void __iomem *)ioaddr->lbal_addr); tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); Loading Loading @@ -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 * @tf: Taskfile to convert Loading Loading @@ -902,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) memset(&tf, 0, sizeof(tf)); err = ata_chk_err(ap); ap->ops->tf_read(ap, &tf); err = tf.feature; dev->class = ATA_DEV_NONE; Loading Loading @@ -1140,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) unsigned int major_version; u16 tmp; unsigned long xfer_modes; u8 status; unsigned int using_edd; DECLARE_COMPLETION(wait); struct ata_queued_cmd *qc; Loading Loading @@ -1194,8 +1169,11 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) else wait_for_completion(&wait); status = ata_chk_status(ap); if (status & ATA_ERR) { spin_lock_irqsave(&ap->host_set->lock, flags); 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 * the ATA signature for some ATAPI devices. Until the Loading @@ -1208,7 +1186,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) * to have this problem. */ 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) { dev->class = ATA_DEV_ATAPI; qc->cursg = 0; Loading Loading @@ -2685,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) * 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; unsigned long flags; Loading @@ -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); ap->flags &= ~ATA_FLAG_NOINTR; ata_irq_on(ap); ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, err_mask); spin_unlock_irqrestore(&ap->host_set->lock, flags); } Loading Loading @@ -2790,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap) 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 */ Loading Loading @@ -3158,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap) static void ata_pio_error(struct ata_port *ap) { 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); 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; 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) Loading Loading @@ -3292,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) ap->id, qc->tf.command, drv_stat, host_stat); /* complete taskfile transaction */ ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, ac_err_mask(drv_stat)); break; } Loading Loading @@ -3397,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 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; } Loading Loading @@ -3456,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) * 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; Loading @@ -3473,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) qc->flags &= ~ATA_QCFLAG_ACTIVE; /* 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), * return immediately Loading Loading @@ -3911,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap, ap->ops->irq_clear(ap); /* complete taskfile transaction */ ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status)); break; default: Loading Loading @@ -4006,7 +3981,7 @@ static void atapi_packet_task(void *_data) /* sleep-wait for BSY to clear */ DPRINTK("busy wait\n"); if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) goto err_out; goto err_out_status; /* make sure DRQ is set */ status = ata_chk_status(ap); Loading Loading @@ -4043,8 +4018,10 @@ static void atapi_packet_task(void *_data) return; err_out_status: status = ata_chk_status(ap); err_out: ata_poll_qc_complete(qc, ATA_ERR); ata_poll_qc_complete(qc, __ac_err_mask(status)); } Loading Loading @@ -4550,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int 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; 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) return NULL; Loading Loading @@ -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 & (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)) probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1); } else { if (n_ports == 2) probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); Loading Loading @@ -4867,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis); EXPORT_SYMBOL_GPL(ata_tf_from_fis); EXPORT_SYMBOL_GPL(ata_check_status); EXPORT_SYMBOL_GPL(ata_altstatus); EXPORT_SYMBOL_GPL(ata_chk_err); EXPORT_SYMBOL_GPL(ata_exec_command); EXPORT_SYMBOL_GPL(ata_port_start); EXPORT_SYMBOL_GPL(ata_port_stop); Loading drivers/scsi/libata-scsi.c +28 −18 Original line number Diff line number Diff line Loading @@ -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 * 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, &sb[1], &sb[2], &sb[3]); sb[1] &= 0x0f; Loading Loading @@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) * Use ata_to_sense_error() to map status register bits * 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, &sb[2], &sb[12], &sb[13]); sb[2] &= 0x0f; Loading @@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) sb[0] = 0x70; 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 */ sb[0] |= 0x80; /* set valid bit */ sb[3] = tf->device & 0x0f; Loading @@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) sb[5] = tf->lbam; sb[6] = tf->lbal; } else { /* TODO: C/H/S */ } } /** Loading Loading @@ -1199,10 +1207,12 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm 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; 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 * user mandated it or if there's an error. Note that if we Loading @@ -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 * was no error, SK, ASC and ASCQ will all be zero. */ if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && ((cmd->cmnd[2] & 0x20) || need_sense)) { if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && ((cdb[2] & 0x20) || need_sense)) { ata_gen_ata_desc_sense(qc); } else { if (!need_sense) { Loading Loading @@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, 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; VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); 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); VPRINTK("ENTER, err_mask 0x%X\n", err_mask); else if (unlikely(drv_stat & ATA_ERR)) { if (unlikely(err_mask & AC_ERR_DEV)) { DPRINTK("request check condition\n"); /* FIXME: command completion with check condition Loading @@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 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 { u8 *scsicmd = cmd->cmnd; Loading drivers/scsi/libata.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ struct ata_scsi_args { /* libata-core.c */ 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, struct ata_device *dev); extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); Loading Loading
drivers/scsi/ahci.c +23 −32 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/dma-mapping.h> #include <linux/device.h> #include "scsi.h" #include <scsi/scsi_host.h> #include <linux/libata.h> Loading Loading @@ -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_qc_prep(struct ata_queued_cmd *qc); 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 void ahci_remove_one (struct pci_dev *pdev); Loading Loading @@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = { .check_status = ahci_check_status, .check_altstatus = ahci_check_status, .check_err = ahci_check_err, .dev_select = ata_noop_dev_select, .tf_read = ahci_tf_read, Loading Loading @@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap) 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) { struct ahci_port_priv *pp = ap->private_data; Loading Loading @@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap) * not being called from the SCSI EH. */ 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); Loading Loading @@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) if (status & PORT_IRQ_FATAL) { ahci_intr_error(ap, status); if (qc) ata_qc_complete(qc, ATA_ERR); ata_qc_complete(qc, AC_ERR_OTHER); } return 1; Loading Loading @@ -684,9 +676,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * if (ata_ratelimit()) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); printk(KERN_WARNING "ahci(%s): unhandled interrupt on port %u\n", pci_name(pdev), i); dev_printk(KERN_WARNING, &pdev->dev, "unhandled interrupt on port %u\n", i); } VPRINTK("port %u\n", i); Loading @@ -695,9 +687,8 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * if (ata_ratelimit()) { struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); printk(KERN_WARNING "ahci(%s): interrupt on disabled port %u\n", pci_name(pdev), i); dev_printk(KERN_WARNING, &pdev->dev, "interrupt on disabled port %u\n", i); } } Loading Loading @@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) tmp = readl(mmio + HOST_CTL); if (tmp & HOST_RESET) { printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", pci_name(pdev), tmp); dev_printk(KERN_ERR, &pdev->dev, "controller reset failed (0x%x)\n", tmp); return -EIO; } Loading Loading @@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) if (rc) { rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "64-bit DMA enable failed\n"); return rc; } } } else { rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "32-bit DMA enable failed\n"); return rc; } rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); if (rc) { printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", pci_name(pdev)); dev_printk(KERN_ERR, &pdev->dev, "32-bit consistent DMA enable failed\n"); return rc; } } Loading Loading @@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) else 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" , pci_name(pdev), (vers >> 24) & 0xff, (vers >> 16) & 0xff, Loading @@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) impl, 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\n" , pci_name(pdev), cap & (1 << 31) ? "64bit " : "", cap & (1 << 30) ? "ncq " : "", Loading Loading @@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) VPRINTK("ENTER\n"); 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); if (rc) Loading
drivers/scsi/ata_piix.c +9 −6 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <linux/init.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/device.h> #include "scsi.h" #include <scsi/scsi_host.h> #include <linux/libata.h> Loading Loading @@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; 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; 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) */ if (!in_module_init) return -ENODEV; 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) { u8 tmp; Loading Loading @@ -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]->host_flags |= ATA_FLAG_SLAVE_POSS; 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) Loading
drivers/scsi/libata-core.c +28 −52 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) struct ata_ioports *ioaddr = &ap->ioaddr; 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->lbal = inb(ioaddr->lbal_addr); tf->lbam = inb(ioaddr->lbam_addr); Loading Loading @@ -406,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) struct ata_ioports *ioaddr = &ap->ioaddr; 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->lbal = readb((void __iomem *)ioaddr->lbal_addr); tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); Loading Loading @@ -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 * @tf: Taskfile to convert Loading Loading @@ -902,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) memset(&tf, 0, sizeof(tf)); err = ata_chk_err(ap); ap->ops->tf_read(ap, &tf); err = tf.feature; dev->class = ATA_DEV_NONE; Loading Loading @@ -1140,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) unsigned int major_version; u16 tmp; unsigned long xfer_modes; u8 status; unsigned int using_edd; DECLARE_COMPLETION(wait); struct ata_queued_cmd *qc; Loading Loading @@ -1194,8 +1169,11 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) else wait_for_completion(&wait); status = ata_chk_status(ap); if (status & ATA_ERR) { spin_lock_irqsave(&ap->host_set->lock, flags); 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 * the ATA signature for some ATAPI devices. Until the Loading @@ -1208,7 +1186,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) * to have this problem. */ 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) { dev->class = ATA_DEV_ATAPI; qc->cursg = 0; Loading Loading @@ -2685,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) * 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; unsigned long flags; Loading @@ -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); ap->flags &= ~ATA_FLAG_NOINTR; ata_irq_on(ap); ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, err_mask); spin_unlock_irqrestore(&ap->host_set->lock, flags); } Loading Loading @@ -2790,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap) 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 */ Loading Loading @@ -3158,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap) static void ata_pio_error(struct ata_port *ap) { 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); 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; 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) Loading Loading @@ -3292,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) ap->id, qc->tf.command, drv_stat, host_stat); /* complete taskfile transaction */ ata_qc_complete(qc, drv_stat); ata_qc_complete(qc, ac_err_mask(drv_stat)); break; } Loading Loading @@ -3397,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 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; } Loading Loading @@ -3456,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) * 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; Loading @@ -3473,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) qc->flags &= ~ATA_QCFLAG_ACTIVE; /* 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), * return immediately Loading Loading @@ -3911,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap, ap->ops->irq_clear(ap); /* complete taskfile transaction */ ata_qc_complete(qc, status); ata_qc_complete(qc, ac_err_mask(status)); break; default: Loading Loading @@ -4006,7 +3981,7 @@ static void atapi_packet_task(void *_data) /* sleep-wait for BSY to clear */ DPRINTK("busy wait\n"); if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) goto err_out; goto err_out_status; /* make sure DRQ is set */ status = ata_chk_status(ap); Loading Loading @@ -4043,8 +4018,10 @@ static void atapi_packet_task(void *_data) return; err_out_status: status = ata_chk_status(ap); err_out: ata_poll_qc_complete(qc, ATA_ERR); ata_poll_qc_complete(qc, __ac_err_mask(status)); } Loading Loading @@ -4550,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int 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; 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) return NULL; Loading Loading @@ -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 & (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)) probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1); } else { if (n_ports == 2) probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); Loading Loading @@ -4867,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis); EXPORT_SYMBOL_GPL(ata_tf_from_fis); EXPORT_SYMBOL_GPL(ata_check_status); EXPORT_SYMBOL_GPL(ata_altstatus); EXPORT_SYMBOL_GPL(ata_chk_err); EXPORT_SYMBOL_GPL(ata_exec_command); EXPORT_SYMBOL_GPL(ata_port_start); EXPORT_SYMBOL_GPL(ata_port_stop); Loading
drivers/scsi/libata-scsi.c +28 −18 Original line number Diff line number Diff line Loading @@ -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 * 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, &sb[1], &sb[2], &sb[3]); sb[1] &= 0x0f; Loading Loading @@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) * Use ata_to_sense_error() to map status register bits * 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, &sb[2], &sb[12], &sb[13]); sb[2] &= 0x0f; Loading @@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) sb[0] = 0x70; 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 */ sb[0] |= 0x80; /* set valid bit */ sb[3] = tf->device & 0x0f; Loading @@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) sb[5] = tf->lbam; sb[6] = tf->lbal; } else { /* TODO: C/H/S */ } } /** Loading Loading @@ -1199,10 +1207,12 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm 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; 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 * user mandated it or if there's an error. Note that if we Loading @@ -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 * was no error, SK, ASC and ASCQ will all be zero. */ if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && ((cmd->cmnd[2] & 0x20) || need_sense)) { if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && ((cdb[2] & 0x20) || need_sense)) { ata_gen_ata_desc_sense(qc); } else { if (!need_sense) { Loading Loading @@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, 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; VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); 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); VPRINTK("ENTER, err_mask 0x%X\n", err_mask); else if (unlikely(drv_stat & ATA_ERR)) { if (unlikely(err_mask & AC_ERR_DEV)) { DPRINTK("request check condition\n"); /* FIXME: command completion with check condition Loading @@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 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 { u8 *scsicmd = cmd->cmnd; Loading
drivers/scsi/libata.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ struct ata_scsi_args { /* libata-core.c */ 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, struct ata_device *dev); extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); Loading