From patchwork Tue Oct 13 13:18:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 7385231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7146D9F4DD for ; Tue, 13 Oct 2015 13:20:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83A6620751 for ; Tue, 13 Oct 2015 13:20:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D9F5207C2 for ; Tue, 13 Oct 2015 13:20:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZlzTg-0004BS-3i; Tue, 13 Oct 2015 13:18:52 +0000 Received: from galahad.ideasonboard.com ([2001:4b98:dc2:45:216:3eff:febb:480d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZlzTc-0003LM-Ff for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2015 13:18:49 +0000 Received: from avalon.bb.dnainternet.fi (85-23-193-79.bb.dnainternet.fi [85.23.193.79]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 2DC1C20066; Tue, 13 Oct 2015 15:17:35 +0200 (CEST) From: Laurent Pinchart To: linux-media@vger.kernel.org Subject: [RFC/PATCH] media: omap3isp: Set maximum DMA segment size Date: Tue, 13 Oct 2015 16:18:36 +0300 Message-Id: <1444742316-27986-1-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.4.9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151013_061848_714053_844BF245 X-CRM114-Status: GOOD ( 12.60 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lars-Peter Clausen , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, sakari.ailus@iki.fi, Shuah Khan , robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 The maximum DMA segment size controls the IOMMU mapping granularity. Its default value is 64kB, resulting in potentially non-contiguous IOMMU mappings. Configure it to 4GB to ensure that buffers get mapped contiguously. Signed-off-by: Laurent Pinchart --- drivers/media/platform/omap3isp/isp.c | 4 ++++ drivers/media/platform/omap3isp/isp.h | 1 + 2 files changed, 5 insertions(+) I'm posting this as an RFC because I'm not happy with the patch, even if it gets the job done. On ARM the maximum DMA segment size is used when creating IOMMU mappings. As a large number of devices require contiguous memory buffers (this is a very common requirement for video-related embedded devices) the default 64kB value doesn't work. I haven't investigated the history behind this API in details but I have a feeling something is not quite right. We force most drivers to explicitly set the maximum segment size from a default that seems valid for specific use cases only. Furthermore, as the DMA parameters are not stored directly in struct device this require allocation of external memory for which we have no proper management rule, making automatic handling of the DMA parameters in frameworks or helper functions cumbersome (for a discussion on this topic see http://www.spinics.net/lists/linux-media/msg92467.html and http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/305913.html). Is it time to fix this mess ? diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 17430a6ed85a..ebf7dc76e94d 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2444,6 +2444,10 @@ static int isp_probe(struct platform_device *pdev) if (ret) goto error; + isp->dev->dma_parms = &isp->dma_parms; + dma_set_max_seg_size(isp->dev, DMA_BIT_MASK(32)); + dma_set_seg_boundary(isp->dev, 0xffffffff); + platform_set_drvdata(pdev, isp); /* Regulators */ diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index e579943175c4..4b2231cf01be 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -193,6 +193,7 @@ struct isp_device { u32 syscon_offset; u32 phy_type; + struct device_dma_parameters dma_parms; struct dma_iommu_mapping *mapping; /* ISP Obj */