8003886361b80fc835e7f45c96f6d5c906d70bb2
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / i915_sysfs.c
1 /*
2  * Copyright © 2012 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  * Authors:
24  *    Ben Widawsky <ben@bwidawsk.net>
25  *
26  */
27
28 #include <linux/device.h>
29 #include <linux/module.h>
30 #include <linux/stat.h>
31 #include <linux/sysfs.h>
32 #include "intel_drv.h"
33 #include "i915_drv.h"
34
35 #ifdef CONFIG_PM
36 static u32 calc_residency(struct drm_device *dev, const u32 reg)
37 {
38         struct drm_i915_private *dev_priv = dev->dev_private;
39         u64 raw_time; /* 32b value may overflow during fixed point math */
40         u64 units = 128ULL, div = 100000ULL, bias = 100ULL;
41
42         if (!intel_enable_rc6(dev))
43                 return 0;
44
45         /* On VLV, residency time is in CZ units rather than 1.28us */
46         if (IS_VALLEYVIEW(dev)) {
47                 u32 clkctl2;
48
49                 clkctl2 = I915_READ(VLV_CLK_CTL2) >>
50                         CLK_CTL2_CZCOUNT_30NS_SHIFT;
51                 if (!clkctl2) {
52                         WARN(!clkctl2, "bogus CZ count value");
53                         return 0;
54                 }
55                 units = DIV_ROUND_UP_ULL(30ULL * bias, (u64)clkctl2);
56                 if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
57                         units <<= 8;
58
59                 div = 1000000ULL * bias;
60         }
61
62         raw_time = I915_READ(reg) * units;
63         return DIV_ROUND_UP_ULL(raw_time, div);
64 }
65
66 static ssize_t
67 show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf)
68 {
69         struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev);
70         return snprintf(buf, PAGE_SIZE, "%x\n", intel_enable_rc6(dminor->dev));
71 }
72
73 static ssize_t
74 show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf)
75 {
76         struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev);
77         u32 rc6_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6);
78         return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency);
79 }
80
81 static ssize_t
82 show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf)
83 {
84         struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev);
85         u32 rc6p_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6p);
86         if (IS_VALLEYVIEW(dminor->dev))
87                 rc6p_residency = 0;
88         return snprintf(buf, PAGE_SIZE, "%u\n", rc6p_residency);
89 }
90
91 static ssize_t
92 show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf)
93 {
94         struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev);
95         u32 rc6pp_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6pp);
96         if (IS_VALLEYVIEW(dminor->dev))
97                 rc6pp_residency = 0;
98         return snprintf(buf, PAGE_SIZE, "%u\n", rc6pp_residency);
99 }
100
101 static DEVICE_ATTR(rc6_enable, S_IRUGO, show_rc6_mask, NULL);
102 static DEVICE_ATTR(rc6_residency_ms, S_IRUGO, show_rc6_ms, NULL);
103 static DEVICE_ATTR(rc6p_residency_ms, S_IRUGO, show_rc6p_ms, NULL);
104 static DEVICE_ATTR(rc6pp_residency_ms, S_IRUGO, show_rc6pp_ms, NULL);
105
106 static struct attribute *rc6_attrs[] = {
107         &dev_attr_rc6_enable.attr,
108         &dev_attr_rc6_residency_ms.attr,
109         &dev_attr_rc6p_residency_ms.attr,
110         &dev_attr_rc6pp_residency_ms.attr,
111         NULL
112 };
113
114 static struct attribute_group rc6_attr_group = {
115         .name = power_group_name,
116         .attrs =  rc6_attrs
117 };
118 #endif
119
120 static int l3_access_valid(struct drm_device *dev, loff_t offset)
121 {
122         if (!HAS_L3_DPF(dev))
123                 return -EPERM;
124
125         if (offset % 4 != 0)
126                 return -EINVAL;
127
128         if (offset >= GEN7_L3LOG_SIZE)
129                 return -ENXIO;
130
131         return 0;
132 }
133
134 static ssize_t
135 i915_l3_read(struct file *filp, struct kobject *kobj,
136              struct bin_attribute *attr, char *buf,
137              loff_t offset, size_t count)
138 {
139         struct device *dev = container_of(kobj, struct device, kobj);
140         struct drm_minor *dminor = container_of(dev, struct drm_minor, kdev);
141         struct drm_device *drm_dev = dminor->dev;
142         struct drm_i915_private *dev_priv = drm_dev->dev_private;
143         int slice = (int)(uintptr_t)attr->private;
144         int ret;
145
146         count = round_down(count, 4);
147
148         ret = l3_access_valid(drm_dev, offset);
149         if (ret)
150                 return ret;
151
152         count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count);
153
154         ret = i915_mutex_lock_interruptible(drm_dev);
155         if (ret)
156                 return ret;
157
158         if (dev_priv->l3_parity.remap_info[slice])
159                 memcpy(buf,
160                        dev_priv->l3_parity.remap_info[slice] + (offset/4),
161                        count);
162         else
163                 memset(buf, 0, count);
164
165         mutex_unlock(&drm_dev->struct_mutex);
166
167         return count;
168 }
169
170 static ssize_t
171 i915_l3_write(struct file *filp, struct kobject *kobj,
172               struct bin_attribute *attr, char *buf,
173               loff_t offset, size_t count)
174 {
175         struct device *dev = container_of(kobj, struct device, kobj);
176         struct drm_minor *dminor = container_of(dev, struct drm_minor, kdev);
177         struct drm_device *drm_dev = dminor->dev;
178         struct drm_i915_private *dev_priv = drm_dev->dev_private;
179         struct i915_hw_context *ctx;
180         u32 *temp = NULL; /* Just here to make handling failures easy */
181         int slice = (int)(uintptr_t)attr->private;
182         int ret;
183
184         ret = l3_access_valid(drm_dev, offset);
185         if (ret)
186                 return ret;
187
188         if (dev_priv->hw_contexts_disabled)
189                 return -ENXIO;
190
191         ret = i915_mutex_lock_interruptible(drm_dev);
192         if (ret)
193                 return ret;
194
195         if (!dev_priv->l3_parity.remap_info[slice]) {
196                 temp = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL);
197                 if (!temp) {
198                         mutex_unlock(&drm_dev->struct_mutex);
199                         return -ENOMEM;
200                 }
201         }
202
203         ret = i915_gpu_idle(drm_dev);
204         if (ret) {
205                 kfree(temp);
206                 mutex_unlock(&drm_dev->struct_mutex);
207                 return ret;
208         }
209
210         /* TODO: Ideally we really want a GPU reset here to make sure errors
211          * aren't propagated. Since I cannot find a stable way to reset the GPU
212          * at this point it is left as a TODO.
213         */
214         if (temp)
215                 dev_priv->l3_parity.remap_info[slice] = temp;
216
217         memcpy(dev_priv->l3_parity.remap_info[slice] + (offset/4), buf, count);
218
219         /* NB: We defer the remapping until we switch to the context */
220         list_for_each_entry(ctx, &dev_priv->context_list, link)
221                 ctx->remap_slice |= (1<<slice);
222
223         mutex_unlock(&drm_dev->struct_mutex);
224
225         return count;
226 }
227
228 static struct bin_attribute dpf_attrs = {
229         .attr = {.name = "l3_parity", .mode = (S_IRUSR | S_IWUSR)},
230         .size = GEN7_L3LOG_SIZE,
231         .read = i915_l3_read,
232         .write = i915_l3_write,
233         .mmap = NULL,
234         .private = (void *)0
235 };
236
237 static struct bin_attribute dpf_attrs_1 = {
238         .attr = {.name = "l3_parity_slice_1", .mode = (S_IRUSR | S_IWUSR)},
239         .size = GEN7_L3LOG_SIZE,
240         .read = i915_l3_read,
241         .write = i915_l3_write,
242         .mmap = NULL,
243         .private = (void *)1
244 };
245
246 static ssize_t gt_cur_freq_mhz_show(struct device *kdev,
247                                     struct device_attribute *attr, char *buf)
248 {
249         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
250         struct drm_device *dev = minor->dev;
251         struct drm_i915_private *dev_priv = dev->dev_private;
252         int ret;
253
254         mutex_lock(&dev_priv->rps.hw_lock);
255         if (IS_VALLEYVIEW(dev_priv->dev)) {
256                 u32 freq;
257                 freq = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
258                 ret = vlv_gpu_freq(dev_priv->mem_freq, (freq >> 8) & 0xff);
259         } else {
260                 ret = dev_priv->rps.cur_delay * GT_FREQUENCY_MULTIPLIER;
261         }
262         mutex_unlock(&dev_priv->rps.hw_lock);
263
264         return snprintf(buf, PAGE_SIZE, "%d\n", ret);
265 }
266
267 static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev,
268                                      struct device_attribute *attr, char *buf)
269 {
270         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
271         struct drm_device *dev = minor->dev;
272         struct drm_i915_private *dev_priv = dev->dev_private;
273
274         return snprintf(buf, PAGE_SIZE, "%d\n",
275                         vlv_gpu_freq(dev_priv->mem_freq,
276                                      dev_priv->rps.rpe_delay));
277 }
278
279 static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
280 {
281         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
282         struct drm_device *dev = minor->dev;
283         struct drm_i915_private *dev_priv = dev->dev_private;
284         int ret;
285
286         mutex_lock(&dev_priv->rps.hw_lock);
287         if (IS_VALLEYVIEW(dev_priv->dev))
288                 ret = vlv_gpu_freq(dev_priv->mem_freq, dev_priv->rps.max_delay);
289         else
290                 ret = dev_priv->rps.max_delay * GT_FREQUENCY_MULTIPLIER;
291         mutex_unlock(&dev_priv->rps.hw_lock);
292
293         return snprintf(buf, PAGE_SIZE, "%d\n", ret);
294 }
295
296 static ssize_t gt_max_freq_mhz_store(struct device *kdev,
297                                      struct device_attribute *attr,
298                                      const char *buf, size_t count)
299 {
300         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
301         struct drm_device *dev = minor->dev;
302         struct drm_i915_private *dev_priv = dev->dev_private;
303         u32 val, rp_state_cap, hw_max, hw_min, non_oc_max;
304         ssize_t ret;
305
306         ret = kstrtou32(buf, 0, &val);
307         if (ret)
308                 return ret;
309
310         mutex_lock(&dev_priv->rps.hw_lock);
311
312         if (IS_VALLEYVIEW(dev_priv->dev)) {
313                 val = vlv_freq_opcode(dev_priv->mem_freq, val);
314
315                 hw_max = valleyview_rps_max_freq(dev_priv);
316                 hw_min = valleyview_rps_min_freq(dev_priv);
317                 non_oc_max = hw_max;
318         } else {
319                 val /= GT_FREQUENCY_MULTIPLIER;
320
321                 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
322                 hw_max = dev_priv->rps.hw_max;
323                 non_oc_max = (rp_state_cap & 0xff);
324                 hw_min = ((rp_state_cap & 0xff0000) >> 16);
325         }
326
327         if (val < hw_min || val > hw_max ||
328             val < dev_priv->rps.min_delay) {
329                 mutex_unlock(&dev_priv->rps.hw_lock);
330                 return -EINVAL;
331         }
332
333         if (val > non_oc_max)
334                 DRM_DEBUG("User requested overclocking to %d\n",
335                           val * GT_FREQUENCY_MULTIPLIER);
336
337         if (dev_priv->rps.cur_delay > val) {
338                 if (IS_VALLEYVIEW(dev_priv->dev))
339                         valleyview_set_rps(dev_priv->dev, val);
340                 else
341                         gen6_set_rps(dev_priv->dev, val);
342         }
343
344         dev_priv->rps.max_delay = val;
345
346         mutex_unlock(&dev_priv->rps.hw_lock);
347
348         return count;
349 }
350
351 static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
352 {
353         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
354         struct drm_device *dev = minor->dev;
355         struct drm_i915_private *dev_priv = dev->dev_private;
356         int ret;
357
358         mutex_lock(&dev_priv->rps.hw_lock);
359         if (IS_VALLEYVIEW(dev_priv->dev))
360                 ret = vlv_gpu_freq(dev_priv->mem_freq, dev_priv->rps.min_delay);
361         else
362                 ret = dev_priv->rps.min_delay * GT_FREQUENCY_MULTIPLIER;
363         mutex_unlock(&dev_priv->rps.hw_lock);
364
365         return snprintf(buf, PAGE_SIZE, "%d\n", ret);
366 }
367
368 static ssize_t gt_min_freq_mhz_store(struct device *kdev,
369                                      struct device_attribute *attr,
370                                      const char *buf, size_t count)
371 {
372         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
373         struct drm_device *dev = minor->dev;
374         struct drm_i915_private *dev_priv = dev->dev_private;
375         u32 val, rp_state_cap, hw_max, hw_min;
376         ssize_t ret;
377
378         ret = kstrtou32(buf, 0, &val);
379         if (ret)
380                 return ret;
381
382         mutex_lock(&dev_priv->rps.hw_lock);
383
384         if (IS_VALLEYVIEW(dev)) {
385                 val = vlv_freq_opcode(dev_priv->mem_freq, val);
386
387                 hw_max = valleyview_rps_max_freq(dev_priv);
388                 hw_min = valleyview_rps_min_freq(dev_priv);
389         } else {
390                 val /= GT_FREQUENCY_MULTIPLIER;
391
392                 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
393                 hw_max = dev_priv->rps.hw_max;
394                 hw_min = ((rp_state_cap & 0xff0000) >> 16);
395         }
396
397         if (val < hw_min || val > hw_max || val > dev_priv->rps.max_delay) {
398                 mutex_unlock(&dev_priv->rps.hw_lock);
399                 return -EINVAL;
400         }
401
402         if (dev_priv->rps.cur_delay < val) {
403                 if (IS_VALLEYVIEW(dev))
404                         valleyview_set_rps(dev, val);
405                 else
406                         gen6_set_rps(dev_priv->dev, val);
407         }
408
409         dev_priv->rps.min_delay = val;
410
411         mutex_unlock(&dev_priv->rps.hw_lock);
412
413         return count;
414
415 }
416
417 static DEVICE_ATTR(gt_cur_freq_mhz, S_IRUGO, gt_cur_freq_mhz_show, NULL);
418 static DEVICE_ATTR(gt_max_freq_mhz, S_IRUGO | S_IWUSR, gt_max_freq_mhz_show, gt_max_freq_mhz_store);
419 static DEVICE_ATTR(gt_min_freq_mhz, S_IRUGO | S_IWUSR, gt_min_freq_mhz_show, gt_min_freq_mhz_store);
420
421 static DEVICE_ATTR(vlv_rpe_freq_mhz, S_IRUGO, vlv_rpe_freq_mhz_show, NULL);
422
423 static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf);
424 static DEVICE_ATTR(gt_RP0_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
425 static DEVICE_ATTR(gt_RP1_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
426 static DEVICE_ATTR(gt_RPn_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
427
428 /* For now we have a static number of RP states */
429 static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
430 {
431         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
432         struct drm_device *dev = minor->dev;
433         struct drm_i915_private *dev_priv = dev->dev_private;
434         u32 val, rp_state_cap;
435         ssize_t ret;
436
437         ret = mutex_lock_interruptible(&dev->struct_mutex);
438         if (ret)
439                 return ret;
440         rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
441         mutex_unlock(&dev->struct_mutex);
442
443         if (attr == &dev_attr_gt_RP0_freq_mhz) {
444                 val = ((rp_state_cap & 0x0000ff) >> 0) * GT_FREQUENCY_MULTIPLIER;
445         } else if (attr == &dev_attr_gt_RP1_freq_mhz) {
446                 val = ((rp_state_cap & 0x00ff00) >> 8) * GT_FREQUENCY_MULTIPLIER;
447         } else if (attr == &dev_attr_gt_RPn_freq_mhz) {
448                 val = ((rp_state_cap & 0xff0000) >> 16) * GT_FREQUENCY_MULTIPLIER;
449         } else {
450                 BUG();
451         }
452         return snprintf(buf, PAGE_SIZE, "%d\n", val);
453 }
454
455 static const struct attribute *gen6_attrs[] = {
456         &dev_attr_gt_cur_freq_mhz.attr,
457         &dev_attr_gt_max_freq_mhz.attr,
458         &dev_attr_gt_min_freq_mhz.attr,
459         &dev_attr_gt_RP0_freq_mhz.attr,
460         &dev_attr_gt_RP1_freq_mhz.attr,
461         &dev_attr_gt_RPn_freq_mhz.attr,
462         NULL,
463 };
464
465 static const struct attribute *vlv_attrs[] = {
466         &dev_attr_gt_cur_freq_mhz.attr,
467         &dev_attr_gt_max_freq_mhz.attr,
468         &dev_attr_gt_min_freq_mhz.attr,
469         &dev_attr_vlv_rpe_freq_mhz.attr,
470         NULL,
471 };
472
473 static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
474                                 struct bin_attribute *attr, char *buf,
475                                 loff_t off, size_t count)
476 {
477
478         struct device *kdev = container_of(kobj, struct device, kobj);
479         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
480         struct drm_device *dev = minor->dev;
481         struct i915_error_state_file_priv error_priv;
482         struct drm_i915_error_state_buf error_str;
483         ssize_t ret_count = 0;
484         int ret;
485
486         memset(&error_priv, 0, sizeof(error_priv));
487
488         ret = i915_error_state_buf_init(&error_str, count, off);
489         if (ret)
490                 return ret;
491
492         error_priv.dev = dev;
493         i915_error_state_get(dev, &error_priv);
494
495         ret = i915_error_state_to_str(&error_str, &error_priv);
496         if (ret)
497                 goto out;
498
499         ret_count = count < error_str.bytes ? count : error_str.bytes;
500
501         memcpy(buf, error_str.buf, ret_count);
502 out:
503         i915_error_state_put(&error_priv);
504         i915_error_state_buf_release(&error_str);
505
506         return ret ?: ret_count;
507 }
508
509 static ssize_t error_state_write(struct file *file, struct kobject *kobj,
510                                  struct bin_attribute *attr, char *buf,
511                                  loff_t off, size_t count)
512 {
513         struct device *kdev = container_of(kobj, struct device, kobj);
514         struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
515         struct drm_device *dev = minor->dev;
516         int ret;
517
518         DRM_DEBUG_DRIVER("Resetting error state\n");
519
520         ret = mutex_lock_interruptible(&dev->struct_mutex);
521         if (ret)
522                 return ret;
523
524         i915_destroy_error_state(dev);
525         mutex_unlock(&dev->struct_mutex);
526
527         return count;
528 }
529
530 static struct bin_attribute error_state_attr = {
531         .attr.name = "error",
532         .attr.mode = S_IRUSR | S_IWUSR,
533         .size = 0,
534         .read = error_state_read,
535         .write = error_state_write,
536 };
537
538 void i915_setup_sysfs(struct drm_device *dev)
539 {
540         int ret;
541
542 #ifdef CONFIG_PM
543         if (INTEL_INFO(dev)->gen >= 6) {
544                 ret = sysfs_merge_group(&dev->primary->kdev.kobj,
545                                         &rc6_attr_group);
546                 if (ret)
547                         DRM_ERROR("RC6 residency sysfs setup failed\n");
548         }
549 #endif
550         if (HAS_L3_DPF(dev)) {
551                 ret = device_create_bin_file(&dev->primary->kdev, &dpf_attrs);
552                 if (ret)
553                         DRM_ERROR("l3 parity sysfs setup failed\n");
554
555                 if (NUM_L3_SLICES(dev) > 1) {
556                         ret = device_create_bin_file(&dev->primary->kdev,
557                                                      &dpf_attrs_1);
558                         if (ret)
559                                 DRM_ERROR("l3 parity slice 1 setup failed\n");
560                 }
561         }
562
563         ret = 0;
564         if (IS_VALLEYVIEW(dev))
565                 ret = sysfs_create_files(&dev->primary->kdev.kobj, vlv_attrs);
566         else if (INTEL_INFO(dev)->gen >= 6)
567                 ret = sysfs_create_files(&dev->primary->kdev.kobj, gen6_attrs);
568         if (ret)
569                 DRM_ERROR("RPS sysfs setup failed\n");
570
571         ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
572                                     &error_state_attr);
573         if (ret)
574                 DRM_ERROR("error_state sysfs setup failed\n");
575 }
576
577 void i915_teardown_sysfs(struct drm_device *dev)
578 {
579         sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
580         if (IS_VALLEYVIEW(dev))
581                 sysfs_remove_files(&dev->primary->kdev.kobj, vlv_attrs);
582         else
583                 sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
584         device_remove_bin_file(&dev->primary->kdev,  &dpf_attrs_1);
585         device_remove_bin_file(&dev->primary->kdev,  &dpf_attrs);
586 #ifdef CONFIG_PM
587         sysfs_unmerge_group(&dev->primary->kdev.kobj, &rc6_attr_group);
588 #endif
589 }