From patchwork Fri Nov 14 18:56:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 40861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4FEB0240ED for ; Fri, 14 Nov 2014 18:59:12 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id bs8sf1368817wib.8 for ; Fri, 14 Nov 2014 10:59:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=8Cyu4fc6HvMbgiXd8LnLJNnxurBZfk44vvvknxCUdVU=; b=AP+igFnm3RLo9GMNE+w+Q9vvhMYyoZO3sUhhg4BenyfVguJaspxFjyy2jUPy4N1X3P 9SfJEBa2snzYyPKsPkTrX+VJ9jjXEwNG2gToZwLUX3ALK+Jg+yUM+OhCNMRsjNNhRn4I y12vI3chf16O02XKmApXTYpCiXn8kGiAWY3Q9j7bsq4kxvAg+UoJ0cgI1iXg6dOCiPdq 1e4n6N94jTlHg8C/Cx7ApFkj/DQe0UDkhvFL7m+qOKICsLCqIpr1ElSd2p0Ps6w5OKQp tnps9O1iOZp02+RBdUaLmp3ZBhRnZR7sof9PDcG5w5pDQCLERnqItq5sLVxB0Vfmq9mX Vx8Q== X-Gm-Message-State: ALoCoQmIkWLo3jsp8KR3weJCA0qUqRo0CsXoD3NAeJp+UpliLACHAHQVaTpr9ho1WVLjzjBnSRzw X-Received: by 10.180.100.100 with SMTP id ex4mr1414791wib.2.1415991551625; Fri, 14 Nov 2014 10:59:11 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.40 with SMTP id 8ls1004114lar.61.gmail; Fri, 14 Nov 2014 10:59:11 -0800 (PST) X-Received: by 10.112.42.114 with SMTP id n18mr9898136lbl.44.1415991551305; Fri, 14 Nov 2014 10:59:11 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id iz2si42537476lbc.92.2014.11.14.10.59.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 10:59:11 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so1647726lam.7 for ; Fri, 14 Nov 2014 10:59:11 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr9743505lbo.32.1415991551154; Fri, 14 Nov 2014 10:59:11 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp818430lbc; Fri, 14 Nov 2014 10:59:10 -0800 (PST) X-Received: by 10.70.129.225 with SMTP id nz1mr11709789pdb.121.1415991549576; Fri, 14 Nov 2014 10:59:09 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l4si29020044pdh.244.2014.11.14.10.59.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Nov 2014 10:59:09 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1XpM4C-0002ir-OR; Fri, 14 Nov 2014 18:57:56 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XpM3O-0002PU-P8; Fri, 14 Nov 2014 18:57:07 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.36]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id sAEIuZwo008177; Fri, 14 Nov 2014 18:56:35 GMT Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id C3B521AE020C; Fri, 14 Nov 2014 18:56:39 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org Subject: [RFC PATCH v4 6/8] dma-mapping: set dma segment properties in of_dma_configure Date: Fri, 14 Nov 2014 18:56:35 +0000 Message-Id: <1415991397-9618-7-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415991397-9618-1-git-send-email-will.deacon@arm.com> References: <1415991397-9618-1-git-send-email-will.deacon@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141114_105707_196720_C670DF7E X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: jroedel@suse.de, arnd@arndb.de, Will Deacon , thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, Varun.Sethi@freescale.com, m.szyprowski@samsung.com, dwmw2@infradead.org, hdoyu@nvidia.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 of_dma_configure determines the size of the DMA range for a device by either parsing the dma-ranges property or inspecting the coherent DMA mask. This same information can be used to initialise the max segment size and boundary_mask to a default value. Signed-off-by: Will Deacon --- drivers/of/platform.c | 4 ++++ include/linux/amba/bus.h | 1 + include/linux/platform_device.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b89caf8c7586..0a2842d91db4 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -191,6 +191,8 @@ static void of_dma_configure(struct device *dev) dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); } dev->dma_pfn_offset = offset; + dma_set_max_seg_size(dev, size); + dma_set_seg_boundary(dev, size); coherent = of_dma_is_coherent(dev->of_node); dev_dbg(dev, "device is%sdma coherent\n", @@ -236,6 +238,7 @@ static struct platform_device *of_platform_device_create_pdata( dev->dev.bus = &platform_bus_type; dev->dev.platform_data = platform_data; + dev->dev.dma_parms = &dev->dma_parms; of_dma_configure(&dev->dev); if (of_device_add(dev) != 0) { @@ -295,6 +298,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, dev->dev.of_node = of_node_get(node); dev->dev.parent = parent; dev->dev.platform_data = platform_data; + dev->dev.dma_parms = &dev->dma_parms; if (bus_id) dev_set_name(&dev->dev, "%s", bus_id); else diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index c324f5700d1a..9b232eeb6c20 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -32,6 +32,7 @@ struct amba_device { struct clk *pclk; unsigned int periphid; unsigned int irq[AMBA_NR_IRQS]; + struct device_dma_parameters dma_parms; }; struct amba_driver { diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 153d303af7eb..8dc48487b34b 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -27,6 +27,8 @@ struct platform_device { u32 num_resources; struct resource *resource; + struct device_dma_parameters dma_parms; + const struct platform_device_id *id_entry; char *driver_override; /* Driver name to force a match */