lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 16 Dec 2012 18:25:59 +0100
From:	Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>
To:	Hideki EIRAKU <hdk@...l.co.jp>
Cc:	Paul Mundt <lethal@...ux-sh.org>,
	Magnus Damm <magnus.damm@...il.com>,
	Simon Horman <horms@...ge.net.au>, linux-sh@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Katsuya MATSUBARA <matsu@...l.co.jp>,
	Damian Hobson-Garcia <dhobsong@...l.co.jp>
Subject: [PATCH/WIP/RFC 13/14] shmobile-ipmmu: Remove unneeded lock_add spinlock

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 <laurent.pinchart+renesas@...asonboard.com>
---
 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;
 }
-- 
1.7.8.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