From patchwork Wed Mar 25 08:37:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 14258 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2P8bf8f027184 for ; Wed, 25 Mar 2009 08:37:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbZCYIhS (ORCPT ); Wed, 25 Mar 2009 04:37:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751862AbZCYIhS (ORCPT ); Wed, 25 Mar 2009 04:37:18 -0400 Received: from mail.gmx.net ([213.165.64.20]:56269 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752649AbZCYIhP (ORCPT ); Wed, 25 Mar 2009 04:37:15 -0400 Received: (qmail invoked by alias); 25 Mar 2009 08:37:12 -0000 Received: from p57BD2934.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.41.52] by mail.gmx.net (mp045) with SMTP; 25 Mar 2009 09:37:12 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX19WSRcpdwBW8R90mm4fGClTYwV6aUuVY0Rp6At45h x0Szr8wRypXpHJ Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1LmObr-0001cE-NM; Wed, 25 Mar 2009 09:37:15 +0100 Date: Wed, 25 Mar 2009 09:37:15 +0100 (CET) From: Guennadi Liakhovetski To: Robert Jarzmik cc: Linux Media Mailing List Subject: [PATCH] pxa-camera: simplify the .buf_queue path by merging two loops In-Reply-To: <87hc1tdzv2.fsf@free.fr> Message-ID: References: <1236986240-24115-1-git-send-email-robert.jarzmik@free.fr> <1236986240-24115-2-git-send-email-robert.jarzmik@free.fr> <1236986240-24115-3-git-send-email-robert.jarzmik@free.fr> <1236986240-24115-4-git-send-email-robert.jarzmik@free.fr> <87hc1tdzv2.fsf@free.fr> MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.51 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Acked-by: Robert Jarzmik --- On Mon, 16 Mar 2009, Robert Jarzmik wrote: > Guennadi Liakhovetski 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(-) 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; + } } /**