public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] cfg80211: add PM hooks
@ 2008-08-04 12:33 Johannes Berg
  2008-08-04 16:15 ` Marcel Holtmann
  2008-08-04 17:29 ` Johannes Berg
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Berg @ 2008-08-04 12:33 UTC (permalink / raw)
  To: linux-wireless

This should help implement suspend/resume in mac80211, these
hooks will be run before the device is suspended and after it
resumes. Therefore, they can touch the hardware as much as
they want to.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
This should help whoever wants to implement suspend/resume for mac80211.
I don't intend to, at the moment, but I think these hooks should be
used.

 include/net/cfg80211.h |    6 ++++++
 net/wireless/sysfs.c   |   30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

--- everything.orig/include/net/cfg80211.h	2008-08-04 14:22:39.000000000 +0200
+++ everything/include/net/cfg80211.h	2008-08-04 14:26:31.000000000 +0200
@@ -285,6 +285,9 @@ struct wiphy;
  * wireless extensions but this is subject to reevaluation as soon as this
  * code is used more widely and we have a first user without wext.
  *
+ * @suspend: wiphy device needs to be suspended
+ * @resume: wiphy device needs to be resumed
+ *
  * @add_virtual_intf: create a new virtual interface with the given name
  *
  * @del_virtual_intf: remove the virtual interface determined by ifindex.
@@ -320,6 +323,9 @@ struct wiphy;
  * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
  */
 struct cfg80211_ops {
+	int	(*suspend)(struct wiphy *wiphy);
+	int	(*resume)(struct wiphy *wiphy);
+
 	int	(*add_virtual_intf)(struct wiphy *wiphy, char *name,
 				    enum nl80211_iftype type, u32 *flags,
 				    struct vif_params *params);
--- everything.orig/net/wireless/sysfs.c	2008-08-04 14:22:39.000000000 +0200
+++ everything/net/wireless/sysfs.c	2008-08-04 14:31:58.000000000 +0200
@@ -60,6 +60,34 @@ static int wiphy_uevent(struct device *d
 }
 #endif
 
+static int wiphy_suspend(struct device *dev, pm_message_t state)
+{
+	struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
+	int ret = 0;
+
+	if (rdev->ops->suspend) {
+		rtnl_lock();
+		ret = rdev->ops->suspend(&rdev->wiphy);
+		rtnl_unlock();
+	}
+
+	return ret;
+}
+
+static int wiphy_resume(struct device *dev)
+{
+	struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
+	int ret = 0;
+
+	if (rdev->ops->resume) {
+		rtnl_lock();
+		ret = rdev->ops->suspend(&rdev->wiphy);
+		rtnl_unlock();
+	}
+
+	return ret;
+}
+
 struct class ieee80211_class = {
 	.name = "ieee80211",
 	.owner = THIS_MODULE,
@@ -68,6 +96,8 @@ struct class ieee80211_class = {
 #ifdef CONFIG_HOTPLUG
 	.dev_uevent = wiphy_uevent,
 #endif
+	.suspend = wiphy_suspend,
+	.resume = wiphy_resume,
 };
 
 int wiphy_sysfs_init(void)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 12:33 [RFC] cfg80211: add PM hooks Johannes Berg
@ 2008-08-04 16:15 ` Marcel Holtmann
  2008-08-04 16:19   ` Johannes Berg
  2008-08-04 17:29 ` Johannes Berg
  1 sibling, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2008-08-04 16:15 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

Hi Johannes,

> This should help implement suspend/resume in mac80211, these
> hooks will be run before the device is suspended and after it
> resumes. Therefore, they can touch the hardware as much as
> they want to.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> This should help whoever wants to implement suspend/resume for  
> mac80211.
> I don't intend to, at the moment, but I think these hooks should be
> used.
>
> include/net/cfg80211.h |    6 ++++++
> net/wireless/sysfs.c   |   30 ++++++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+)
>
> --- everything.orig/include/net/cfg80211.h	2008-08-04  
> 14:22:39.000000000 +0200
> +++ everything/include/net/cfg80211.h	2008-08-04 14:26:31.000000000  
> +0200
> @@ -285,6 +285,9 @@ struct wiphy;
>  * wireless extensions but this is subject to reevaluation as soon  
> as this
>  * code is used more widely and we have a first user without wext.
>  *
> + * @suspend: wiphy device needs to be suspended
> + * @resume: wiphy device needs to be resumed
> + *
>  * @add_virtual_intf: create a new virtual interface with the given  
> name
>  *
>  * @del_virtual_intf: remove the virtual interface determined by  
> ifindex.
> @@ -320,6 +323,9 @@ struct wiphy;
>  * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
>  */
> struct cfg80211_ops {
> +	int	(*suspend)(struct wiphy *wiphy);
> +	int	(*resume)(struct wiphy *wiphy);
> +
> 	int	(*add_virtual_intf)(struct wiphy *wiphy, char *name,
> 				    enum nl80211_iftype type, u32 *flags,
> 				    struct vif_params *params);
> --- everything.orig/net/wireless/sysfs.c	2008-08-04  
> 14:22:39.000000000 +0200
> +++ everything/net/wireless/sysfs.c	2008-08-04 14:31:58.000000000  
> +0200
> @@ -60,6 +60,34 @@ static int wiphy_uevent(struct device *d
> }
> #endif
>
> +static int wiphy_suspend(struct device *dev, pm_message_t state)
> +{
> +	struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
> +	int ret = 0;
> +
> +	if (rdev->ops->suspend) {
> +		rtnl_lock();
> +		ret = rdev->ops->suspend(&rdev->wiphy);
> +		rtnl_unlock();
> +	}
> +
> +	return ret;
> +}
> +
> +static int wiphy_resume(struct device *dev)
> +{
> +	struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
> +	int ret = 0;
> +
> +	if (rdev->ops->resume) {
> +		rtnl_lock();
> +		ret = rdev->ops->suspend(&rdev->wiphy);
> +		rtnl_unlock();
> +	}
> +
> +	return ret;
> +}
> +
> struct class ieee80211_class = {
> 	.name = "ieee80211",
> 	.owner = THIS_MODULE,
> @@ -68,6 +96,8 @@ struct class ieee80211_class = {
> #ifdef CONFIG_HOTPLUG
> 	.dev_uevent = wiphy_uevent,
> #endif
> +	.suspend = wiphy_suspend,
> +	.resume = wiphy_resume,
> };

this needs to be wrapped into CONFIG_PM, because otherwise the build  
will fail when CONFIG_PM is not enabled.

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 16:15 ` Marcel Holtmann
@ 2008-08-04 16:19   ` Johannes Berg
  2008-08-04 16:27     ` Marcel Holtmann
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2008-08-04 16:19 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 332 bytes --]

On Mon, 2008-08-04 at 18:15 +0200, Marcel Holtmann wrote:

> > +	.suspend = wiphy_suspend,
> > +	.resume = wiphy_resume,
> > };
> 
> this needs to be wrapped into CONFIG_PM, because otherwise the build  
> will fail when CONFIG_PM is not enabled.

