Skip to content

Commit 07bc9dc

Browse files
committed
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
Pull powerpc fixes from Ben Herrenschmidt: "Here is a series of powerpc fixes. It's a bit big, mostly because of the series of 11 "EEH" patches from Gavin. The EEH (Our IBM specific PCI/PCIe Enhanced Error Handling) code had been rotting for a while and this merge window saw a significant rework & fixing of it by Gavin Shan. However, that wasn't complete and left some open issues. There were still a few corner cases that didn't work properly, for example in relation to hotplug and devices without explicit error handlers. We had some patches but they weren't quite good enough yet so I left them off the 3.11 merge window. Gavin since then fixed it all up, we ran quite a few rounds of testing and it seems fairly solid (at least probably more than it has ever been). This should probably have made -rc1 but both Gavin and I took some vacation so it had to wait for -rc2. The rest is more bug fixes, mostly to new features recently added, for example, we missed the cpu table entry for one of the two models of P8 (we didn't realize they had different PVR [Processor Version Register] values), some module CRC issues, etc..." * 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (23 commits) powerpc/perf: BHRB filter configuration should follow the task powerpc/perf: Ignore separate BHRB privilege state filter request powerpc/powernv: Mark pnv_pci_init_ioda2_phb() as __init powerpc/mm: Use the correct SLB(LLP) encoding in tlbie instruction powerpc/mm: Fix fallthrough bug in hpte_decode powerpc/pseries: Fix a typo in pSeries_lpar_hpte_insert() powerpc/eeh: Introdce flag to protect sysfs powerpc/eeh: Fix unbalanced enable for IRQ powerpc/eeh: Don't use pci_dev during BAR restore powerpc/eeh: Use partial hotplug for EEH unaware drivers powerpc/pci: Partial tree hotplug support powerpc/eeh: Use safe list traversal when walking EEH devices powerpc/eeh: Keep PE during hotplug powerpc/pci/hotplug: Don't need to remove from EEH cache twice powerpc/pci: Override pcibios_release_device() powerpc/eeh: Export functions for hotplug powerpc/eeh: Remove reference to PCI device powerpc: Fix the corrupt r3 error during MCE handling. powerpc/perf: Set PPC_FEATURE2_EBB when we register the power8 PMU powerpc/pseries: Drop "select HOTPLUG" ...
2 parents b48a97b + ff3d79d commit 07bc9dc

26 files changed

Lines changed: 390 additions & 169 deletions

‎arch/powerpc/include/asm/eeh.h‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct device_node;
5555
#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */
5656
#define EEH_PE_PHB_DEAD (1 << 2) /* Dead PHB */
5757

58+
#define EEH_PE_KEEP (1 << 8) /* Keep PE on hotplug */
59+
5860
struct eeh_pe {
5961
int type; /* PE type: PHB/Bus/Device */
6062
int state; /* PE EEH dependent mode */
@@ -72,8 +74,8 @@ struct eeh_pe {
7274
struct list_head child; /* Child PEs */
7375
};
7476

75-
#define eeh_pe_for_each_dev(pe, edev) \
76-
list_for_each_entry(edev, &pe->edevs, list)
77+
#define eeh_pe_for_each_dev(pe, edev, tmp) \
78+
list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
7779

7880
/*
7981
* The struct is used to trace EEH state for the associated
@@ -82,19 +84,27 @@ struct eeh_pe {
8284
* another tree except the currently existing tree of PCI
8385
* buses and PCI devices
8486
*/
85-
#define EEH_DEV_IRQ_DISABLED (1<<0) /* Interrupt disabled */
87+
#define EEH_DEV_BRIDGE (1 << 0) /* PCI bridge */
88+
#define EEH_DEV_ROOT_PORT (1 << 1) /* PCIe root port */
89+
#define EEH_DEV_DS_PORT (1 << 2) /* Downstream port */
90+
#define EEH_DEV_IRQ_DISABLED (1 << 3) /* Interrupt disabled */
91+
#define EEH_DEV_DISCONNECTED (1 << 4) /* Removing from PE */
92+
93+
#define EEH_DEV_SYSFS (1 << 8) /* Sysfs created */
8694

8795
struct eeh_dev {
8896
int mode; /* EEH mode */
8997
int class_code; /* Class code of the device */
9098
int config_addr; /* Config address */
9199
int pe_config_addr; /* PE config address */
92100
u32 config_space[16]; /* Saved PCI config space */
101+
u8 pcie_cap; /* Saved PCIe capability */
93102
struct eeh_pe *pe; /* Associated PE */
94103
struct list_head list; /* Form link list in the PE */
95104
struct pci_controller *phb; /* Associated PHB */
96105
struct device_node *dn; /* Associated device node */
97106
struct pci_dev *pdev; /* Associated PCI device */
107+
struct pci_bus *bus; /* PCI bus for partial hotplug */
98108
};
99109

100110
static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
@@ -193,8 +203,10 @@ int eeh_phb_pe_create(struct pci_controller *phb);
193203
struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
194204
struct eeh_pe *eeh_pe_get(struct eeh_dev *edev);
195205
int eeh_add_to_parent_pe(struct eeh_dev *edev);
196-
int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe);
206+
int eeh_rmv_from_parent_pe(struct eeh_dev *edev);
197207
void eeh_pe_update_time_stamp(struct eeh_pe *pe);
208+
void *eeh_pe_traverse(struct eeh_pe *root,
209+
eeh_traverse_func fn, void *flag);
198210
void *eeh_pe_dev_traverse(struct eeh_pe *root,
199211
eeh_traverse_func fn, void *flag);
200212
void eeh_pe_restore_bars(struct eeh_pe *pe);
@@ -209,10 +221,12 @@ unsigned long eeh_check_failure(const volatile void __iomem *token,
209221
unsigned long val);
210222
int eeh_dev_check_failure(struct eeh_dev *edev);
211223
void eeh_addr_cache_build(void);
224+
void eeh_add_device_early(struct device_node *);
212225
void eeh_add_device_tree_early(struct device_node *);
226+
void eeh_add_device_late(struct pci_dev *);
213227
void eeh_add_device_tree_late(struct pci_bus *);
214228
void eeh_add_sysfs_files(struct pci_bus *);
215-
void eeh_remove_bus_device(struct pci_dev *, int);
229+
void eeh_remove_device(struct pci_dev *);
216230

