From patchwork Mon Jun 6 03:57:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9157163 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 2AD1E60573 for ; Mon, 6 Jun 2016 04:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2151527C8F for ; Mon, 6 Jun 2016 04:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16030281DB; Mon, 6 Jun 2016 04:08:14 +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 47D50281D2 for ; Mon, 6 Jun 2016 04:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbcFFEH5 (ORCPT ); Mon, 6 Jun 2016 00:07:57 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34406 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbcFFEHz (ORCPT ); Mon, 6 Jun 2016 00:07:55 -0400 Received: by mail-pa0-f68.google.com with SMTP id ug1so812946pab.1; Sun, 05 Jun 2016 21:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=5FJ0JkOwy+rEDhJOZuganOnSOA4gXwnbvUk2hAOr4H8=; b=WYtLvbVq5jZLFr81GdiySsvSvu76nmkvzFnatPn++FB5crT0dSWXHPLb8L8PKQD31t phaEOhoW/KoCb5aTWgaP59Pnxk9TCB/I+cQUU7uPCFCOCPJQzWRNk9RcF45QGCnly6OL lCYog5Y00PfphXYUO4tuQofX1P0skMHnvZXzlgUhiWdgX0uu+wS3O2mBLcAMyNgA2GnV BcQqCdJVwv/fXbfzvG+hgSyNVfsRwt1DpLVG950nEN9rEu4FSNCZHE0vL0KrkR+Sjp7D P7zJ1K5bkR2Pn7ihl+k8YCp/7kwx5Q+fe0Kew4LUgdpNTdZ/48ZMAqWYHWMlchSlgM2X EgGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:date:message-id:in-reply-to :references:subject; bh=5FJ0JkOwy+rEDhJOZuganOnSOA4gXwnbvUk2hAOr4H8=; b=VYznAPSlLlIS+pD7JP+rMVwVa2JdprZ9Gc7t1OcKAPeJCClNlATSNys42ZlxMHVUko 6L2DUhJgUM55x0gHZQQVWF1x5S5Meory0IGwFbpaP74q08gz79Dxb+pFmKeo+rThi7w1 764b0Pn0EtF1R281FR954JH1jpzkLgtfAW9zKL5BXx2209z6HpqCIDqsWd2WOjkaHEgC dvmHqoGB0tYfkbE8P4Cu2xEl6te2iyVmlLzeViNF9nUxJdcF8V5B38qTy/pmwGNdpIgn mJ+LlAWZjt9e85MErrkJvFi0X84comunZo5dSYBiP7SEre7NVJXLYsp7D3fdUCDuj/2l zayA== X-Gm-Message-State: ALyK8tLvdkHQgSulJ1MU1IH5m1/FN+sPkLZueg+u5kmRRLL7mSAbk+5kg3ioFU18gTHh+g== X-Received: by 10.66.179.169 with SMTP id dh9mr22137238pac.133.1465186074532; Sun, 05 Jun 2016 21:07:54 -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 bf4sm21033641pac.4.2016.06.05.21.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jun 2016 21:07:52 -0700 (PDT) From: Magnus Damm To: iommu@lists.linux-foundation.org Cc: laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, joro@8bytes.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, horms+renesas@verge.net.au, Magnus Damm Date: Mon, 06 Jun 2016 12:57:32 +0900 Message-Id: <20160606035732.31763.39717.sendpatchset@little-apple> In-Reply-To: <20160606035723.31763.66500.sendpatchset@little-apple> References: <20160606035723.31763.66500.sendpatchset@little-apple> Subject: [PATCH v2 01/11] 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 V1: - Moved patch to front of the series drivers/iommu/ipmmu-vmsa.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) --- 0008/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-06 10:08:53.410607110 +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); @@ -929,13 +933,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"); @@ -946,6 +970,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); @@ -965,7 +990,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) { @@ -1014,11 +1040,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",