diff options
author | Tejun Heo <htejun@gmail.com> | 2005-11-05 14:29:01 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-05 14:29:01 -0500 |
commit | 537a95d9351f41cc3c24ddb2a646aedd6debb21b (patch) | |
tree | e3bd5b05c2d396db3eb59997d3cc1b9e54df0ba6 | |
parent | fecb4a0c87c2bcaee1f3cf800126eef752a07ed3 (diff) |
[libata] restore sg on DMA mapping failure
-rw-r--r-- | drivers/scsi/libata-core.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index e1346cddd37..1c1a7caf785 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -2622,8 +2622,11 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2622 | 2622 | ||
2623 | dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, | 2623 | dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, |
2624 | sg->length, dir); | 2624 | sg->length, dir); |
2625 | if (dma_mapping_error(dma_address)) | 2625 | if (dma_mapping_error(dma_address)) { |
2626 | /* restore sg */ | ||
2627 | sg->length += qc->pad_len; | ||
2626 | return -1; | 2628 | return -1; |
2629 | } | ||
2627 | 2630 | ||
2628 | sg_dma_address(sg) = dma_address; | 2631 | sg_dma_address(sg) = dma_address; |
2629 | sg_dma_len(sg) = sg->length; | 2632 | sg_dma_len(sg) = sg->length; |
@@ -2694,8 +2697,11 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2694 | 2697 | ||
2695 | dir = qc->dma_dir; | 2698 | dir = qc->dma_dir; |
2696 | n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); | 2699 | n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); |
2697 | if (n_elem < 1) | 2700 | if (n_elem < 1) { |
2701 | /* restore last sg */ | ||
2702 | lsg->length += qc->pad_len; | ||
2698 | return -1; | 2703 | return -1; |
2704 | } | ||
2699 | 2705 | ||
2700 | DPRINTK("%d sg elements mapped\n", n_elem); | 2706 | DPRINTK("%d sg elements mapped\n", n_elem); |
2701 | 2707 | ||