From patchwork Wed Jun 8 07:18:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9163497 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 4BC3D60832 for ; Wed, 8 Jun 2016 07:28:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C7B128373 for ; Wed, 8 Jun 2016 07:28:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 314F42838E; Wed, 8 Jun 2016 07:28:58 +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=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 BC56728373 for ; Wed, 8 Jun 2016 07:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161416AbcFHH24 (ORCPT ); Wed, 8 Jun 2016 03:28:56 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35173 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932881AbcFHH2y (ORCPT ); Wed, 8 Jun 2016 03:28:54 -0400 Received: by mail-pf0-f194.google.com with SMTP id t190so2861835pfb.2; Wed, 08 Jun 2016 00:28:53 -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=e6Z3SNJ3VomeNlVV58iojfv9ceCSseCFzifLBZYa10Q=; b=pDW8APpjYc07QuacWR0FSZAnPns99vIpu7cddnmuL+wCPToywPtMzI7tYR9NlKR7KT 65noVT9vXFV4Ygd5xAEoWlWQTuYRDH/Fa7TFmCNTBYQugPwOUC8SnRzrCEPablCUMvJE Yz/TcN2MTU1cbia2YO+PDq07ACSQ53c4q4nGQXPKQxmfTPlSErJi9dTGmwURyb3RDz1L eSlwCBU2rh1ZsJX2sAExW0phZDxVwoSc8BuPKWsq3OOjlfbf9kHgNKZiOKlhAt3v+FyW Mxzrd7rh6DPzWl6SoE0LhBYgT/69lLJPQzXcxGav5wYBya+UaNRuP/h5W0AgUnNfwcGh /aAw== 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=e6Z3SNJ3VomeNlVV58iojfv9ceCSseCFzifLBZYa10Q=; b=R+z3DMiLX/M8huFwZYd6NTgZqic4TosEkVoISdVzZEc3JcrBPZ+tqQAwUffjAK3zBW akbUc/t/oDDCAt73v1X3zME6/A3B/kDZUxwV4TwnWAWaqfi6SgyqB1CGrhcysnxkZNYn V9JKL5roJhLhkwWBTqK/dBimnooF+15SdgvQMEUaRt8xczOU3Tldas+zXKUvs2WRW8mr vhsyI4bFrmpYT9oPlDV7aJDYExj8S3Mi9mQP5sAt0kq1m8lDkGZyXF+4X6OwdF/4R/tv 3KWECgIgoBAjs+J0MS3JD6xc1PNzD7GCtF7XAGdDL88O0Y9UpEO+yWIyts5t2Xy4ezeC Fdow== X-Gm-Message-State: ALyK8tKv2NyxdLXv/t0HO9SUuw9MAp82peEJoRPT8O7PrLWsWLy720QMkf2y5AeI3uiyUg== X-Received: by 10.98.105.138 with SMTP id e132mr4270959pfc.59.1465370933120; Wed, 08 Jun 2016 00:28:53 -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 d24sm40147270pfb.90.2016.06.08.00.28.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 00:28: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 , robin.murphy@arm.com, m.szyprowski@samsung.com Date: Wed, 08 Jun 2016 16:18:34 +0900 Message-Id: <20160608071834.7560.85882.sendpatchset@little-apple> In-Reply-To: <20160608071737.7560.32571.sendpatchset@little-apple> References: <20160608071737.7560.32571.sendpatchset@little-apple> Subject: [PATCH v4 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access 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 Not all architectures have an iommu member in their archdata, so use #ifdefs support build wit COMPILE_TEST on any architecture. Signed-off-by: Magnus Damm --- Changes since V3: - New patch drivers/iommu/ipmmu-vmsa.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) --- 0009/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-08 15:01:40.970607110 +0900 @@ -70,6 +70,25 @@ static struct ipmmu_vmsa_domain *to_vmsa return container_of(dom, struct ipmmu_vmsa_domain, io_domain); } +#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) +static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev) +{ + return dev->archdata.iommu; +} +static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p) +{ + dev->archdata.iommu = p; +} +#else +static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev) +{ + return NULL; +} +static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p) +{ +} +#endif + #define TLB_LOOP_TIMEOUT 100 /* 100us */ /* ----------------------------------------------------------------------------- @@ -539,7 +558,7 @@ static void ipmmu_domain_free(struct iom static int ipmmu_attach_device(struct iommu_domain *io_domain, struct device *dev) { - struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu; + struct ipmmu_vmsa_archdata *archdata = to_archdata(dev); struct ipmmu_vmsa_device *mmu = archdata->mmu; struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); unsigned long flags; @@ -581,7 +600,7 @@ static int ipmmu_attach_device(struct io static void ipmmu_detach_device(struct iommu_domain *io_domain, struct device *dev) { - struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu; + struct ipmmu_vmsa_archdata *archdata = to_archdata(dev); struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); unsigned int i; @@ -701,7 +720,7 @@ static int ipmmu_init_platform_device(st archdata->mmu = mmu; archdata->utlbs = utlbs; archdata->num_utlbs = num_utlbs; - dev->archdata.iommu = archdata; + set_archdata(dev, archdata); return 0; error: @@ -713,12 +732,11 @@ error: static int ipmmu_add_device(struct device *dev) { - struct ipmmu_vmsa_archdata *archdata; struct ipmmu_vmsa_device *mmu = NULL; struct iommu_group *group; int ret; - if (dev->archdata.iommu) { + if (to_archdata(dev)) { dev_warn(dev, "IOMMU driver already assigned to device %s\n", dev_name(dev)); return -EINVAL; @@ -754,8 +772,7 @@ static int ipmmu_add_device(struct devic * - Make the mapping size configurable ? We currently use a 2GB mapping * at a 1GB offset to ensure that NULL VAs will fault. */ - archdata = dev->archdata.iommu; - mmu = archdata->mmu; + mmu = to_archdata(dev)->mmu; if (!mmu->mapping) { struct dma_iommu_mapping *mapping; @@ -783,7 +800,7 @@ error: if (mmu) arm_iommu_release_mapping(mmu->mapping); - dev->archdata.iommu = NULL; + set_archdata(dev, NULL); if (!IS_ERR_OR_NULL(group)) iommu_group_remove_device(dev); @@ -793,7 +810,7 @@ error: static void ipmmu_remove_device(struct device *dev) { - struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu; + struct ipmmu_vmsa_archdata *archdata = to_archdata(dev); arm_iommu_detach_device(dev); iommu_group_remove_device(dev); @@ -801,7 +818,7 @@ static void ipmmu_remove_device(struct d kfree(archdata->utlbs); kfree(archdata); - dev->archdata.iommu = NULL; + set_archdata(dev, NULL); } static struct iommu_domain *ipmmu_domain_alloc(unsigned type)