diff mbox

pxa-camera: simplify the .buf_queue path by merging two loops

Message ID Pine.LNX.4.64.0903250935090.5795@axis700.grange (mailing list archive)
State RFC
Headers show

Commit Message

Guennadi Liakhovetski March 25, 2009, 8:37 a.m. UTC
pxa_dma_update_sg_tail() is called only once, runs exactly the same loop as the
caller and has to recalculate the last element in an sg-list, that the caller
has already calculated. Eliminate redundancy by merging the two loops and
re-using the calculated pointer. This also saves a bit of performance which is
always good during video-capture.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

On Mon, 16 Mar 2009, Robert Jarzmik wrote:

> Guennadi Liakhovetski <g.liakhovetski@gmx.de> writes:
> 
> > pxa_dma_update_sg_tail is called only here, why not inline it and also put 
> > inside one loop?
> As for the inline, I'm pretty sure you know it is automatically done by gcc.
> 
> As for moving it inside the loop, that would certainly improve performance. Yet
> I find it more readable/maintainable that way, and will leave it. But I won't be
> bothered at all if you retransform it back to your view, that's up to you.

Robert, this is what I'm going to apply on top of your patch-series. 
Please, object:-)

 drivers/media/video/pxa_camera.c |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)

Comments

Robert Jarzmik March 25, 2009, 8:40 p.m. UTC | #1
Guennadi Liakhovetski <g.liakhovetski@gmx.de> writes:

> pxa_dma_update_sg_tail() is called only once, runs exactly the same loop as the
> caller and has to recalculate the last element in an sg-list, that the caller
> has already calculated. Eliminate redundancy by merging the two loops and
> re-using the calculated pointer. This also saves a bit of performance which is
> always good during video-capture.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>
> On Mon, 16 Mar 2009, Robert Jarzmik wrote:
>
>> Guennadi Liakhovetski <g.liakhovetski@gmx.de> writes:
>> 
>> > pxa_dma_update_sg_tail is called only here, why not inline it and also put 
>> > inside one loop?
>> As for the inline, I'm pretty sure you know it is automatically done by gcc.
>> 
>> As for moving it inside the loop, that would certainly improve performance. Yet
>> I find it more readable/maintainable that way, and will leave it. But I won't be
>> bothered at all if you retransform it back to your view, that's up to you.
>
> Robert, this is what I'm going to apply on top of your patch-series. 
> Please, object:-)
Here you are : :)
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

--
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index cfa113c..c639845 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -566,15 +566,6 @@  static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
 	}
 }
 
-static void pxa_dma_update_sg_tail(struct pxa_camera_dev *pcdev,
-				   struct pxa_buffer *buf)
-{
-	int i;
-
-	for (i = 0; i < pcdev->channels; i++)
-		pcdev->sg_tail[i] = buf->dmas[i].sg_cpu + buf->dmas[i].sglen;
-}
-
 static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
 				 struct pxa_buffer *buf)
 {
@@ -585,12 +576,13 @@  static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
 		buf_last_desc = buf->dmas[i].sg_cpu + buf->dmas[i].sglen;
 		buf_last_desc->ddadr = DDADR_STOP;
 
-		if (!pcdev->sg_tail[i])
-			continue;
-		pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma;
-	}
+		if (pcdev->sg_tail[i])
+			/* Link the new buffer to the old tail */
+			pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma;
 
-	pxa_dma_update_sg_tail(pcdev, buf);
+		/* Update the channel tail */
+		pcdev->sg_tail[i] = buf_last_desc;
+	}
 }
 
 /**