libata: convert core and drivers to ->hw_tag usage
authorJens Axboe <axboe@kernel.dk>
Fri, 11 May 2018 18:51:04 +0000 (12:51 -0600)
committerTejun Heo <tj@kernel.org>
Fri, 11 May 2018 20:10:43 +0000 (13:10 -0700)
Anything that goes to the hardware should use ->hw_tag, anything
related to internal lookup should be using ->tag.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/acard-ahci.c
drivers/ata/libahci.c
drivers/ata/libata-core.c
drivers/ata/libata-scsi.c
drivers/ata/sata_dwc_460ex.c
drivers/ata/sata_fsl.c
drivers/ata/sata_mv.c
drivers/ata/sata_nv.c
drivers/ata/sata_sil24.c

index 940ddbc..583e366 100644 (file)
@@ -271,7 +271,7 @@ static void acard_ahci_qc_prep(struct ata_queued_cmd *qc)
         * Fill in command table information.  First, the header,
         * a SATA Register - Host to Device command FIS.
         */
-       cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
+       cmd_tbl = pp->cmd_tbl + qc->hw_tag * AHCI_CMD_TBL_SZ;
 
        ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
        if (is_atapi) {
@@ -294,7 +294,7 @@ static void acard_ahci_qc_prep(struct ata_queued_cmd *qc)
        if (is_atapi)
                opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;
 
-       ahci_fill_cmd_slot(pp, qc->tag, opts);
+       ahci_fill_cmd_slot(pp, qc->hw_tag, opts);
 }
 
 static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
index 7adcf3c..d043597 100644 (file)
@@ -1645,7 +1645,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
         * Fill in command table information.  First, the header,
         * a SATA Register - Host to Device command FIS.
         */
-       cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
+       cmd_tbl = pp->cmd_tbl + qc->hw_tag * AHCI_CMD_TBL_SZ;
 
        ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
        if (is_atapi) {
@@ -1666,7 +1666,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
        if (is_atapi)
                opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;
 
-       ahci_fill_cmd_slot(pp, qc->tag, opts);
+       ahci_fill_cmd_slot(pp, qc->hw_tag, opts);
 }
 
 static void ahci_fbs_dec_intr(struct ata_port *ap)
@@ -2002,7 +2002,7 @@ unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
        pp->active_link = qc->dev->link;
 
        if (ata_is_ncq(qc->tf.protocol))
-               writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
+               writel(1 << qc->hw_tag, port_mmio + PORT_SCR_ACT);
 
        if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) {
                u32 fbs = readl(port_mmio + PORT_FBS);
@@ -2012,7 +2012,7 @@ unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
                pp->fbs_last_dev = qc->dev->link->pmp;
        }
 
-       writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
+       writel(1 << qc->hw_tag, port_mmio + PORT_CMD_ISSUE);
 
        ahci_sw_activity(qc->dev->link);
 
index 4dc67c7..1687e24 100644 (file)
@@ -5177,7 +5177,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
 
        /* command should be marked inactive atomically with qc completion */
        if (ata_is_ncq(qc->tf.protocol)) {
-               link->sactive &= ~(1 << qc->tag);
+               link->sactive &= ~(1 << qc->hw_tag);
                if (!link->sactive)
                        ap->nr_active_links--;
        } else {
@@ -5405,16 +5405,16 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
        WARN_ON_ONCE(ap->ops->error_handler && ata_tag_valid(link->active_tag));
 
        if (ata_is_ncq(prot)) {
-               WARN_ON_ONCE(link->sactive & (1 << qc->tag));
+               WARN_ON_ONCE(link->sactive & (1 << qc->hw_tag));
 
                if (!link->sactive)
                        ap->nr_active_links++;
-               link->sactive |= 1 << qc->tag;
+               link->sactive |= 1 << qc->hw_tag;
        } else {
                WARN_ON_ONCE(link->sactive);
 
                ap->nr_active_links++;
-               link->active_tag = qc->tag;
+               link->active_tag = qc->hw_tag;
        }
 
        qc->flags |= ATA_QCFLAG_ACTIVE;
index 8d76de9..28e1af2 100644 (file)
@@ -1898,7 +1898,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
        qc->nbytes = n_block * scmd->device->sector_size;
 
        rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags,
-                            qc->tag, class);
+                            qc->hw_tag, class);
 
        if (likely(rc == 0))
                return 0;
@@ -3236,7 +3236,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
 
        /* For NCQ commands copy the tag value */
        if (ata_is_ncq(tf->protocol))
-               tf->nsect = qc->tag << 3;
+               tf->nsect = qc->hw_tag << 3;
 
        /* enforce correct master/slave bit */
        tf->device = dev->devno ?
@@ -3516,7 +3516,7 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
                tf->protocol = ATA_PROT_NCQ;
                tf->command = ATA_CMD_FPDMA_SEND;
                tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f;
