Skip to content

Commit

Permalink
s390/pci: add locking for fmb access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Apr 15, 2015
1 parent 6001018 commit 80ed156
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions arch/s390/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions arch/s390/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions arch/s390/pci/pci_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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)
Expand Down

0 comments on commit 80ed156

Please sign in to comment.