diff options
Diffstat (limited to 'lib/scatterlist.c')
-rw-r--r-- | lib/scatterlist.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index a295e404e908..0d475d8167bf 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c | |||
@@ -314,6 +314,7 @@ void sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl, | |||
314 | miter->__sg = sgl; | 314 | miter->__sg = sgl; |
315 | miter->__nents = nents; | 315 | miter->__nents = nents; |
316 | miter->__offset = 0; | 316 | miter->__offset = 0; |
317 | WARN_ON(!(flags & (SG_MITER_TO_SG | SG_MITER_FROM_SG))); | ||
317 | miter->__flags = flags; | 318 | miter->__flags = flags; |
318 | } | 319 | } |
319 | EXPORT_SYMBOL(sg_miter_start); | 320 | EXPORT_SYMBOL(sg_miter_start); |
@@ -394,6 +395,9 @@ void sg_miter_stop(struct sg_mapping_iter *miter) | |||
394 | if (miter->addr) { | 395 | if (miter->addr) { |
395 | miter->__offset += miter->consumed; | 396 | miter->__offset += miter->consumed; |
396 | 397 | ||
398 | if (miter->__flags & SG_MITER_TO_SG) | ||
399 | flush_kernel_dcache_page(miter->page); | ||
400 | |||
397 | if (miter->__flags & SG_MITER_ATOMIC) { | 401 | if (miter->__flags & SG_MITER_ATOMIC) { |
398 | WARN_ON(!irqs_disabled()); | 402 | WARN_ON(!irqs_disabled()); |
399 | kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ); | 403 | kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ); |
@@ -426,8 +430,14 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, | |||
426 | unsigned int offset = 0; | 430 | unsigned int offset = 0; |
427 | struct sg_mapping_iter miter; | 431 | struct sg_mapping_iter miter; |
428 | unsigned long flags; | 432 | unsigned long flags; |
433 | unsigned int sg_flags = SG_MITER_ATOMIC; | ||
434 | |||
435 | if (to_buffer) | ||
436 | sg_flags |= SG_MITER_FROM_SG; | ||
437 | else | ||
438 | sg_flags |= SG_MITER_TO_SG; | ||
429 | 439 | ||
430 | sg_miter_start(&miter, sgl, nents, SG_MITER_ATOMIC); | 440 | sg_miter_start(&miter, sgl, nents, sg_flags); |
431 | 441 | ||
432 | local_irq_save(flags); | 442 | local_irq_save(flags); |
433 | 443 | ||
@@ -438,10 +448,8 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, | |||
438 | 448 | ||
439 | if (to_buffer) | 449 | if (to_buffer) |
440 | memcpy(buf + offset, miter.addr, len); | 450 | memcpy(buf + offset, miter.addr, len); |
441 | else { | 451 | else |
442 | memcpy(miter.addr, buf + offset, len); | 452 | memcpy(miter.addr, buf + offset, len); |
443 | flush_kernel_dcache_page(miter.page); | ||
444 | } | ||
445 | 453 | ||
446 | offset += len; | 454 | offset += len; |
447 | } | 455 | } |