From patchwork Sun Dec 16 17:25:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1885261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id E9105DFAC4 for ; Sun, 16 Dec 2012 17:31:50 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TkI0u-0006ut-8W; Sun, 16 Dec 2012 17:28:32 +0000 Received: from perceval.ideasonboard.com ([95.142.166.194]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TkHxi-0005A1-Kt for linux-arm-kernel@lists.infradead.org; Sun, 16 Dec 2012 17:25:16 +0000 Received: from avalon.quadriga.com (unknown [194.136.87.226]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F41A035A8B; Sun, 16 Dec 2012 18:25:00 +0100 (CET) From: Laurent Pinchart To: Hideki EIRAKU Subject: [PATCH/WIP/RFC 13/14] shmobile-ipmmu: Remove unneeded lock_add spinlock Date: Sun, 16 Dec 2012 18:25:59 +0100 Message-Id: <1355678760-27357-14-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1355678760-27357-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1350290093-998-1-git-send-email-hdk@igel.co.jp> <1355678760-27357-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121216_122514_867594_178D9249 X-CRM114-Status: GOOD ( 10.05 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Katsuya MATSUBARA , Simon Horman , linux-sh@vger.kernel.org, Magnus Damm , linux-kernel@vger.kernel.org, Paul Mundt , Damian Hobson-Garcia , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ipmmu_add_device() can never race with shmobile_iommu_attach_all_devices(), called by ipmmu_iommu_init() as the former is called from an arch initcall and the later from a subsys initcall. Remove the unneeded spinlock as well as the arm_iommu_attach_device() in ipmmu_add_device(), as the condition that guards the call is always false. Signed-off-by: Laurent Pinchart --- drivers/iommu/shmobile-iommu.c | 18 +++--------------- 1 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/shmobile-iommu.c b/drivers/iommu/shmobile-iommu.c index bf1d0a4..2592d25 100644 --- a/drivers/iommu/shmobile-iommu.c +++ b/drivers/iommu/shmobile-iommu.c @@ -51,7 +51,6 @@ static struct dma_iommu_mapping *iommu_mapping; static struct device *ipmmu_devices; static struct dma_pool *l1pool, *l2pool; static spinlock_t lock; -static DEFINE_SPINLOCK(lock_add); static struct shmobile_iommu_domain *attached; static int num_attached_devices; @@ -313,15 +312,12 @@ static struct iommu_ops shmobile_iommu_ops = { static int shmobile_iommu_attach_all_devices(struct shmobile_ipmmu *ipmmu) { struct device *dev; - int ret = 0; - spin_lock(&lock_add); iommu_mapping = arm_iommu_create_mapping(&platform_bus_type, 0x0, L1_LEN << 20, 0); - if (IS_ERR_OR_NULL(iommu_mapping)) { - ret = PTR_ERR(iommu_mapping); - goto err; - } + if (IS_ERR_OR_NULL(iommu_mapping)) + return PTR_ERR(iommu_mapping); + for (dev = ipmmu_devices; dev; ) { struct shmobile_iommu_arch_data *data = dev->archdata.iommu; @@ -332,8 +328,6 @@ static int shmobile_iommu_attach_all_devices(struct shmobile_ipmmu *ipmmu) dev = data->next; } -err: - spin_unlock(&lock_add); return 0; } @@ -347,14 +341,8 @@ int ipmmu_add_device(struct device *dev) dev->archdata.iommu = data; - spin_lock(&lock_add); data->next = ipmmu_devices; ipmmu_devices = dev; - if (!IS_ERR_OR_NULL(iommu_mapping)) { - if (arm_iommu_attach_device(dev, iommu_mapping)) - pr_err("arm_iommu_attach_device failed\n"); - } - spin_unlock(&lock_add); return 0; }