-               tf->nsect = qc->tag << 3;
+               tf->nsect = qc->hw_tag << 3;
                tf->hob_feature = (size / 512) >> 8;
                tf->feature = size / 512;
 
@@ -3736,7 +3736,7 @@ static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
                tf->protocol = ATA_PROT_NCQ;
                tf->command = ATA_CMD_FPDMA_RECV;
                tf->hob_nsect = ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN & 0x1f;
-               tf->nsect = qc->tag << 3;
+               tf->nsect = qc->hw_tag << 3;
                tf->feature = sect & 0xff;
                tf->hob_feature = (sect >> 8) & 0xff;
                tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES | (options << 8);
@@ -3815,7 +3815,7 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
                tf->protocol = ATA_PROT_NCQ_NODATA;
                tf->command = ATA_CMD_NCQ_NON_DATA;
                tf->feature = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT;
-               tf->nsect = qc->tag << 3;
+               tf->nsect = qc->hw_tag << 3;
                tf->auxiliary = sa | ((u16)all << 8);
        } else {
                tf->protocol = ATA_PROT_NODATA;
index ce3d667..6f142aa 100644 (file)
@@ -761,7 +761,7 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status)
        if (tag > 0) {
                dev_info(ap->dev,
                         "%s tag=%u cmd=0x%02x dma dir=%s proto=%s dmacr=0x%08x\n",
-                        __func__, qc->tag, qc->tf.command,
+                        __func__, qc->hw_tag, qc->tf.command,
                         get_dma_dir_descript(qc->dma_dir),
                         get_prot_descript(qc->tf.protocol),
                         sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr));
@@ -789,7 +789,7 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc,
 {
        u8 status = 0;
        u32 mask = 0x0;
-       u8 tag = qc->tag;
+       u8 tag = qc->hw_tag;
        struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
        struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
        hsdev->sactive_queued = 0;
@@ -997,7 +997,7 @@ static void sata_dwc_bmdma_setup_by_tag(struct ata_queued_cmd *qc, u8 tag)
 
 static void sata_dwc_bmdma_setup(struct ata_queued_cmd *qc)
 {
-       u8 tag = qc->tag;
+       u8 tag = qc->hw_tag;
 
        if (ata_is_ncq(qc->tf.protocol)) {
                dev_dbg(qc->ap->dev, "%s: ap->link.sactive=0x%08x tag=%d\n",
@@ -1059,7 +1059,7 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
 
 static void sata_dwc_bmdma_start(struct ata_queued_cmd *qc)
 {
-       u8 tag = qc->tag;
+       u8 tag = qc->hw_tag;
 
        if (ata_is_ncq(qc->tf.protocol)) {
                dev_dbg(qc->ap->dev, "%s: ap->link.sactive=0x%08x tag=%d\n",
@@ -1074,17 +1074,17 @@ static void sata_dwc_bmdma_start(struct ata_queued_cmd *qc)
 static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc)
 {
        u32 sactive;
-       u8 tag = qc->tag;
+       u8 tag = qc->hw_tag;
        struct ata_port *ap = qc->ap;
        struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
 
 #ifdef DEBUG_NCQ
-       if (qc->tag > 0 || ap->link.sactive > 1)
+       if (qc->hw_tag > 0 || ap->link.sactive > 1)
                dev_info(ap->dev,
                         "%s ap id=%d cmd(0x%02x)=%s qc tag=%d prot=%s ap active_tag=0x%08x ap sactive=0x%08x\n",
                         __func__, ap->print_id, qc->tf.command,
                         ata_get_cmd_descript(qc->tf.command),
-                        qc->tag, get_prot_descript(qc->tf.protocol),
+                        qc->hw_tag, get_prot_descript(qc->tf.protocol),
                         ap->link.active_tag, ap->link.sactive);
 #endif
 
index 95bf3ab..cb67847 100644 (file)
@@ -519,7 +519,7 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)
        struct sata_fsl_port_priv *pp = ap->private_data;
        struct sata_fsl_host_priv *host_priv = ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
-       unsigned int tag = sata_fsl_tag(qc->tag, hcr_base);
+       unsigned int tag = sata_fsl_tag(qc->hw_tag, hcr_base);
        struct command_desc *cd;
        u32 desc_info = CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE;
        u32 num_prde = 0;
@@ -566,7 +566,7 @@ static unsigned int sata_fsl_qc_issue(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
        struct sata_fsl_host_priv *host_priv = ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
-       unsigned int tag = sata_fsl_tag(qc->tag, hcr_base);
+       unsigned int tag = sata_fsl_tag(qc->hw_tag, hcr_base);
 
        VPRINTK("xx_qc_issue called,CQ=0x%x,CA=0x%x,CE=0x%x,CC=0x%x\n",
                ioread32(CQ + hcr_base),
@@ -595,7 +595,7 @@ static bool sata_fsl_qc_fill_rtf(struct ata_queued_cmd *qc)
        struct sata_fsl_port_priv *pp = qc->ap->private_data;
        struct sata_fsl_host_priv *host_priv = qc->ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
-       unsigned int tag = sata_fsl_tag(qc->tag, hcr_base);
+       unsigned int tag = sata_fsl_tag(qc->hw_tag, hcr_base);
        struct command_desc *cd;
 
        cd = pp->cmdentry + tag;
index 42d4589..3a08f38 100644 (file)
@@ -1802,7 +1802,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
        struct mv_sg *mv_sg, *last_sg = NULL;
        unsigned int si;
 
-       mv_sg = pp->sg_tbl[qc->tag];
+       mv_sg = pp->sg_tbl[qc->hw_tag];
        for_each_sg(qc->sg, sg, qc->n_elem, si) {
                dma_addr_t addr = sg_dma_address(sg);
                u32 sg_len = sg_dma_len(sg);
@@ -1903,9 +1903,9 @@ static void mv_bmdma_setup(struct ata_queued_cmd *qc)
        writel(0, port_mmio + BMDMA_CMD);
 
        /* load PRD table addr. */
-       writel((pp->sg_tbl_dma[qc->tag] >> 16) >> 16,
+       writel((pp->sg_tbl_dma[qc->hw_tag] >> 16) >> 16,
                port_mmio + BMDMA_PRD_HIGH);
-       writelfl(pp->sg_tbl_dma[qc->tag],
+       writelfl(pp->sg_tbl_dma[qc->hw_tag],
                port_mmio + BMDMA_PRD_LOW);
 
        /* issue r/w command */
@@ -2071,17 +2071,17 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
         */
        if (!(tf->flags & ATA_TFLAG_WRITE))
                flags |= CRQB_FLAG_READ;
-       WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
-       flags |= qc->tag << CRQB_TAG_SHIFT;
+       WARN_ON(MV_MAX_Q_DEPTH <= qc->hw_tag);
+       flags |= qc->hw_tag << CRQB_TAG_SHIFT;
        flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT;
 
        /* get current queue index from software */
        in_index = pp->req_idx;
 
        pp->crqb[in_index].sg_addr =
-               cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff);
+               cpu_to_le32(pp->sg_tbl_dma[qc->hw_tag] & 0xffffffff);
        pp->crqb[in_index].sg_addr_hi =
-               cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16);
+               cpu_to_le32((pp->sg_tbl_dma[qc->hw_tag] >> 16) >> 16);
        pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags);
 
        cw = &pp->crqb[in_index].ata_cmd[0];
@@ -2164,17 +2164,17 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
        if (!(tf->flags & ATA_TFLAG_WRITE))
                flags |= CRQB_FLAG_READ;
 
-       WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
-       flags |= qc->tag << CRQB_TAG_SHIFT;
-       flags |= qc->tag << CRQB_HOSTQ_SHIFT;
+       WARN_ON(MV_MAX_Q_DEPTH <= qc->hw_tag);
+       flags |= qc->hw_tag << CRQB_TAG_SHIFT;
+       flags |= qc->hw_tag << CRQB_HOSTQ_SHIFT;
        flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT;
 
        /* get current queue index from software */
        in_index = pp->req_idx;
 
        crqb = (struct mv_crqb_iie *) &pp->crqb[in_index];
-       crqb->addr = cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff);
-       crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16);
+       crqb->addr = cpu_to_le32(pp->sg_tbl_dma[qc->hw_tag] & 0xffffffff);
+       crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->hw_tag] >> 16) >> 16);
        crqb->flags = cpu_to_le32(flags);
 
        crqb->ata_cmd[0] = cpu_to_le32(
index b6e9ad6..d83afc3 100644 (file)
@@ -1342,11 +1342,11 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb)
 
        for_each_sg(qc->sg, sg, qc->n_elem, si) {
                aprd = (si < 5) ? &cpb->aprd[si] :
-                              &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (si-5)];
+                       &pp->aprd[NV_ADMA_SGTBL_LEN * qc->hw_tag + (si-5)];
                nv_adma_fill_aprd(qc, sg, si, aprd);
        }
        if (si > 5)
-               cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag)));
+               cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->hw_tag)));
        else
                cpb->next_aprd = cpu_to_le64(0);
 }
