Skip to content

Commit

Permalink
Merge branch 'for-jeff' of git://htj.dyndns.org/libata-tj into tejun-…
Browse files Browse the repository at this point in the history
…merge
  • Loading branch information
Jeff Garzik committed May 15, 2006
2 parents 5006ecc + aee10a0 commit efa6e7e
Show file tree
Hide file tree
Showing 25 changed files with 3,680 additions and 1,161 deletions.
346 changes: 210 additions & 136 deletions drivers/scsi/ahci.c

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions drivers/scsi/ata_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ static const struct ata_port_operations piix_pata_ops = {
.qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot,

.eng_timeout = ata_eng_timeout,
.freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd,

.irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear,
Expand Down Expand Up @@ -271,7 +274,10 @@ static const struct ata_port_operations piix_sata_ops = {
.qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot,

.eng_timeout = ata_eng_timeout,
.freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler,
.post_internal_cmd = ata_bmdma_post_internal_cmd,

.irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear,
Expand Down Expand Up @@ -484,7 +490,7 @@ static int piix_pata_probe_reset(struct ata_port *ap, unsigned int *classes)
struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);

if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) {
printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
return 0;
}

Expand Down Expand Up @@ -565,7 +571,7 @@ static unsigned int piix_sata_probe (struct ata_port *ap)
static int piix_sata_probe_reset(struct ata_port *ap, unsigned int *classes)
{
if (!piix_sata_probe(ap)) {
printk(KERN_INFO "ata%u: SATA port has no device.\n", ap->id);
ata_port_printk(ap, KERN_INFO, "SATA port has no device.\n");
return 0;
}

Expand Down
143 changes: 143 additions & 0 deletions drivers/scsi/libata-bmdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,149 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc)
ata_altstatus(ap); /* dummy read */
}

/**
* ata_bmdma_freeze - Freeze BMDMA controller port
* @ap: port to freeze
*
* Freeze BMDMA controller port.
*
* LOCKING:
* Inherited from caller.
*/
void ata_bmdma_freeze(struct ata_port *ap)
{
struct ata_ioports *ioaddr = &ap->ioaddr;

ap->ctl |= ATA_NIEN;
ap->last_ctl = ap->ctl;

if (ap->flags & ATA_FLAG_MMIO)
writeb(ap->ctl, (void __iomem *)ioaddr->ctl_addr);
else
outb(ap->ctl, ioaddr->ctl_addr);
}

/**
* ata_bmdma_thaw - Thaw BMDMA controller port
* @ap: port to thaw
*
* Thaw BMDMA controller port.
*
* LOCKING:
* Inherited from caller.
*/
void ata_bmdma_thaw(struct ata_port *ap)
{
/* clear & re-enable interrupts */
ata_chk_status(ap);
ap->ops->irq_clear(ap);
if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */
ata_irq_on(ap);
}

/**
* ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
* @ap: port to handle error for
* @softreset: softreset method (can be NULL)
* @hardreset: hardreset method (can be NULL)
* @postreset: postreset method (can be NULL)
*
* Handle error for ATA BMDMA controller. It can handle both
* PATA and SATA controllers. Many controllers should be able to
* use this EH as-is or with some added handling before and
* after.
*
* This function is intended to be used for constructing
* ->error_handler callback by low level drivers.
*
* LOCKING:
* Kernel thread context (may sleep)
*/
void ata_bmdma_drive_eh(struct ata_port *ap, ata_reset_fn_t softreset,
ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
{
struct ata_host_set *host_set = ap->host_set;
struct ata_eh_context *ehc = &ap->eh_context;
struct ata_queued_cmd *qc;
unsigned long flags;
int thaw = 0;

qc = __ata_qc_from_tag(ap, ap->active_tag);
if (qc && !(qc->flags & ATA_QCFLAG_FAILED))
qc = NULL;

/* reset PIO HSM and stop DMA engine */
spin_lock_irqsave(&host_set->lock, flags);

ap->hsm_task_state = HSM_ST_IDLE;

if (qc && (qc->tf.protocol == ATA_PROT_DMA ||
qc->tf.protocol == ATA_PROT_ATAPI_DMA)) {
u8 host_stat;

host_stat = ata_bmdma_status(ap);

ata_ehi_push_desc(&ehc->i, "BMDMA stat 0x%x", host_stat);

/* BMDMA controllers indicate host bus error by
* setting DMA_ERR bit and timing out. As it wasn't
* really a timeout event, adjust error mask and
* cancel frozen state.
*/
if (qc->err_mask == AC_ERR_TIMEOUT && host_stat & ATA_DMA_ERR) {
qc->err_mask = AC_ERR_HOST_BUS;
thaw = 1;
}

ap->ops->bmdma_stop(qc);
}

ata_altstatus(ap);
ata_chk_status(ap);
ap->ops->irq_clear(ap);

spin_unlock_irqrestore(&host_set->lock, flags);

if (thaw)
ata_eh_thaw_port(ap);

/* PIO and DMA engines have been stopped, perform recovery */
ata_do_eh(ap, softreset, hardreset, postreset);
}

/**
* ata_bmdma_error_handler - Stock error handler for BMDMA controller
* @ap: port to handle error for
*
* Stock error handler for BMDMA controller.
*
* LOCKING:
* Kernel thread context (may sleep)
*/
void ata_bmdma_error_handler(struct ata_port *ap)
{
ata_reset_fn_t hardreset;

hardreset = NULL;
if (sata_scr_valid(ap))
hardreset = sata_std_hardreset;

ata_bmdma_drive_eh(ap, ata_std_softreset, hardreset, ata_std_postreset);
}

/**
* ata_bmdma_post_internal_cmd - Stock post_internal_cmd for
* BMDMA controller
* @qc: internal command to clean up
*
* LOCKING:
* Kernel thread context (may sleep)
*/
void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
{
ata_bmdma_stop(qc);
}

#ifdef CONFIG_PCI
static struct ata_probe_ent *
ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
Expand Down
Loading

0 comments on commit efa6e7e

Please sign in to comment.