aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-19 14:43:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-19 14:43:21 -0500
commit806dace637e4d37a5569c3e2345adcbd473b3d12 (patch)
treec897b9da1bfcf687e05faf82eb4677369af94adc /arch
parentcdc7ef8981317cfa9a462b784935e4d2705c6776 (diff)
parentd795ddad36cbc828176c898a5084549030539162 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull second set of s390 patches from Martin Schwidefsky: "The handling of the PCI hotplug notifications has been improved, the zfcp dumper can now detect the HSA size dynamically and the default install kernel has been changed to the compressed bzImage. And two bug-fixes for scm and 3720" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/pci: implement hotplug notifications s390/scm_block: do not hide eadm subchannel dependency s390/sclp: Consolidate early sclp init calls to sclp_early_detect() s390/sclp: Move early code from sclp_cmd.c to sclp_early.c s390/sclp: Determine HSA size dynamically for zfcpdump s390/sclp: Move declarations for sclp_sdias into separate header file s390/pci: implement pcibios_remove_bus s390/pci: improve handling of bus resources s390/3270: fix missing device_destroy() call s390/boot: Install bzImage as default kernel image
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/boot/Makefile4
-rw-r--r--arch/s390/include/asm/ctl_reg.h2
-rw-r--r--arch/s390/include/asm/eadm.h13
-rw-r--r--arch/s390/include/asm/pci.h6
-rw-r--r--arch/s390/include/asm/sclp.h3
-rw-r--r--arch/s390/include/asm/setup.h3
-rw-r--r--arch/s390/kernel/crash_dump.c22
-rw-r--r--arch/s390/kernel/early.c2
-rw-r--r--arch/s390/kernel/setup.c7
-rw-r--r--arch/s390/pci/pci.c202
-rw-r--r--arch/s390/pci/pci_clp.c8
-rw-r--r--arch/s390/pci/pci_event.c79
12 files changed, 197 insertions, 154 deletions
diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
index f2737a005afc..9a42ecec5647 100644
--- a/arch/s390/boot/Makefile
+++ b/arch/s390/boot/Makefile
@@ -21,6 +21,6 @@ $(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
21$(obj)/compressed/vmlinux: FORCE 21$(obj)/compressed/vmlinux: FORCE
22 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 22 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
23 23
24install: $(CONFIGURE) $(obj)/image 24install: $(CONFIGURE) $(obj)/bzImage
25 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/image \ 25 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
26 System.map "$(INSTALL_PATH)" 26 System.map "$(INSTALL_PATH)"
diff --git a/arch/s390/include/asm/ctl_reg.h b/arch/s390/include/asm/ctl_reg.h
index 9b69c0befdca..4e63f1a13600 100644
--- a/arch/s390/include/asm/ctl_reg.h
+++ b/arch/s390/include/asm/ctl_reg.h
@@ -7,6 +7,8 @@
7#ifndef __ASM_CTL_REG_H 7#ifndef __ASM_CTL_REG_H
8#define __ASM_CTL_REG_H 8#define __ASM_CTL_REG_H
9 9
10#include <linux/bug.h>
11
10#ifdef CONFIG_64BIT 12#ifdef CONFIG_64BIT
11# define __CTL_LOAD "lctlg" 13# define __CTL_LOAD "lctlg"
12# define __CTL_STORE "stctg" 14# define __CTL_STORE "stctg"
diff --git a/arch/s390/include/asm/eadm.h b/arch/s390/include/asm/eadm.h
index dc9200ca32ed..67026300c88e 100644
--- a/arch/s390/include/asm/eadm.h
+++ b/arch/s390/include/asm/eadm.h
@@ -111,18 +111,7 @@ struct scm_driver {
111int scm_driver_register(struct scm_driver *scmdrv); 111int scm_driver_register(struct scm_driver *scmdrv);
112void scm_driver_unregister(struct scm_driver *scmdrv); 112void scm_driver_unregister(struct scm_driver *scmdrv);
113 113
114int scm_start_aob(struct aob *aob); 114int eadm_start_aob(struct aob *aob);
115void scm_irq_handler(struct aob *aob, int error); 115void scm_irq_handler(struct aob *aob, int error);
116 116
117struct eadm_ops {
118 int (*eadm_start) (struct aob *aob);
119 struct module *owner;
120};
121
122int scm_get_ref(void);
123void scm_put_ref(void);
124
125void register_eadm_ops(struct eadm_ops *ops);
126void unregister_eadm_ops(struct eadm_ops *ops);
127
128#endif /* _ASM_S390_EADM_H */ 117#endif /* _ASM_S390_EADM_H */
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 1cc185da9d38..c129ab2ac731 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -63,9 +63,10 @@ enum zpci_state {
63}; 63};
64 64
65struct zpci_bar_struct { 65struct zpci_bar_struct {
66 struct resource *res; /* bus resource */
66 u32 val; /* bar start & 3 flag bits */ 67 u32 val; /* bar start & 3 flag bits */
67 u8 size; /* order 2 exponent */
68 u16 map_idx; /* index into bar mapping array */ 68 u16 map_idx; /* index into bar mapping array */
69 u8 size; /* order 2 exponent */
69}; 70};
70 71
71/* Private data per function */ 72/* Private data per function */
@@ -97,6 +98,7 @@ struct zpci_dev {
97 unsigned long iommu_pages; 98 unsigned long iommu_pages;
98 unsigned int next_bit; 99 unsigned int next_bit;
99 100
101 char res_name[16];
100 struct zpci_bar_struct bars[PCI_BAR_COUNT]; 102 struct zpci_bar_struct bars[PCI_BAR_COUNT];
101 103
102 u64 start_dma; /* Start of available DMA addresses */ 104 u64 start_dma; /* Start of available DMA addresses */
@@ -122,12 +124,10 @@ static inline bool zdev_enabled(struct zpci_dev *zdev)
122 Prototypes 124 Prototypes
123----------------------------------------------------------------------------- */ 125----------------------------------------------------------------------------- */
124/* Base stuff */ 126/* Base stuff */
125struct zpci_dev *zpci_alloc_device(void);
126int zpci_create_device(struct zpci_dev *); 127int zpci_create_device(struct zpci_dev *);
127int zpci_enable_device(struct zpci_dev *); 128int zpci_enable_device(struct zpci_dev *);
128int zpci_disable_device(struct zpci_dev *); 129int zpci_disable_device(struct zpci_dev *);
129void zpci_stop_device(struct zpci_dev *); 130void zpci_stop_device(struct zpci_dev *);
130void zpci_free_device(struct zpci_dev *);
131int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64); 131int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
132int zpci_unregister_ioat(struct zpci_dev *, u8); 132int zpci_unregister_ioat(struct zpci_dev *, u8);
133 133
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index 7dc7f9c63b65..30ef748bc161 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -43,7 +43,6 @@ struct sclp_cpu_info {
43int sclp_get_cpu_info(struct sclp_cpu_info *info); 43int sclp_get_cpu_info(struct sclp_cpu_info *info);
44int sclp_cpu_configure(u8 cpu); 44int sclp_cpu_configure(u8 cpu);
45int sclp_cpu_deconfigure(u8 cpu); 45int sclp_cpu_deconfigure(u8 cpu);
46void sclp_facilities_detect(void);
47unsigned long long sclp_get_rnmax(void); 46unsigned long long sclp_get_rnmax(void);
48unsigned long long sclp_get_rzm(void); 47unsigned long long sclp_get_rzm(void);
49int sclp_sdias_blk_count(void); 48int sclp_sdias_blk_count(void);
@@ -57,5 +56,7 @@ bool sclp_has_vt220(void);
57int sclp_pci_configure(u32 fid); 56int sclp_pci_configure(u32 fid);
58int sclp_pci_deconfigure(u32 fid); 57int sclp_pci_deconfigure(u32 fid);
59int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode); 58int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode);
59unsigned long sclp_get_hsa_size(void);
60void sclp_early_detect(void);
60 61
61#endif /* _ASM_S390_SCLP_H */ 62#endif /* _ASM_S390_SCLP_H */
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index df802ee14af6..94cfbe442f12 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -107,9 +107,6 @@ void create_mem_hole(struct mem_chunk mem_chunk[], unsigned long addr,
107#define MACHINE_HAS_RRBM (S390_lowcore.machine_flags & MACHINE_FLAG_RRBM) 107#define MACHINE_HAS_RRBM (S390_lowcore.machine_flags & MACHINE_FLAG_RRBM)
108#endif /* CONFIG_64BIT */ 108#endif /* CONFIG_64BIT */
109 109
110#define ZFCPDUMP_HSA_SIZE (32UL<<20)
111#define ZFCPDUMP_HSA_SIZE_MAX (64UL<<20)
112
113/* 110/*
114 * Console mode. Override with conmode= 111 * Console mode. Override with conmode=
115 */ 112 */
diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
index f45b2ab0cb81..d7658c4b2ed5 100644
--- a/arch/s390/kernel/crash_dump.c
+++ b/arch/s390/kernel/crash_dump.c
@@ -95,7 +95,7 @@ static void *elfcorehdr_newmem;
95/* 95/*
96 * Copy one page from zfcpdump "oldmem" 96 * Copy one page from zfcpdump "oldmem"
97 * 97 *
98 * For pages below ZFCPDUMP_HSA_SIZE memory from the HSA is copied. Otherwise 98 * For pages below HSA size memory from the HSA is copied. Otherwise
99 * real memory copy is used. 99 * real memory copy is used.
100 */ 100 */
101static ssize_t copy_oldmem_page_zfcpdump(char *buf, size_t csize, 101static ssize_t copy_oldmem_page_zfcpdump(char *buf, size_t csize,
@@ -103,7 +103,7 @@ static ssize_t copy_oldmem_page_zfcpdump(char *buf, size_t csize,
103{ 103{
104 int rc; 104 int rc;
105 105
106 if (src < ZFCPDUMP_HSA_SIZE) { 106 if (src < sclp_get_hsa_size()) {
107 rc = memcpy_hsa(buf, src, csize, userbuf); 107 rc = memcpy_hsa(buf, src, csize, userbuf);
108 } else { 108 } else {
109 if (userbuf) 109 if (userbuf)
@@ -188,18 +188,19 @@ static int remap_oldmem_pfn_range_kdump(struct vm_area_struct *vma,
188/* 188/*
189 * Remap "oldmem" for zfcpdump 189 * Remap "oldmem" for zfcpdump
190 * 190 *
191 * We only map available memory above ZFCPDUMP_HSA_SIZE. Memory below 191 * We only map available memory above HSA size. Memory below HSA size
192 * ZFCPDUMP_HSA_SIZE is read on demand using the copy_oldmem_page() function. 192 * is read on demand using the copy_oldmem_page() function.
193 */ 193 */
194static int remap_oldmem_pfn_range_zfcpdump(struct vm_area_struct *vma, 194static int remap_oldmem_pfn_range_zfcpdump(struct vm_area_struct *vma,
195 unsigned long from, 195 unsigned long from,
196 unsigned long pfn, 196 unsigned long pfn,
197 unsigned long size, pgprot_t prot) 197 unsigned long size, pgprot_t prot)
198{ 198{
199 unsigned long hsa_end = sclp_get_hsa_size();
199 unsigned long size_hsa; 200 unsigned long size_hsa;
200 201
201 if (pfn < ZFCPDUMP_HSA_SIZE >> PAGE_SHIFT) { 202 if (pfn < hsa_end >> PAGE_SHIFT) {
202 size_hsa = min(size, ZFCPDUMP_HSA_SIZE - (pfn << PAGE_SHIFT)); 203 size_hsa = min(size, hsa_end - (pfn << PAGE_SHIFT));
203 if (size == size_hsa) 204 if (size == size_hsa)
204 return 0; 205 return 0;
205 size -= size_hsa; 206 size -= size_hsa;
@@ -238,9 +239,9 @@ int copy_from_oldmem(void *dest, void *src, size_t count)
238 return rc; 239 return rc;
239 } 240 }
240 } else { 241 } else {
241 if ((unsigned long) src < ZFCPDUMP_HSA_SIZE) { 242 unsigned long hsa_end = sclp_get_hsa_size();
242 copied = min(count, 243 if ((unsigned long) src < hsa_end) {
243 ZFCPDUMP_HSA_SIZE - (unsigned long) src); 244 copied = min(count, hsa_end - (unsigned long) src);
244 rc = memcpy_hsa(dest, (unsigned long) src, copied, 0); 245 rc = memcpy_hsa(dest, (unsigned long) src, copied, 0);
245 if (rc) 246 if (rc)
246 return rc; 247 return rc;
@@ -580,6 +581,9 @@ int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)
580 /* If elfcorehdr= has been passed via cmdline, we use that one */ 581 /* If elfcorehdr= has been passed via cmdline, we use that one */
581 if (elfcorehdr_addr != ELFCORE_ADDR_MAX) 582 if (elfcorehdr_addr != ELFCORE_ADDR_MAX)
582 return 0; 583 return 0;
584 /* If we cannot get HSA size for zfcpdump return error */
585 if (ipl_info.type == IPL_TYPE_FCP_DUMP && !sclp_get_hsa_size())
586 return -ENODEV;
583 mem_chunk_cnt = get_mem_chunk_cnt(); 587 mem_chunk_cnt = get_mem_chunk_cnt();
584 588
585 alloc_size = 0x1000 + get_cpu_cnt() * 0x300 + 589 alloc_size = 0x1000 + get_cpu_cnt() * 0x300 +
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 96543ac400a7..fca20b5fe79e 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -483,7 +483,7 @@ void __init startup_init(void)
483 detect_diag44(); 483 detect_diag44();
484 detect_machine_facilities(); 484 detect_machine_facilities();
485 setup_topology(); 485 setup_topology();
486 sclp_facilities_detect(); 486 sclp_early_detect();
487#ifdef CONFIG_DYNAMIC_FTRACE 487#ifdef CONFIG_DYNAMIC_FTRACE
488 S390_lowcore.ftrace_func = (unsigned long)ftrace_caller; 488 S390_lowcore.ftrace_func = (unsigned long)ftrace_caller;
489#endif 489#endif
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index ffe1c53264a7..4444875266ee 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -471,8 +471,9 @@ static void __init setup_memory_end(void)
471 471
472 472
473#ifdef CONFIG_ZFCPDUMP 473#ifdef CONFIG_ZFCPDUMP
474 if (ipl_info.type == IPL_TYPE_FCP_DUMP && !OLDMEM_BASE) { 474 if (ipl_info.type == IPL_TYPE_FCP_DUMP &&
475 memory_end = ZFCPDUMP_HSA_SIZE; 475 !OLDMEM_BASE && sclp_get_hsa_size()) {
476 memory_end = sclp_get_hsa_size();
476 memory_end_set = 1; 477 memory_end_set = 1;
477 } 478 }
478#endif 479#endif
@@ -586,7 +587,7 @@ static unsigned long __init find_crash_base(unsigned long crash_size,
586 crash_base = (chunk->addr + chunk->size) - crash_size; 587 crash_base = (chunk->addr + chunk->size) - crash_size;
587 if (crash_base < crash_size) 588 if (crash_base < crash_size)
588 continue; 589 continue;
589 if (crash_base < ZFCPDUMP_HSA_SIZE_MAX) 590 if (crash_base < sclp_get_hsa_size())
590 continue; 591 continue;
591 if (crash_base < (unsigned long) INITRD_START + INITRD_SIZE) 592 if (crash_base < (unsigned long) INITRD_START + INITRD_SIZE)
592 continue; 593 continue;
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 0c9a17780e4b..bf7c73d71eef 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -530,20 +530,6 @@ static void zpci_unmap_resources(struct zpci_dev *zdev)
530 } 530 }
531} 531}
532 532
533struct zpci_dev *zpci_alloc_device(void)
534{
535 struct zpci_dev *zdev;
536
537 /* Alloc memory for our private pci device data */
538 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
539 return zdev ? : ERR_PTR(-ENOMEM);
540}
541
542void zpci_free_device(struct zpci_dev *zdev)
543{
544 kfree(zdev);
545}
546
547int pcibios_add_platform_entries(struct pci_dev *pdev) 533int pcibios_add_platform_entries(struct pci_dev *pdev)
548{ 534{
549 return zpci_sysfs_add_device(&pdev->dev); 535 return zpci_sysfs_add_device(&pdev->dev);
@@ -579,37 +565,6 @@ static void zpci_irq_exit(void)
579 unregister_adapter_interrupt(&zpci_airq); 565 unregister_adapter_interrupt(&zpci_airq);
580} 566}
581 567
582static struct resource *zpci_alloc_bus_resource(unsigned long start, unsigned long size,
583 unsigned long flags, int domain)
584{
585 struct resource *r;
586 char *name;
587 int rc;
588
589 r = kzalloc(sizeof(*r), GFP_KERNEL);
590 if (!r)
591 return ERR_PTR(-ENOMEM);
592 r->start = start;
593 r->end = r->start + size - 1;
594 r->flags = flags;
595 r->parent = &iomem_resource;
596 name = kmalloc(18, GFP_KERNEL);
597 if (!name) {
598 kfree(r);
599 return ERR_PTR(-ENOMEM);
600 }
601 sprintf(name, "PCI Bus: %04x:%02x", domain, ZPCI_BUS_NR);
602 r->name = name;
603
604 rc = request_resource(&iomem_resource, r);
605 if (rc) {
606 kfree(r->name);
607 kfree(r);
608 return ERR_PTR(-ENOMEM);
609 }
610 return r;
611}
612
613static int zpci_alloc_iomap(struct zpci_dev *zdev) 568static int zpci_alloc_iomap(struct zpci_dev *zdev)
614{ 569{
615 int entry; 570 int entry;
@@ -633,6 +588,82 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
633 spin_unlock(&zpci_iomap_lock); 588 spin_unlock(&zpci_iomap_lock);
634} 589}
635 590
591static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start,
592 unsigned long size, unsigned long flags)
593{
594 struct resource *r;
595
596 r = kzalloc(sizeof(*r), GFP_KERNEL);
597 if (!r)
598 return NULL;
599
600 r->start = start;
601 r->end = r->start + size - 1;
602 r->flags = flags;
603 r->name = zdev->res_name;
604
605 if (request_resource(&iomem_resource, r)) {
606 kfree(r);
607 return NULL;
608 }
609 return r;
610}
611
612static int zpci_setup_bus_resources(struct zpci_dev *zdev,
613 struct list_head *resources)
614{
615 unsigned long addr, size, flags;
616 struct resource *res;
617 int i, entry;
618
619 snprintf(zdev->res_name, sizeof(zdev->res_name),
620 "PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR);
621
622 for (i = 0; i < PCI_BAR_COUNT; i++) {
623 if (!zdev->bars[i].size)
624 continue;
625 entry = zpci_alloc_iomap(zdev);
626 if (entry < 0)
627 return entry;
628 zdev->bars[i].map_idx = entry;
629
630 /* only MMIO is supported */
631 flags = IORESOURCE_MEM;
632 if (zdev->bars[i].val & 8)
633 flags |= IORESOURCE_PREFETCH;
634 if (zdev->bars[i].val & 4)
635 flags |= IORESOURCE_MEM_64;
636
637 addr = ZPCI_IOMAP_ADDR_BASE + ((u64) entry << 48);
638
639 size = 1UL << zdev->bars[i].size;
640
641 res = __alloc_res(zdev, addr, size, flags);
642 if (!res) {
643 zpci_free_iomap(zdev, entry);
644 return -ENOMEM;
645 }
646 zdev->bars[i].res = res;
647 pci_add_resource(resources, res);
648 }
649
650 return 0;
651}
652
653static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
654{
655 int i;
656
657 for (i = 0; i < PCI_BAR_COUNT; i++) {
658 if (!zdev->bars[i].size)
659 continue;
660
661 zpci_free_iomap(zdev, zdev->bars[i].map_idx);
662 release_resource(zdev->bars[i].res);
663 kfree(zdev->bars[i].res);
664 }
665}
666
636int pcibios_add_device(struct pci_dev *pdev) 667int pcibios_add_device(struct pci_dev *pdev)
637{ 668{
638 struct zpci_dev *zdev = get_zdev(pdev); 669 struct zpci_dev *zdev = get_zdev(pdev);
@@ -729,52 +760,6 @@ struct dev_pm_ops pcibios_pm_ops = {
729}; 760};
730#endif /* CONFIG_HIBERNATE_CALLBACKS */ 761#endif /* CONFIG_HIBERNATE_CALLBACKS */
731 762
732static int zpci_scan_bus(struct zpci_dev *zdev)
733{
734 struct resource *res;
735 LIST_HEAD(resources);
736 int i;
737
738 /* allocate mapping entry for each used bar */
739 for (i = 0; i < PCI_BAR_COUNT; i++) {
740 unsigned long addr, size, flags;
741 int entry;
742
743 if (!zdev->bars[i].size)
744 continue;
745 entry = zpci_alloc_iomap(zdev);
746 if (entry < 0)
747 return entry;
748 zdev->bars[i].map_idx = entry;
749
750 /* only MMIO is supported */
751 flags = IORESOURCE_MEM;
752 if (zdev->bars[i].val & 8)
753 flags |= IORESOURCE_PREFETCH;
754 if (zdev->bars[i].val & 4)
755 flags |= IORESOURCE_MEM_64;
756
757 addr = ZPCI_IOMAP_ADDR_BASE + ((u64) entry << 48);
758
759 size = 1UL << zdev->bars[i].size;
760
761 res = zpci_alloc_bus_resource(addr, size, flags, zdev->domain);
762 if (IS_ERR(res)) {
763 zpci_free_iomap(zdev, entry);
764 return PTR_ERR(res);
765 }
766 pci_add_resource(&resources, res);
767 }
768
769 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
770 zdev, &resources);
771 if (!zdev->bus)
772 return -EIO;
773
774 zdev->bus->max_bus_speed = zdev->max_bus_speed;
775 return 0;
776}
777
778static int zpci_alloc_domain(struct zpci_dev *zdev) 763static int zpci_alloc_domain(struct zpci_dev *zdev)
779{ 764{
780 spin_lock(&zpci_domain_lock); 765 spin_lock(&zpci_domain_lock);
@@ -795,6 +780,41 @@ static void zpci_free_domain(struct zpci_dev *zdev)
795 spin_unlock(&zpci_domain_lock); 780 spin_unlock(&zpci_domain_lock);
796} 781}
797 782
783void pcibios_remove_bus(struct pci_bus *bus)
784{
785 struct zpci_dev *zdev = get_zdev_by_bus(bus);
786
787 zpci_exit_slot(zdev);
788 zpci_cleanup_bus_resources(zdev);
789 zpci_free_domain(zdev);
790
791 spin_lock(&zpci_list_lock);
792 list_del(&zdev->entry);
793 spin_unlock(&zpci_list_lock);
794
795 kfree(zdev);
796}
797
798static int zpci_scan_bus(struct zpci_dev *zdev)
799{
800 LIST_HEAD(resources);
801 int ret;
802
803 ret = zpci_setup_bus_resources(zdev, &resources);
804 if (ret)
805 return ret;
806
807 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
808 zdev, &resources);
809 if (!zdev->bus) {
810 zpci_cleanup_bus_resources(zdev);
811 return -EIO;
812 }
813
814 zdev->bus->max_bus_speed = zdev->max_bus_speed;
815 return 0;
816}
817
798int zpci_enable_device(struct zpci_dev *zdev) 818int zpci_enable_device(struct zpci_dev *zdev)
799{ 819{
800 int rc; 820 int rc;
diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c
index 84147984224a..c747394029ee 100644
--- a/arch/s390/pci/pci_clp.c
+++ b/arch/s390/pci/pci_clp.c
@@ -155,9 +155,9 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured)
155 int rc; 155 int rc;
156 156
157 zpci_dbg(3, "add fid:%x, fh:%x, c:%d\n", fid, fh, configured); 157 zpci_dbg(3, "add fid:%x, fh:%x, c:%d\n", fid, fh, configured);
158 zdev = zpci_alloc_device(); 158 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
159 if (IS_ERR(zdev)) 159 if (!zdev)
160 return PTR_ERR(zdev); 160 return -ENOMEM;
161 161
162 zdev->fh = fh; 162 zdev->fh = fh;
163 zdev->fid = fid; 163 zdev->fid = fid;
@@ -178,7 +178,7 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured)
178 return 0; 178 return 0;
179 179
180error: 180error:
181 zpci_free_device(zdev); 181 kfree(zdev);
182 return rc; 182 return rc;
183} 183}
184 184
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
index 278e671ec9ac..800f064b0da7 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <asm/pci_debug.h> 13#include <asm/pci_debug.h>
14#include <asm/sclp.h>
14 15
15/* Content Code Description for PCI Function Error */ 16/* Content Code Description for PCI Function Error */
16struct zpci_ccdf_err { 17struct zpci_ccdf_err {
@@ -42,10 +43,27 @@ struct zpci_ccdf_avail {
42 u16 pec; /* PCI event code */ 43 u16 pec; /* PCI event code */
43} __packed; 44} __packed;
44 45
45static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf) 46void zpci_event_error(void *data)
46{ 47{
48 struct zpci_ccdf_err *ccdf = data;
49 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
50
51 zpci_err("error CCDF:\n");
52 zpci_err_hex(ccdf, sizeof(*ccdf));
53
54 if (!zdev)
55 return;
56
57 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
58 pci_name(zdev->pdev), ccdf->pec, ccdf->fid);
59}
60
61void zpci_event_availability(void *data)
62{
63 struct zpci_ccdf_avail *ccdf = data;
47 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 64 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
48 struct pci_dev *pdev = zdev ? zdev->pdev : NULL; 65 struct pci_dev *pdev = zdev ? zdev->pdev : NULL;
66 int ret;
49 67
50 pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n", 68 pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n",
51 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); 69 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid);
@@ -53,36 +71,47 @@ static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf)
53 zpci_err_hex(ccdf, sizeof(*ccdf)); 71 zpci_err_hex(ccdf, sizeof(*ccdf));
54 72
55 switch (ccdf->pec) { 73 switch (ccdf->pec) {
56 case 0x0301: 74 case 0x0301: /* Standby -> Configured */
57 zpci_enable_device(zdev); 75 if (!zdev || zdev->state == ZPCI_FN_STATE_CONFIGURED)
76 break;
77 zdev->state = ZPCI_FN_STATE_CONFIGURED;
78 ret = zpci_enable_device(zdev);
79 if (ret)
80 break;
81 pci_rescan_bus(zdev->bus);
58 break; 82 break;
59 case 0x0302: 83 case 0x0302: /* Reserved -> Standby */
60 clp_add_pci_device(ccdf->fid, ccdf->fh, 0); 84 clp_add_pci_device(ccdf->fid, ccdf->fh, 0);
61 break; 85 break;
62 case 0x0306: 86 case 0x0303: /* Deconfiguration requested */
87 if (pdev)
88 pci_stop_and_remove_bus_device(pdev);
89
90 ret = zpci_disable_device(zdev);
91 if (ret)
92 break;
93
94 ret = sclp_pci_deconfigure(zdev->fid);
95 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, ret);
96 if (!ret)
97 zdev->state = ZPCI_FN_STATE_STANDBY;
98
99 break;
100 case 0x0304: /* Configured -> Standby */
101 if (pdev)
102 pci_stop_and_remove_bus_device(pdev);
103
104 zpci_disable_device(zdev);
105 zdev->state = ZPCI_FN_STATE_STANDBY;
106 break;
107 case 0x0306: /* 0x308 or 0x302 for multiple devices */
63 clp_rescan_pci_devices(); 108 clp_rescan_pci_devices();
64 break; 109 break;
110 case 0x0308: /* Standby -> Reserved */
111 pci_stop_root_bus(zdev->bus);
112 pci_remove_root_bus(zdev->bus);
113 break;
65 default: 114 default:
66 break; 115 break;
67 } 116 }
68} 117}
69
70void zpci_event_error(void *data)
71{
72 struct zpci_ccdf_err *ccdf = data;
73 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
74
75 zpci_err("error CCDF:\n");
76 zpci_err_hex(ccdf, sizeof(*ccdf));
77
78 if (!zdev)
79 return;
80
81 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
82 pci_name(zdev->pdev), ccdf->pec, ccdf->fid);
83}
84
85void zpci_event_availability(void *data)
86{
87 zpci_event_log_avail(data);
88}