diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2015-04-10 15:34:33 +0300 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-04-15 13:23:53 +0300 |
commit | 80ed156a3d12819a8c839f40f5b6996c4aa117a5 (patch) | |
tree | e7cc5c5e155456168ed80b1f0f69205c2d6cc437 /arch/s390 | |
parent | 6001018ae8c659e624351d2e73b1272bacd68d6a (diff) | |
download | linux-80ed156a3d12819a8c839f40f5b6996c4aa117a5.tar.xz |
s390/pci: add locking for fmb access
Function measurement can be toggled at runtime. Make sure that
all access to the fmb is protected via a mutex.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/include/asm/pci.h | 2 | ||||
-rw-r--r-- | arch/s390/pci/pci.c | 1 | ||||
-rw-r--r-- | arch/s390/pci/pci_debug.c | 15 |
3 files changed, 12 insertions, 6 deletions
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index d318e38dcb83..a648338c434a 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -7,6 +7,7 @@ #define PCI_BAR_COUNT 6 #include <linux/pci.h> +#include <linux/mutex.h> #include <asm-generic/pci.h> #include <asm-generic/pci-dma-compat.h> #include <asm/pci_clp.h> @@ -76,6 +77,7 @@ struct zpci_dev { u8 pft; /* pci function type */ u16 domain; + struct mutex lock; u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ u32 uid; /* user defined id */ u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */ diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 281893864e1b..598f023cf8a6 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -827,6 +827,7 @@ int zpci_create_device(struct zpci_dev *zdev) if (rc) goto out; + mutex_init(&zdev->lock); if (zdev->state == ZPCI_FN_STATE_CONFIGURED) { rc = zpci_enable_device(zdev); if (rc) diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c index 97db1a411d54..3fc9b4d90b59 100644 --- a/arch/s390/pci/pci_debug.c +++ b/arch/s390/pci/pci_debug.c @@ -58,8 +58,12 @@ static int pci_perf_show(struct seq_file *m, void *v) if (!zdev) return 0; - if (!zdev->fmb) + + mutex_lock(&zdev->lock); + if (!zdev->fmb) { + mutex_unlock(&zdev->lock); return seq_printf(m, "FMB statistics disabled\n"); + } /* header */ seq_printf(m, "FMB @ %p\n", zdev->fmb); @@ -78,6 +82,7 @@ static int pci_perf_show(struct seq_file *m, void *v) pci_perf_names[i], *(stat + i)); pci_sw_counter_show(m); + mutex_unlock(&zdev->lock); return 0; } @@ -95,19 +100,17 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf, if (rc) return rc; + mutex_lock(&zdev->lock); switch (val) { case 0: rc = zpci_fmb_disable_device(zdev); - if (rc) - return rc; break; case 1: rc = zpci_fmb_enable_device(zdev); - if (rc) - return rc; break; } - return count; + mutex_unlock(&zdev->lock); + return rc ? rc : count; } static int pci_perf_seq_open(struct inode *inode, struct file *filp) |