From patchwork Wed Mar 8 11:01:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9610845 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 AD2B66016C for ; Wed, 8 Mar 2017 11:07:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFB4427CEA for ; Wed, 8 Mar 2017 11:07:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A478128567; Wed, 8 Mar 2017 11:07:57 +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 1575727CEA for ; Wed, 8 Mar 2017 11:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667AbdCHLHS (ORCPT ); Wed, 8 Mar 2017 06:07:18 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36495 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752666AbdCHLHR (ORCPT ); Wed, 8 Mar 2017 06:07:17 -0500 Received: by mail-pg0-f67.google.com with SMTP id 25so3140376pgy.3; Wed, 08 Mar 2017 03:07:16 -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=Q2q/a0U9EKJ1qCuuagZK3lDYvNb+5nMZ4eEDLCRLp/c=; b=U3p9qgwCfUhCXog0XGZkXaDhe3KD5o2pXoGmiPkFKXSoVXrRHC5tQvJ0zkQ6ydloIo Xx1GKsmUYXiw2ARTU3/Uu7Cl/1pn1hA06Zp1vZW/nmjI02RvCp9AIM3ZXatxt0E35fTc gznQSezZkoGqeKWNQ/+hOTH1Kqw+U0A6BfMCvL/+I4nFIPyOqqinvQO5PFEH26W/AVmf 8auwIOmOqZi4h+H1osTbIV1ITXTs2LkIVT2knkLezk/sIdtxtCdTY6IXBz4d6+na75wU yAEBXlWTq7YRdGewD5RDhjvWldqvenlMIzNZbDurWU2+Ag6+kmiXvxtood06/dTm1NMT S02Q== 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=Q2q/a0U9EKJ1qCuuagZK3lDYvNb+5nMZ4eEDLCRLp/c=; b=Vh+mEsK4LL43qBIIXlMOK+dP3KI+BO2pe651q6GdYbz45h6PQEfQ19sxbhyvbu9ES0 jJ//nCOofZmYYsmgtVLwNdhsv6ma+AaiX7GPJVG0oDDRDX7o7seeNqGiqNkQDTwAnCgt O4t9H1Ijxe83Cg2dC2l746TgkSsX4X+sTNJyPDS6zeutJkE58UfVFuxURhgivDc9FxRS anqkwLZAOVDNk5+ti2UH0hN0vZM/TVx/qsm1J6yQuaduGcPOoiVNypsSeylbwBKwpQB0 Wo2Dc+Ko7djVGpOk0dLYDo8A4ZP4yVPRcfIVCSK/1QlMOFmAETZH5z3dR4SfujRyuHew c8Fw== X-Gm-Message-State: AMke39k2qH914IfJLLqvU5MM/DuxZ1FYgTi5NNyK1fxFRwno2Jxzg9N/R57lRIx+542pMA== X-Received: by 10.84.128.100 with SMTP id 91mr7795177pla.94.1488971235413; Wed, 08 Mar 2017 03:07:15 -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 c22sm5540531pgn.43.2017.03.08.03.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 03:07:13 -0800 (PST) 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: Wed, 08 Mar 2017 20:01:33 +0900 Message-Id: <148897089355.16106.305846051553789544.sendpatchset@little-apple> In-Reply-To: <148897088333.16106.13237004440297956899.sendpatchset@little-apple> References: <148897088333.16106.13237004440297956899.sendpatchset@little-apple> Subject: [PATCH v3 01/09] iommu/ipmmu-vmsa: Introduce features, break out alias 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 struct ipmmu_features to track various hardware and software implementation changes inside the driver for different kinds of IPMMU hardware. Add use_ns_alias_offset as a first example of a feature to control if the secure register bank offset should be used or not. Signed-off-by: Magnus Damm --- Changes since V2: - None Changes since V1: - Moved patch to front of the series drivers/iommu/ipmmu-vmsa.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) --- 0007/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2017-03-07 12:25:47.000000000 +0900 @@ -32,11 +32,15 @@ #define IPMMU_CTX_MAX 1 +struct ipmmu_features { + bool use_ns_alias_offset; +}; + struct ipmmu_vmsa_device { struct device *dev; void __iomem *base; struct list_head list; - + const struct ipmmu_features *features; unsigned int num_utlbs; spinlock_t lock; /* Protects ctx and domains[] */ DECLARE_BITMAP(ctx, IPMMU_CTX_MAX); @@ -999,13 +1003,33 @@ static void ipmmu_device_reset(struct ip ipmmu_write(mmu, i * IM_CTX_SIZE + IMCTR, 0); } +static const struct ipmmu_features ipmmu_features_default = { + .use_ns_alias_offset = true, +}; + +static const struct of_device_id ipmmu_of_ids[] = { + { + .compatible = "renesas,ipmmu-vmsa", + .data = &ipmmu_features_default, + }, { + /* Terminator */ + }, +}; + +MODULE_DEVICE_TABLE(of, ipmmu_of_ids); + static int ipmmu_probe(struct platform_device *pdev) { struct ipmmu_vmsa_device *mmu; + const struct of_device_id *match; struct resource *res; int irq; int ret; + match = of_match_node(ipmmu_of_ids, pdev->dev.of_node); + if (!match) + return -EINVAL; + mmu = devm_kzalloc(&pdev->dev, sizeof(*mmu), GFP_KERNEL); if (!mmu) { dev_err(&pdev->dev, "cannot allocate device data\n"); @@ -1016,6 +1040,7 @@ static int ipmmu_probe(struct platform_d mmu->num_utlbs = 32; spin_lock_init(&mmu->lock); bitmap_zero(mmu->ctx, IPMMU_CTX_MAX); + mmu->features = match->data; /* Map I/O memory and request IRQ. */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1035,7 +1060,8 @@ static int ipmmu_probe(struct platform_d * Offset the registers base unconditionally to point to the non-secure * alias space for now. */ - mmu->base += IM_NS_ALIAS_OFFSET; + if (mmu->features->use_ns_alias_offset) + mmu->base += IM_NS_ALIAS_OFFSET; irq = platform_get_irq(pdev, 0); if (irq < 0) { @@ -1084,11 +1110,6 @@ static int ipmmu_remove(struct platform_ return 0; } -static const struct of_device_id ipmmu_of_ids[] = { - { .compatible = "renesas,ipmmu-vmsa", }, - { } -}; - static struct platform_driver ipmmu_driver = { .driver = { .name = "ipmmu-vmsa",