diff options
author | Jan Glauber <jang@linux.vnet.ibm.com> | 2012-11-29 08:36:55 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-11-30 11:47:26 -0500 |
commit | 1e8da9566b56e371902381f42e209df79090486e (patch) | |
tree | 19838ee72542f9c6df6bdffc76081e2358fc238b /arch/s390 | |
parent | 7441b0627e2251370902305a204e1330a696ca04 (diff) |
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>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/include/asm/pci.h | 4 | ||||
-rw-r--r-- | arch/s390/pci/Makefile | 2 | ||||
-rw-r--r-- | arch/s390/pci/pci.c | 6 | ||||
-rw-r--r-- | arch/s390/pci/pci_sysfs.c | 86 |
4 files changed, 97 insertions, 1 deletions
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 48ce434d6fda..a6175ad0c42f 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h | |||
@@ -141,6 +141,10 @@ struct zpci_dev *get_zdev(struct pci_dev *); | |||
141 | struct zpci_dev *get_zdev_by_fid(u32); | 141 | struct zpci_dev *get_zdev_by_fid(u32); |
142 | bool zpci_fid_present(u32); | 142 | bool zpci_fid_present(u32); |
143 | 143 | ||
144 | /* sysfs */ | ||
145 | int zpci_sysfs_add_device(struct device *); | ||
146 | void zpci_sysfs_remove_device(struct device *); | ||
147 | |||
144 | /* DMA */ | 148 | /* DMA */ |
145 | int zpci_dma_init(void); | 149 | int zpci_dma_init(void); |
146 | void zpci_dma_exit(void); | 150 | void zpci_dma_exit(void); |
diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile index 7e36f42ba086..ab0827b6bc4b 100644 --- a/arch/s390/pci/Makefile +++ b/arch/s390/pci/Makefile | |||
@@ -3,4 +3,4 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_PCI) += pci.o pci_dma.o pci_clp.o pci_msi.o \ | 5 | 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 |
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index c523594a6d45..0723b1077a64 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c | |||
@@ -628,6 +628,7 @@ static void zpci_remove_device(struct pci_dev *pdev) | |||
628 | dev_info(&pdev->dev, "Removing device %u\n", zdev->domain); | 628 | dev_info(&pdev->dev, "Removing device %u\n", zdev->domain); |
629 | zdev->state = ZPCI_FN_STATE_CONFIGURED; | 629 | zdev->state = ZPCI_FN_STATE_CONFIGURED; |
630 | zpci_dma_exit_device(zdev); | 630 | zpci_dma_exit_device(zdev); |
631 | zpci_sysfs_remove_device(&pdev->dev); | ||
631 | zpci_unmap_resources(pdev); | 632 | zpci_unmap_resources(pdev); |
632 | list_del(&zdev->entry); /* can be called from init */ | 633 | list_del(&zdev->entry); /* can be called from init */ |
633 | zdev->pdev = NULL; | 634 | zdev->pdev = NULL; |
@@ -676,6 +677,11 @@ void pcibios_disable_device(struct pci_dev *pdev) | |||
676 | pdev->sysdata = NULL; | 677 | pdev->sysdata = NULL; |
677 | } | 678 | } |
678 | 679 | ||
680 | int pcibios_add_platform_entries(struct pci_dev *pdev) | ||
681 | { | ||
682 | return zpci_sysfs_add_device(&pdev->dev); | ||
683 | } | ||
684 | |||
679 | int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data) | 685 | int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data) |
680 | { | 686 | { |
681 | int msi_nr = irq_to_msi_nr(irq); | 687 | int msi_nr = irq_to_msi_nr(irq); |
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c new file mode 100644 index 000000000000..a42cce69d0a0 --- /dev/null +++ b/arch/s390/pci/pci_sysfs.c | |||
@@ -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 | } | ||