From patchwork Sun Mar 23 05:44:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 3878791 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 536549F2E8 for ; Sun, 23 Mar 2014 05:45:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EFDB202F0 for ; Sun, 23 Mar 2014 05:45:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 412B920220 for ; Sun, 23 Mar 2014 05:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750850AbaCWFoY (ORCPT ); Sun, 23 Mar 2014 01:44:24 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:37130 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbaCWFoX (ORCPT ); Sun, 23 Mar 2014 01:44:23 -0400 Received: by mail-pa0-f42.google.com with SMTP id fb1so4089622pad.15 for ; Sat, 22 Mar 2014 22:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ej2kHMQOshsUcEOa/ulVdVHD5JapATToMw/DfkM/V6c=; b=u7dQeftN+BTgOXb12a522aBv3bx8HYKxij1hiCJqO3T0X6OnnuhzLqMZUC++pS7FPz ia/1jIP+pI6LCJQQtzWP5ey+2lgslkiQ0zUOdP1kcMrvOQ0w39+IA8qhKlnM2uJe2185 Z/XQfVv1MLc+tDYvnaOHPz9bVBXA7JD8pLhAyAAFbXKaiHRc3qHoq+cpfdWKQOHdcTxE DT426z54Jx6ucqYZhw26I+JAxbXeU7xdxsfdywRRRLH0dZatHwcCfGmzW1KJr0CxhEmY V/Ay+r1uZ3dGIhd+0SfBvXkX9J8ZlRbcjP33wS+7LfYMPDz8IHsbk7ZJgJtINfFvoFw0 MABg== X-Received: by 10.68.237.228 with SMTP id vf4mr964862pbc.131.1395553462730; Sat, 22 Mar 2014 22:44:22 -0700 (PDT) Received: from localhost.localdomain ([115.117.231.180]) by mx.google.com with ESMTPSA id iv2sm18951471pbc.19.2014.03.22.22.44.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 22 Mar 2014 22:44:21 -0700 (PDT) From: "Lad, Prabhakar" To: LMML Cc: LKML , Mauro Carvalho Chehab , Lad Prabhakar , DLOS Subject: [PATCH for v3.15] media: davinci: vpfe: make sure all the buffers unmapped and released Date: Sun, 23 Mar 2014 11:14:11 +0530 Message-Id: <1395553451-21249-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Lad, Prabhakar" this patch makes sure that it terminates if any IO in progress and also makes sure that all the buffers are unmapped. It was observed that with several runs of application the application sometimes failed to allocate memory, This patch makes sure it all the buffers are released. Using kmemleak it was found that buffer were not released, this patch fixes following issue, echo scan > /sys/kernel/debug/kmemleak Kernel message reads: memleak: 3 new suspected memory leaks (see /sys/kernel/debug/kmemleak) Then, cat /sys/kernel/debug/kmemleak unreferenced object 0xc564a480 (size 192): comm "mttest", pid 764, jiffies 4294945878 (age 487.160s) hex dump (first 32 bytes): 00 00 00 00 28 07 07 20 d0 02 00 00 e0 01 00 00 ....(.. ........ 00 00 00 00 00 64 05 00 01 00 00 00 01 00 00 00 .....d.......... backtrace: [] create_object+0x10c/0x28c [] kmemleak_alloc+0x3c/0x70 [] __kmalloc+0x11c/0x1d4 [] __videobuf_alloc+0x1c/0x3c [] videobuf_alloc_vb+0x38/0x80 [] __videobuf_mmap_setup+0x9c/0x108 [] videobuf_reqbufs.part.10+0x12c/0x1bc [] videobuf_reqbufs+0x6c/0x8c [] vpfe_reqbufs+0xcc/0x130 [] v4l_reqbufs+0x50/0x54 [] __video_do_ioctl+0x260/0x2c4 [] video_usercopy+0xf0/0x310 [] video_ioctl2+0x14/0x1c [] v4l2_ioctl+0x104/0x14c [] do_vfs_ioctl+0x80/0x2d0 [] SyS_ioctl+0x44/0x64 unreferenced object 0xc564ac00 (size 192): comm "mttest", pid 764, jiffies 4294945878 (age 487.160s) hex dump (first 32 bytes): 01 00 00 00 28 07 07 20 d0 02 00 00 e0 01 00 00 ....(.. ........ 00 00 00 00 00 64 05 00 01 00 00 00 01 00 00 00 .....d.......... backtrace: [] create_object+0x10c/0x28c [] kmemleak_alloc+0x3c/0x70 [] __kmalloc+0x11c/0x1d4 [] __videobuf_alloc+0x1c/0x3c [] videobuf_alloc_vb+0x38/0x80 [] __videobuf_mmap_setup+0x9c/0x108 [] videobuf_reqbufs.part.10+0x12c/0x1bc [] videobuf_reqbufs+0x6c/0x8c [] vpfe_reqbufs+0xcc/0x130 [] v4l_reqbufs+0x50/0x54 [] __video_do_ioctl+0x260/0x2c4 [] video_usercopy+0xf0/0x310 [] video_ioctl2+0x14/0x1c [] v4l2_ioctl+0x104/0x14c [] do_vfs_ioctl+0x80/0x2d0 [] SyS_ioctl+0x44/0x64 unreferenced object 0xc564a180 (size 192): comm "mttest", pid 764, jiffies 4294945880 (age 487.140s) hex dump (first 32 bytes): 02 00 00 00 28 07 07 20 d0 02 00 00 e0 01 00 00 ....(.. ........ 00 00 00 00 00 64 05 00 01 00 00 00 01 00 00 00 .....d.......... backtrace: [] create_object+0x10c/0x28c [] kmemleak_alloc+0x3c/0x70 [] __kmalloc+0x11c/0x1d4 [] __videobuf_alloc+0x1c/0x3c [] videobuf_alloc_vb+0x38/0x80 [] __videobuf_mmap_setup+0x9c/0x108 [] videobuf_reqbufs.part.10+0x12c/0x1bc [] videobuf_reqbufs+0x6c/0x8c [] vpfe_reqbufs+0xcc/0x130 [] v4l_reqbufs+0x50/0x54 [] __video_do_ioctl+0x260/0x2c4 [] video_usercopy+0xf0/0x310 [] video_ioctl2+0x14/0x1c [] v4l2_ioctl+0x104/0x14c [] do_vfs_ioctl+0x80/0x2d0 [] SyS_ioctl+0x44/0x64 Reported-by: Jimmy Ho Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpfe_capture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 9474f4a..ac6c8c6 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -734,6 +734,8 @@ static int vpfe_release(struct file *file) } vpfe_dev->io_usrs = 0; vpfe_dev->numbuffers = config_params.numbuffers; + videobuf_stop(&vpfe_dev->buffer_queue); + videobuf_mmap_free(&vpfe_dev->buffer_queue); } /* Decrement device usrs counter */