Skip to content

Commit

Permalink
ata: make qc_prep return ata_completion_errors
Browse files Browse the repository at this point in the history
commit 95364f3 upstream.

In case a driver wants to return an error from qc_prep, return enum
ata_completion_errors. sata_mv is one of those drivers -- see the next
patch. Other drivers return the newly defined AC_ERR_OK.

[v2] use enum ata_completion_errors and AC_ERR_OK.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-ide@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Oct 1, 2020
1 parent 1a93281 commit 6002dcd
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Documentation/DocBook/libata.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ Many legacy IDE drivers use ata_bmdma_status() as the bmdma_status() hook.

<sect2><title>High-level taskfile hooks</title>
<programlisting>
void (*qc_prep) (struct ata_queued_cmd *qc);
enum ata_completion_errors (*qc_prep) (struct ata_queued_cmd *qc);
int (*qc_issue) (struct ata_queued_cmd *qc);
</programlisting>

Expand Down
6 changes: 4 additions & 2 deletions drivers/ata/acard-ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct acard_sg {
__le32 size; /* bit 31 (EOT) max==0x10000 (64k) */
};

static void acard_ahci_qc_prep(struct ata_queued_cmd *qc);
static enum ata_completion_errors acard_ahci_qc_prep(struct ata_queued_cmd *qc);
static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
static int acard_ahci_port_start(struct ata_port *ap);
static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
Expand Down Expand Up @@ -257,7 +257,7 @@ static unsigned int acard_ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
return si;
}

static void acard_ahci_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors acard_ahci_qc_prep(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct ahci_port_priv *pp = ap->private_data;
Expand Down Expand Up @@ -295,6 +295,8 @@ static void acard_ahci_qc_prep(struct ata_queued_cmd *qc)
opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;

ahci_fill_cmd_slot(pp, qc->tag, opts);

return AC_ERR_OK;
}

static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
Expand Down
6 changes: 4 additions & 2 deletions drivers/ata/libahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
static int ahci_port_start(struct ata_port *ap);
static void ahci_port_stop(struct ata_port *ap);
static void ahci_qc_prep(struct ata_queued_cmd *qc);
static enum ata_completion_errors ahci_qc_prep(struct ata_queued_cmd *qc);
static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc);
static void ahci_freeze(struct ata_port *ap);
static void ahci_thaw(struct ata_port *ap);
Expand Down Expand Up @@ -1535,7 +1535,7 @@ static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc)
return sata_pmp_qc_defer_cmd_switch(qc);
}

static void ahci_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors ahci_qc_prep(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct ahci_port_priv *pp = ap->private_data;
Expand Down Expand Up @@ -1571,6 +1571,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;

ahci_fill_cmd_slot(pp, qc->tag, opts);

return AC_ERR_OK;
}

static void ahci_fbs_dec_intr(struct ata_port *ap)
Expand Down
9 changes: 7 additions & 2 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4713,7 +4713,10 @@ int ata_std_qc_defer(struct ata_queued_cmd *qc)
return ATA_DEFER_LINK;
}

void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc)
{
return AC_ERR_OK;
}

/**
* ata_sg_init - Associate command with scatter-gather table.
Expand Down Expand Up @@ -5126,7 +5129,9 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
return;
}

ap->ops->qc_prep(qc);
qc->err_mask |= ap->ops->qc_prep(qc);
if (unlikely(qc->err_mask))
goto err;
trace_ata_qc_issue(qc);
qc->err_mask |= ap->ops->qc_issue(qc);
if (unlikely(qc->err_mask))
Expand Down
12 changes: 8 additions & 4 deletions drivers/ata/libata-sff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2741,12 +2741,14 @@ static void ata_bmdma_fill_sg_dumb(struct ata_queued_cmd *qc)
* LOCKING:
* spin_lock_irqsave(host lock)
*/
void ata_bmdma_qc_prep(struct ata_queued_cmd *qc)
enum ata_completion_errors ata_bmdma_qc_prep(struct ata_queued_cmd *qc)
{
if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;

ata_bmdma_fill_sg(qc);

return AC_ERR_OK;
}
EXPORT_SYMBOL_GPL(ata_bmdma_qc_prep);

