Skip to content

Commit

Permalink
powerpc/eeh: Refactor EEH flag accessors
Browse files Browse the repository at this point in the history
There are multiple global EEH flags. Almost each flag has its own
accessor, which doesn't make sense. The patch refactors EEH flag
accessors so that they look unified:

  eeh_add_flag():   Add EEH flag
  eeh_clear_flag(): Clear EEH flag
  eeh_has_flag():   Check if one specific flag has been set
  eeh_enabled():    Check if EEH functionality has been enabled

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Gavin Shan authored and Benjamin Herrenschmidt committed Aug 5, 2014
1 parent a3032ca commit 05b1721
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 38 deletions.
32 changes: 11 additions & 21 deletions arch/powerpc/include/asm/eeh.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,36 +206,28 @@ extern int eeh_subsystem_flags;
extern struct eeh_ops *eeh_ops;
extern raw_spinlock_t confirm_error_lock;

static inline bool eeh_enabled(void)
static inline void eeh_add_flag(int flag)
{
if ((eeh_subsystem_flags & EEH_FORCE_DISABLED) ||
!(eeh_subsystem_flags & EEH_ENABLED))
return false;

return true;
eeh_subsystem_flags |= flag;
}

static inline void eeh_set_enable(bool mode)
static inline void eeh_clear_flag(int flag)
{
if (mode)
eeh_subsystem_flags |= EEH_ENABLED;
else
eeh_subsystem_flags &= ~EEH_ENABLED;
eeh_subsystem_flags &= ~flag;
}

static inline void eeh_probe_mode_set(int flag)
static inline bool eeh_has_flag(int flag)
{
eeh_subsystem_flags |= flag;
return !!(eeh_subsystem_flags & flag);
}

static inline int eeh_probe_mode_devtree(void)
static inline bool eeh_enabled(void)
{
return (eeh_subsystem_flags & EEH_PROBE_MODE_DEVTREE);
}
if (eeh_has_flag(EEH_FORCE_DISABLED) ||
!eeh_has_flag(EEH_ENABLED))
return false;

static inline int eeh_probe_mode_dev(void)
{
return (eeh_subsystem_flags & EEH_PROBE_MODE_DEV);
return true;
}

static inline void eeh_serialize_lock(unsigned long *flags)
Expand Down Expand Up @@ -314,8 +306,6 @@ static inline bool eeh_enabled(void)
return false;
}

static inline void eeh_set_enable(bool mode) { }

static inline int eeh_init(void)
{
return 0;
Expand Down
20 changes: 10 additions & 10 deletions arch/powerpc/kernel/eeh.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static struct eeh_stats eeh_stats;
static int __init eeh_setup(char *str)
{
if (!strcmp(str, "off"))
eeh_subsystem_flags |= EEH_FORCE_DISABLED;
eeh_add_flag(EEH_FORCE_DISABLED);

return 1;
}
Expand Down Expand Up @@ -252,7 +252,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
* 0xFF's is always returned from PCI config space.
*/
if (!(pe->type & EEH_PE_PHB)) {
if (eeh_probe_mode_devtree())
if (eeh_has_flag(EEH_PROBE_MODE_DEVTREE))
eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
eeh_ops->configure_bridge(pe);
eeh_pe_restore_bars(pe);
Expand Down Expand Up @@ -303,7 +303,7 @@ static int eeh_phb_check_failure(struct eeh_pe *pe)
unsigned long flags;
int ret;

if (!eeh_probe_mode_dev())
if (!eeh_has_flag(EEH_PROBE_MODE_DEV))
return -EPERM;

/* Find the PHB PE */
Expand Down Expand Up @@ -801,7 +801,7 @@ int __exit eeh_ops_unregister(const char *name)
static int eeh_reboot_notifier(struct notifier_block *nb,
unsigned long action, void *unused)
{
eeh_set_enable(false);
eeh_clear_flag(EEH_ENABLED);
return NOTIFY_DONE;
}

Expand Down Expand Up @@ -865,13 +865,13 @@ int eeh_init(void)
return ret;

/* Enable EEH for all adapters */
if (eeh_probe_mode_devtree()) {
if (eeh_has_flag(EEH_PROBE_MODE_DEVTREE)) {
list_for_each_entry_safe(hose, tmp,
&hose_list, list_node) {
phb = hose->dn;
traverse_pci_devices(phb, eeh_ops->of_probe, NULL);
}
} else if (eeh_probe_mode_dev()) {
} else if (eeh_has_flag(EEH_PROBE_MODE_DEV)) {
list_for_each_entry_safe(hose, tmp,
&hose_list, list_node)
pci_walk_bus(hose->bus, eeh_ops->dev_probe, NULL);
Expand Down Expand Up @@ -923,7 +923,7 @@ void eeh_add_device_early(struct device_node *dn)
* would delay the probe until late stage because
* the PCI device isn't available this moment.
*/
if (!eeh_probe_mode_devtree())
if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE))
return;

if (!of_node_to_eeh_dev(dn))
Expand Down Expand Up @@ -1009,7 +1009,7 @@ void eeh_add_device_late(struct pci_dev *dev)
* We have to do the EEH probe here because the PCI device
* hasn't been created yet in the early stage.
*/
if (eeh_probe_mode_dev())
if (eeh_has_flag(EEH_PROBE_MODE_DEV))
eeh_ops->dev_probe(dev, NULL);

eeh_addr_cache_insert_dev(dev);
Expand Down Expand Up @@ -1430,9 +1430,9 @@ static const struct file_operations proc_eeh_operations = {
static int eeh_enable_dbgfs_set(void *data, u64 val)
{
if (val)
eeh_subsystem_flags &= ~EEH_FORCE_DISABLED;
eeh_clear_flag(EEH_FORCE_DISABLED);
else
eeh_subsystem_flags |= EEH_FORCE_DISABLED;
eeh_add_flag(EEH_FORCE_DISABLED);

/* Notify the backend */
if (eeh_ops->post_init)
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/eeh_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static void __eeh_addr_cache_insert_dev(struct pci_dev *dev)
}

/* Skip any devices for which EEH is not enabled. */
if (!eeh_probe_mode_dev() && !edev->pe) {
if (!edev->pe) {
#ifdef DEBUG
pr_info("PCI: skip building address cache for=%s - %s\n",
pci_name(dev), dn->full_name);
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/powernv/eeh-powernv.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static int powernv_eeh_init(void)
return -EINVAL;
}

/* Set EEH probe mode */
eeh_probe_mode_set(EEH_PROBE_MODE_DEV);
/* Set probe mode */
eeh_add_flag(EEH_PROBE_MODE_DEV);

return 0;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
* Enable EEH explicitly so that we will do EEH check
* while accessing I/O stuff
*/
eeh_set_enable(true);
eeh_add_flag(EEH_ENABLED);

/* Save memory bars */
eeh_save_bars(edev);
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/platforms/powernv/pci-ioda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,6 @@ static void pnv_pci_ioda_fixup(void)
pnv_pci_ioda_create_dbgfs();

#ifdef CONFIG_EEH
eeh_probe_mode_set(EEH_PROBE_MODE_DEV);
eeh_init();
eeh_addr_cache_build();
#endif
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/pseries/eeh_pseries.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int pseries_eeh_init(void)
}

/* Set EEH probe mode */
eeh_probe_mode_set(EEH_PROBE_MODE_DEVTREE);
eeh_add_flag(EEH_PROBE_MODE_DEVTREE);

return 0;
}
Expand Down Expand Up @@ -297,7 +297,7 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
enable = 1;

if (enable) {
eeh_set_enable(true);
eeh_add_flag(EEH_ENABLED);
eeh_add_to_parent_pe(edev);

pr_debug("%s: EEH enabled on %s PHB#%d-PE#%x, config addr#%x\n",
Expand Down

0 comments on commit 05b1721

Please sign in to comment.