217231
/**
218232
* EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
@@ -252,13 +266,17 @@ static inline unsigned long eeh_check_failure(const volatile void __iomem *token
252266

253267
static inline void eeh_addr_cache_build(void) { }
254268

269+
static inline void eeh_add_device_early(struct device_node *dn) { }
270+
255271
static inline void eeh_add_device_tree_early(struct device_node *dn) { }
256272

273+
static inline void eeh_add_device_late(struct pci_dev *dev) { }
274+
257275
static inline void eeh_add_device_tree_late(struct pci_bus *bus) { }
258276

259277
static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
260278

261-
static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { }
279+
static inline void eeh_remove_device(struct pci_dev *dev) { }
262280

263281
#define EEH_POSSIBLE_ERROR(val, type) (0)
264282
#define EEH_IO_ERROR_VALUE(size) (-1UL)

‎arch/powerpc/include/asm/hw_irq.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void)
9696
#endif
9797

9898
#define hard_irq_disable() do { \
99-
u8 _was_enabled = get_paca()->soft_enabled; \
99+
u8 _was_enabled; \
100100
__hard_irq_disable(); \
101-
get_paca()->soft_enabled = 0; \
102-
get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \
101+
_was_enabled = local_paca->soft_enabled; \
102+
local_paca->soft_enabled = 0; \
103+
local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
103104
if (_was_enabled) \
104105
trace_hardirqs_off(); \
105106
} while(0)

‎arch/powerpc/include/asm/module.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ struct exception_table_entry;
8282
void sort_ex_table(struct exception_table_entry *start,
8383
struct exception_table_entry *finish);
8484

85-
#ifdef CONFIG_MODVERSIONS
85+
#if defined(CONFIG_MODVERSIONS) && defined(CONFIG_PPC64)
8686
#define ARCH_RELOCATES_KCRCTAB
87-
88-
extern const unsigned long reloc_start[];
87+
#define reloc_start PHYSICAL_START
8988
#endif
9089
#endif /* __KERNEL__ */
9190
#endif /* _ASM_POWERPC_MODULE_H */

‎arch/powerpc/include/asm/pci-bridge.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
209209
extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
210210

211211
/** Remove all of the PCI devices under this bus */
212-
extern void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe);
213212
extern void pcibios_remove_pci_devices(struct pci_bus *bus);
214213

215214
/** Discover new pci devices under this bus, and add them */

‎arch/powerpc/include/asm/reg.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,8 @@
10881088
#define PVR_970MP 0x0044
10891089
#define PVR_970GX 0x0045
10901090
#define PVR_POWER7p 0x004A
1091-
#define PVR_POWER8 0x004B
1091+
#define PVR_POWER8E 0x004B
1092+
#define PVR_POWER8 0x004D
10921093
#define PVR_BE 0x0070
10931094
#define PVR_PA6T 0x0090
10941095

