Message ID | 1406693390-31849-1-git-send-email-zhaowei.yuan@samsung.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Hi Zhaowei, On Wed, Jul 30, 2014 at 9:39 AM, Zhaowei Yuan <zhaowei.yuan@samsung.com> wrote: > Current algorithm relies on the fact that caller will align the > size to PAGE_SIZE, otherwise order will be decreased to negative > when remain size is less than PAGE_SIZE, it makes the function > hard to be migrated. > This patch sloves the hidden problem. > > Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com> > --- > drivers/media/v4l2-core/videobuf2-dma-sg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c > index adefc31..40d18aa 100644 > --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c > +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c > @@ -58,7 +58,7 @@ static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf, > > order = get_order(size); > /* Dont over allocate*/ > - if ((PAGE_SIZE << order) > size) > + if (order > 0 && (PAGE_SIZE << order) > size) > order--; If size is not page aligned, then wouldn't decrementing the order under-allocate the memory?
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index adefc31..40d18aa 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -58,7 +58,7 @@ static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf, order = get_order(size); /* Dont over allocate*/ - if ((PAGE_SIZE << order) > size) + if (order > 0 && (PAGE_SIZE << order) > size) order--; pages = NULL;
Current algorithm relies on the fact that caller will align the size to PAGE_SIZE, otherwise order will be decreased to negative when remain size is less than PAGE_SIZE, it makes the function hard to be migrated. This patch sloves the hidden problem. Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com> --- drivers/media/v4l2-core/videobuf2-dma-sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html