aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/msg.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-11-02 12:53:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-11-02 12:53:19 -0500
commitc35102c3e15f90fe604523a2fbffd9dc158b455a (patch)
tree0c248939a1f424701b583873360c91e081bfe810 /net/tipc/msg.c
parent20107f84b29536887b958e38b20474cccc619322 (diff)
parent4b46d6416548fb6a0940dfd9911fd895eb6247b3 (diff)
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: ARM: ensure initial page tables are setup for SMP systems ARM: 5776/1: Check compiler version and EABI support when adding ARM unwind support. ARM: 5774/1: Fix Realview ARM1176PB board reboot ARM: Fix errata 411920 workarounds ARM: Fix sparsemem with SPARSEMEM_EXTREME enabled ARM: Use GFP_DMA only for masks _less_ than 32-bit ARM: integrator: allow Integrator to be built with highmem ARM: Fix signal restart issues with NX and OABI compat
Diffstat (limited to 'net/tipc/msg.c')
0 files changed, 0 insertions, 0 deletions
ysocki <rjw@sisk.pl> 2012-04-29 16:54:17 -0400 committer Rafael J. Wysocki <rjw@sisk.pl> 2012-05-01 15:28:03 -0400 PM / Domains: Rework default device stop governor function, v2' href='/cgit/cgit.cgi/litmus-rt-ext-res.git/commit/drivers/base/power/domain_governor.c?id=a5bef810ad9816a3a8e500d8832be77d52903a12'>a5bef810ad98
b02c999ac325


6ff7bb0d02f8


9df3921e0265
6ff7bb0d02f8




9df3921e0265
0759e80b84e3
6ff7bb0d02f8



0759e80b84e3
a5bef810ad98
b02c999ac325
a5bef810ad98


6ff7bb0d02f8

a5bef810ad98




0759e80b84e3
704d2ce6603f
0759e80b84e3
704d2ce6603f
0759e80b84e3
704d2ce6603f

0759e80b84e3


704d2ce6603f


2b1d88cda32f

704d2ce6603f
0759e80b84e3


704d2ce6603f

a5bef810ad98
704d2ce6603f


a5bef810ad98
a98f1b78ecf3
a5bef810ad98

9df3921e0265
a5bef810ad98
9df3921e0265
b02c999ac325

fc5cbf0c94b6

221e9b58380a



b723b0eb91e0
221e9b58380a
221e9b58380a
fc5cbf0c94b6

6ff7bb0d02f8
221e9b58380a
b723b0eb91e0
221e9b58380a











221e9b58380a






b723b0eb91e0


221e9b58380a




221e9b58380a

dd8683e97f12
221e9b58380a
dd8683e97f12




221e9b58380a
dd8683e97f12
704d2ce6603f
0759e80b84e3

704d2ce6603f
0759e80b84e3
dd8683e97f12
221e9b58380a
dd8683e97f12


b723b0eb91e0

221e9b58380a


dd8683e97f12


221e9b58380a
b723b0eb91e0
dd8683e97f12
221e9b58380a

b723b0eb91e0


221e9b58380a
fc5cbf0c94b6

221e9b58380a


268cd2ed3d44





fc5cbf0c94b6

































925b44a273aa




e59a8db8d9b7
9df3921e0265
e59a8db8d9b7


925b44a273aa




9df3921e0265
925b44a273aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259







                                                                                


                            
                          
 


                                                                    
                          
 







                                                                               
                                                                              






                                                                                
                                                           
                                               
         
 
                                             




                                                 
   
                                                                              

                         
                                                  

                                                            
                            
                          


                                         


                                                   
                                                 




                                                                
                                      
                                        



                                                        
                               
                             
 


                                                                           

                                                                                




                                                                 
                                                                      
                                                                            
                                                                                     
                                             
                                        

                                                                              


                                                                             


                             

                                                         
                  


                                                                                

                                       
                                     


                                                            
         
 

                                                                             
                                                     
           
                                     

 

                                                             



                                                          
                            
                           
 

                                                                    
 
 
                             











                                                                      






                                                                              


                                                                           




                                                                     

                                                               
                                  
 




                                                                               
                                           
                                                            
                  

                                                                               
                   
                                                                            
                                 
 


                                                    

                                                                           


          


                                                                             
           
                                
                            

          


                                                                              
           

                                                         


                    





                                                                                

































                                                                       




                                                                 
                                                 
                                         


                                               




                                                                       
                                         
  
/*
 * drivers/base/power/domain_governor.c - Governors for device PM domains.
 *
 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
 *
 * This file is released under the GPLv2.
 */

