aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2015-04-10 08:34:33 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-04-15 06:23:53 -0400
commit80ed156a3d12819a8c839f40f5b6996c4aa117a5 (patch)
treee7cc5c5e155456168ed80b1f0f69205c2d6cc437 /arch/s390
parent6001018ae8c659e624351d2e73b1272bacd68d6a (diff)
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.h2
-rw-r--r--arch/s390/pci/pci.c1
-rw-r--r--arch/s390/pci/pci_debug.c15
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 @@
7#define PCI_BAR_COUNT 6 7#define PCI_BAR_COUNT 6
8 8
9#include <linux/pci.h> 9#include <linux/pci.h>
10#include <linux/mutex.h>
10#include <asm-generic/pci.h> 11#include <asm-generic/pci.h>
11#include <asm-generic/pci-dma-compat.h> 12#include <asm-generic/pci-dma-compat.h>
12#include <asm/pci_clp.h> 13#include <asm/pci_clp.h>
@@ -76,6 +77,7 @@ struct zpci_dev {
76 u8 pft; /* pci function type */ 77 u8 pft; /* pci function type */
77 u16 domain; 78 u16 domain;
78 79
80 struct mutex lock;
79 u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ 81 u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
80 u32 uid; /* user defined id */ 82 u32 uid; /* user defined id */
81 u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */ 83 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)
827 if (rc) 827 if (rc)
828 goto out; 828 goto out;
829 829
830 mutex_init(&zdev->lock);
830 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) { 831 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
831 rc = zpci_enable_device(zdev); 832 rc = zpci_enable_device(zdev);
832 if (rc) 833 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)
58 58
59 if (!zdev) 59 if (!zdev)
60 return 0; 60 return 0;
61 if (!zdev->fmb) 61
62 mutex_lock(&zdev->lock);
63 if (!zdev->fmb) {
64 mutex_unlock(&zdev->lock);
62 return seq_printf(m, "FMB statistics disabled\n"); 65 return seq_printf(m, "FMB statistics disabled\n");
66 }
63 67
64 /* header */ 68 /* header */
65 seq_printf(m, "FMB @ %p\n", zdev->fmb); 69 seq_printf(m, "FMB @ %p\n", zdev->fmb);
@@ -78,6 +82,7 @@ static int pci_perf_show(struct seq_file *m, void *v)
78 pci_perf_names[i], *(stat + i)); 82 pci_perf_names[i], *(stat + i));
79 83
80 pci_sw_counter_show(m); 84 pci_sw_counter_show(m);
85 mutex_unlock(&zdev->lock);
81 return 0; 86 return 0;
82} 87}
83 88
@@ -95,19 +100,17 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
95 if (rc) 100 if (rc)
96 return rc; 101 return rc;
97 102
103 mutex_lock(&zdev->lock);
98 switch (val) { 104 switch (val) {
99 case 0: 105 case 0:
100 rc = zpci_fmb_disable_device(zdev); 106 rc = zpci_fmb_disable_device(zdev);
101 if (rc)
102 return rc;
103 break; 107 break;
104 case 1: 108 case 1:
105 rc = zpci_fmb_enable_device(zdev); 109 rc = zpci_fmb_enable_device(zdev);
106 if (rc)
107 return rc;
108 break; 110 break;
109 } 111 }
110 return count; 112 mutex_unlock(&zdev->lock);
113 return rc ? rc : count;
111} 114}
112 115
113static int pci_perf_seq_open(struct inode *inode, struct file *filp) 116static int pci_perf_seq_open(struct inode *inode, struct file *filp)