From patchwork Mon May 6 22:28:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Fischer X-Patchwork-Id: 2526541 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork2.kernel.org (Postfix) with ESMTP id E8FB2DF230 for ; Mon, 6 May 2013 22:30:57 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r46MSgFJ004469; Mon, 6 May 2013 17:28:43 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r46MSgti008348; Mon, 6 May 2013 17:28:42 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Mon, 6 May 2013 17:28:42 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r46MSfpb022551; Mon, 6 May 2013 17:28:41 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id DBB1B80627; Mon, 6 May 2013 17:28:41 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 6E9CB80626 for ; Mon, 6 May 2013 17:28:40 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r46MSebk007014 for ; Mon, 6 May 2013 17:28:40 -0500 (CDT) Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r46MSdKQ028886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 May 2013 17:28:39 -0500 Received: from [216.82.242.147:7273] by server-14.bemta-8.messagelabs.com id B7/C1-19972-79E28815; Mon, 06 May 2013 22:28:39 +0000 X-Env-Sender: todd.fischer@ridgerun.com X-Msg-Ref: server-3.tower-95.messagelabs.com!1367879317!24021156!1 X-Originating-IP: [209.85.160.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25105 invoked from network); 6 May 2013 22:28:38 -0000 Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by server-3.tower-95.messagelabs.com with RC4-SHA encrypted SMTP; 6 May 2013 22:28:38 -0000 Received: by mail-pb0-f47.google.com with SMTP id uo1so2219204pbc.20 for ; Mon, 06 May 2013 15:28:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=DSc38twmlFhYTeFXOuxu6ZEUQlHE2nsnDtzQF9BzyIY=; b=YPfV9ze4RfUoZWZapv2WvSiuy90fDI1utL1yq6Qr6lHI2uGdHwq7wFNoI5R9ZPUVEJ VEjnwYVjAbs1GvBmnmuGgan4Rn2T8NRAr6chB55GhO3u0VoEYmo+gtxqlM4K+XSBvSwe vA+DfkHxwnix/hvS/fqoZJ2xOxsEGyRPkH2hdfKvbMp/1P3PmNoNdHTJQdN1Olc4ah5o 4R2+ZmZWbEsTyMWw/byeinF5srdrfw1gqDAuAQLNqTj4q5Jd8RcBQI9bg8zxKB/p+o2A pWmW4N/QZk9FZ51+/3T/KD68fecsYBtVh9uGuM6ekkqzcWUQX80zNLdCNn8wYiFDFGb9 Ur6g== X-Received: by 10.68.107.164 with SMTP id hd4mr9633870pbb.161.1367879317410; Mon, 06 May 2013 15:28:37 -0700 (PDT) Received: from [10.111.0.4] (fischerfamily.org. [71.216.156.246]) by mx.google.com with ESMTPSA id xl10sm27396984pac.15.2013.05.06.15.28.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 15:28:36 -0700 (PDT) Message-ID: <51882E90.3020803@ridgerun.com> Date: Mon, 6 May 2013 16:28:32 -0600 From: Todd Fischer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Davinci Linux Subject: video processing front end mutex usage and parameter passing X-Gm-Message-State: ALoCoQluHbeO+KHE8Oc/sL59dxgQvkae7mQDL7sk8obfVR3G8dfnLPucAS2Ov4vVlp8uoKHe9Ytl X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Hi, In reviewing vpfe_capture.c, we are seeing some code that seems wrong. We don't fully understand when the VPFE device lock needs to be held, but it seems the lock is not used consistently. Also in some cases we found a pointer to a structure was passed in as a parameter and instead of accessing the contents of the structure the value of the pointer parameter that is local to the function was modified (effectively doing nothing). The code has been in the kernel for 3+ years. Below is an example of what we think needs to be changed. We haven't tested the changes as we are still trying to verify the mutex usage. Can someone familiar with the VPFE code give us some feedback if we are on the right track? Todd @@ -1001,7 +1003,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv, /* First detach any IRQ if currently attached */ vpfe_detach_irq(vpfe_dev); - vpfe_dev->fmt = *fmt; + memcpy(vpfe_dev->fmt, fmt, sizeof(struct v4l2_format)); /* set image capture parameters in the ccdc */ ret = vpfe_config_ccdc_image_format(vpfe_dev); mutex_unlock(&vpfe_dev->lock); diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 28d019d..dc050b5 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -945,7 +945,9 @@ static int vpfe_g_fmt_vid_cap(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n"); /* Fill in the information about format */ - *fmt = vpfe_dev->fmt; + mutex_lock(&vpfe_dev->lock); + memcpy(fmt, vpfe_dev->fmt, sizeof(struct v4l2_format)); + mutex_unlock(&vpfe_dev->lock); return ret; }