Commit 2b13abe5 authored by Jeff Garzik's avatar Jeff Garzik

[libata] ->qc_prep hook

Rename ->fill_sg hook to ->qc_prep, and call it unconditionally
(as opposed to ->fill_sg, which was called only when the
flag ATA_QCFLAG_SG was set).
parent 5ae20cc7
...@@ -138,7 +138,7 @@ static struct ata_port_operations piix_pata_ops = { ...@@ -138,7 +138,7 @@ static struct ata_port_operations piix_pata_ops = {
.bmdma_setup = ata_bmdma_setup_pio, .bmdma_setup = ata_bmdma_setup_pio,
.bmdma_start = ata_bmdma_start_pio, .bmdma_start = ata_bmdma_start_pio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
...@@ -161,7 +161,7 @@ static struct ata_port_operations piix_sata_ops = { ...@@ -161,7 +161,7 @@ static struct ata_port_operations piix_sata_ops = {
.bmdma_setup = ata_bmdma_setup_pio, .bmdma_setup = ata_bmdma_setup_pio,
.bmdma_start = ata_bmdma_start_pio, .bmdma_start = ata_bmdma_start_pio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -1775,13 +1775,13 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) ...@@ -1775,13 +1775,13 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
} }
/** /**
* ata_fill_sg - * ata_fill_sg - Fill PCI IDE PRD table
* @qc: * @qc: Metadata associated with taskfile to be transferred
* *
* LOCKING: * LOCKING:
* *
*/ */
void ata_fill_sg(struct ata_queued_cmd *qc) static void ata_fill_sg(struct ata_queued_cmd *qc)
{ {
struct scatterlist *sg = qc->sg; struct scatterlist *sg = qc->sg;
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
...@@ -1822,6 +1822,21 @@ void ata_fill_sg(struct ata_queued_cmd *qc) ...@@ -1822,6 +1822,21 @@ void ata_fill_sg(struct ata_queued_cmd *qc)
ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
} }
/**
* ata_qc_prep - Prepare taskfile for submission
* @qc: Metadata associated with taskfile to be prepared
*
* LOCKING:
* spin_lock_irqsave(host_set lock)
*/
void ata_qc_prep(struct ata_queued_cmd *qc)
{
if (!(qc->flags & ATA_QCFLAG_SG))
return;
ata_fill_sg(qc);
}
/** /**
* ata_sg_setup_one - * ata_sg_setup_one -
* @qc: * @qc:
...@@ -1839,7 +1854,6 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) ...@@ -1839,7 +1854,6 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
struct scsi_cmnd *cmd = qc->scsicmd; struct scsi_cmnd *cmd = qc->scsicmd;
int dir = scsi_to_pci_dma_dir(cmd->sc_data_direction); int dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
struct scatterlist *sg = qc->sg; struct scatterlist *sg = qc->sg;
unsigned int have_sg = (qc->flags & ATA_QCFLAG_SG);
dma_addr_t dma_address; dma_addr_t dma_address;
assert(sg == &qc->sgent); assert(sg == &qc->sgent);
...@@ -1849,9 +1863,6 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) ...@@ -1849,9 +1863,6 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
sg->offset = (unsigned long) cmd->request_buffer & ~PAGE_MASK; sg->offset = (unsigned long) cmd->request_buffer & ~PAGE_MASK;
sg_dma_len(sg) = cmd->request_bufflen; sg_dma_len(sg) = cmd->request_bufflen;
if (!have_sg)
return 0;
dma_address = pci_map_single(ap->host_set->pdev, cmd->request_buffer, dma_address = pci_map_single(ap->host_set->pdev, cmd->request_buffer,
cmd->request_bufflen, dir); cmd->request_bufflen, dir);
if (pci_dma_mapping_error(dma_address)) if (pci_dma_mapping_error(dma_address))
...@@ -1881,22 +1892,19 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) ...@@ -1881,22 +1892,19 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct scsi_cmnd *cmd = qc->scsicmd; struct scsi_cmnd *cmd = qc->scsicmd;
struct scatterlist *sg; struct scatterlist *sg;
int n_elem; int n_elem, dir;
unsigned int have_sg = (qc->flags & ATA_QCFLAG_SG);
VPRINTK("ENTER, ata%u, use_sg %d\n", ap->id, cmd->use_sg); VPRINTK("ENTER, ata%u, use_sg %d\n", ap->id, cmd->use_sg);
assert(cmd->use_sg > 0); assert(cmd->use_sg > 0);
sg = (struct scatterlist *)cmd->request_buffer; sg = (struct scatterlist *)cmd->request_buffer;
if (have_sg) { dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
int dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
n_elem = pci_map_sg(ap->host_set->pdev, sg, cmd->use_sg, dir); n_elem = pci_map_sg(ap->host_set->pdev, sg, cmd->use_sg, dir);
if (n_elem < 1) if (n_elem < 1)
return -1; return -1;
DPRINTK("%d sg elements mapped\n", n_elem); DPRINTK("%d sg elements mapped\n", n_elem);
} else {
n_elem = cmd->use_sg;
}
qc->n_elem = n_elem; qc->n_elem = n_elem;
return 0; return 0;
...@@ -2325,10 +2333,10 @@ int ata_qc_issue(struct ata_queued_cmd *qc) ...@@ -2325,10 +2333,10 @@ int ata_qc_issue(struct ata_queued_cmd *qc)
if (ata_sg_setup_one(qc)) if (ata_sg_setup_one(qc))
goto err_out; goto err_out;
} }
ap->ops->fill_sg(qc);
} }
ap->ops->qc_prep(qc);
qc->ap->active_tag = qc->tag; qc->ap->active_tag = qc->tag;
qc->flags |= ATA_QCFLAG_ACTIVE; qc->flags |= ATA_QCFLAG_ACTIVE;
...@@ -3325,7 +3333,7 @@ EXPORT_SYMBOL_GPL(ata_exec_command_mmio); ...@@ -3325,7 +3333,7 @@ EXPORT_SYMBOL_GPL(ata_exec_command_mmio);
EXPORT_SYMBOL_GPL(ata_port_start); EXPORT_SYMBOL_GPL(ata_port_start);
EXPORT_SYMBOL_GPL(ata_port_stop); EXPORT_SYMBOL_GPL(ata_port_stop);
EXPORT_SYMBOL_GPL(ata_interrupt); EXPORT_SYMBOL_GPL(ata_interrupt);
EXPORT_SYMBOL_GPL(ata_fill_sg); EXPORT_SYMBOL_GPL(ata_qc_prep);
EXPORT_SYMBOL_GPL(ata_bmdma_setup_pio); EXPORT_SYMBOL_GPL(ata_bmdma_setup_pio);
EXPORT_SYMBOL_GPL(ata_bmdma_start_pio); EXPORT_SYMBOL_GPL(ata_bmdma_start_pio);
EXPORT_SYMBOL_GPL(ata_bmdma_setup_mmio); EXPORT_SYMBOL_GPL(ata_bmdma_setup_mmio);
......
...@@ -81,7 +81,7 @@ static void pdc_eng_timeout(struct ata_port *ap); ...@@ -81,7 +81,7 @@ static void pdc_eng_timeout(struct ata_port *ap);
static int pdc_port_start(struct ata_port *ap); static int pdc_port_start(struct ata_port *ap);
static void pdc_port_stop(struct ata_port *ap); static void pdc_port_stop(struct ata_port *ap);
static void pdc_phy_reset(struct ata_port *ap); static void pdc_phy_reset(struct ata_port *ap);
static void pdc_fill_sg(struct ata_queued_cmd *qc); static void pdc_qc_prep(struct ata_queued_cmd *qc);
static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf);
static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
static inline void pdc_dma_complete (struct ata_port *ap, static inline void pdc_dma_complete (struct ata_port *ap,
...@@ -114,7 +114,7 @@ static struct ata_port_operations pdc_sata_ops = { ...@@ -114,7 +114,7 @@ static struct ata_port_operations pdc_sata_ops = {
.phy_reset = pdc_phy_reset, .phy_reset = pdc_phy_reset,
.bmdma_setup = pdc_dma_setup, .bmdma_setup = pdc_dma_setup,
.bmdma_start = pdc_dma_start, .bmdma_start = pdc_dma_start,
.fill_sg = pdc_fill_sg, .qc_prep = pdc_qc_prep,
.eng_timeout = pdc_eng_timeout, .eng_timeout = pdc_eng_timeout,
.irq_handler = pdc_interrupt, .irq_handler = pdc_interrupt,
.scr_read = pdc_sata_scr_read, .scr_read = pdc_sata_scr_read,
...@@ -261,14 +261,14 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, ...@@ -261,14 +261,14 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4));
} }
static void pdc_fill_sg(struct ata_queued_cmd *qc) static void pdc_qc_prep(struct ata_queued_cmd *qc)
{ {
struct pdc_port_priv *pp = qc->ap->private_data; struct pdc_port_priv *pp = qc->ap->private_data;
unsigned int i; unsigned int i;
VPRINTK("ENTER\n"); VPRINTK("ENTER\n");
ata_fill_sg(qc); ata_qc_prep(qc);
i = pdc_pkt_header(&qc->tf, qc->ap->prd_dma, qc->dev->devno, pp->pkt); i = pdc_pkt_header(&qc->tf, qc->ap->prd_dma, qc->dev->devno, pp->pkt);
......
...@@ -131,7 +131,7 @@ static struct ata_port_operations sil_ops = { ...@@ -131,7 +131,7 @@ static struct ata_port_operations sil_ops = {
.post_set_mode = sil_post_set_mode, .post_set_mode = sil_post_set_mode,
.bmdma_setup = ata_bmdma_setup_mmio, .bmdma_setup = ata_bmdma_setup_mmio,
.bmdma_start = ata_bmdma_start_mmio, .bmdma_start = ata_bmdma_start_mmio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.scr_read = sil_scr_read, .scr_read = sil_scr_read,
......
...@@ -100,7 +100,7 @@ static struct ata_port_operations sis_ops = { ...@@ -100,7 +100,7 @@ static struct ata_port_operations sis_ops = {
.phy_reset = sata_phy_reset, .phy_reset = sata_phy_reset,
.bmdma_setup = ata_bmdma_setup_pio, .bmdma_setup = ata_bmdma_setup_pio,
.bmdma_start = ata_bmdma_start_pio, .bmdma_start = ata_bmdma_start_pio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.scr_read = sis_scr_read, .scr_read = sis_scr_read,
......
...@@ -233,7 +233,7 @@ static struct ata_port_operations k2_sata_ops = { ...@@ -233,7 +233,7 @@ static struct ata_port_operations k2_sata_ops = {
.phy_reset = sata_phy_reset, .phy_reset = sata_phy_reset,
.bmdma_setup = ata_bmdma_setup_mmio, .bmdma_setup = ata_bmdma_setup_mmio,
.bmdma_start = ata_bmdma_start_mmio, .bmdma_start = ata_bmdma_start_mmio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.scr_read = k2_sata_scr_read, .scr_read = k2_sata_scr_read,
......
...@@ -153,7 +153,7 @@ static void pdc_eng_timeout(struct ata_port *ap); ...@@ -153,7 +153,7 @@ static void pdc_eng_timeout(struct ata_port *ap);
static void pdc_20621_phy_reset (struct ata_port *ap); static void pdc_20621_phy_reset (struct ata_port *ap);
static int pdc_port_start(struct ata_port *ap); static int pdc_port_start(struct ata_port *ap);
static void pdc_port_stop(struct ata_port *ap); static void pdc_port_stop(struct ata_port *ap);
static void pdc20621_fill_sg(struct ata_queued_cmd *qc); static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf);
static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
static void pdc20621_host_stop(struct ata_host_set *host_set); static void pdc20621_host_stop(struct ata_host_set *host_set);
...@@ -200,7 +200,7 @@ static struct ata_port_operations pdc_20621_ops = { ...@@ -200,7 +200,7 @@ static struct ata_port_operations pdc_20621_ops = {
.phy_reset = pdc_20621_phy_reset, .phy_reset = pdc_20621_phy_reset,
.bmdma_setup = pdc20621_dma_setup, .bmdma_setup = pdc20621_dma_setup,
.bmdma_start = pdc20621_dma_start, .bmdma_start = pdc20621_dma_start,
.fill_sg = pdc20621_fill_sg, .qc_prep = pdc20621_qc_prep,
.eng_timeout = pdc_eng_timeout, .eng_timeout = pdc_eng_timeout,
.irq_handler = pdc20621_interrupt, .irq_handler = pdc20621_interrupt,
.port_start = pdc_port_start, .port_start = pdc_port_start,
...@@ -434,7 +434,7 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf, ...@@ -434,7 +434,7 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf,
buf32[dw + 3]); buf32[dw + 3]);
} }
static void pdc20621_fill_sg(struct ata_queued_cmd *qc) static void pdc20621_qc_prep(struct ata_queued_cmd *qc)
{ {
struct scatterlist *sg = qc->sg; struct scatterlist *sg = qc->sg;
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
...@@ -446,6 +446,9 @@ static void pdc20621_fill_sg(struct ata_queued_cmd *qc) ...@@ -446,6 +446,9 @@ static void pdc20621_fill_sg(struct ata_queued_cmd *qc)
unsigned int i, last, idx, total_len = 0, sgt_len; unsigned int i, last, idx, total_len = 0, sgt_len;
u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
if (!(qc->flags & ATA_QCFLAG_SG))
return;
VPRINTK("ata%u: ENTER\n", ap->id); VPRINTK("ata%u: ENTER\n", ap->id);
/* hard-code chip #0 */ /* hard-code chip #0 */
......
...@@ -108,7 +108,7 @@ static struct ata_port_operations svia_sata_ops = { ...@@ -108,7 +108,7 @@ static struct ata_port_operations svia_sata_ops = {
.bmdma_setup = ata_bmdma_setup_pio, .bmdma_setup = ata_bmdma_setup_pio,
.bmdma_start = ata_bmdma_start_pio, .bmdma_start = ata_bmdma_start_pio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -215,7 +215,7 @@ static struct ata_port_operations vsc_sata_ops = { ...@@ -215,7 +215,7 @@ static struct ata_port_operations vsc_sata_ops = {
.phy_reset = sata_phy_reset, .phy_reset = sata_phy_reset,
.bmdma_setup = ata_bmdma_setup_mmio, .bmdma_setup = ata_bmdma_setup_mmio,
.bmdma_start = ata_bmdma_start_mmio, .bmdma_start = ata_bmdma_start_mmio,
.fill_sg = ata_fill_sg, .qc_prep = ata_qc_prep,
.eng_timeout = ata_eng_timeout, .eng_timeout = ata_eng_timeout,
.irq_handler = vsc_sata_interrupt, .irq_handler = vsc_sata_interrupt,
.scr_read = vsc_sata_scr_read, .scr_read = vsc_sata_scr_read,
......
...@@ -315,7 +315,7 @@ struct ata_port_operations { ...@@ -315,7 +315,7 @@ struct ata_port_operations {
void (*bmdma_setup) (struct ata_queued_cmd *qc); void (*bmdma_setup) (struct ata_queued_cmd *qc);
void (*bmdma_start) (struct ata_queued_cmd *qc); void (*bmdma_start) (struct ata_queued_cmd *qc);
void (*fill_sg) (struct ata_queued_cmd *qc); void (*qc_prep) (struct ata_queued_cmd *qc);
void (*eng_timeout) (struct ata_port *ap); void (*eng_timeout) (struct ata_port *ap);
irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
...@@ -375,7 +375,7 @@ extern void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); ...@@ -375,7 +375,7 @@ extern void ata_exec_command_mmio(struct ata_port *ap, 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);
extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
extern void ata_fill_sg(struct ata_queued_cmd *qc); extern void ata_qc_prep(struct ata_queued_cmd *qc);
extern void ata_dev_id_string(struct ata_device *dev, unsigned char *s, extern void ata_dev_id_string(struct ata_device *dev, unsigned char *s,
unsigned int ofs, unsigned int len); unsigned int ofs, unsigned int len);
extern void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc); extern void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc);
......
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