From patchwork Wed Aug 1 14:27:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Gershgorin X-Patchwork-Id: 1264391 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4D695DF215 for ; Wed, 1 Aug 2012 14:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754703Ab2HAO1S (ORCPT ); Wed, 1 Aug 2012 10:27:18 -0400 Received: from ftp.meprolight.com ([194.90.149.17]:37015 "EHLO meprolight.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752421Ab2HAO1S convert rfc822-to-8bit (ORCPT ); Wed, 1 Aug 2012 10:27:18 -0400 Received: from Internal Mail-Server by Mail-SeCure (envelope-from alexg@meprolight.com) with RC4-MD5 encrypted SMTP; 1 Aug 2012 16:19:07 +0000 Received: from MEP-EXCH.meprolight.com ([192.168.111.10]) by MEP-EXCH.meprolight.com ([192.168.111.10]) with mapi; Wed, 1 Aug 2012 17:27:24 +0300 From: Alex Gershgorin To: Guennadi Liakhovetski CC: Mauro Carvalho Chehab , "laurent.pinchart@ideasonboard.com" , "m.szyprowski@samsung.com" , "linux-media@vger.kernel.org" Date: Wed, 1 Aug 2012 17:27:24 +0300 Subject: RE: [PATCH v2] media: mx3_camera: buf_init() add buffer state check Thread-Topic: [PATCH v2] media: mx3_camera: buf_init() add buffer state check Thread-Index: Ac1vvG6h/IpoSqhHRsyfz8KB+9YMLQAMZZOe Message-ID: <4875438356E7CA4A8F2145FCD3E61C0B2E31A0CA1D@MEP-EXCH.meprolight.com> References: <1343675227-9061-1-git-send-email-alexg@meprolight.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Alex Gershgorin This patch check the state of the buffer when calling buf_init() method. The thread http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/48587 also includes report witch can show the problem. This patch solved the problem. Both MMAP and USERPTR methods was successfully tested. Signed-off-by: Alex Gershgorin [g.liakhovetski@gmx.de: remove mx3_camera_buffer::state completely] Signed-off-by: Guennadi Liakhovetski --- > > Hi Alex > > Thanks for your explanation. Please, check whether this version of your > > patch also fixes the problem and works in both MMAP and USERPTR modes. > > Thanks > > Guennadi Hi Guennadi, This is a good upgrade :-) I tested both modes, it works fine without any problems. Sincerely, Alex 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 --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index 02d54a0..0af24d0 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c @@ -61,15 +61,9 @@ #define MAX_VIDEO_MEM 16 -enum csi_buffer_state { - CSI_BUF_NEEDS_INIT, - CSI_BUF_PREPARED, -}; - struct mx3_camera_buffer { /* common v4l buffer stuff -- must be first */ struct vb2_buffer vb; - enum csi_buffer_state state; struct list_head queue; /* One descriptot per scatterlist (per frame) */ @@ -285,7 +279,7 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb) goto error; } - if (buf->state == CSI_BUF_NEEDS_INIT) { + if (!buf->txd) { sg_dma_address(sg) = vb2_dma_contig_plane_dma_addr(vb, 0); sg_dma_len(sg) = new_size; @@ -298,7 +292,6 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb) txd->callback_param = txd; txd->callback = mx3_cam_dma_done; - buf->state = CSI_BUF_PREPARED; buf->txd = txd; } else { txd = buf->txd; @@ -385,7 +378,6 @@ static void mx3_videobuf_release(struct vb2_buffer *vb) /* Doesn't hurt also if the list is empty */ list_del_init(&buf->queue); - buf->state = CSI_BUF_NEEDS_INIT; if (txd) { buf->txd = NULL; @@ -405,13 +397,13 @@ static int mx3_videobuf_init(struct vb2_buffer *vb) struct mx3_camera_dev *mx3_cam = ici->priv; struct mx3_camera_buffer *buf = to_mx3_vb(vb); - /* This is for locking debugging only */ - INIT_LIST_HEAD(&buf->queue); - sg_init_table(&buf->sg, 1); + if (!buf->txd) { + /* This is for locking debugging only */ + INIT_LIST_HEAD(&buf->queue); + sg_init_table(&buf->sg, 1); - buf->state = CSI_BUF_NEEDS_INIT; - - mx3_cam->buf_total += vb2_plane_size(vb, 0); + mx3_cam->buf_total += vb2_plane_size(vb, 0); + } return 0; }--