Skip to content

Commit 1e8da95

Browse files
Jan GlauberMartin Schwidefsky
authored andcommitted
s390/pci: s390 specific PCI sysfs attributes
Add some s390 specific sysfs attributes to the PCI device directory. The following attributes are introduced: - function_id (PCI function ID) - function_handle (PCI function handle) - pchid (PCI channel ID) - pfgid (PCI function group ID aka PCI root complex) Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 7441b06 commit 1e8da95

4 files changed

Lines changed: 97 additions & 1 deletion

File tree

‎arch/s390/include/asm/pci.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ struct zpci_dev *get_zdev(struct pci_dev *);
141141
struct zpci_dev *get_zdev_by_fid(u32);
142142
bool zpci_fid_present(u32);
143143

144+
/* sysfs */
145+
int zpci_sysfs_add_device(struct device *);
146+
void zpci_sysfs_remove_device(struct device *);
147+
144148
/* DMA */
145149
int zpci_dma_init(void);
146150
void zpci_dma_exit(void);

‎arch/s390/pci/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#
44

55
obj-$(CONFIG_PCI) += pci.o pci_dma.o pci_clp.o pci_msi.o \
6-
pci_event.o
6+
pci_sysfs.o pci_event.o

‎arch/s390/pci/pci.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ static void zpci_remove_device(struct pci_dev *pdev)
628628
dev_info(&pdev->dev, "Removing device %u\n", zdev->domain);
629629
zdev->state = ZPCI_FN_STATE_CONFIGURED;
630630
zpci_dma_exit_device(zdev);
631+
zpci_sysfs_remove_device(&pdev->dev);
631632
zpci_unmap_resources(pdev);
632633
list_del(&zdev->entry); /* can be called from init */
633634
zdev->pdev = NULL;
@@ -676,6 +677,11 @@ void pcibios_disable_device(struct pci_dev *pdev)
676677
pdev->sysdata = NULL;
677678
}
678679

680+
int pcibios_add_platform_entries(struct pci_dev *pdev)
681+
{
682+
return zpci_sysfs_add_device(&pdev->dev);
683+
}
684+
679685
int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data)
680686
{
681687
int msi_nr = irq_to_msi_nr(irq);

‎arch/s390/pci/pci_sysfs.c‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright IBM Corp. 2012
3+
*
4+
* Author(s):
5+
* Jan Glauber <jang@linux.vnet.ibm.com>
6+
*/
7+
8+
#define COMPONENT "zPCI"
9+
#define pr_fmt(fmt) COMPONENT ": " fmt
10+
11+
#include <linux/kernel.h>
12+
#include <linux/stat.h>
13+
#include <linux/pci.h>
14+
15+
static ssize_t show_fid(struct device *dev, struct device_attribute *attr,
16+
char *buf)
17+
{
18+
struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
19+
20+
sprintf(buf, "0x%08x\n", zdev->fid);
21+
return strlen(buf);
22+
}
23+
static DEVICE_ATTR(function_id, S_IRUGO, show_fid, NULL);
24+
25+
static ssize_t show_fh(struct device *dev, struct device_attribute *attr,
26+
char *buf)
27+
{
28+
struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
29+
30+
sprintf(buf, "0x%08x\n", zdev->fh);
31+
return strlen(buf);
32+
}
33+
static DEVICE_ATTR(function_handle, S_IRUGO, show_fh, NULL);
34+
35+
static ssize_t show_pchid(struct device *dev, struct device_attribute *attr,
36+
char *buf)
37+
{
38+
struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
39+
40+
sprintf(buf, "0x%04x\n", zdev->pchid);
41+
return strlen(buf);
42+
}
43+
static DEVICE_ATTR(pchid, S_IRUGO, show_pchid, NULL);
44+
45+
static ssize_t show_pfgid(struct device *dev, struct device_attribute *attr,
46+
char *buf)
47+
{
48+
struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
49+
50+
sprintf(buf, "0x%02x\n", zdev->pfgid);
51+
return strlen(buf);
52+
}
53+
static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL);
54+
55+
static struct device_attribute *zpci_dev_attrs[] = {
56+
&dev_attr_function_id,
57+
&dev_attr_function_handle,
58+
&dev_attr_pchid,
59+
&dev_attr_pfgid,
60+
NULL,
61+
};
62+
63+
int zpci_sysfs_add_device(struct device *dev)
64+
{
65+
int i, rc = 0;
66+
67+
for (i = 0; zpci_dev_attrs[i]; i++) {
68+
rc = device_create_file(dev, zpci_dev_attrs[i]);
69+
if (rc)
70+
goto error;
71+
}
72+
return 0;
73+
74+
error:
75+
while (--i >= 0)
76+
device_remove_file(dev, zpci_dev_attrs[i]);
77+
return rc;
78+
}
79+
80+
void zpci_sysfs_remove_device(struct device *dev)
81+
{
82+
int i;
83+
84+
for (i = 0; zpci_dev_attrs[i]; i++)
85+
device_remove_file(dev, zpci_dev_attrs[i]);
86+
}

0 commit comments

Comments
 (0)