Expand All @@ -2759,12 +2761,14 @@ EXPORT_SYMBOL_GPL(ata_bmdma_qc_prep);
* LOCKING:
* spin_lock_irqsave(host lock)
*/
void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc)
enum ata_completion_errors ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc)
{
if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;

ata_bmdma_fill_sg_dumb(qc);

return AC_ERR_OK;
}
EXPORT_SYMBOL_GPL(ata_bmdma_dumb_qc_prep);

Expand Down
6 changes: 4 additions & 2 deletions drivers/ata/pata_macio.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static int pata_macio_cable_detect(struct ata_port *ap)
return ATA_CBL_PATA40;
}

static void pata_macio_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc)
{
unsigned int write = (qc->tf.flags & ATA_TFLAG_WRITE);
struct ata_port *ap = qc->ap;
Expand All @@ -520,7 +520,7 @@ static void pata_macio_qc_prep(struct ata_queued_cmd *qc)
__func__, qc, qc->flags, write, qc->dev->devno);

if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;

table = (struct dbdma_cmd *) priv->dma_table_cpu;

Expand Down Expand Up @@ -565,6 +565,8 @@ static void pata_macio_qc_prep(struct ata_queued_cmd *qc)
table->command = cpu_to_le16(DBDMA_STOP);

dev_dbgdma(priv->dev, "%s: %d DMA list entries\n", __func__, pi);

return AC_ERR_OK;
}


Expand Down
8 changes: 5 additions & 3 deletions drivers/ata/pata_pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,27 @@ static void pxa_ata_dma_irq(void *d)
/*
* Prepare taskfile for submission.
*/
static void pxa_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors pxa_qc_prep(struct ata_queued_cmd *qc)
{
struct pata_pxa_data *pd = qc->ap->private_data;
struct dma_async_tx_descriptor *tx;
enum dma_transfer_direction dir;

if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;

dir = (qc->dma_dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM);
tx = dmaengine_prep_slave_sg(pd->dma_chan, qc->sg, qc->n_elem, dir,
DMA_PREP_INTERRUPT);
if (!tx) {
ata_dev_err(qc->dev, "prep_slave_sg() failed\n");
return;
return AC_ERR_OK;
}
tx->callback = pxa_ata_dma_irq;
tx->callback_param = pd;
pd->dma_cookie = dmaengine_submit(tx);

return AC_ERR_OK;
}

/*
Expand Down
7 changes: 4 additions & 3 deletions drivers/ata/pdc_adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent);
static int adma_port_start(struct ata_port *ap);
static void adma_port_stop(struct ata_port *ap);
static void adma_qc_prep(struct ata_queued_cmd *qc);
static enum ata_completion_errors adma_qc_prep(struct ata_queued_cmd *qc);
static unsigned int adma_qc_issue(struct ata_queued_cmd *qc);
static int adma_check_atapi_dma(struct ata_queued_cmd *qc);
static void adma_freeze(struct ata_port *ap);
Expand Down Expand Up @@ -311,7 +311,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
return i;
}

static void adma_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors adma_qc_prep(struct ata_queued_cmd *qc)
{
struct adma_port_priv *pp = qc->ap->private_data;
u8 *buf = pp->pkt;
Expand All @@ -322,7 +322,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)

adma_enter_reg_mode(qc->ap);
if (qc->tf.protocol != ATA_PROT_DMA)
return;
return AC_ERR_OK;

buf[i++] = 0; /* Response flags */
buf[i++] = 0; /* reserved */
Expand Down Expand Up @@ -387,6 +387,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)
printk("%s\n", obuf);
}
#endif
return AC_ERR_OK;
}

static inline void adma_packet_start(struct ata_queued_cmd *qc)
Expand Down
4 changes: 3 additions & 1 deletion drivers/ata/sata_fsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
return num_prde;
}

