提交 5d82720a 编写于 作者: F FUJITA Tomonori 提交者: Bartlomiej Zolnierkiewicz

ide: save the returned value of dma_map_sg

dma_map_sg could return a value different to 'nents' argument of
dma_map_sg so the ide stack needs to save it for the later usage
(e.g. for_each_sg).

The ide stack also needs to save the original sg_nents value for
pci_unmap_sg.
Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
[bart: backport to Linus' tree]
Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
上级 3eb76c1c
...@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) ...@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct scatterlist *sg = hwif->sg_table; struct scatterlist *sg = hwif->sg_table;
int i;
ide_map_sg(drive, rq); ide_map_sg(drive, rq);
...@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) ...@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
else else
hwif->sg_dma_direction = DMA_TO_DEVICE; hwif->sg_dma_direction = DMA_TO_DEVICE;
return dma_map_sg(hwif->dev, sg, hwif->sg_nents, i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
hwif->sg_dma_direction); if (i) {
hwif->orig_sg_nents = hwif->sg_nents;
hwif->sg_nents = i;
}
return i;
} }
EXPORT_SYMBOL_GPL(ide_build_sglist); EXPORT_SYMBOL_GPL(ide_build_sglist);
...@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive) ...@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->orig_sg_nents,
hwif->sg_dma_direction); hwif->sg_dma_direction);
} }
EXPORT_SYMBOL_GPL(ide_destroy_dmatable); EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
......
...@@ -797,6 +797,7 @@ typedef struct hwif_s { ...@@ -797,6 +797,7 @@ typedef struct hwif_s {
struct scatterlist *sg_table; struct scatterlist *sg_table;
int sg_max_nents; /* Maximum number of entries in it */ int sg_max_nents; /* Maximum number of entries in it */
int sg_nents; /* Current number of entries in it */ int sg_nents; /* Current number of entries in it */
int orig_sg_nents;
int sg_dma_direction; /* dma transfer direction */ int sg_dma_direction; /* dma transfer direction */
/* data phase of the active command (currently only valid for PIO/DMA) */ /* data phase of the active command (currently only valid for PIO/DMA) */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册