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: 10751 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 08C6D23E00 for ; Tue, 14 Aug 2012 15:38:09 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id CD38CA18A36 for ; Tue, 14 Aug 2012 15:38:08 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id g10so622554ghb.11 for ; Tue, 14 Aug 2012 08:38:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-tm-as-mml:cc:subject:x-beenthere :x-mailman-version:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=Js7B3kK4M0j+BaCoI0qn9mFkEsVXzu0tgKGjrAw7dmQ=; b=oaLqgAmjDXUGqdGSTqmTE1mWKxtsQyd5zvuX4n5qIgHnl5DUH5Hl0OWPmdyV84Sd5E CU+tnGi8BBpIBMnX1BScqf0pm0KrPBsNaJfWOw1BLMyBUgJy9iWh4gg40B/PROFFdurq jGgtQgfibK5vcHdscI4JDpSveKeozDphF/2zfSfVxRLglyNtl1B3iPR0cRFv3KeRxJ6P qVr++ssU3/PQxIdDqb6ysxDHYjz8bWfCNsEwMEItn7eqpz9SUBQGkn9C6Ka172ZPES3A TCZUZqaoaJIpgMRjIxr8tp++4W1NTn8s57/2LVLcRpGR2q73ESsc3aF3iacDXtJa+1Ej RgUQ== Received: by 10.50.57.168 with SMTP id j8mr12375854igq.16.1344958688555; Tue, 14 Aug 2012 08:38:08 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.200 with SMTP id ew8csp20692igc; Tue, 14 Aug 2012 08:38:07 -0700 (PDT) Received: by 10.180.81.133 with SMTP id a5mr28859780wiy.17.1344958687416; Tue, 14 Aug 2012 08:38:07 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id q54si3194701wei.96.2012.08.14.08.38.06; Tue, 14 Aug 2012 08:38:07 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JC1-0008Ve-5g; Tue, 14 Aug 2012 15:38:05 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JBz-0008Un-3i for linaro-mm-sig@lists.linaro.org; Tue, 14 Aug 2012 15:38:03 +0000 Received: from epcpsbgm2.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M8R00J7K4RDDVJ0@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:38:01 +0900 (KST) X-AuditID: cbfee61b-b7faf6d00000476a-20-502a70d9c637 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D2.2A.18282.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 linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:38:01 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org 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+t9jAd2bBVoBBtOmmFt8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGQd3vWMveMpecfzHG5YGxoNsXYycHBICJhKfH5xjhbDFJC7c Ww8U5+IQEljEKDFz3RYoZy2TxMnfb9hBqtiAOo4t+cwIYosIOEicvjuLGaSIWeAQs8T+3tdg RcIC4RI9q3uZQWwWAVWJr9NXgdm8Ah4SOy5uYIJYJy/x9H4f2BmcQPGXm7qBhnIAbXOXWPjT fwIj7wJGhlWMoqkFyQXFSem5RnrFibnFpXnpesn5uZsYwV5/Jr2DcVWDxSFGAQ5GJR7ewkTN ACHWxLLiytxDjBIczEoivEVBWgFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeU28v/oLCaQnlqRm p6YWpBbBZJk4OKUaGOdzzzZzypgSVRO/wlVk84znoombpQXvpcddMzJiYDcJnjLnHpdH1LE7 veK13hl1zKy+CryPGwT7D6xUWV4d9SVntV+h+Nt5C/n6bhTPmHLlQFdNCu8xmU+6Nu92l31M VhS2+LFuTUjxZuke80C2qsC/c8LzmgKf1XbUth58KxsZ0aZv2X1KiaU4I9FQi7moOBEA7K61 i/YBAAA= X-TM-AS-MML: No Cc: k.debski@samsung.com, pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, dmitriyz@google.com, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCHv8 22/26] media: vb2: fail if user ptr buffer is not correctly aligned X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmY96zIkRLt1FqQWu4NP0WgQtN+5CzjkB+gdiXkOC+/Tb3LNu+4h8qph9wbmPl7oCziuh5Z 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)