aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_nv.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-05 02:43:11 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:14 -0500
commitff2aeb1eb64c8a4770a6304f9addbae9f9828646 (patch)
treec6febbec290ec6c40bf3abc7bcdb7188f5039443 /drivers/ata/sata_nv.c
parentf92a26365a72333f418abe82700c6030d4a1a807 (diff)
libata: convert to chained sg
libata used private sg iterator to handle padding sg. Now that sg can be chained, padding can be handled using standard sg ops. Convert to chained sg. * s/qc->__sg/qc->sg/ * s/qc->pad_sgent/qc->extra_sg[]/. Because chaining consumes one sg entry. There need to be two extra sg entries. The renaming is also for future addition of other extra sg entries. * Padding setup is moved into ata_sg_setup_extra() which is organized in a way that future addition of other extra sg entries is easy. * qc->orig_n_elem is unused and removed. * qc->n_elem now contains the number of sg entries that LLDs should map. qc->mapped_n_elem is added to carry the original number of mapped sgs for unmapping. * The last sg of the original sg list is used to chain to extra sg list. The original last sg is pointed to by qc->last_sg and the content is stored in qc->saved_last_sg. It's restored during ata_sg_clean(). * All sg walking code has been updated. Unnecessary assertions and checks for conditions the core layer already guarantees are removed. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_nv.c')
-rw-r--r--drivers/ata/sata_nv.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index ed5dc7cb50cd..a0f98fdab7a0 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1336,21 +1336,18 @@ static void nv_adma_fill_aprd(struct ata_queued_cmd *qc,
1336static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) 1336static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb)
1337{ 1337{
1338 struct nv_adma_port_priv *pp = qc->ap->private_data; 1338 struct nv_adma_port_priv *pp = qc->ap->private_data;
1339 unsigned int idx;
1340 struct nv_adma_prd *aprd; 1339 struct nv_adma_prd *aprd;
1341 struct scatterlist *sg; 1340 struct scatterlist *sg;
1341 unsigned int si;
1342 1342
1343 VPRINTK("ENTER\n"); 1343 VPRINTK("ENTER\n");
1344 1344
1345 idx = 0; 1345 for_each_sg(qc->sg, sg, qc->n_elem, si) {
1346 1346 aprd = (si < 5) ? &cpb->aprd[si] :
1347 ata_for_each_sg(sg, qc) { 1347 &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (si-5)];
1348 aprd = (idx < 5) ? &cpb->aprd[idx] : 1348 nv_adma_fill_aprd(qc, sg, si, aprd);
1349 &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)];
1350 nv_adma_fill_aprd(qc, sg, idx, aprd);
1351 idx++;
1352 } 1349 }
1353 if (idx > 5) 1350 if (si > 5)
1354 cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag))); 1351 cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag)));
1355 else 1352 else
1356 cpb->next_aprd = cpu_to_le64(0); 1353 cpb->next_aprd = cpu_to_le64(0);
@@ -1995,17 +1992,14 @@ static void nv_swncq_fill_sg(struct ata_queued_cmd *qc)
1995{ 1992{
1996 struct ata_port *ap = qc->ap; 1993 struct ata_port *ap = qc->ap;
1997 struct scatterlist *sg; 1994 struct scatterlist *sg;
1998 unsigned int idx;
1999 struct nv_swncq_port_priv *pp = ap->private_data; 1995 struct nv_swncq_port_priv *pp = ap->private_data;
2000 struct ata_prd *prd; 1996 struct ata_prd *prd;
2001 1997 unsigned int si, idx;
2002 WARN_ON(qc->__sg == NULL);
2003 WARN_ON(qc->n_elem == 0 && qc->pad_len == 0);
2004 1998
2005 prd = pp->prd + ATA_MAX_PRD * qc->tag; 1999 prd = pp->prd + ATA_MAX_PRD * qc->tag;
2006 2000
2007 idx = 0; 2001 idx = 0;
2008 ata_for_each_sg(sg, qc) { 2002 for_each_sg(qc->sg, sg, qc->n_elem, si) {
2009 u32 addr, offset; 2003 u32 addr, offset;
2010 u32 sg_len, len; 2004 u32 sg_len, len;
2011 2005
@@ -2027,8 +2021,7 @@ static void nv_swncq_fill_sg(struct ata_queued_cmd *qc)
2027 } 2021 }
2028 } 2022 }
2029 2023
2030 if (idx) 2024 prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
2031 prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
2032} 2025}
2033 2026
2034static unsigned int nv_swncq_issue_atacmd(struct ata_port *ap, 2027static unsigned int nv_swncq_issue_atacmd(struct ata_port *ap,