linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: v4l2: make alloction alogthim more robust and flexible
@ 2014-07-30  3:55 Zhaowei Yuan
  2014-07-30 14:07 ` Andreas Färber
  2014-11-11 11:13 ` Sakari Ailus
  0 siblings, 2 replies; 3+ messages in thread
From: Zhaowei Yuan @ 2014-07-30  3:55 UTC (permalink / raw)
  To: linux-media, k.debski, kyungmin.park, jtp.park
  Cc: linux-samsung-soc, m.chehab

Current algothim 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--;

 		pages = NULL;
--
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: v4l2: make alloction alogthim more robust and flexible
  2014-07-30  3:55 [PATCH] media: v4l2: make alloction alogthim more robust and flexible Zhaowei Yuan
@ 2014-07-30 14:07 ` Andreas Färber
  2014-11-11 11:13 ` Sakari Ailus
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2014-07-30 14:07 UTC (permalink / raw)
  To: Zhaowei Yuan, linux-media, k.debski, kyungmin.park, jtp.park
  Cc: linux-samsung-soc, m.chehab

Hi,

A few trivial typos:

s/alloction/allocation/

s/alogthim/algorithm/

Am 30.07.2014 05:55, schrieb Zhaowei Yuan:
> Current algothim relies on the fact that caller will align the

s/algothim/algorithm/

> size to PAGE_SIZE, otherwise order will be decreased to negative
> when remain size is less than PAGE_SIZE, it makes the function

s/remain/remaining/

> hard to be migrated.
> This patch sloves the hidden problem.

s/sloves/solves/

> 
> Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: v4l2: make alloction alogthim more robust and flexible
  2014-07-30  3:55 [PATCH] media: v4l2: make alloction alogthim more robust and flexible Zhaowei Yuan
  2014-07-30 14:07 ` Andreas Färber
@ 2014-11-11 11:13 ` Sakari Ailus
  1 sibling, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2014-11-11 11:13 UTC (permalink / raw)
  To: Zhaowei Yuan
  Cc: linux-media, k.debski, kyungmin.park, jtp.park, linux-samsung-soc,
	m.chehab

Hi Zhaowei,

My apologies for the delayed reply.

On Wed, Jul 30, 2014 at 11:55:32AM +0800, Zhaowei Yuan wrote:
> Current algothim 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--;
> 
>  		pages = NULL;

With comments from Andreas taken into account,

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

I'd consider this for the stable series as well.

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-11 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30  3:55 [PATCH] media: v4l2: make alloction alogthim more robust and flexible Zhaowei Yuan
2014-07-30 14:07 ` Andreas Färber
2014-11-11 11:13 ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).