I thought so too, but then I looked at include/linux/device.h

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 16:19   ` Johannes Berg
@ 2008-08-04 16:27     ` Marcel Holtmann
  2008-08-04 16:36       ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2008-08-04 16:27 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

Hi Johannes,

>>> +	.suspend = wiphy_suspend,
>>> +	.resume = wiphy_resume,
>>> };
>>
>> this needs to be wrapped into CONFIG_PM, because otherwise the build
>> will fail when CONFIG_PM is not enabled.
>
> I thought so too, but then I looked at include/linux/device.h

when did this got changed? And more to the point, why nobody bothered  
to remove all the CONFIG_PM and CONFIG_HOTPLUG ifdefs splattered  
around the kernel. It must be part of Greg's changes to remove class  
devices. I am not sure this is all the right approach since  
potentially it blots the kernel.

This would also means that the CONFIG_HOTPLUG for dev_uevent can go  
away.

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 16:27     ` Marcel Holtmann
@ 2008-08-04 16:36       ` Johannes Berg
  2008-08-04 16:39         ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2008-08-04 16:36 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]

On Mon, 2008-08-04 at 18:27 +0200, Marcel Holtmann wrote:

> >>> +	.suspend = wiphy_suspend,
> >>> +	.resume = wiphy_resume,
> >>> };
> >>
> >> this needs to be wrapped into CONFIG_PM, because otherwise the build
> >> will fail when CONFIG_PM is not enabled.
> >
> > I thought so too, but then I looked at include/linux/device.h
> 
> when did this got changed? 

No idea.

> And more to the point, why nobody bothered  
> to remove all the CONFIG_PM and CONFIG_HOTPLUG ifdefs splattered  
> around the kernel. 

Most of them are for struct device_driver and not struct class though,
so I haven't checked.

> It must be part of Greg's changes to remove class  
> devices. I am not sure this is all the right approach since  
> potentially it blots the kernel.

I suppose drivers still have a choice. I just decided that this was so
little code it didn't matter.

The more interesting question I guess is: are we now required to have
these callbacks even if CONFIG_PM(_SLEEP) is not defined? I'm not all
that interested in trying to find answers right now though.

> This would also means that the CONFIG_HOTPLUG for dev_uevent can go  
> away.

Indeed, it could.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 16:36       ` Johannes Berg
@ 2008-08-04 16:39         ` Johannes Berg
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2008-08-04 16:39 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]


> The more interesting question I guess is: are we now required to have
> these callbacks even if CONFIG_PM(_SLEEP) is not defined? I'm not all
> that interested in trying to find answers right now though.

In fact, I don't even want this patch merged. I just think that it'd be
the right approach for anyone trying to implement suspend/resume support
for mac80211.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] cfg80211: add PM hooks
  2008-08-04 12:33 [RFC] cfg80211: add PM hooks Johannes Berg
  2008-08-04 16:15 ` Marcel Holtmann
@ 2008-08-04 17:29 ` Johannes Berg
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2008-08-04 17:29 UTC (permalink / raw)
  To: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 400 bytes --]

On Mon, 2008-08-04 at 14:33 +0200, Johannes Berg wrote:
>  

>  struct class ieee80211_class = {
>  	.name = "ieee80211",
>  	.owner = THIS_MODULE,
> @@ -68,6 +96,8 @@ struct class ieee80211_class = {
>  #ifdef CONFIG_HOTPLUG
>  	.dev_uevent = wiphy_uevent,
>  #endif
> +	.suspend = wiphy_suspend,
> +	.resume = wiphy_resume,

And it looks like we should be using .pm here.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-08-04 18:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 12:33 [RFC] cfg80211: add PM hooks Johannes Berg
2008-08-04 16:15 ` Marcel Holtmann
2008-08-04 16:19   ` Johannes Berg
2008-08-04 16:27     ` Marcel Holtmann
2008-08-04 16:36       ` Johannes Berg
2008-08-04 16:39         ` Johannes Berg
2008-08-04 17:29 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox