From patchwork Mon Jan 23 12:12: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: 9532405 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 959226042F for ; Mon, 23 Jan 2017 12:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C39927C2D for ; Mon, 23 Jan 2017 12:19:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F9242831B; Mon, 23 Jan 2017 12:19:33 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 F10E927C2D for ; Mon, 23 Jan 2017 12:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751086AbdAWMT1 (ORCPT ); Mon, 23 Jan 2017 07:19:27 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36434 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751016AbdAWMT0 (ORCPT ); Mon, 23 Jan 2017 07:19:26 -0500 Received: by mail-pf0-f193.google.com with SMTP id 19so9948051pfo.3 for ; Mon, 23 Jan 2017 04:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=ibMz3g89x6xkTZaURgLO9753mOO5guP+h8H04cCckXU=; b=PqApHrU9+q5uEmf0K9G7YYvClGpIfkGaxEpxyaKmIaasv54nt4PMH9qWlQPscX7tYI Lk/p/jENrkHpw2ckGFk4ZzOHgNNoZs2IIi57o3X7q/rd2+1r4717KGYXaaiR0GrhxtR6 3cfVCR+WjOqcvzMtJc3p5xk3iLJRjuTRMiGT6r2RwTojl6XXle9lbCt/3yIxiE/SrWWC IJNbp9BakMmQN1pDTxt85HsgWcuL26NKVwclsZdr40YOYPDCB688BUO1aM4pTCHPqK6G 7TmwapCXVKpyi7FC/1eQr3bjV0fpZmcMXDT8PClM5qlqfcmLNNLLAR7OWpnPNeUtRE6O kvhw== 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:in-reply-to :references:subject; bh=ibMz3g89x6xkTZaURgLO9753mOO5guP+h8H04cCckXU=; b=nO2LyqQ6TCwM4ms+f1abHSGb+jA7h97J1wSAzWgiEmIcx6m983y3Q0/v9lkEMflKX0 TpUy4LUc69xbTN2xdpAe+n6nwDvVrfcw4EfDgiPRSuCl+2nhk9PluxfkbyAMIhXkll7A mxILw5CM4wDBChB3rEnLnM4OoZQLxAlDhPtLZzcGwupWZX2eR9mg8bCjb2h6eOdj1w9Y uu8f2/pjBljDO2lPS8YSJ//8ttURHZawQ6VAI/p3i9wDc+fLVaUbhDVk9XU7BJkid5tZ ZqOqnBYh14OytsYKgxwWKubXsPbTRAtZZvwPKPnMW2RgXAutPz26kyfaajC+xVIs9y3g pOKA== X-Gm-Message-State: AIkVDXJwO2FkJMPxwR1vk8Usl6TW/vKdfMZ5UWWnzPxoeG7icYc28CwwtUeu9Pc4PG2RSA== X-Received: by 10.84.168.131 with SMTP id f3mr2402088plb.163.1485173965517; Mon, 23 Jan 2017 04:19:25 -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 c15sm36668255pfd.36.2017.01.23.04.18.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jan 2017 04:18:46 -0800 (PST) From: Magnus Damm To: iommu@lists.linux-foundation.org Cc: laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, joro@8bytes.org, linux-renesas-soc@vger.kernel.org, horms+renesas@verge.net.au, Magnus Damm , linux-arm-kernel@lists.infradead.org Date: Mon, 23 Jan 2017 21:12:25 +0900 Message-Id: <148517354599.18128.1970642879780864733.sendpatchset@little-apple> In-Reply-To: <148517349585.18128.10696161017872202809.sendpatchset@little-apple> References: <148517349585.18128.10696161017872202809.sendpatchset@little-apple> Subject: [PATCH/RFC 2/2] iommu/ipmmu-vmsa: Opt-in slave devices based on ES version 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 Match on r8a7795 ES2 and enable a certain DMA controller. In other cases the IPMMU driver remains disabled. Signed-off-by: Magnus Damm --- drivers/iommu/ipmmu-vmsa.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- 0001/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2017-01-23 20:57:02.620607110 +0900 @@ -23,6 +23,7 @@ #include #include #include +#include #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) #include @@ -1002,16 +1003,39 @@ static void ipmmu_domain_free_dma(struct } } +static const struct soc_device_attribute r8a7795es2[] = { + { .soc_id = "r8a7795", .revision = "ES2.*" }, + { /* sentinel */ } +}; + +static int ipmmu_slave_whitelist(struct device *dev) +{ + /* Opt-in slave devices based on SoC and ES version */ + if (soc_device_match(r8a7795es2)) { + if (!strcmp(dev_name(dev), "e7310000.dma-controller")) + return 0; + } + + /* By default, do not allow use of IPMMU */ + return -ENODEV; +} + static int ipmmu_add_device_dma(struct device *dev) { struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu; struct iommu_group *group; + int ret; /* only accept devices with iommus property */ if (of_count_phandle_with_args(dev->of_node, "iommus", "#iommu-cells") < 0) return -ENODEV; + /* opt-in devices based on SoC and ES version */ + ret = ipmmu_slave_whitelist(dev); + if (ret) + return ret; + group = iommu_group_get_for_dev(dev); if (IS_ERR(group)) return PTR_ERR(group);