From patchwork Fri Jan 27 06:24:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9540621 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEA0560415 for ; Fri, 27 Jan 2017 06:30:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B037C20952 for ; Fri, 27 Jan 2017 06:30:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A512627F93; Fri, 27 Jan 2017 06:30:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E93820952 for ; Fri, 27 Jan 2017 06:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754098AbdA0Gat (ORCPT ); Fri, 27 Jan 2017 01:30:49 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35279 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753841AbdA0Gas (ORCPT ); Fri, 27 Jan 2017 01:30:48 -0500 Received: by mail-pf0-f193.google.com with SMTP id f144so17973093pfa.2 for ; Thu, 26 Jan 2017 22:30:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:date:message-id:subject; bh=bRxeBQDHu/Anp8zdl6XdIfas4fowoJ61s4DcjwAcOgY=; b=FBIkJEV0jePIUoeNSN7mWgi4sUddb0iK1AnnlCzUAXEsomgAQ34wNq99+YFPC1SuYI DcMbpm26sCZiX8YrzYX9onA/hezw341Ack/Cpmx4S086X2zQazR7ZPlpf6cwq3IO0eeC Rt02mCly21WD55JAFNjMsVLtCdm4kkB6LsSLTx2xoWmc8/suPfNXWeE4krKjjg5+2ziw b4XboTvp7ie3IW7SvHqVVHK3G1fPT4OEFLoGeMExUp8lhflvFJIK/JgpkSy1iSVnYg12 pKxIH5/k6B7EG/senVnKydLZmmyYUtHkulyy+VLgaMYfn67Ubi0Yzm0DoPn4HxpEaTEv V1mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:date:message-id:subject; bh=bRxeBQDHu/Anp8zdl6XdIfas4fowoJ61s4DcjwAcOgY=; b=THAvLjf2JlENJaV3l84Lne7c0rt7Bhzhh/tpSsWurvC6J45t0K2H2674XUfbai+e8y GJ5/dtPkeZLN+HXYJXfQjW1E8ST9T2l43TVqNCqKD/XwA51EccYiq1oxrLdcxV3shhVp b1HRm+h9mpc7jxHxSVcCOiqpRB2IY6TccVVoFPLRFMNvBScPTqsOSxBPpmGyVlwq/2/z 1OU1SLIL37PBoGIVCQsNmxLlBJ65BQDG1cmsiuy70CO11d9qIUyNZj1vX4V9iZx5Kmp+ bP69lEsQd7IGEWsKGa+cdbdcnzYSR2w950JnMO7Z8mMc+KTd3IhFG55fOgyyJR6tEJ7c wCKQ== X-Gm-Message-State: AIkVDXJgy3x/nBKl1xX1Gw02sH+GyHsGL/ZrxeE1qHSzxQEhpVhi5k+2rCf6E5btzgO18A== X-Received: by 10.98.92.4 with SMTP id q4mr7328985pfb.151.1485498643171; Thu, 26 Jan 2017 22:30:43 -0800 (PST) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id c11sm7873093pfk.14.2017.01.26.22.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 22:30:42 -0800 (PST) From: Magnus Damm To: iommu@lists.linux-foundation.org Cc: linux-renesas-soc@vger.kernel.org, Magnus Damm , robin.murphy@arm.com, joro@8bytes.org Date: Fri, 27 Jan 2017 15:24:25 +0900 Message-Id: <148549826507.23190.1460689571069015835.sendpatchset@little-apple> Subject: [PATCH/RFC] iommu/dma: Per-domain flag to control size-alignment Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Introduce the flag "no_size_align" to allow disabling size-alignment on a per-domain basis. This follows the suggestion by the comment in the code, however a per-device control may be preferred? Needed to make virtual space contiguous for certain devices. Signed-off-by: Magnus Damm --- drivers/iommu/dma-iommu.c | 6 +++++- include/linux/iommu.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) --- 0001/drivers/iommu/dma-iommu.c +++ work/drivers/iommu/dma-iommu.c 2017-01-27 15:17:50.280607110 +0900 @@ -209,14 +209,18 @@ static struct iova *__alloc_iova(struct struct iova_domain *iovad = cookie_iovad(domain); unsigned long shift = iova_shift(iovad); unsigned long length = iova_align(iovad, size) >> shift; + bool size_aligned = true; if (domain->geometry.force_aperture) dma_limit = min(dma_limit, domain->geometry.aperture_end); + + if (domain->no_size_align) + size_aligned = false; /* * Enforce size-alignment to be safe - there could perhaps be an * attribute to control this per-device, or at least per-domain... */ - return alloc_iova(iovad, length, dma_limit >> shift, true); + return alloc_iova(iovad, length, dma_limit >> shift, size_aligned); } /* The IOVA allocator knows what we mapped, so just unmap whatever that was */ --- 0001/include/linux/iommu.h +++ work/include/linux/iommu.h 2017-01-27 15:16:37.630607110 +0900 @@ -83,6 +83,7 @@ struct iommu_domain { iommu_fault_handler_t handler; void *handler_token; struct iommu_domain_geometry geometry; + bool no_size_align; void *iova_cookie; };