From patchwork Mon Oct 16 12:30:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 10008197 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 071EC60230 for ; Mon, 16 Oct 2017 12:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13E823794 for ; Mon, 16 Oct 2017 12:33:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63812845E; Mon, 16 Oct 2017 12:33:20 +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=unavailable 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 D5EBD23794 for ; Mon, 16 Oct 2017 12:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752163AbdJPMcx (ORCPT ); Mon, 16 Oct 2017 08:32:53 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:54736 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149AbdJPMcv (ORCPT ); Mon, 16 Oct 2017 08:32:51 -0400 Received: by mail-pg0-f66.google.com with SMTP id l24so6643076pgu.11; Mon, 16 Oct 2017 05:32:51 -0700 (PDT) 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=0A+I5FfAbVvAlGmjj6+g5jicarNXQvWnxM3D0njw2r8=; b=h5wEWWsQk2ZeysCods+fu4fSRdstklcKbCfXRtwzxV10L6xrNDVLKtkix2YhKFSt0r 0Y1/TVAuPafpcFVp87YPMh/R11G//h7O478QLXOndVpuiTFBvccRExbohSrbF8niO06M oqYRPZdXhDZgRu3UXR0/vD/c7VQ0gbbDmux5DnZ3GX8ePbsALlabr5D0tv6Imcu3glPy KxVDpeS66wioDfs6PfsiUiXD+MpElZNRyKunL4nABPbgbiov+xAeGnItC3CRw7eDp2pk iQLh18pYN6bzncfvVKmRyuw/6kCwsKek8rpVwKmf+VlQIkeB8awdp67ErNVc7WOpPjuf ldUA== 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=0A+I5FfAbVvAlGmjj6+g5jicarNXQvWnxM3D0njw2r8=; b=VMO5hEgE4PiVNo92CwNIRvETBu+2DjDtiXO9+tPb360gT9botjhGCqbM7hWzH83m1o mugKhCaG6Ohyz7joUepwJ61HmpYxbXw79C/O34s/rvSrXHvpbqM9v70oLScsLatEGX1x ERLpD4X62X8kRbN4dB6p7aVpmQOuu6LlLMElVQ/ikl3kMNz9eiU4wuHndePHcJtImBG4 jYjmkN9hx+RjK+t1hfBt1VKUVFXbZtYCW7ShSkaO70EoyGfOhXO2W1BZmFC6KWWRW89C 8bfluINM/KMgaLp8dhCzf3H2aMJZKob+OosRpsy/NWpkDFOj0HjPxzv4gHjEmm+uy9ko +KvA== X-Gm-Message-State: AMCzsaU4lKb4zq316e0g73n9HLx9eqWc7Y08HYbblCojr3NhhPB8bBGl FEpESu8x9UWGizfdNwM9C8KfLvGJ X-Google-Smtp-Source: AOwi7QC9Nw93VxNAMll+FVYqW6B/iuTpMMW2SiOG8tsM/FWplN3mhqezftsIQdTB7JDFnfFepCEKsw== X-Received: by 10.98.8.74 with SMTP id c71mr8586306pfd.101.1508157171067; Mon, 16 Oct 2017 05:32:51 -0700 (PDT) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id r64sm14487010pfg.25.2017.10.16.05.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 05:32:49 -0700 (PDT) From: Magnus Damm To: joro@8bytes.org Cc: laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, iommu@lists.linux-foundation.org, horms+renesas@verge.net.au, Magnus Damm , robin.murphy@arm.com, m.szyprowski@samsung.com Date: Mon, 16 Oct 2017 21:30:50 +0900 Message-Id: <150815705058.32763.9807688583552282804.sendpatchset@little-apple> In-Reply-To: <150815695455.32763.1660214306749693609.sendpatchset@little-apple> References: <150815695455.32763.1660214306749693609.sendpatchset@little-apple> Subject: [PATCH v5 09/09] iommu/ipmmu-vmsa: Hook up r8a7795 DT matching code 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 Tie in r8a7795 features and update the IOMMU_OF_DECLARE compat string to include the updated compat string. Signed-off-by: Magnus Damm --- Changes since V4: - Got rid of root device availability check in ->xlate() -> deferred probing is used to make sure the root is always present Changes since V3: - Rebased code on top of [PATCH 00/04] iommu/ipmmu-vmsa: 32-bit ARM update This includes support for iommu_fwspec_add_ids() - Use dev_err() instead of dev_info() - Thanks Geert! - Moved single-invokation check into of_xlate() - Thanks Geert! - Dropped TODO list Changes since V2: - Check for lack of root device in ->xlate() This fixed a bug when IPMMU-MM is disabled in DT the system hangs on boot - Added code to ipmmu_init_platform_device() to handle multiple ->xlate() calls - Include empty white list by default - Updated TODO list Changes since V1: - Enable multi context feature - Update TODO list drivers/iommu/ipmmu-vmsa.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) --- 0019/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2017-10-16 19:53:14.710607110 +0900 @@ -25,6 +25,7 @@ #include #include #include +#include #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) #include @@ -735,9 +736,24 @@ static int ipmmu_init_platform_device(st return 0; } +static bool ipmmu_slave_whitelist(struct device *dev) +{ + /* By default, do not allow use of IPMMU */ + return false; +} + +static const struct soc_device_attribute soc_r8a7795[] = { + { .soc_id = "r8a7795", }, + { /* sentinel */ } +}; + static int ipmmu_of_xlate(struct device *dev, struct of_phandle_args *spec) { + /* For R-Car Gen3 use a white list to opt-in slave devices */ + if (soc_device_match(soc_r8a7795) && !ipmmu_slave_whitelist(dev)) + return -ENODEV; + iommu_fwspec_add_ids(dev, spec->args, 1); /* Initialize once - xlate() will call multiple times */ @@ -996,11 +1012,22 @@ static const struct ipmmu_features ipmmu .twobit_imttbcr_sl0 = false, }; +static const struct ipmmu_features ipmmu_features_r8a7795 = { + .use_ns_alias_offset = false, + .has_cache_leaf_nodes = true, + .number_of_contexts = 8, + .setup_imbuscr = false, + .twobit_imttbcr_sl0 = true, +}; + static const struct of_device_id ipmmu_of_ids[] = { { .compatible = "renesas,ipmmu-vmsa", .data = &ipmmu_features_default, }, { + .compatible = "renesas,ipmmu-r8a7795", + .data = &ipmmu_features_r8a7795, + }, { /* Terminator */ }, }; @@ -1185,6 +1212,8 @@ static int __init ipmmu_vmsa_iommu_of_se IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa", ipmmu_vmsa_iommu_of_setup); +IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795", + ipmmu_vmsa_iommu_of_setup); #endif MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");