Commit 82087c03 authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

net/smc: switch smcd_dev_list spinlock to mutex

The similar smc_ib_devices spinlock has been converted to a mutex.
Protecting the smcd_dev_list by a mutex is possible as well. This
patch converts the smcd_dev_list spinlock to a mutex.

Fixes: c6ba7c9b ("net/smc: add base infrastructure for SMC-D and ISM")
Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 92f3cb0e
...@@ -1971,11 +1971,11 @@ static void smc_core_going_away(void) ...@@ -1971,11 +1971,11 @@ static void smc_core_going_away(void)
} }
mutex_unlock(&smc_ib_devices.mutex); mutex_unlock(&smc_ib_devices.mutex);
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_for_each_entry(smcd, &smcd_dev_list.list, list) { list_for_each_entry(smcd, &smcd_dev_list.list, list) {
smcd->going_away = 1; smcd->going_away = 1;
} }
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
} }
/* Clean up all SMC link groups */ /* Clean up all SMC link groups */
...@@ -1987,10 +1987,10 @@ static void smc_lgrs_shutdown(void) ...@@ -1987,10 +1987,10 @@ static void smc_lgrs_shutdown(void)
smc_smcr_terminate_all(NULL); smc_smcr_terminate_all(NULL);
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_for_each_entry(smcd, &smcd_dev_list.list, list) list_for_each_entry(smcd, &smcd_dev_list.list, list)
smc_smcd_terminate_all(smcd); smc_smcd_terminate_all(smcd);
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
} }
static int smc_core_reboot_event(struct notifier_block *this, static int smc_core_reboot_event(struct notifier_block *this,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
struct smcd_dev_list smcd_dev_list = { struct smcd_dev_list smcd_dev_list = {
.list = LIST_HEAD_INIT(smcd_dev_list.list), .list = LIST_HEAD_INIT(smcd_dev_list.list),
.lock = __SPIN_LOCK_UNLOCKED(smcd_dev_list.lock) .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex)
}; };
/* Test if an ISM communication is possible. */ /* Test if an ISM communication is possible. */
...@@ -317,9 +318,9 @@ EXPORT_SYMBOL_GPL(smcd_alloc_dev); ...@@ -317,9 +318,9 @@ EXPORT_SYMBOL_GPL(smcd_alloc_dev);
int smcd_register_dev(struct smcd_dev *smcd) int smcd_register_dev(struct smcd_dev *smcd)
{ {
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_add_tail(&smcd->list, &smcd_dev_list.list); list_add_tail(&smcd->list, &smcd_dev_list.list);
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n", pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n",
dev_name(&smcd->dev), smcd->pnetid, dev_name(&smcd->dev), smcd->pnetid,
...@@ -333,9 +334,9 @@ void smcd_unregister_dev(struct smcd_dev *smcd) ...@@ -333,9 +334,9 @@ void smcd_unregister_dev(struct smcd_dev *smcd)
{ {
pr_warn_ratelimited("smc: removing smcd device %s\n", pr_warn_ratelimited("smc: removing smcd device %s\n",
dev_name(&smcd->dev)); dev_name(&smcd->dev));
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_del_init(&smcd->list); list_del_init(&smcd->list);
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
smcd->going_away = 1; smcd->going_away = 1;
smc_smcd_terminate_all(smcd); smc_smcd_terminate_all(smcd);
flush_workqueue(smcd->event_wq); flush_workqueue(smcd->event_wq);
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
#define SMCD_ISM_H #define SMCD_ISM_H
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/mutex.h>
#include "smc.h" #include "smc.h"
struct smcd_dev_list { /* List of SMCD devices */ struct smcd_dev_list { /* List of SMCD devices */
struct list_head list; struct list_head list;
spinlock_t lock; /* Protects list of devices */ struct mutex mutex; /* Protects list of devices */
}; };
extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */ extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */
......
...@@ -152,7 +152,7 @@ static int smc_pnet_remove_by_pnetid(struct net *net, char *pnet_name) ...@@ -152,7 +152,7 @@ static int smc_pnet_remove_by_pnetid(struct net *net, char *pnet_name)
} }
mutex_unlock(&smc_ib_devices.mutex); mutex_unlock(&smc_ib_devices.mutex);
/* remove smcd devices */ /* remove smcd devices */
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) { list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) {
if (smcd_dev->pnetid_by_user && if (smcd_dev->pnetid_by_user &&
(!pnet_name || (!pnet_name ||
...@@ -166,7 +166,7 @@ static int smc_pnet_remove_by_pnetid(struct net *net, char *pnet_name) ...@@ -166,7 +166,7 @@ static int smc_pnet_remove_by_pnetid(struct net *net, char *pnet_name)
rc = 0; rc = 0;
} }
} }
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
return rc; return rc;
} }
...@@ -259,13 +259,13 @@ static bool smc_pnet_apply_smcd(struct smcd_dev *smcd_dev, char *pnet_name) ...@@ -259,13 +259,13 @@ static bool smc_pnet_apply_smcd(struct smcd_dev *smcd_dev, char *pnet_name)
u8 pnet_null[SMC_MAX_PNETID_LEN] = {0}; u8 pnet_null[SMC_MAX_PNETID_LEN] = {0};
bool applied = false; bool applied = false;
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
if (smc_pnet_match(smcd_dev->pnetid, pnet_null)) { if (smc_pnet_match(smcd_dev->pnetid, pnet_null)) {
memcpy(smcd_dev->pnetid, pnet_name, SMC_MAX_PNETID_LEN); memcpy(smcd_dev->pnetid, pnet_name, SMC_MAX_PNETID_LEN);
smcd_dev->pnetid_by_user = true; smcd_dev->pnetid_by_user = true;
applied = true; applied = true;
} }
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
return applied; return applied;
} }
...@@ -321,7 +321,7 @@ static struct smcd_dev *smc_pnet_find_smcd(char *smcd_name) ...@@ -321,7 +321,7 @@ static struct smcd_dev *smc_pnet_find_smcd(char *smcd_name)
{ {
struct smcd_dev *smcd_dev; struct smcd_dev *smcd_dev;
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) { list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) {
if (!strncmp(dev_name(&smcd_dev->dev), smcd_name, if (!strncmp(dev_name(&smcd_dev->dev), smcd_name,
IB_DEVICE_NAME_MAX - 1)) IB_DEVICE_NAME_MAX - 1))
...@@ -329,7 +329,7 @@ static struct smcd_dev *smc_pnet_find_smcd(char *smcd_name) ...@@ -329,7 +329,7 @@ static struct smcd_dev *smc_pnet_find_smcd(char *smcd_name)
} }
smcd_dev = NULL; smcd_dev = NULL;
out: out:
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
return smcd_dev; return smcd_dev;
} }
...@@ -925,7 +925,7 @@ static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev, ...@@ -925,7 +925,7 @@ static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev,
smc_pnet_find_ndev_pnetid_by_table(ndev, ndev_pnetid)) smc_pnet_find_ndev_pnetid_by_table(ndev, ndev_pnetid))
return; /* pnetid could not be determined */ return; /* pnetid could not be determined */
spin_lock(&smcd_dev_list.lock); mutex_lock(&smcd_dev_list.mutex);
list_for_each_entry(ismdev, &smcd_dev_list.list, list) { list_for_each_entry(ismdev, &smcd_dev_list.list, list) {
if (smc_pnet_match(ismdev->pnetid, ndev_pnetid) && if (smc_pnet_match(ismdev->pnetid, ndev_pnetid) &&
!ismdev->going_away) { !ismdev->going_away) {
...@@ -933,7 +933,7 @@ static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev, ...@@ -933,7 +933,7 @@ static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev,
break; break;
} }
} }
spin_unlock(&smcd_dev_list.lock); mutex_unlock(&smcd_dev_list.mutex);
} }
/* PNET table analysis for a given sock: /* PNET table analysis for a given sock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment