Commit 80ed156a authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

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: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 6001018a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define PCI_BAR_COUNT 6 #define PCI_BAR_COUNT 6
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/mutex.h>
#include <asm-generic/pci.h> #include <asm-generic/pci.h>
#include <asm-generic/pci-dma-compat.h> #include <asm-generic/pci-dma-compat.h>
#include <asm/pci_clp.h> #include <asm/pci_clp.h>
...@@ -76,6 +77,7 @@ struct zpci_dev { ...@@ -76,6 +77,7 @@ struct zpci_dev {
u8 pft; /* pci function type */ u8 pft; /* pci function type */
u16 domain; u16 domain;
struct mutex lock;
u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
u32 uid; /* user defined id */ u32 uid; /* user defined id */
u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */ u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */
......
...@@ -827,6 +827,7 @@ int zpci_create_device(struct zpci_dev *zdev) ...@@ -827,6 +827,7 @@ int zpci_create_device(struct zpci_dev *zdev)
if (rc) if (rc)
goto out; goto out;
mutex_init(&zdev->lock);
if (zdev->state == ZPCI_FN_STATE_CONFIGURED) { if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
rc = zpci_enable_device(zdev); rc = zpci_enable_device(zdev);
if (rc) if (rc)
......
...@@ -58,8 +58,12 @@ static int pci_perf_show(struct seq_file *m, void *v) ...@@ -58,8 +58,12 @@ static int pci_perf_show(struct seq_file *m, void *v)
if (!zdev) if (!zdev)
return 0; return 0;
if (!zdev->fmb)
mutex_lock(&zdev->lock);
if (!zdev->fmb) {
mutex_unlock(&zdev->lock);
return seq_printf(m, "FMB statistics disabled\n"); return seq_printf(m, "FMB statistics disabled\n");
}
/* header */ /* header */
seq_printf(m, "FMB @ %p\n", zdev->fmb); seq_printf(m, "FMB @ %p\n", zdev->fmb);
...@@ -78,6 +82,7 @@ static int pci_perf_show(struct seq_file *m, void *v) ...@@ -78,6 +82,7 @@ static int pci_perf_show(struct seq_file *m, void *v)
pci_perf_names[i], *(stat + i)); pci_perf_names[i], *(stat + i));
pci_sw_counter_show(m); pci_sw_counter_show(m);
mutex_unlock(&zdev->lock);
return 0; return 0;
} }
...@@ -95,19 +100,17 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf, ...@@ -95,19 +100,17 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
if (rc) if (rc)
return rc; return rc;
mutex_lock(&zdev->lock);
switch (val) { switch (val) {
case 0: case 0:
rc = zpci_fmb_disable_device(zdev); rc = zpci_fmb_disable_device(zdev);
if (rc)
return rc;
break; break;
case 1: case 1:
rc = zpci_fmb_enable_device(zdev); rc = zpci_fmb_enable_device(zdev);
if (rc)
return rc;
break; break;
} }
return count; mutex_unlock(&zdev->lock);
return rc ? rc : count;
} }
static int pci_perf_seq_open(struct inode *inode, struct file *filp) static int pci_perf_seq_open(struct inode *inode, struct file *filp)
......
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