From patchwork Fri Jan 27 06:14:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9540611 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 AA6A6604B9 for ; Fri, 27 Jan 2017 06:21:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AFCD280B0 for ; Fri, 27 Jan 2017 06:21:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FD1127F85; Fri, 27 Jan 2017 06:21:53 +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 61B1B280B0 for ; Fri, 27 Jan 2017 06:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753948AbdA0GVw (ORCPT ); Fri, 27 Jan 2017 01:21:52 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34416 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753950AbdA0GVt (ORCPT ); Fri, 27 Jan 2017 01:21:49 -0500 Received: by mail-pf0-f195.google.com with SMTP id y143so17954909pfb.1 for ; Thu, 26 Jan 2017 22:21:04 -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=FYTHXrIA9/o0I/mk9J51fx1N4Ko50RaRDUtEFmUzrxQ=; b=mJxAVuoh5lv9eIPfjueNbmO/5U11EIiczGWLEbSslcHIEzOq0GFl6/XT6cYylucvj+ irvWTtrj9Qk2qMFz6YXMUna6iKB0+7qDG6Xtlng5r55ctXL3tVhOggyH3JU08YrGyU6Q 28OTkKRLr0yB6sgcp+kJB80unGDlGa1vibLI18Fw1NTxYG/BGuFqSaOPDBwoHcqKUIOM Kgjc71yKga2OUZpaUERyTgbGj/dNYWbfKr4lRmMUmokgDqKkHmOc5ux9ye0GNH7Xy8ox 2kTQHg9N9MSQtrkigf6P0/oYVT4ut9i2eSr0GwcOYhuO32hhu4+f6dWgAIYZybaLSFkF f2bg== 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=FYTHXrIA9/o0I/mk9J51fx1N4Ko50RaRDUtEFmUzrxQ=; b=m9rYOqq/J2t6jy0Te3MiygH7Oh3GykQOdrYYrusI9e6F7/fG6FFPgC/62kZh10DAJA pjMG8SSQ5A8Z5+T9uDrmBi6kXdEWe/T1g/+5enqBZFeGazs1NfkkByD/Hzk7+XqM889B wva7YXriG7beTXjjNWbO0F/eCxEk0FF52JVoXl/wsjdBEnTJFZF823tgI7LaXxxRS5g6 pLUaycavIVsmk1O8PwHVVP/chSf1SMTbyU9rO51wp/WPYAxvK45Ha1tdYYPbCFN7ogoc 8zuFirUFjbNNjzGF8zNpdSXhMM8S39YKYJmz/G1pD4pcau3A6nlZMCTn82gu9rPeDHkB +Zpg== X-Gm-Message-State: AIkVDXKgc+jx+iIyD7b3v+l01DZUajkhcEBmb/UCpUv55V5nSW2zm3pQ0lW0gj1b0YqU/g== X-Received: by 10.84.254.74 with SMTP id a10mr9855668pln.57.1485498063697; Thu, 26 Jan 2017 22:21:03 -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 i82sm7762789pfk.52.2017.01.26.22.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 22:21:02 -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 , robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Date: Fri, 27 Jan 2017 15:14:45 +0900 Message-Id: <148549768562.22203.6722636560743534786.sendpatchset@little-apple> In-Reply-To: <148549764733.22203.16459470412085471955.sendpatchset@little-apple> References: <148549764733.22203.16459470412085471955.sendpatchset@little-apple> Subject: [PATCH/RFC v2 3/4] 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 --- Changes since V1: - Perform white list check in ->xlate() instead of ->add_device() drivers/iommu/ipmmu-vmsa.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) --- 0009/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2017-01-27 13:14:47.470607110 +0900 @@ -23,6 +23,7 @@ #include #include #include +#include #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) #include @@ -1032,9 +1033,33 @@ static void ipmmu_remove_device_dma(stru iommu_group_remove_device(dev); } +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_of_xlate_dma(struct device *dev, struct of_phandle_args *spec) { + int ret; + + /* Opt-in devices based on SoC and ES version */ + ret = ipmmu_slave_whitelist(dev); + if (ret) + return ret; + /* For now only tested on R-Car Gen3 with ARM64 arch init order * TODO: Test R-Car Gen2 with ARM32 arch init order */