From patchwork Thu Mar 17 16:29:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 8613161 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 464AAC0553 for ; Thu, 17 Mar 2016 16:28:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEAE12026F for ; Thu, 17 Mar 2016 16:28:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 129272026C for ; Thu, 17 Mar 2016 16:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030873AbcCQQ0M (ORCPT ); Thu, 17 Mar 2016 12:26:12 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34252 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030293AbcCQQ0K (ORCPT ); Thu, 17 Mar 2016 12:26:10 -0400 Received: by mail-pf0-f169.google.com with SMTP id x3so127044327pfb.1; Thu, 17 Mar 2016 09:26:10 -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=idDAJ2JaV1UqMA5He3vxXofe02aWLk8FLxY3Vy68LUk=; b=FpiN3IKX/V6HYF14zEsfjXH9yMGKTR2ldYdvT567aU7O2BDO4CUTnFIbxYDM4VVbu5 DYfFkNBhVLrUm42Xe3MHMOwOClPaciz4VU6FidPjQfYHNH4NhdqyOuz7R4HP5dQXhQVj S2T/T6eYW7xfPlMcfXprZ4mILm/hGiR0qRj0ULqru/9FQtZCKJ4ZEOmzTVHgC1vMcaHE YW6DHs5o0y1YkNqF0WGRLmIfitGML247yYyGXpyr5i1203FHxdYNIgc3Nob5yPBJZ9Mv R45vWlN6yalyoOVf2FNxJVLIFIsz/SAVLWaFw7qB1fn/lrXt2xD4+Qsbo68m4xtsvHru sYrA== 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=idDAJ2JaV1UqMA5He3vxXofe02aWLk8FLxY3Vy68LUk=; b=P/TC0Ff4nB/Om6weRrWfwcbQaYKNGmdqz79GcWGDk8qH2iVxBoN28yGMM/aAlgyajj LHiHDJEPrAKsvjIaLXxmyElqCQfJl16Rc1uTeXLRqgKwzId6H5xmimJQcN08+A1ZSBz4 ULpKGwBRBK1Oeb8dNRKxfFM7qc2Y+rs6sFyc9lq4jGEg4TdgiyYXT9aOb2AvjhGKbXpl Xnaz4ec42RcskrchIlrszsQqUojBNOiVYmWrsxAbmbPpjVJzfPw0KB04PCpFJ0rYHHe3 TnvrSa8sbPxfqq4koHgO/6Yw1jz6R7DCreyjjAd+NyKMSKrolsuxECJLUpGkq3jq9VvY z/zw== X-Gm-Message-State: AD7BkJI8fmB2QuQ+6a51Ahc/zSLkzBiL3dhNK0PZ7e9jhl1G3X/SeQI6DuYJ7pTppBQMIw== X-Received: by 10.98.68.91 with SMTP id r88mr16318738pfa.12.1458231964853; Thu, 17 Mar 2016 09:26:04 -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 kw10sm14541013pab.0.2016.03.17.09.26.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2016 09:26:03 -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: Fri, 18 Mar 2016 01:29:28 +0900 Message-Id: <20160317162928.24104.46943.sendpatchset@little-apple> In-Reply-To: <20160317162909.24104.31682.sendpatchset@little-apple> References: <20160317162909.24104.31682.sendpatchset@little-apple> Subject: [PATCH 02/10] iommu/ipmmu-vmsa: Enable multi context support Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Add support for up to 4 contexts. Each context is mapped to one domain. One domain is associated with each device, however one or more uTLBs for a single device are kept in the same domain. Signed-off-by: Magnus Damm --- drivers/iommu/ipmmu-vmsa.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- 0015/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2016-03-18 00:15:49.180513000 +0900 @@ -31,7 +31,7 @@ #include "io-pgtable.h" -#define IPMMU_CTX_MAX 1 +#define IPMMU_CTX_MAX 4 struct ipmmu_vmsa_device { struct device *dev; @@ -536,6 +536,13 @@ static int ipmmu_attach_device(struct io /* The domain hasn't been used yet, initialize it. */ domain->mmu = mmu; ret = ipmmu_domain_init_context(domain); + if (ret < 0) { + dev_err(dev, "Unable to initialize IPMMU context\n"); + domain->mmu = NULL; + } else { + dev_info(dev, "Using IPMMU context %u\n", + domain->context_id); + } } else if (domain->mmu != mmu) { /* * Something is wrong, we can't attach two devices using @@ -915,7 +922,7 @@ static void ipmmu_device_reset(struct ip unsigned int i; /* Disable all contexts. */ - for (i = 0; i < 4; ++i) + for (i = 0; i < IPMMU_CTX_MAX; ++i) ipmmu_write(mmu, i * IM_CTX_SIZE + IMCTR, 0); }