From patchwork Fri Jul 12 06:12:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 2826805 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F343DC0AB2 for ; Fri, 12 Jul 2013 06:12:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16E472012D for ; Fri, 12 Jul 2013 06:12:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3E8520136 for ; Fri, 12 Jul 2013 06:12:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908Ab3GLGM5 (ORCPT ); Fri, 12 Jul 2013 02:12:57 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:63275 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752418Ab3GLGMz (ORCPT ); Fri, 12 Jul 2013 02:12:55 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPT007OJ7XGWKQ0@mailout3.samsung.com>; Fri, 12 Jul 2013 15:12:52 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.116]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 2D.3D.08825.46E9FD15; Fri, 12 Jul 2013 15:12:52 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-0c-51df9e64e5f8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 2C.EB.21068.46E9FD15; Fri, 12 Jul 2013 15:12:52 +0900 (KST) Received: from localhost.localdomain ([10.252.81.149]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MPT008WA7XDQH20@mmp2.samsung.com>; Fri, 12 Jul 2013 15:12:52 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: maarten.lankhorst@canonical.com, daniel@ffwll.ch, robdclark@gmail.com, sumit.semwal@linaro.org, linux@arm.linux.org.uk, kyungmin.park@samsung.com, myungjoo.ham@samsung.com, yj44.cho@samsung.com, Inki Dae Subject: [RFC PATCH v1 2/2] dma-buf: add lock callback for fcntl system call Date: Fri, 12 Jul 2013 15:12:46 +0900 Message-id: <1373609566-10784-3-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1373609566-10784-1-git-send-email-inki.dae@samsung.com> References: <1373609566-10784-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsWyRsSkRDdl3v1Ag5k7DCz+b5vIbHHl63s2 i0n3J7BYnG16w26x6fE1VosTfR9YLXo2bGW1uH2Z1+Lp0wtsFrcbV7BZPF/4g9ni1N3P7BZ7 d05mdOD1aGnuYfOY1dDL5rH32wIWj52z7rJ73Lm2h83jfvdxJo/NS+o9+rasYvT4vEkugDOK yyYlNSezLLVI3y6BK+Pl6lNsBbt4K86v+cPUwPiJq4uRk0NCwETi1MqtbBC2mMSFe+uBbC4O IYGljBL3Oh6ywRQde9zIDJGYzigxpe8olNPGJPGz9zJYFZuAqsTEFffB2kUEWhkldj/YxgLi MAu8YpTY1T+JCaRKWMBH4mfDJnYQmwWoo+34BEYQm1fARWLO427WLkYOoH0KEnMm2YCEOQVc JW4vXcgKYgsBlXyaMQ9spoTAW3aJi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Z6KiJzFKiyfnAJJJXEm9obGJmZGlkbmhhZGxOmrCSOO/BVutAIYH0xJLU7NTU gtQimC1MHJxSDYyWN2/4Z/MeNHX/fk7hYnTmn7URihd530jXzzVTWN4uoGWy+tze908WbBCp vmXVyP6ZZ+2d8jKtK+v5V3Ft5OfbF2ZfmO+klsOutNdtopey2JbM/268dnttfdf7OfzYeUzr Kvcm/pAz70XP7/khxxvptF1PY9ZCrrIFl+em7TNRq5zQ73DDOFyJpTgj0VCLuag4EQDNVQ2H GAMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch adds lock callback to dma buf file operations, and this callback will be called by fcntl system call. With this patch, fcntl system call can be used for buffer synchronization between CPU and CPU, and CPU and DMA in user mode. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/base/dma-buf.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 9a26981..e1b8583 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -80,9 +80,42 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) return dmabuf->ops->mmap(dmabuf, vma); } +static int dma_buf_lock(struct file *file, int cmd, struct file_lock *fl) +{ + struct dma_buf *dmabuf; + unsigned int type; + bool wait = false; + + if (!is_dma_buf_file(file)) + return -EINVAL; + + dmabuf = file->private_data; + + if ((fl->fl_type & F_UNLCK) == F_UNLCK) { + dmabuf_sync_single_unlock(dmabuf); + return 0; + } + + /* convert flock type to dmabuf sync type. */ + if ((fl->fl_type & F_WRLCK) == F_WRLCK) + type = DMA_BUF_ACCESS_W; + else if ((fl->fl_type & F_RDLCK) == F_RDLCK) + type = DMA_BUF_ACCESS_R; + else + return -EINVAL; + + if (fl->fl_flags & FL_SLEEP) + wait = true; + + /* TODO. the locking to certain region should also be considered. */ + + return dmabuf_sync_single_lock(dmabuf, type, wait); +} + static const struct file_operations dma_buf_fops = { .release = dma_buf_release, .mmap = dma_buf_mmap_internal, + .lock = dma_buf_lock, }; /*