From patchwork Tue Dec 15 12:02:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 7854021 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 7758FBEEE1 for ; Tue, 15 Dec 2015 12:01:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D853202FE for ; Tue, 15 Dec 2015 12:01:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B601A2034C for ; Tue, 15 Dec 2015 12:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965183AbbLOMBE (ORCPT ); Tue, 15 Dec 2015 07:01:04 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34010 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964921AbbLOMBB (ORCPT ); Tue, 15 Dec 2015 07:01:01 -0500 Received: by mail-pf0-f182.google.com with SMTP id o64so3812085pfb.1; Tue, 15 Dec 2015 04:01:00 -0800 (PST) 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=5lhQHpE9gjjIcSpkkGAIFhXJJBC2/JaFpJEcaSb8OEk=; b=K9edmazJRmmhQlyNOZ+NngjLF2t+VNLQ3NAoT+PRHSD2Bt73V2nfIDIbc33LuZZ+rT 5bhFAVqcpF0457hhehn4mHxBjXnH8t8jGUlbdmNa1ZE0RgOOhDm0+Gf0W6I9ys1m02fF weJOaR94ffhPisUPR2nITSo2o3GFbohO3c/bm3ayRjEDWxIuqrel3+GOySSfJAOx/JWf RKtshfK8YsgY7NKxDQ8dKsdvQ8DC8Dsrwk8uFijOSnvsZs0atVfKi3Wl0RtX+rlVz1/H GvRGPL2vQo1+9K5qI7SlnRSApWMItYSCi9eiKdkrBZjBTNRobK3dPBkLRwxcPdNXywYS +/0g== X-Received: by 10.98.9.4 with SMTP id e4mr43502705pfd.18.1450180860652; Tue, 15 Dec 2015 04:01:00 -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 x86sm1926301pfi.68.2015.12.15.04.00.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Dec 2015 04:00:59 -0800 (PST) From: Magnus Damm To: iommu@lists.linux-foundation.org Cc: laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, linux-sh@vger.kernel.org, joro@8bytes.org, linux-kernel@vger.kernel.org, horms+renesas@verge.net.au, Magnus Damm Date: Tue, 15 Dec 2015 21:02:39 +0900 Message-Id: <20151215120239.26216.43390.sendpatchset@little-apple> In-Reply-To: <20151215120212.26216.61530.sendpatchset@little-apple> References: <20151215120212.26216.61530.sendpatchset@little-apple> Subject: [PATCH 03/06] iommu/ipmmu-vmsa: Break out utlb control function Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Introduce the function ipmmu_utlb_ctrl() that shares code to enable or disable utlbs. Signed-off-by: Magnus Damm --- drivers/iommu/ipmmu-vmsa.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0004/drivers/iommu/ipmmu-vmsa.c +++ work/drivers/iommu/ipmmu-vmsa.c 2015-12-15 13:17:40.580513000 +0900 @@ -279,9 +279,18 @@ static void ipmmu_utlb_enable(struct ipm static void ipmmu_utlb_disable(struct ipmmu_vmsa_domain *domain, unsigned int utlb) { - struct ipmmu_vmsa_device *mmu = domain->mmu; + ipmmu_write(domain->mmu, IMUCTR(utlb), 0); +} + +static void ipmmu_utlb_ctrl(struct ipmmu_vmsa_domain *domain, + void (*fn)(struct ipmmu_vmsa_domain *, + unsigned int utlb), struct device *dev) +{ + struct ipmmu_vmsa_dev_data *dev_data = get_dev_data(dev); + unsigned int i; - ipmmu_write(mmu, IMUCTR(utlb), 0); + for (i = 0; i < dev_data->num_utlbs; ++i) + fn(domain, dev_data->utlbs[i]); } static void ipmmu_tlb_flush_all(void *cookie) @@ -503,7 +512,6 @@ static int ipmmu_attach_device(struct io struct ipmmu_vmsa_device *mmu = dev_data->mmu; struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); unsigned long flags; - unsigned int i; int ret = 0; if (!mmu) { @@ -529,24 +537,16 @@ static int ipmmu_attach_device(struct io spin_unlock_irqrestore(&domain->lock, flags); - if (ret < 0) - return ret; + if (!ret) + ipmmu_utlb_ctrl(domain, ipmmu_utlb_enable, dev); - for (i = 0; i < dev_data->num_utlbs; ++i) - ipmmu_utlb_enable(domain, dev_data->utlbs[i]); - - return 0; + return ret; } static void ipmmu_detach_device(struct iommu_domain *io_domain, struct device *dev) { - struct ipmmu_vmsa_dev_data *dev_data = get_dev_data(dev); - struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); - unsigned int i; - - for (i = 0; i < dev_data->num_utlbs; ++i) - ipmmu_utlb_disable(domain, dev_data->utlbs[i]); + ipmmu_utlb_ctrl(to_vmsa_domain(io_domain), ipmmu_utlb_disable, dev); /* * TODO: Optimize by disabling the context when no device is attached.