1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Power Management Quality of Service (PM QoS) support base.
4 *
5 * Copyright (C) 2020 Intel Corporation
6 *
7 * Authors:
8 * Mark Gross <mgross@linux.intel.com>
9 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 *
11 * Provided here is an interface for specifying PM QoS dependencies. It allows
12 * entities depending on QoS constraints to register their requests which are
13 * aggregated as appropriate to produce effective constraints (target values)
14 * that can be monitored by entities needing to respect them, either by polling
15 * or through a built-in notification mechanism.
16 *
17 * In addition to the basic functionality, more specific interfaces for managing
18 * global CPU latency QoS requests and frequency QoS requests are provided.
19 */
20
21 /*#define DEBUG*/
22
23 #include <linux/pm_qos.h>
24 #include <linux/sched.h>
25 #include <linux/spinlock.h>
26 #include <linux/slab.h>
27 #include <linux/time.h>
28 #include <linux/fs.h>
29 #include <linux/device.h>
30 #include <linux/miscdevice.h>
31 #include <linux/string.h>
32 #include <linux/platform_device.h>
33 #include <linux/init.h>
34 #include <linux/kernel.h>
35 #include <linux/debugfs.h>
36 #include <linux/seq_file.h>
37
38 #include <linux/uaccess.h>
39 #include <linux/export.h>
40 #include <trace/events/power.h>
41 #include <trace/hooks/power.h>
42
43 /*
44 * locking rule: all changes to constraints or notifiers lists
45 * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
46 * held, taken with _irqsave. One lock to rule them all
47 */
48 static DEFINE_SPINLOCK(pm_qos_lock);
49
50 /**
51 * pm_qos_read_value - Return the current effective constraint value.
52 * @c: List of PM QoS constraint requests.
53 */
pm_qos_read_value(struct pm_qos_constraints * c)54 s32 pm_qos_read_value(struct pm_qos_constraints *c)
55 {
56 return READ_ONCE(c->target_value);
57 }
58
pm_qos_get_value(struct pm_qos_constraints * c)59 static int pm_qos_get_value(struct pm_qos_constraints *c)
60 {
61 if (plist_head_empty(&c->list))
62 return c->no_constraint_value;
63
64 switch (c->type) {
65 case PM_QOS_MIN:
66 return plist_first(&c->list)->prio;
67
68 case PM_QOS_MAX:
69 return plist_last(&c->list)->prio;
70
71 default:
72 WARN(1, "Unknown PM QoS type in %s\n", __func__);
73 return PM_QOS_DEFAULT_VALUE;
74 }
75 }
76
pm_qos_set_value(struct pm_qos_constraints * c,s32 value)77 static void pm_qos_set_value(struct pm_qos_constraints *c, s32 value)
78 {
79 WRITE_ONCE(c->target_value, value);
80 }
81
82 /**
83 * pm_qos_update_target - Update a list of PM QoS constraint requests.
84 * @c: List of PM QoS requests.
85 * @node: Target list entry.
86 * @action: Action to carry out (add, update or remove).
87 * @value: New request value for the target list entry.
88 *
89 * Update the given list of PM QoS constraint requests, @c, by carrying an
90 * @action involving the @node list entry and @value on it.
91 *
92 * The recognized values of @action are PM_QOS_ADD_REQ (store @value in @node
93 * and add it to the list), PM_QOS_UPDATE_REQ (remove @node from the list, store
94 * @value in it and add it to the list again), and PM_QOS_REMOVE_REQ (remove
95 * @node from the list, ignore @value).
96 *
97 * Return: 1 if the aggregate constraint value has changed, 0 otherwise.
98 */
pm_qos_update_target(struct pm_qos_constraints * c,struct plist_node * node,enum pm_qos_req_action action,int value)99 int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
100 enum pm_qos_req_action action, int value)
101 {
102 int prev_value, curr_value, new_value;
103 unsigned long flags;
104
105 spin_lock_irqsave(&pm_qos_lock, flags);
106
107 prev_value = pm_qos_get_value(c);
108 if (value == PM_QOS_DEFAULT_VALUE)
109 new_value = c->default_value;
110 else
111 new_value = value;
112
113 switch (action) {
114 case PM_QOS_REMOVE_REQ:
115 plist_del(node, &c->list);
116 break;
117 case PM_QOS_UPDATE_REQ:
118 /*
119 * To change the list, atomically remove, reinit with new value
120 * and add, then see if the aggregate has changed.
121 */
122 plist_del(node, &c->list);
123 fallthrough;
124 case PM_QOS_ADD_REQ:
125 plist_node_init(node, new_value);
126 plist_add(node, &c->list);
127 break;
128 default:
129 /* no action */
130 ;
131 }
132
133 curr_value = pm_qos_get_value(c);
134 pm_qos_set_value(c, curr_value);
135
136 spin_unlock_irqrestore(&pm_qos_lock, flags);
137
138 trace_pm_qos_update_target(action, prev_value, curr_value);
139
140 if (prev_value == curr_value)
141 return 0;
142
143 if (c->notifiers)
144 blocking_notifier_call_chain(c->notifiers, curr_value, NULL);
145
146 return 1;
147 }
148
149 /**
150 * pm_qos_flags_remove_req - Remove device PM QoS flags request.
151 * @pqf: Device PM QoS flags set to remove the request from.
152 * @req: Request to remove from the set.
153 */
pm_qos_flags_remove_req(struct pm_qos_flags * pqf,struct pm_qos_flags_request * req)154 static void pm_qos_flags_remove_req(struct pm_qos_flags *pqf,
155 struct pm_qos_flags_request *req)
156 {
157 s32 val = 0;
158
159 list_del(&req->node);
160 list_for_each_entry(req, &pqf->list, node)
161 val |= req->flags;
162
163 pqf->effective_flags = val;
164 }
165
166 /**
167 * pm_qos_update_flags - Update a set of PM QoS flags.
168 * @pqf: Set of PM QoS flags to update.
169 * @req: Request to add to the set, to modify, or to remove from the set.
170 * @action: Action to take on the set.
171 * @val: Value of the request to add or modify.
172 *
173 * Return: 1 if the aggregate constraint value has changed, 0 otherwise.
174 */
pm_qos_update_flags(struct pm_qos_flags * pqf,struct pm_qos_flags_request * req,enum pm_qos_req_action action,s32 val)175 bool pm_qos_update_flags(struct pm_qos_flags *pqf,
176 struct pm_qos_flags_request *req,
177 enum pm_qos_req_action action, s32 val)
178 {
179 unsigned long irqflags;
180 s32 prev_value, curr_value;
181
182 spin_lock_irqsave(&pm_qos_lock, irqflags);
183
184 prev_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
185
186 switch (action) {
187 case PM_QOS_REMOVE_REQ:
188 pm_qos_flags_remove_req(pqf, req);
189 break;
190 case PM_QOS_UPDATE_REQ:
191 pm_qos_flags_remove_req(pqf, req);
192 fallthrough;
193 case PM_QOS_ADD_REQ:
194 req->flags = val;
195 INIT_LIST_HEAD(&req->node);
196 list_add_tail(&req->node, &pqf->list);
197 pqf->effective_flags |= val;
198 break;
199 default:
200 /* no action */
201 ;
202 }
203
204 curr_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags;
205
206 spin_unlock_irqrestore(&pm_qos_lock, irqflags);
207
208 trace_pm_qos_update_flags(action, prev_value, curr_value);
209
210 return prev_value != curr_value;
211 }
212
213 #ifdef CONFIG_CPU_IDLE
214 /* Definitions related to the CPU latency QoS. */
215
216 static struct pm_qos_constraints cpu_latency_constraints = {
217 .list = PLIST_HEAD_INIT(cpu_latency_constraints.list),
218 .target_value = PM_QOS_CPU_LATENCY_DEFAULT_VALUE,
219 .default_value = PM_QOS_CPU_LATENCY_DEFAULT_VALUE,
220 .no_constraint_value = PM_QOS_CPU_LATENCY_DEFAULT_VALUE,
221 .type = PM_QOS_MIN,
222 };
223
224 /**
225 * cpu_latency_qos_limit - Return current system-wide CPU latency QoS limit.
226 */
cpu_latency_qos_limit(void)227 s32 cpu_latency_qos_limit(void)
228 {
229 return pm_qos_read_value(&cpu_latency_constraints);
230 }
231
232 /**
233 * cpu_latency_qos_request_active - Check the given PM QoS request.
234 * @req: PM QoS request to check.
235 *
236 * Return: 'true' if @req has been added to the CPU latency QoS list, 'false'
237 * otherwise.
238 */
cpu_latency_qos_request_active(struct pm_qos_request * req)239 bool cpu_latency_qos_request_active(struct pm_qos_request *req)
240 {
241 return req->qos == &cpu_latency_constraints;
242 }
243 EXPORT_SYMBOL_GPL(cpu_latency_qos_request_active);
244
cpu_latency_qos_apply(struct pm_qos_request * req,enum pm_qos_req_action action,s32 value)245 static void cpu_latency_qos_apply(struct pm_qos_request *req,
246 enum pm_qos_req_action action, s32 value)
247 {
248 int ret = pm_qos_update_target(req->qos, &req->node, action, value);
249 if (ret > 0)
250 wake_up_all_idle_cpus();
251 }
252
253 /**
254 * cpu_latency_qos_add_request - Add new CPU latency QoS request.
255 * @req: Pointer to a preallocated handle.
256 * @value: Requested constraint value.
257 *
258 * Use @value to initialize the request handle pointed to by @req, insert it as
259 * a new entry to the CPU latency QoS list and recompute the effective QoS
260 * constraint for that list.
261 *
262 * Callers need to save the handle for later use in updates and removal of the
263 * QoS request represented by it.
264 */
cpu_latency_qos_add_request(struct pm_qos_request * req,s32 value)265 void cpu_latency_qos_add_request(struct pm_qos_request *req, s32 value)
266 {
267 if (!req)
268 return;
269
270 if (cpu_latency_qos_request_active(req)) {
271 WARN(1, KERN_ERR "%s called for already added request\n", __func__);
272 return;
273 }
274
275 trace_pm_qos_add_request(value);
276
277 req->qos = &cpu_latency_constraints;
278 cpu_latency_qos_apply(req, PM_QOS_ADD_REQ, value);
279 }
280 EXPORT_SYMBOL_GPL(cpu_latency_qos_add_request);
281
282 /**
283 * cpu_latency_qos_update_request - Modify existing CPU latency QoS request.
284 * @req : QoS request to update.
285 * @new_value: New requested constraint value.
286 *
287 * Use @new_value to update the QoS request represented by @req in the CPU
288 * latency QoS list along with updating the effective constraint value for that
289 * list.
290 */
cpu_latency_qos_update_request(struct pm_qos_request * req,s32 new_value)291 void cpu_latency_qos_update_request(struct pm_qos_request *req, s32 new_value)
292 {
293 if (!req)
294 return;
295
296 if (!cpu_latency_qos_request_active(req)) {
297 WARN(1, KERN_ERR "%s called for unknown object\n", __func__);
298 return;
299 }
300
301 trace_pm_qos_update_request(new_value);
302
303 if (new_value == req->node.prio)
304 return;
305
306 cpu_latency_qos_apply(req, PM_QOS_UPDATE_REQ, new_value);
307 }
308 EXPORT_SYMBOL_GPL(cpu_latency_qos_update_request);
309
310 /**
311 * cpu_latency_qos_remove_request - Remove existing CPU latency QoS request.
312 * @req: QoS request to remove.
313 *
314 * Remove the CPU latency QoS request represented by @req from the CPU latency
315 * QoS list along with updating the effective constraint value for that list.
316 */
cpu_latency_qos_remove_request(struct pm_qos_request * req)317 void cpu_latency_qos_remove_request(struct pm_qos_request *req)
318 {
319 if (!req)
320 return;
321
322 if (!cpu_latency_qos_request_active(req)) {
323 WARN(1, KERN_ERR "%s called for unknown object\n", __func__);
324 return;
325 }
326
327 trace_pm_qos_remove_request(PM_QOS_DEFAULT_VALUE);
328
329 cpu_latency_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
330 memset(req, 0, sizeof(*req));
331 }
332 EXPORT_SYMBOL_GPL(cpu_latency_qos_remove_request);
333
334 /* User space interface to the CPU latency QoS via misc device. */
335
cpu_latency_qos_open(struct inode * inode,struct file * filp)336 static int cpu_latency_qos_open(struct inode *inode, struct file *filp)
337 {
338 struct pm_qos_request *req;
339
340 req = kzalloc(sizeof(*req), GFP_KERNEL);
341 if (!req)
342 return -ENOMEM;
343
344 cpu_latency_qos_add_request(req, PM_QOS_DEFAULT_VALUE);
345 filp->private_data = req;
346
347 return 0;
348 }
349
cpu_latency_qos_release(struct inode * inode,struct file * filp)350 static int cpu_latency_qos_release(struct inode *inode, struct file *filp)
351 {
352 struct pm_qos_request *req = filp->private_data;
353
354 filp->private_data = NULL;
355
356 cpu_latency_qos_remove_request(req);
357 kfree(req);
358
359 return 0;
360 }
361
cpu_latency_qos_read(struct file * filp,char __user * buf,size_t count,loff_t * f_pos)362 static ssize_t cpu_latency_qos_read(struct file *filp, char __user *buf,
363 size_t count, loff_t *f_pos)
364 {
365 struct pm_qos_request *req = filp->private_data;
366 unsigned long flags;
367 s32 value;
368
369 if (!req || !cpu_latency_qos_request_active(req))
370 return -EINVAL;
371
372 spin_lock_irqsave(&pm_qos_lock, flags);
373 value = pm_qos_get_value(&cpu_latency_constraints);
374 spin_unlock_irqrestore(&pm_qos_lock, flags);
375
376 return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
377 }
378
cpu_latency_qos_write(struct file * filp,const char __user * buf,size_t count,loff_t * f_pos)379 static ssize_t cpu_latency_qos_write(struct file *filp, const char __user *buf,
380 size_t count, loff_t *f_pos)
381 {
382 s32 value;
383
384 if (count == sizeof(s32)) {
385 if (copy_from_user(&value, buf, sizeof(s32)))
386 return -EFAULT;
387 } else {
388 int ret;
389
390 ret = kstrtos32_from_user(buf, count, 16, &value);
391 if (ret)
392 return ret;
393 }
394
395 cpu_latency_qos_update_request(filp->private_data, value);
396
397 return count;
398 }
399
400 static const struct file_operations cpu_latency_qos_fops = {
401 .write = cpu_latency_qos_write,
402 .read = cpu_latency_qos_read,
403 .open = cpu_latency_qos_open,
404 .release = cpu_latency_qos_release,
405 .llseek = noop_llseek,
406 };
407
408 static struct miscdevice cpu_latency_qos_miscdev = {
409 .minor = MISC_DYNAMIC_MINOR,
410 .name = "cpu_dma_latency",
411 .fops = &cpu_latency_qos_fops,
412 };
413
cpu_latency_qos_init(void)414 static int __init cpu_latency_qos_init(void)
415 {
416 int ret;
417
418 ret = misc_register(&cpu_latency_qos_miscdev);
419 if (ret < 0)
420 pr_err("%s: %s setup failed\n", __func__,
421 cpu_latency_qos_miscdev.name);
422
423 return ret;
424 }
425 late_initcall(cpu_latency_qos_init);
426 #endif /* CONFIG_CPU_IDLE */
427
428 /* Definitions related to the frequency QoS below. */
429
430 /**
431 * freq_constraints_init - Initialize frequency QoS constraints.
432 * @qos: Frequency QoS constraints to initialize.
433 */
freq_constraints_init(struct freq_constraints * qos)434 void freq_constraints_init(struct freq_constraints *qos)
435 {
436 struct pm_qos_constraints *c;
437
438 c = &qos->min_freq;
439 plist_head_init(&c->list);
440 c->target_value = FREQ_QOS_MIN_DEFAULT_VALUE;
441 c->default_value = FREQ_QOS_MIN_DEFAULT_VALUE;
442 c->no_constraint_value = FREQ_QOS_MIN_DEFAULT_VALUE;
443 c->type = PM_QOS_MAX;
444 c->notifiers = &qos->min_freq_notifiers;
445 BLOCKING_INIT_NOTIFIER_HEAD(c->notifiers);
446
447 c = &qos->max_freq;
448 plist_head_init(&c->list);
449 c->target_value = FREQ_QOS_MAX_DEFAULT_VALUE;
450 c->default_value = FREQ_QOS_MAX_DEFAULT_VALUE;
451 c->no_constraint_value = FREQ_QOS_MAX_DEFAULT_VALUE;
452 c->type = PM_QOS_MIN;
453 c->notifiers = &qos->max_freq_notifiers;
454 BLOCKING_INIT_NOTIFIER_HEAD(c->notifiers);
455 }
456
457 /**
458 * freq_qos_read_value - Get frequency QoS constraint for a given list.
459 * @qos: Constraints to evaluate.
460 * @type: QoS request type.
461 */
freq_qos_read_value(struct freq_constraints * qos,enum freq_qos_req_type type)462 s32 freq_qos_read_value(struct freq_constraints *qos,
463 enum freq_qos_req_type type)
464 {
465 s32 ret;
466
467 switch (type) {
468 case FREQ_QOS_MIN:
469 ret = IS_ERR_OR_NULL(qos) ?
470 FREQ_QOS_MIN_DEFAULT_VALUE :
471 pm_qos_read_value(&qos->min_freq);
472 break;
473 case FREQ_QOS_MAX:
474 ret = IS_ERR_OR_NULL(qos) ?
475 FREQ_QOS_MAX_DEFAULT_VALUE :
476 pm_qos_read_value(&qos->max_freq);
477 break;
478 default:
479 WARN_ON(1);
480 ret = 0;
481 }
482
483 return ret;
484 }
485
486 /**
487 * freq_qos_apply - Add/modify/remove frequency QoS request.
488 * @req: Constraint request to apply.
489 * @action: Action to perform (add/update/remove).
490 * @value: Value to assign to the QoS request.
491 *
492 * This is only meant to be called from inside pm_qos, not drivers.
493 */
freq_qos_apply(struct freq_qos_request * req,enum pm_qos_req_action action,s32 value)494 int freq_qos_apply(struct freq_qos_request *req,
495 enum pm_qos_req_action action, s32 value)
496 {
497 int ret;
498
499 switch(req->type) {
500 case FREQ_QOS_MIN:
501 ret = pm_qos_update_target(&req->qos->min_freq, &req->pnode,
502 action, value);
503 break;
504 case FREQ_QOS_MAX:
505 ret = pm_qos_update_target(&req->qos->max_freq, &req->pnode,
506 action, value);
507 break;
508 default:
509 ret = -EINVAL;
510 }
511
512 return ret;
513 }
514
515 /**
516 * freq_qos_add_request - Insert new frequency QoS request into a given list.
517 * @qos: Constraints to update.
518 * @req: Preallocated request object.
519 * @type: Request type.
520 * @value: Request value.
521 *
522 * Insert a new entry into the @qos list of requests, recompute the effective
523 * QoS constraint value for that list and initialize the @req object. The
524 * caller needs to save that object for later use in updates and removal.
525 *
526 * Return 1 if the effective constraint value has changed, 0 if the effective
527 * constraint value has not changed, or a negative error code on failures.
528 */
freq_qos_add_request(struct freq_constraints * qos,struct freq_qos_request * req,enum freq_qos_req_type type,s32 value)529 int freq_qos_add_request(struct freq_constraints *qos,
530 struct freq_qos_request *req,
531 enum freq_qos_req_type type, s32 value)
532 {
533 int ret;
534
535 if (IS_ERR_OR_NULL(qos) || !req)
536 return -EINVAL;
537
538 if (WARN(freq_qos_request_active(req),
539 "%s() called for active request\n", __func__))
540 return -EINVAL;
541
542 req->qos = qos;
543 req->type = type;
544 ret = freq_qos_apply(req, PM_QOS_ADD_REQ, value);
545 if (ret < 0) {
546 req->qos = NULL;
547 req->type = 0;
548 }
549
550 trace_android_vh_freq_qos_add_request(qos, req, type, value, ret);
551 return ret;
552 }
553 EXPORT_SYMBOL_GPL(freq_qos_add_request);
554
555 /**
556 * freq_qos_update_request - Modify existing frequency QoS request.
557 * @req: Request to modify.
558 * @new_value: New request value.
559 *
560 * Update an existing frequency QoS request along with the effective constraint
561 * value for the list of requests it belongs to.
562 *
563 * Return 1 if the effective constraint value has changed, 0 if the effective
564 * constraint value has not changed, or a negative error code on failures.
565 */
freq_qos_update_request(struct freq_qos_request * req,s32 new_value)566 int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
567 {
568 if (!req)
569 return -EINVAL;
570
571 if (WARN(!freq_qos_request_active(req),
572 "%s() called for unknown object\n", __func__))
573 return -EINVAL;
574
575 trace_android_vh_freq_qos_update_request(req, new_value);
576 if (req->pnode.prio == new_value)
577 return 0;
578
579 return freq_qos_apply(req, PM_QOS_UPDATE_REQ, new_value);
580 }
581 EXPORT_SYMBOL_GPL(freq_qos_update_request);
582
583 /**
584 * freq_qos_remove_request - Remove frequency QoS request from its list.
585 * @req: Request to remove.
586 *
587 * Remove the given frequency QoS request from the list of constraints it
588 * belongs to and recompute the effective constraint value for that list.
589 *
590 * Return 1 if the effective constraint value has changed, 0 if the effective
591 * constraint value has not changed, or a negative error code on failures.
592 */
freq_qos_remove_request(struct freq_qos_request * req)593 int freq_qos_remove_request(struct freq_qos_request *req)
594 {
595 int ret;
596
597 if (!req)
598 return -EINVAL;
599
600 if (WARN(!freq_qos_request_active(req),
601 "%s() called for unknown object\n", __func__))
602 return -EINVAL;
603
604 trace_android_vh_freq_qos_remove_request(req);
605 ret = freq_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
606 req->qos = NULL;
607 req->type = 0;
608
609 return ret;
610 }
611 EXPORT_SYMBOL_GPL(freq_qos_remove_request);
612
613 /**
614 * freq_qos_add_notifier - Add frequency QoS change notifier.
615 * @qos: List of requests to add the notifier to.
616 * @type: Request type.
617 * @notifier: Notifier block to add.
618 */
freq_qos_add_notifier(struct freq_constraints * qos,enum freq_qos_req_type type,struct notifier_block * notifier)619 int freq_qos_add_notifier(struct freq_constraints *qos,
620 enum freq_qos_req_type type,
621 struct notifier_block *notifier)
622 {
623 int ret;
624
625 if (IS_ERR_OR_NULL(qos) || !notifier)
626 return -EINVAL;
627
628 switch (type) {
629 case FREQ_QOS_MIN:
630 ret = blocking_notifier_chain_register(qos->min_freq.notifiers,
631 notifier);
632 break;
633 case FREQ_QOS_MAX:
634 ret = blocking_notifier_chain_register(qos->max_freq.notifiers,
635 notifier);
636 break;
637 default:
638 WARN_ON(1);
639 ret = -EINVAL;
640 }
641
642 return ret;
643 }
644 EXPORT_SYMBOL_GPL(freq_qos_add_notifier);
645
646 /**
647 * freq_qos_remove_notifier - Remove frequency QoS change notifier.
648 * @qos: List of requests to remove the notifier from.
649 * @type: Request type.
650 * @notifier: Notifier block to remove.
651 */
freq_qos_remove_notifier(struct freq_constraints * qos,enum freq_qos_req_type type,struct notifier_block * notifier)652 int freq_qos_remove_notifier(struct freq_constraints *qos,
653 enum freq_qos_req_type type,
654 struct notifier_block *notifier)
655 {
656 int ret;
657
658 if (IS_ERR_OR_NULL(qos) || !notifier)
659 return -EINVAL;
660
661 switch (type) {
662 case FREQ_QOS_MIN:
663 ret = blocking_notifier_chain_unregister(qos->min_freq.notifiers,
664 notifier);
665 break;
666 case FREQ_QOS_MAX:
667 ret = blocking_notifier_chain_unregister(qos->max_freq.notifiers,
668 notifier);
669 break;
670 default:
671 WARN_ON(1);
672 ret = -EINVAL;
673 }
674
675 return ret;
676 }
677 EXPORT_SYMBOL_GPL(freq_qos_remove_notifier);
678