static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors sata_fsl_qc_prep(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct sata_fsl_port_priv *pp = ap->private_data;
Expand Down Expand Up @@ -559,6 +559,8 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)

VPRINTK("SATA FSL : xx_qc_prep, di = 0x%x, ttl = %d, num_prde = %d\n",
desc_info, ttl_dwords, num_prde);

return AC_ERR_OK;
}

static unsigned int sata_fsl_qc_issue(struct ata_queued_cmd *qc)
Expand Down
4 changes: 3 additions & 1 deletion drivers/ata/sata_inic162x.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ static void inic_fill_sg(struct inic_prd *prd, struct ata_queued_cmd *qc)
prd[-1].flags |= PRD_END;
}

static void inic_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors inic_qc_prep(struct ata_queued_cmd *qc)
{
struct inic_port_priv *pp = qc->ap->private_data;
struct inic_pkt *pkt = pp->pkt;
Expand Down Expand Up @@ -532,6 +532,8 @@ static void inic_qc_prep(struct ata_queued_cmd *qc)
inic_fill_sg(prd, qc);

pp->cpb_tbl[0] = pp->pkt_dma;

return AC_ERR_OK;
}

static unsigned int inic_qc_issue(struct ata_queued_cmd *qc)
Expand Down
26 changes: 15 additions & 11 deletions drivers/ata/sata_mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val)
static int mv_port_start(struct ata_port *ap);
static void mv_port_stop(struct ata_port *ap);
static int mv_qc_defer(struct ata_queued_cmd *qc);
static void mv_qc_prep(struct ata_queued_cmd *qc);
static void mv_qc_prep_iie(struct ata_queued_cmd *qc);
static enum ata_completion_errors mv_qc_prep(struct ata_queued_cmd *qc);
static enum ata_completion_errors mv_qc_prep_iie(struct ata_queued_cmd *qc);
static unsigned int mv_qc_issue(struct ata_queued_cmd *qc);
static int mv_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
Expand Down Expand Up @@ -2046,7 +2046,7 @@ static void mv_rw_multi_errata_sata24(struct ata_queued_cmd *qc)
* LOCKING:
* Inherited from caller.
*/
static void mv_qc_prep(struct ata_queued_cmd *qc)
static enum ata_completion_errors mv_qc_prep(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct mv_port_priv *pp = ap->private_data;
Expand All @@ -2058,15 +2058,15 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
switch (tf->protocol) {
case ATA_PROT_DMA:
if (tf->command == ATA_CMD_DSM)
return;
return AC_ERR_OK;
/* fall-thru */
case ATA_PROT_NCQ:
break; /* continue below */
case ATA_PROT_PIO:
mv_rw_multi_errata_sata24(qc);
return;
return AC_ERR_OK;
default:
return;
return AC_ERR_OK;
}

/* Fill in command request block
Expand Down Expand Up @@ -2131,8 +2131,10 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */

if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;
mv_fill_sg(qc);

return AC_ERR_OK;
}

/**
Expand All @@ -2147,7 +2149,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
* LOCKING:
* Inherited from caller.
*/
static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
static enum ata_completion_errors mv_qc_prep_iie(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct mv_port_priv *pp = ap->private_data;
Expand All @@ -2158,9 +2160,9 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)

if ((tf->protocol != ATA_PROT_DMA) &&
(tf->protocol != ATA_PROT_NCQ))
return;
return AC_ERR_OK;
if (tf->command == ATA_CMD_DSM)
return; /* use bmdma for this */
return AC_ERR_OK; /* use bmdma for this */

/* Fill in Gen IIE command request block */
if (!(tf->flags & ATA_TFLAG_WRITE))
Expand Down Expand Up @@ -2201,8 +2203,10 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
);

if (!(qc->flags & ATA_QCFLAG_DMAMAP))
return;
return AC_ERR_OK;
mv_fill_sg(qc);

return AC_ERR_OK;
}

/**
Expand Down
Loading

0 comments on commit 6002dcd

Please sign in to comment.