bcma: invalidate the mapped core over suspend/resume
Subsystems (4)
Rafał Miłecki
maintainerPATCH v2 1/5 bcma: invalidate the mapped core over suspend/resume
This clears the currently mapped core when suspending, to force re-mapping after resume. Without that we were touching default core registers believing some other core is mapped. Such a behaviour resulted in lockups on some machines.
---
We don't call drivers suspend/resume handlers with this patch but this at least fixes lockup. Having non-working driver after resume is still better than having locked up machine.
--- drivers/bcma/host_pci.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/bcma/host_pci.c +3 -0
@@ -237,11 +237,14 @@ static void bcma_host_pci_remove(struct pci_dev *dev)#ifdef CONFIG_PM static int bcma_host_pci_suspend (struct pci_dev *dev,pm_message_t state) { +struct bcma_bus *bus =pci_get_drvdata (dev); +/* Host specific */ pci_save_state (dev);pci_disable_device (dev);pci_set_power_state (dev,pci_choose_state (dev, state)); + bus->mapped_core =NULL ;return 0 ; }
Signature · 1 line
1.7.7
Rafał Miłecki
maintainerPATCH v2 2/5 bcma: convert suspend/resume to pm_ops
From: Linus Torvalds <[email protected]>
.. and avoid doing the unnecessary PCI operations - the PCI layer will do them for us.
--- drivers/bcma/host_pci.c | 42 ++++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 26 deletions(-)
drivers/bcma/host_pci.c +16 -26
@@ -235,41 +235,32 @@ static void bcma_host_pci_remove(struct pci_dev *dev) }#ifdef CONFIG_PM -static int bcma_host_pci_suspend (struct pci_dev *dev,pm_message_t state) +static int bcma_host_pci_suspend (struct device *dev) { -struct bcma_bus *bus =pci_get_drvdata (dev); - -/* Host specific */ -pci_save_state (dev); -pci_disable_device (dev); -pci_set_power_state (dev,pci_choose_state (dev, state)); +struct pci_dev *pdev =to_pci_dev (dev); +struct bcma_bus *bus =pci_get_drvdata (pdev); bus->mapped_core =NULL ; +return 0 ; } -static int bcma_host_pci_resume (struct pci_dev *dev) +static int bcma_host_pci_resume (struct device *dev) { -struct bcma_bus *bus =pci_get_drvdata (dev); -int err; +struct pci_dev *pdev =to_pci_dev (dev); +struct bcma_bus *bus =pci_get_drvdata (pdev); -/* Host specific */ -pci_set_power_state (dev,0 ); - err =pci_enable_device (dev); -if (err) -return err; -pci_restore_state (dev); +return bcma_bus_resume (bus); +} -/* Bus specific */ - err =bcma_bus_resume (bus); -if (err) -return err; +static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend, + bcma_host_pci_resume); +#define BCMA_PM_OPS (&bcma_pm_ops) -return 0 ; -}#else /* CONFIG_PM */ -# define bcma_host_pci_suspend NULL -# define bcma_host_pci_resume NULL + +#define BCMA_PM_OPS NULL +#endif /* CONFIG_PM */ static DEFINE_PCI_DEVICE_TABLE (bcma_pci_bridge_tbl) = {
@@ -287,8 +278,7 @@ static struct pci_driver bcma_pci_bridge_driver = { .id_table = bcma_pci_bridge_tbl, .probe = bcma_host_pci_probe, .remove = bcma_host_pci_remove, - .suspend = bcma_host_pci_suspend, - .resume = bcma_host_pci_resume, + .driver.pm = BCMA_PM_OPS, };int __init bcma_host_pci_init (void )
Signature · 1 line
1.7.7
Rafał Miłecki
maintainerPATCH v2 3/5 bcma: add stub for bcma_bus_suspend()
In reply to Rafał MiłeckiFrom: Linus Torvalds <[email protected]>
.. and connect it up with the pci host bcma driver.
Now, the next step is to connect those bcma bus-level suspend/resume functions to the actual bcma device suspend resume functions.
--- drivers/bcma/bcma_private.h | 1 + drivers/bcma/host_pci.c | 2 +- drivers/bcma/main.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletions(-)
drivers/bcma/bcma_private.h +1 -0
@@ -19,6 +19,7 @@ int __init bcma_bus_early_register(struct bcma_bus *bus,struct bcma_device *core_cc, struct bcma_device *core_mips);#ifdef CONFIG_PM +int bcma_bus_suspend (struct bcma_bus *bus);int bcma_bus_resume (struct bcma_bus *bus);#endif
drivers/bcma/host_pci.c +1 -1
@@ -242,7 +242,7 @@ static int bcma_host_pci_suspend(struct device *dev) bus->mapped_core =NULL ; -return 0 ; +return bcma_bus_suspend (bus); }static int bcma_host_pci_resume (struct device *dev)
drivers/bcma/main.c +5 -0
@@ -241,6 +241,11 @@ int __init bcma_bus_early_register(struct bcma_bus *bus, }#ifdef CONFIG_PM +int bcma_bus_suspend (struct bcma_bus *bus) +{ +return 0 ; +} +int bcma_bus_resume (struct bcma_bus *bus) {struct bcma_device *core;
Signature · 1 line
1.7.7
Rafał Miłecki
maintainerPATCH v2 4/5 bcma: connect the bcma bus suspend/resume to the bcma driver suspend/resume
In reply to Rafał MiłeckiFrom: Linus Torvalds <[email protected]>
Now the low-level driver actually gets informed that it is getting suspended and resumed.
--- drivers/bcma/main.c | 19 +++++++++++++++++++ .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 2 +- include/linux/bcma/bcma.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/bcma/main.c +19 -0
@@ -243,6 +243,16 @@ int __init bcma_bus_early_register(struct bcma_bus *bus,#ifdef CONFIG_PM int bcma_bus_suspend (struct bcma_bus *bus) { +struct bcma_device *core; + +list_for_each_entry (core, &bus->cores, list) { +struct device_driver *drv = core->dev.driver; +if (drv) { + struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv); +if (adrv->suspend) + adrv->suspend (core); + } + }return 0 ; }
@@ -257,6 +267,15 @@ int bcma_bus_resume(struct bcma_bus *bus)bcma_core_chipcommon_init (&bus->drv_cc); } +list_for_each_entry (core, &bus->cores, list) { +struct device_driver *drv = core->dev.driver; +if (drv) { + struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv); +if (adrv->resume) + adrv->resume (core); + } + } +return 0 ; }#endif
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +1 -1
@@ -1135,7 +1135,7 @@ static int brcms_pci_suspend(struct pci_dev *pdev)return pci_set_power_state (pdev, PCI_D3hot); } -static int brcms_suspend (struct bcma_device *pdev,pm_message_t state) +static int brcms_suspend (struct bcma_device *pdev) {struct brcms_info *wl;struct ieee80211_hw *hw;
include/linux/bcma/bcma.h +1 -1
@@ -162,7 +162,7 @@ struct bcma_driver {int (*probe)(struct bcma_device *dev);void (*remove)(struct bcma_device *dev); -int (*suspend)(struct bcma_device *dev,pm_message_t state); +int (*suspend)(struct bcma_device *dev);int (*resume)(struct bcma_device *dev);void (*shutdown)(struct bcma_device *dev);
Signature · 1 line
1.7.7
Rafał Miłecki
maintainerPATCH v2 5/5 brcmsmac: remove PCI suspend/resume from bcma driver
In reply to Rafał MiłeckiFrom: Linus Torvalds <[email protected]>
The brcmsmac driver isn't a PCI driver any more, it's a bcma one. The PCI device has been resumed by the PCI driver (the generic PCI layer, really), we should be resuming just our own driver state.
Also add pr_debug() calls to show that we now actually get the suspend/resume events.
--- .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 38 ++------------------ 1 files changed, 3 insertions(+), 35 deletions(-)
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +3 -35
@@ -1128,13 +1128,6 @@ static int __devinit brcms_bcma_probe(struct bcma_device *pdev)return 0 ; } -static int brcms_pci_suspend (struct pci_dev *pdev) -{ -pci_save_state (pdev); -pci_disable_device (pdev); -return pci_set_power_state (pdev, PCI_D3hot); -} -static int brcms_suspend (struct bcma_device *pdev) {struct brcms_info *wl;
@@ -1153,40 +1146,15 @@ static int brcms_suspend(struct bcma_device *pdev) wl->pub->hw_up = false;spin_unlock_bh (&wl->lock); -/* temporarily do suspend ourselves */ -return brcms_pci_suspend (pdev->bus->host_pci); -} - -static int brcms_pci_resume (struct pci_dev *pdev) -{ -int err =0 ; -uint val; - - err =pci_set_power_state (pdev,PCI_D0 ); -if (err) -return err; - -pci_restore_state (pdev); - - err =pci_enable_device (pdev); -if (err) -return err; - -pci_set_master (pdev); - -pci_read_config_dword (pdev,0x40 , &val); -if ((val &0x0000ff00 ) !=0 ) -pci_write_config_dword (pdev,0x40 , val &0xffff00ff ); +pr_debug ("brcms_suspend ok\n" );return 0 ; }static int brcms_resume (struct bcma_device *pdev) { -/* -* just do pci resume for now until bcma supports it. -*/ -return brcms_pci_resume (pdev->bus->host_pci); +pr_debug ("brcms_resume ok\n" ); +return 0 ; }static struct bcma_driver brcms_bcma_driver = {
Signature · 1 line
1.7.7