* [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume
@ 2012-01-13 22:58 Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 2/5] bcma: convert suspend/resume to pm_ops Rafał Miłecki
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-01-13 22:58 UTC (permalink / raw)
To: John W. Linville
Cc: Network Development, Linus Torvalds, Arend van Spriel,
Larry Finger, Alwin Beukers, Roland Vossen, Franky (Zhenhui) Lin,
Rafał Miłecki, stable
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.
Cc: stable@vger.kernel.org
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
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(-)
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 443b83a..c1ca9e3 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -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;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 2/5] bcma: convert suspend/resume to pm_ops
2012-01-13 22:58 [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume Rafał Miłecki
@ 2012-01-13 22:58 ` Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 3/5] bcma: add stub for bcma_bus_suspend() Rafał Miłecki
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-01-13 22:58 UTC (permalink / raw)
To: John W. Linville
Cc: Network Development, Linus Torvalds, Arend van Spriel,
Larry Finger, Alwin Beukers, Roland Vossen, Franky (Zhenhui) Lin,
Rafał Miłecki
From: Linus Torvalds <torvalds@linux-foundation.org>
.. and avoid doing the unnecessary PCI operations - the PCI layer will
do them for us.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
drivers/bcma/host_pci.c | 42 ++++++++++++++++--------------------------
1 files changed, 16 insertions(+), 26 deletions(-)
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index c1ca9e3..86dfeea 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -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)
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 3/5] bcma: add stub for bcma_bus_suspend()
2012-01-13 22:58 [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 2/5] bcma: convert suspend/resume to pm_ops Rafał Miłecki
@ 2012-01-13 22:58 ` Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 4/5] bcma: connect the bcma bus suspend/resume to the bcma driver suspend/resume Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 5/5] brcmsmac: remove PCI suspend/resume from bcma driver Rafał Miłecki
3 siblings, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-01-13 22:58 UTC (permalink / raw)
To: John W. Linville
Cc: Network Development, Linus Torvalds, Arend van Spriel,
Larry Finger, Alwin Beukers, Roland Vossen, Franky (Zhenhui) Lin,
Rafał Miłecki
From: Linus Torvalds <torvalds@linux-foundation.org>
.. 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.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
drivers/bcma/bcma_private.h | 1 +
drivers/bcma/host_pci.c | 2 +-
drivers/bcma/main.c | 5 +++++
3 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index fda56bd..0def898 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -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
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 86dfeea..f59244e 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -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)
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 10f92b3..b711d9d 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -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;
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 4/5] bcma: connect the bcma bus suspend/resume to the bcma driver suspend/resume
2012-01-13 22:58 [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 2/5] bcma: convert suspend/resume to pm_ops Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 3/5] bcma: add stub for bcma_bus_suspend() Rafał Miłecki
@ 2012-01-13 22:58 ` Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 5/5] brcmsmac: remove PCI suspend/resume from bcma driver Rafał Miłecki
3 siblings, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-01-13 22:58 UTC (permalink / raw)
To: John W. Linville
Cc: Network Development, Linus Torvalds, Arend van Spriel,
Larry Finger, Alwin Beukers, Roland Vossen, Franky (Zhenhui) Lin
From: Linus Torvalds <torvalds@linux-foundation.org>
Now the low-level driver actually gets informed that it is getting suspended and resumed.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
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(-)
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index b711d9d..febbc0a 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -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
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 77fdc45..19721db 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -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;
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index f4b8346..83c209f 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -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);
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 5/5] brcmsmac: remove PCI suspend/resume from bcma driver
2012-01-13 22:58 [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume Rafał Miłecki
` (2 preceding siblings ...)
2012-01-13 22:58 ` [PATCH V2 4/5] bcma: connect the bcma bus suspend/resume to the bcma driver suspend/resume Rafał Miłecki
@ 2012-01-13 22:58 ` Rafał Miłecki
3 siblings, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2012-01-13 22:58 UTC (permalink / raw)
To: John W. Linville
Cc: Network Development, Linus Torvalds, Arend van Spriel,
Larry Finger, Alwin Beukers, Roland Vossen, Franky (Zhenhui) Lin
From: Linus Torvalds <torvalds@linux-foundation.org>
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.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
.../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 38 ++------------------
1 files changed, 3 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 19721db..c43b2f8 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -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 = {
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-13 22:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 22:58 [PATCH V2 1/5][STABLE] bcma: invalidate the mapped core over suspend/resume Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 2/5] bcma: convert suspend/resume to pm_ops Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 3/5] bcma: add stub for bcma_bus_suspend() Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 4/5] bcma: connect the bcma bus suspend/resume to the bcma driver suspend/resume Rafał Miłecki
2012-01-13 22:58 ` [PATCH V2 5/5] brcmsmac: remove PCI suspend/resume from bcma driver Rafał Miłecki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).