‎arch/powerpc/kernel/cputable.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,27 @@ static struct cpu_spec __initdata cpu_specs[] = {
494494
.cpu_restore = __restore_cpu_power7,
495495
.platform = "power7+",
496496
},
497-
{ /* Power8 */
497+
{ /* Power8E */
498498
.pvr_mask = 0xffff0000,
499499
.pvr_value = 0x004b0000,
500+
.cpu_name = "POWER8E (raw)",
501+
.cpu_features = CPU_FTRS_POWER8,
502+
.cpu_user_features = COMMON_USER_POWER8,
503+
.cpu_user_features2 = COMMON_USER2_POWER8,
504+
.mmu_features = MMU_FTRS_POWER8,
505+
.icache_bsize = 128,
506+
.dcache_bsize = 128,
507+
.num_pmcs = 6,
508+
.pmc_type = PPC_PMC_IBM,
509+
.oprofile_cpu_type = "ppc64/power8",
510+
.oprofile_type = PPC_OPROFILE_INVALID,
511+
.cpu_setup = __setup_cpu_power8,
512+
.cpu_restore = __restore_cpu_power8,
513+
.platform = "power8",
514+
},
515+
{ /* Power8 */
516+
.pvr_mask = 0xffff0000,
517+
.pvr_value = 0x004d0000,
500518
.cpu_name = "POWER8 (raw)",
501519
.cpu_features = CPU_FTRS_POWER8,
502520
.cpu_user_features = COMMON_USER_POWER8,

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
231231
void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
232232
{
233233
size_t loglen = 0;
234-
struct eeh_dev *edev;
234+
struct eeh_dev *edev, *tmp;
235235
bool valid_cfg_log = true;
236236

237237
/*
@@ -251,7 +251,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
251251
eeh_pe_restore_bars(pe);
252252

253253
pci_regs_buf[0] = 0;
254-
eeh_pe_for_each_dev(pe, edev) {
254+
eeh_pe_for_each_dev(pe, edev, tmp) {
255255
loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen,
256256
EEH_PCI_REGS_LOG_LEN - loglen);
257257
}
@@ -499,8 +499,6 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
499499
}
500500

501501
eeh_dev_check_failure(edev);
502-
503-
pci_dev_put(eeh_dev_to_pci_dev(edev));
504502
return val;
505503
}
506504

@@ -838,7 +836,7 @@ core_initcall_sync(eeh_init);
838836
* on the CEC architecture, type of the device, on earlier boot
839837
* command-line arguments & etc.
840838
*/
841-
static void eeh_add_device_early(struct device_node *dn)
839+
void eeh_add_device_early(struct device_node *dn)
842840
{
843841
struct pci_controller *phb;
844842

@@ -886,7 +884,7 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
886884
* This routine must be used to complete EEH initialization for PCI
887885
* devices that were added after system boot (e.g. hotplug, dlpar).
888886
*/
889-
static void eeh_add_device_late(struct pci_dev *dev)
887+
void eeh_add_device_late(struct pci_dev *dev)
890888
{
891889
struct device_node *dn;
892890
struct eeh_dev *edev;
@@ -902,9 +900,23 @@ static void eeh_add_device_late(struct pci_dev *dev)
902900
pr_debug("EEH: Already referenced !\n");
903901
return;
904902
}
905-
WARN_ON(edev->pdev);
906903

907-
pci_dev_get(dev);
904+
/*
905+
* The EEH cache might not be removed correctly because of
906+
* unbalanced kref to the device during unplug time, which
907+
* relies on pcibios_release_device(). So we have to remove
908+
* that here explicitly.
909+
*/
910+
if (edev->pdev) {
911+
eeh_rmv_from_parent_pe(edev);
912+
eeh_addr_cache_rmv_dev(edev->pdev);
913+
eeh_sysfs_remove_device(edev->pdev);
914+
edev->mode &= ~EEH_DEV_SYSFS;
915+
916+
edev->pdev = NULL;
917+
dev->dev.archdata.edev = NULL;
918+
}
919+
908920
edev->pdev = dev;
909921
dev->dev.archdata.edev = edev;
910922

@@ -967,15 +979,14 @@ EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
967979
/**
968980
* eeh_remove_device - Undo EEH setup for the indicated pci device
969981
* @dev: pci device to be removed
970-
* @purge_pe: remove the PE or not
971982
*
972983
* This routine should be called when a device is removed from
973984
* a running system (e.g. by hotplug or dlpar). It unregisters
974985
* the PCI device from the EEH subsystem. I/O errors affecting
975986
* this device will no longer be detected after this call; thus,
976987
* i/o errors affecting this slot may leave this device unusable.
977988
*/
978-
static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
989+
void eeh_remove_device(struct pci_dev *dev)
979990
{
980991
struct eeh_dev *edev;
981992

@@ -986,42 +997,29 @@ static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
986997
/* Unregister the device with the EEH/PCI address search system */
987998
pr_debug("EEH: Removing device %s\n", pci_name(dev));
988999

989-
if (!edev || !edev->pdev) {
1000+
if (!edev || !edev->pdev || !edev->pe) {
9901001
pr_debug("EEH: Not referenced !\n");
9911002
return;
9921003
}
1004+
1005+
/*
1006+
* During the hotplug for EEH error recovery, we need the EEH
1007+
* device attached to the parent PE in order for BAR restore
1008+
* a bit later. So we keep it for BAR restore and remove it
1009+
* from the parent PE during the BAR resotre.
1010+
*/
9931011
edev->pdev = NULL;
9941012
dev->dev.archdata.edev = NULL;
995-
pci_dev_put(dev);
1013+
if (!(edev->pe->state & EEH_PE_KEEP))
1014+
eeh_rmv_from_parent_pe(edev);
1015+
else
1016+
edev->mode |= EEH_DEV_DISCONNECTED;
9961017

997-
eeh_rmv_from_parent_pe(edev, purge_pe);
9981018
eeh_addr_cache_rmv_dev(dev);
9991019
eeh_sysfs_remove_device(dev);
1020+
edev->mode &= ~EEH_DEV_SYSFS;
10001021
}
10011022

1002-
/**
1003-
* eeh_remove_bus_device - Undo EEH setup for the indicated PCI device
1004-
* @dev: PCI device
1005-
* @purge_pe: remove the corresponding PE or not
1006-
*
1007-
* This routine must be called when a device is removed from the
1008-
* running system through hotplug or dlpar. The corresponding
1009-
* PCI address cache will be removed.
1010-
*/
1011-
void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe)
1012-
{
1013-
struct pci_bus *bus = dev->subordinate;
1014-
struct pci_dev *child, *tmp;
1015-
1016-
eeh_remove_device(dev, purge_pe);
1017-
1018-
if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
1019-
list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
1020-
eeh_remove_bus_device(child, purge_pe);
1021-
}
1022-
}
1023-
EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
1024-
10251023
static int proc_eeh_show(struct seq_file *m, void *v)
10261024
{
10271025
if (0 == eeh_subsystem_enabled) {

‎arch/powerpc/kernel/eeh_cache.c‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,12 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr)
6868
struct pci_io_addr_range *piar;
6969
piar = rb_entry(n, struct pci_io_addr_range, rb_node);
7070

71-
if (addr < piar->addr_lo) {
71+
if (addr < piar->addr_lo)
7272
n = n->rb_left;
73-
} else {
74-
if (addr > piar->addr_hi) {
75-
n = n->rb_right;
76-
} else {
77-
pci_dev_get(piar->pcidev);
78-
return piar->edev;
79-
}
80-
}
73+
else if (addr > piar->addr_hi)
74+
n = n->rb_right;
75+
else
76+
return piar->edev;
8177
}
8278

8379
return NULL;
@@ -156,7 +152,6 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
156152
if (!piar)
157153
return NULL;
158154

159-
pci_dev_get(dev);
160155
piar->addr_lo = alo;
161156
piar->addr_hi = ahi;
162157
piar->edev = pci_dev_to_eeh_dev(dev);
@@ -250,7 +245,6 @@ static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev)
250245

251246
if (piar->pcidev == dev) {
252247
rb_erase(n, &pci_io_addr_cache_root.rb_root);
253-
pci_dev_put(piar->pcidev);
254248
kfree(piar);
255249
goto restart;
256250
}
@@ -302,12 +296,10 @@ void eeh_addr_cache_build(void)
302296
if (!edev)
303297
continue;
304298

305-
pci_dev_get(dev); /* matching put is in eeh_remove_device() */
306299
dev->dev.archdata.edev = edev;
307300
edev->pdev = dev;
308301

309302
eeh_addr_cache_insert_dev(dev);
310-
311303
eeh_sysfs_add_device(dev);
312304
}
313305

0 commit comments

Comments
 (0)