From patchwork Tue Aug 14 15:34:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 1323581 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 858143FC71 for ; Tue, 14 Aug 2012 21:33:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3712B9F30B for ; Tue, 14 Aug 2012 14:33:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id A67499EB42 for ; Tue, 14 Aug 2012 08:38:02 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M8R00MQW4RD8F20@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 15 Aug 2012 00:38:02 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-06-502a70d9899e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 26.9D.17335.9D07A205; Wed, 15 Aug 2012 00:38:01 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M8R004J44MBC810@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 15 Aug 2012 00:38:01 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCHv8 22/26] media: vb2: fail if user ptr buffer is not correctly aligned Date: Tue, 14 Aug 2012 17:34:52 +0200 Message-id: <1344958496-9373-23-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> References: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd2bBVoBBs++m1pc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujIO73rEXPGWvOP7jDUsD40G2LkZODgkBE4l/q5exQNhiEhfu rQeKc3EICSxilLixfjsThLOOSeL5nWZmkCo2oI5jSz4zgtgiAg4Sp+/OYgYpYhY4xCyxv/c1 O0hCWCBcomd1L1gDi4CqxNfpq8BsXgEPiR0XNzBBrJOXeHq/D+wMTqD4y03dQEM5gLa5Syz8 6T+BkXcBI8MqRtHUguSC4qT0XEO94sTc4tK8dL3k/NxNjGCvP5PawbiyweIQowAHoxIPr0Ka ZoAQa2JZcWXuIUYJDmYlEd6iIK0AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzG3l/9hQTSE0tS s1NTC1KLYLJMHJxSDYwHnvqmPJaO3BgYcl9u84rZTO9UNDmqxPfPW6Sw+HLrLsGa3PzzZs3K gV8m9MnF7LB/IffV+imL0Yngsxw+LpGmTsYcutKhrTV6VjqzPE7+2H9ZN+CThEn0PvkKk1en bkaks3eESLaIbPNrNyrK9+y3+nX03Xff04a8Ia4ne+U3V7y1SU0tVGIpzkg01GIuKk4EAFZb z+L2AQAA X-TM-AS-MML: No Cc: t.stanislaws@samsung.com, pawel@osciak.com, mchehab@redhat.com, daniel.vetter@ffwll.ch, subashrp@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Marek Szyprowski Signed-off-by: Marek Szyprowski --- drivers/media/video/videobuf2-dma-contig.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index d44766e..11f4a46 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -498,6 +498,16 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, struct vm_area_struct *vma; struct sg_table *sgt; unsigned long contig_size; + unsigned long dma_align = dma_get_cache_alignment(); + + /* + * DMA transfers are not reliable to buffers which + * are not cache line aligned! + */ + if (vaddr & (dma_align - 1)) { + pr_err("userptr must be aligned to %lu bytes\n", dma_align); + return ERR_PTR(-EINVAL); + } buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf)