rk: ion: assign sg's dma_length in ion allocation if CONFIG_NEED_SG_DMA_LENGTH is set
authorCMY <cmy@rock-chips.com>
Sat, 14 Feb 2015 10:05:01 +0000 (18:05 +0800)
committerCMY <cmy@rock-chips.com>
Wed, 4 Mar 2015 02:39:17 +0000 (10:39 +0800)
(cherry picked from commit c85ce1ade533fe0d02b7539dbe85d55b69386125)

Signed-off-by: CMY <cmy@rock-chips.com>
drivers/staging/android/ion/ion.c

index c808d9fe51e83149206bf098dab22aab12c8a83f..3a97ad0367bbf9a9cfef87ca63bfcd441df5c9f7 100755 (executable)
@@ -265,8 +265,12 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
           allocation via dma_map_sg. The implicit contract here is that
           memory comming from the heaps is ready for dma, ie if it has a
           cached mapping that mapping has been invalidated */
-       for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
+       for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) {
                sg_dma_address(sg) = sg_phys(sg);
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+               sg_dma_len(sg) = sg->length;
+#endif
+       }
        mutex_lock(&dev->buffer_lock);
        ion_buffer_add(dev, buffer);
        mutex_unlock(&dev->buffer_lock);