#include <linux/kernel.h>
#include <linux/pm_domain.h>
#include <linux/pm_qos.h>
#include <linux/hrtimer.h>

static int dev_update_qos_constraint(struct device *dev, void *data)
{
	s64 *constraint_ns_p = data;
	s64 constraint_ns;

	if (dev->power.subsys_data && dev->power.subsys_data->domain_data) {
		/*
		 * Only take suspend-time QoS constraints of devices into
		 * account, because constraints updated after the device has
		 * been suspended are not guaranteed to be taken into account
		 * anyway.  In order for them to take effect, the device has to
		 * be resumed and suspended again.
		 */
		constraint_ns = dev_gpd_data(dev)->td.effective_constraint_ns;
	} else {
		/*
		 * The child is not in a domain and there's no info on its
		 * suspend/resume latencies, so assume them to be negligible and
		 * take its current PM QoS constraint (that's the only thing
		 * known at this point anyway).
		 */
		constraint_ns = dev_pm_qos_read_value(dev);
		constraint_ns *= NSEC_PER_USEC;
	}

	if (constraint_ns < *constraint_ns_p)
		*constraint_ns_p = constraint_ns;

	return 0;
}

/**
 * default_suspend_ok - Default PM domain governor routine to suspend devices.
 * @dev: Device to check.
 */
static bool default_suspend_ok(struct device *dev)
{
	struct gpd_timing_data *td = &dev_gpd_data(dev)->td;
	unsigned long flags;
	s64 constraint_ns;

	dev_dbg(dev, "%s()\n", __func__);

	spin_lock_irqsave(&dev->power.lock, flags);

	if (!td->constraint_changed) {
		bool ret = td->cached_suspend_ok;

		spin_unlock_irqrestore(&dev->power.lock, flags);
		return ret;
	}
	td->constraint_changed = false;
	td->cached_suspend_ok = false;
	td->effective_constraint_ns = 0;
	constraint_ns = __dev_pm_qos_read_value(dev);

	spin_unlock_irqrestore(&dev->power.lock, flags);

	if (constraint_ns == 0)
		return false;

	constraint_ns *= NSEC_PER_USEC;
	/*
	 * We can walk the children without any additional locking, because
	 * they all have been suspended at this point and their
	 * effective_constraint_ns fields won't be modified in parallel with us.
	 */
	if (!dev->power.ignore_children)
		device_for_each_child(dev, &constraint_ns,
				      dev_update_qos_constraint);

	if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS) {
		/* "No restriction", so the device is allowed to suspend. */
		td->effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS;
		td->cached_suspend_ok = true;
	} else if (constraint_ns == 0) {
		/*
		 * This triggers if one of the children that don't belong to a
		 * domain has a zero PM QoS constraint and it's better not to
		 * suspend then.  effective_constraint_ns is zero already and
		 * cached_suspend_ok is false, so bail out.
		 */
		return false;
	} else {
		constraint_ns -= td->suspend_latency_ns +
				td->resume_latency_ns;
		/*
		 * effective_constraint_ns is zero already and cached_suspend_ok
		 * is false, so if the computed value is not positive, return
		 * right away.
		 */
		if (constraint_ns <= 0)
			return false;

		td->effective_constraint_ns = constraint_ns;
		td->cached_suspend_ok = true;
	}

	/*
	 * The children have been suspended already, so we don't need to take
	 * their suspend latencies into account here.
	 */
	return td->cached_suspend_ok;
}

static bool __default_power_down_ok(struct dev_pm_domain *pd,
				     unsigned int state)
{
	struct generic_pm_domain *genpd = pd_to_genpd(pd);
	struct gpd_link *link;
	struct pm_domain_data *pdd;
	s64 min_off_time_ns;
	s64 off_on_time_ns;

	off_on_time_ns = genpd->states[state].power_off_latency_ns +
		genpd->states[state].power_on_latency_ns;


	min_off_time_ns = -1;
	/*
	 * Check if subdomains can be off for enough time.
	 *
	 * All subdomains have been powered off already at this point.
	 */
	list_for_each_entry(link, &genpd->master_links, master_node) {
		struct generic_pm_domain *sd = link->slave;
		s64 sd_max_off_ns = sd->max_off_time_ns;

		if (sd_max_off_ns < 0)
			continue;

		/*
		 * Check if the subdomain is allowed to be off long enough for
		 * the current domain to turn off and on (that's how much time
		 * it will have to wait worst case).
		 */
		if (sd_max_off_ns <= off_on_time_ns)
			return false;

		if (min_off_time_ns > sd_max_off_ns || min_off_time_ns < 0)
			min_off_time_ns = sd_max_off_ns;
	}

	/*
	 * Check if the devices in the domain can be off enough time.
	 */
	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
		struct gpd_timing_data *td;
		s64 constraint_ns;

		/*
		 * Check if the device is allowed to be off long enough for the
		 * domain to turn off and on (that's how much time it will
		 * have to wait worst case).
		 */
		td = &to_gpd_data(pdd)->td;
		constraint_ns = td->effective_constraint_ns;
		/*
		 * Zero means "no suspend at all" and this runs only when all
		 * devices in the domain are suspended, so it must be positive.
		 */
		if (constraint_ns == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS)
			continue;

		if (constraint_ns <= off_on_time_ns)
			return false;

		if (min_off_time_ns > constraint_ns || min_off_time_ns < 0)
			min_off_time_ns = constraint_ns;
	}

	/*
	 * If the computed minimum device off time is negative, there are no
	 * latency constraints, so the domain can spend arbitrary time in the
	 * "off" state.
	 */
	if (min_off_time_ns < 0)
		return true;

	/*
	 * The difference between the computed minimum subdomain or device off
	 * time and the time needed to turn the domain on is the maximum
	 * theoretical time this domain can spend in the "off" state.
	 */
	genpd->max_off_time_ns = min_off_time_ns -
		genpd->states[state].power_on_latency_ns;
	return true;
}

/**
 * default_power_down_ok - Default generic PM domain power off governor routine.
 * @pd: PM domain to check.
 *
 * This routine must be executed under the PM domain's lock.
 */
static bool default_power_down_ok(struct dev_pm_domain *pd)
{
	struct generic_pm_domain *genpd = pd_to_genpd(pd);
	struct gpd_link *link;

	if (!genpd->max_off_time_changed)
		return genpd->cached_power_down_ok;

	/*
	 * We have to invalidate the cached results for the masters, so
	 * use the observation that default_power_down_ok() is not
	 * going to be called for any master until this instance
	 * returns.
	 */
	list_for_each_entry(link, &genpd->slave_links, slave_node)
		link->master->max_off_time_changed = true;

	genpd->max_off_time_ns = -1;
	genpd->max_off_time_changed = false;
	genpd->cached_power_down_ok = true;
	genpd->state_idx = genpd->state_count - 1;

	/* Find a state to power down to, starting from the deepest. */
	while (!__default_power_down_ok(pd, genpd->state_idx)) {
		if (genpd->state_idx == 0) {
			genpd->cached_power_down_ok = false;
			break;
		}
		genpd->state_idx--;
	}

	return genpd->cached_power_down_ok;
}

static bool always_on_power_down_ok(struct dev_pm_domain *domain)
{
	return false;
}

struct dev_power_governor simple_qos_governor = {
	.suspend_ok = default_suspend_ok,
	.power_down_ok = default_power_down_ok,
};

/**
 * pm_genpd_gov_always_on - A governor implementing an always-on policy
 */
struct dev_power_governor pm_domain_always_on_gov = {
	.power_down_ok = always_on_power_down_ok,
	.suspend_ok = default_suspend_ok,
};