From patchwork Wed Oct 19 23:36:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 9385591 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 C6752608A7 for ; Wed, 19 Oct 2016 23:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CAD728B55 for ; Wed, 19 Oct 2016 23:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 917E829087; Wed, 19 Oct 2016 23:44:33 +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=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 271C228B5D for ; Wed, 19 Oct 2016 23:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933047AbcJSXo3 (ORCPT ); Wed, 19 Oct 2016 19:44:29 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33542 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932582AbcJSXo2 (ORCPT ); Wed, 19 Oct 2016 19:44:28 -0400 Received: by mail-pf0-f194.google.com with SMTP id i85so3687200pfa.0; Wed, 19 Oct 2016 16:44:27 -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=sRKa8oDHaQQjVePo9t7/tRt3ts6as2TzZraMZAZsfps=; b=OiZJIUy4XKHsH3xN5EaE9rPZ5p54Wo8Aw6oSIhESmAjxQGoiSKscwxBW9HmL5nZWrE LI/z4r9rZIM80uCtF0gL777zQtqYxLwT4j8ZdOem2K4vy3+tMhk1hGv39cOb1l2avw1m jlOqu7DiZgU3RUTjTQH+c9jiBWYUxx295c1tZUnIDSVs0WeXmJWonb4hzzQb6bYjLxXb HNHF8rqlck8jEk8eOp0cRQ9GUbQVOi9EEGw/8YCTpe9Iu9Ga449I20ZMv2S6LdHSJSJE qt1IPF3Jumx8iJCoXSZ0tto+inqc4EqS+zi87tmdvx2KTKiBpeq15KE7WJWuVtxwmSyJ 09Qg== 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=sRKa8oDHaQQjVePo9t7/tRt3ts6as2TzZraMZAZsfps=; b=iY5Td366ixw90sM/jErY9XSeufdMWY67VtWtBld76RBs28dreblelwjAe9KLFgEAwg rGuQX3Qrt4T68d1QktVjdzFiF0Lt0AuOdc5F51kdg1ULElpO+mG5El64/lk7YObMIxuN 3VnyMmRBw6hAJiB86BXflwt8Gg0x40M5H92yRojtbLtX3m+rFuTKIa102QSxdvGvPOF9 O4EXaTEVsnSn+dHh4vSP8hrMo+63r1YsjpN6d84sAZwjP5w9xbmkA54wh5Pr16YBMnJu vaG4ZrNUG+6zJn0FJfuZRPpmBAPXfNJVPvnNji1ZZxkrjhDkAM8YCpN+ZdXWAXi/4jEA hyVQ== X-Gm-Message-State: AA6/9Rl+3+IHUjL0LO+27KD54rV1/yMrzvLpc7f17ogI9lDk7nCph6gLQdYzyKd8ASVoPw== X-Received: by 10.99.9.129 with SMTP id 123mr12996100pgj.84.1476920667404; Wed, 19 Oct 2016 16:44:27 -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 f75sm8400721pfj.76.2016.10.19.16.44.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 16:44:25 -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: Thu, 20 Oct 2016 08:36:33 +0900 Message-Id: <20161019233633.10506.3943.sendpatchset@little-apple> In-Reply-To: <20161019233533.10506.16810.sendpatchset@little-apple> References: <20161019233533.10506.16810.sendpatchset@little-apple> Subject: [PATCH v6 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 Reviewed-by: Joerg Roedel --- Changes since V5: - None Changes since V4: - None Changes since V3: - New patch drivers/iommu/ipmmu-vmsa.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) --- 0012/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2016-09-20 21:59:21.690607110 +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)