From patchwork Mon Jun 19 09:15:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9795575 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 CD887600C5 for ; Mon, 19 Jun 2017 09:19:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE86A27C05 for ; Mon, 19 Jun 2017 09:19:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C35FC283C0; Mon, 19 Jun 2017 09:19:36 +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=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 336BE283BD for ; Mon, 19 Jun 2017 09:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbdFSJTK (ORCPT ); Mon, 19 Jun 2017 05:19:10 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36282 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753789AbdFSJTI (ORCPT ); Mon, 19 Jun 2017 05:19:08 -0400 Received: by mail-pg0-f67.google.com with SMTP id e187so5853238pgc.3; Mon, 19 Jun 2017 02:19:08 -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=85lj/Y1XLC+hRLeHH7SUomZTGXve4xzaviFbOvOTaV8=; b=oG5JZbuthyjIrRn8FRCsczDUrZFaEGU3spWLRYbaPbV70Y17Ys1drSIQOsR5EeYWb0 twWw2Awa6VkDmXsnyKlYEQvxStQO7kv7rDoelFega9hgwxlZARcOFGBrdxFSYu2yUzYM XxDxoJJoQrFuF0Ez+vkXfDrWLc4wO/uiB4uEdlYJlSJaXGgXeCjYytEs1txvgk1wSbKe LCd73fGevC1G5cVDJ2x/0mf6fzlzu6XV4jvc2skYDPOWPEwl19k3+SxZ18I/HIM2rpus piZVDHlLVi3Dm4pmmOmKoOD0hG4feDAfDZoBs9VKKgNL4rhNVHLnlACHF9LHSDm6P9qN khJg== 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=85lj/Y1XLC+hRLeHH7SUomZTGXve4xzaviFbOvOTaV8=; b=DxbqxvwtC8awjAIznMOD/iBfYx8n549p9FuYXWsJxu/j6ohDVapwek7/zUZoqGDVoN qM5mHYfpvMw6uTLuNoiYjkembJSEO1Lwg8o/2BRFVYPrxk2mmLvwv12GLvBelBzAwOEh AnLq8UVacjG18bsLJsoKIIEjmE3rd34O36Z/Sk+KmurUHonCDbYdaZsgBsDKF1IXcpCP N+7nTfft3caSW1iwHJDOutXCG6j7ZtI+x8rV3qkBocco4dwEmSflnC4Yma0GtvGQvmsT frzunS9xSkd+euhuiTdBAWPP9lT0ts73peYxUe4kCbR0lgynNI+S5dtLknSYn353Zysw VR+A== X-Gm-Message-State: AKS2vOyJo5zuENaOqXTSc8+KnuOCnAjITw1kNAHGLYaqcBhXJkDzKoHR wKYtLDCOqB8Y2w== X-Received: by 10.84.224.74 with SMTP id a10mr17576004plt.219.1497863947951; Mon, 19 Jun 2017 02:19:07 -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 x12sm20530574pgc.47.2017.06.19.02.19.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 02:19:06 -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, 19 Jun 2017 18:15:20 +0900 Message-Id: <149786372027.14868.17337099469033750355.sendpatchset@little-apple> In-Reply-To: <149786362527.14868.2143461703972595839.sendpatchset@little-apple> References: <149786362527.14868.2143461703972595839.sendpatchset@little-apple> Subject: [PATCH v4 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 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 | 48 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) --- 0029/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2017-06-19 14:10:58.930607110 +0900 @@ -25,6 +25,7 @@ #include #include #include +#include #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) #include @@ -730,10 +731,6 @@ static int ipmmu_init_platform_device(st struct platform_device *ipmmu_pdev; struct ipmmu_vmsa_iommu_priv *priv; - /* Initialize once - xlate() will call multiple times */ - if (to_priv(dev)) - return 0; - ipmmu_pdev = of_find_device_by_node(args->np); if (!ipmmu_pdev) return -ENODEV; @@ -748,11 +745,41 @@ 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) { + /* Failing in ->attach_device() results in a hang, so make + * sure the root device is installed before going there + */ + if (!__ipmmu_find_root()) { + dev_err(dev, "Unable to locate IPMMU root device\n"); + return -ENODEV; + } + + /* 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); + /* + * Execute ipmmu_init_platform_device() once per device. + * This xlate() callback will be invoked multiple times. + */ + if (to_priv(dev)) + return 0; + return ipmmu_init_platform_device(dev, spec); } @@ -1003,11 +1030,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 +1223,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");