@@ -1371,7 +1371,7 @@ static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc)
 static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
 {
        struct nv_adma_port_priv *pp = qc->ap->private_data;
-       struct nv_adma_cpb *cpb = &pp->cpb[qc->tag];
+       struct nv_adma_cpb *cpb = &pp->cpb[qc->hw_tag];
        u8 ctl_flags = NV_CPB_CTL_CPB_VALID |
                       NV_CPB_CTL_IEN;
 
@@ -1389,7 +1389,7 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
        wmb();
 
        cpb->len                = 3;
-       cpb->tag                = qc->tag;
+       cpb->tag                = qc->hw_tag;
        cpb->next_cpb_idx       = 0;
 
        /* turn on NCQ flags for NCQ commands */
@@ -1452,9 +1452,9 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc)
                pp->last_issue_ncq = curr_ncq;
        }
 
-       writew(qc->tag, mmio + NV_ADMA_APPEND);
+       writew(qc->hw_tag, mmio + NV_ADMA_APPEND);
 
-       DPRINTK("Issued tag %u\n", qc->tag);
+       DPRINTK("Issued tag %u\n", qc->hw_tag);
 
        return 0;
 }
@@ -1716,8 +1716,8 @@ static void nv_swncq_qc_to_dq(struct ata_port *ap, struct ata_queued_cmd *qc)
 
        /* queue is full */
        WARN_ON(dq->tail - dq->head == ATA_MAX_QUEUE);
-       dq->defer_bits |= (1 << qc->tag);
-       dq->tag[dq->tail++ & (ATA_MAX_QUEUE - 1)] = qc->tag;
+       dq->defer_bits |= (1 << qc->hw_tag);
+       dq->tag[dq->tail++ & (ATA_MAX_QUEUE - 1)] = qc->hw_tag;
 }
 
 static struct ata_queued_cmd *nv_swncq_qc_from_dq(struct ata_port *ap)
@@ -1996,7 +1996,7 @@ static void nv_swncq_fill_sg(struct ata_queued_cmd *qc)
        struct ata_bmdma_prd *prd;
        unsigned int si, idx;
 
-       prd = pp->prd + ATA_MAX_PRD * qc->tag;
+       prd = pp->prd + ATA_MAX_PRD * qc->hw_tag;
 
        idx = 0;
        for_each_sg(qc->sg, sg, qc->n_elem, si) {
@@ -2034,16 +2034,16 @@ static unsigned int nv_swncq_issue_atacmd(struct ata_port *ap,
 
        DPRINTK("Enter\n");
 
-       writel((1 << qc->tag), pp->sactive_block);
-       pp->last_issue_tag = qc->tag;
-       pp->dhfis_bits &= ~(1 << qc->tag);
-       pp->dmafis_bits &= ~(1 << qc->tag);
-       pp->qc_active |= (0x1 << qc->tag);
+       writel((1 << qc->hw_tag), pp->sactive_block);
+       pp->last_issue_tag = qc->hw_tag;
+       pp->dhfis_bits &= ~(1 << qc->hw_tag);
+       pp->dmafis_bits &= ~(1 << qc->hw_tag);
+       pp->qc_active |= (0x1 << qc->hw_tag);
 
        ap->ops->sff_tf_load(ap, &qc->tf);       /* load tf registers */
        ap->ops->sff_exec_command(ap, &qc->tf);
 
-       DPRINTK("Issued tag %u\n", qc->tag);
+       DPRINTK("Issued tag %u\n", qc->hw_tag);
 
        return 0;
 }
@@ -2193,7 +2193,7 @@ static void nv_swncq_dmafis(struct ata_port *ap)
        rw = qc->tf.flags & ATA_TFLAG_WRITE;
 
        /* load PRD table addr. */
-       iowrite32(pp->prd_dma + ATA_PRD_TBL_SZ * qc->tag,
+       iowrite32(pp->prd_dma + ATA_PRD_TBL_SZ * qc->hw_tag,
                  ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
 
        /* specify data direction, triple-check start bit is clear */
index 4b1995e..227e635 100644 (file)
@@ -849,7 +849,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
        struct sil24_sge *sge;
        u16 ctrl = 0;
 
-       cb = &pp->cmd_block[sil24_tag(qc->tag)];
+       cb = &pp->cmd_block[sil24_tag(qc->hw_tag)];
 
        if (!ata_is_atapi(qc->tf.protocol)) {
                prb = &cb->ata.prb;
@@ -891,7 +891,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
        struct sil24_port_priv *pp = ap->private_data;
        void __iomem *port = sil24_port_base(ap);
-       unsigned int tag = sil24_tag(qc->tag);
+       unsigned int tag = sil24_tag(qc->hw_tag);
        dma_addr_t paddr;
        void __iomem *activate;
 
@@ -911,7 +911,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
 
 static bool sil24_qc_fill_rtf(struct ata_queued_cmd *qc)
 {
-       sil24_read_tf(qc->ap, qc->tag, &qc->result_tf);
+       sil24_read_tf(qc->ap, qc->hw_tag, &qc->result_tf);
        return true;
 }