diff options
author | Martin Peres <martin.peres@labri.fr> | 2012-11-19 19:14:13 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-02-20 01:00:24 -0500 |
commit | 12e32896f796ea772d4443c789f9358d46461835 (patch) | |
tree | 16b0b5fe3775500dd1228d332ee9c4aa31c5e18f | |
parent | 0083b91dac482c70eeb96745d9ef604f904da3e5 (diff) |
drm/nouveau/hwmon: add missing alarm thresholds
Expose all the hysteresis parameters + shutdown (emergency) +
fan_boost (fixed pwm trip point).
Signed-off-by: Martin Peres <martin.peres@labri.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.c | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c index a701ff5ffa5b..d456e102682b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_pm.c +++ b/drivers/gpu/drm/nouveau/nouveau_pm.c | |||
@@ -409,6 +409,81 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, nouveau_hwmon_show_temp, | |||
409 | NULL, 0); | 409 | NULL, 0); |
410 | 410 | ||
411 | static ssize_t | 411 | static ssize_t |
412 | nouveau_hwmon_show_temp1_auto_point1_pwm(struct device *d, | ||
413 | struct device_attribute *a, char *buf) | ||
414 | { | ||
415 | return snprintf(buf, PAGE_SIZE, "%d\n", 100); | ||
416 | } | ||
417 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO, | ||
418 | nouveau_hwmon_show_temp1_auto_point1_pwm, NULL, 0); | ||
419 | |||
420 | static ssize_t | ||
421 | nouveau_hwmon_temp1_auto_point1_temp(struct device *d, | ||
422 | struct device_attribute *a, char *buf) | ||
423 | { | ||
424 | struct drm_device *dev = dev_get_drvdata(d); | ||
425 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
426 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
427 | |||
428 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
429 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST) * 1000); | ||
430 | } | ||
431 | static ssize_t | ||
432 | nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d, | ||
433 | struct device_attribute *a, | ||
434 | const char *buf, size_t count) | ||
435 | { | ||
436 | struct drm_device *dev = dev_get_drvdata(d); | ||
437 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
438 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
439 | long value; | ||
440 | |||
441 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
442 | return count; | ||
443 | |||
444 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST, | ||
445 | value / 1000); | ||
446 | |||
447 | return count; | ||
448 | } | ||
449 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IRUGO | S_IWUSR, | ||
450 | nouveau_hwmon_temp1_auto_point1_temp, | ||
451 | nouveau_hwmon_set_temp1_auto_point1_temp, 0); | ||
452 | |||
453 | static ssize_t | ||
454 | nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d, | ||
455 | struct device_attribute *a, char *buf) | ||
456 | { | ||
457 | struct drm_device *dev = dev_get_drvdata(d); | ||
458 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
459 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
460 | |||
461 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
462 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); | ||
463 | } | ||
464 | static ssize_t | ||
465 | nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d, | ||
466 | struct device_attribute *a, | ||
467 | const char *buf, size_t count) | ||
468 | { | ||
469 | struct drm_device *dev = dev_get_drvdata(d); | ||
470 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
471 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
472 | long value; | ||
473 | |||
474 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
475 | return count; | ||
476 | |||
477 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST, | ||
478 | value / 1000); | ||
479 | |||
480 | return count; | ||
481 | } | ||
482 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp_hyst, S_IRUGO | S_IWUSR, | ||
483 | nouveau_hwmon_temp1_auto_point1_temp_hyst, | ||
484 | nouveau_hwmon_set_temp1_auto_point1_temp_hyst, 0); | ||
485 | |||
486 | static ssize_t | ||
412 | nouveau_hwmon_max_temp(struct device *d, struct device_attribute *a, char *buf) | 487 | nouveau_hwmon_max_temp(struct device *d, struct device_attribute *a, char *buf) |
413 | { | 488 | { |
414 | struct drm_device *dev = dev_get_drvdata(d); | 489 | struct drm_device *dev = dev_get_drvdata(d); |
@@ -439,6 +514,38 @@ static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, nouveau_hwmon_max_temp, | |||
439 | 0); | 514 | 0); |
440 | 515 | ||
441 | static ssize_t | 516 | static ssize_t |
517 | nouveau_hwmon_max_temp_hyst(struct device *d, struct device_attribute *a, | ||
518 | char *buf) | ||
519 | { | ||
520 | struct drm_device *dev = dev_get_drvdata(d); | ||
521 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
522 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
523 | |||
524 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
525 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000); | ||
526 | } | ||
527 | static ssize_t | ||
528 | nouveau_hwmon_set_max_temp_hyst(struct device *d, struct device_attribute *a, | ||
529 | const char *buf, size_t count) | ||
530 | { | ||
531 | struct drm_device *dev = dev_get_drvdata(d); | ||
532 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
533 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
534 | long value; | ||
535 | |||
536 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
537 | return count; | ||
538 | |||
539 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST, | ||
540 | value / 1000); | ||
541 | |||
542 | return count; | ||
543 | } | ||
544 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
545 | nouveau_hwmon_max_temp_hyst, | ||
546 | nouveau_hwmon_set_max_temp_hyst, 0); | ||
547 | |||
548 | static ssize_t | ||
442 | nouveau_hwmon_critical_temp(struct device *d, struct device_attribute *a, | 549 | nouveau_hwmon_critical_temp(struct device *d, struct device_attribute *a, |
443 | char *buf) | 550 | char *buf) |
444 | { | 551 | { |
@@ -471,6 +578,107 @@ static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, | |||
471 | nouveau_hwmon_set_critical_temp, | 578 | nouveau_hwmon_set_critical_temp, |
472 | 0); | 579 | 0); |
473 | 580 | ||
581 | static ssize_t | ||
582 | nouveau_hwmon_critical_temp_hyst(struct device *d, struct device_attribute *a, | ||
583 | char *buf) | ||
584 | { | ||
585 | struct drm_device *dev = dev_get_drvdata(d); | ||
586 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
587 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
588 | |||
589 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
590 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST) * 1000); | ||
591 | } | ||
592 | static ssize_t | ||
593 | nouveau_hwmon_set_critical_temp_hyst(struct device *d, | ||
594 | struct device_attribute *a, | ||
595 | const char *buf, | ||
596 | size_t count) | ||
597 | { | ||
598 | struct drm_device *dev = dev_get_drvdata(d); | ||
599 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
600 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
601 | long value; | ||
602 | |||
603 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
604 | return count; | ||
605 | |||
606 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST, | ||
607 | value / 1000); | ||
608 | |||
609 | return count; | ||
610 | } | ||
611 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, | ||
612 | nouveau_hwmon_critical_temp_hyst, | ||
613 | nouveau_hwmon_set_critical_temp_hyst, 0); | ||
614 | static ssize_t | ||
615 | nouveau_hwmon_emergency_temp(struct device *d, struct device_attribute *a, | ||
616 | char *buf) | ||
617 | { | ||
618 | struct drm_device *dev = dev_get_drvdata(d); | ||
619 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
620 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
621 | |||
622 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
623 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN) * 1000); | ||
624 | } | ||
625 | static ssize_t | ||
626 | nouveau_hwmon_set_emergency_temp(struct device *d, struct device_attribute *a, | ||
627 | const char *buf, | ||
628 | size_t count) | ||
629 | { | ||
630 | struct drm_device *dev = dev_get_drvdata(d); | ||
631 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
632 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
633 | long value; | ||
634 | |||
635 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
636 | return count; | ||
637 | |||
638 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN, value / 1000); | ||
639 | |||
640 | return count; | ||
641 | } | ||
642 | static SENSOR_DEVICE_ATTR(temp1_emergency, S_IRUGO | S_IWUSR, | ||
643 | nouveau_hwmon_emergency_temp, | ||
644 | nouveau_hwmon_set_emergency_temp, | ||
645 | 0); | ||
646 | |||
647 | static ssize_t | ||
648 | nouveau_hwmon_emergency_temp_hyst(struct device *d, struct device_attribute *a, | ||
649 | char *buf) | ||
650 | { | ||
651 | struct drm_device *dev = dev_get_drvdata(d); | ||
652 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
653 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
654 | |||
655 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
656 | therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000); | ||
657 | } | ||
658 | static ssize_t | ||
659 | nouveau_hwmon_set_emergency_temp_hyst(struct device *d, | ||
660 | struct device_attribute *a, | ||
661 | const char *buf, | ||
662 | size_t count) | ||
663 | { | ||
664 | struct drm_device *dev = dev_get_drvdata(d); | ||
665 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
666 | struct nouveau_therm *therm = nouveau_therm(drm->device); | ||
667 | long value; | ||
668 | |||
669 | if (kstrtol(buf, 10, &value) == -EINVAL) | ||
670 | return count; | ||
671 | |||
672 | therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST, | ||
673 | value / 1000); | ||
674 | |||
675 | return count; | ||
676 | } | ||
677 | static SENSOR_DEVICE_ATTR(temp1_emergency_hyst, S_IRUGO | S_IWUSR, | ||
678 | nouveau_hwmon_emergency_temp_hyst, | ||
679 | nouveau_hwmon_set_emergency_temp_hyst, | ||
680 | 0); | ||
681 | |||
474 | static ssize_t nouveau_hwmon_show_name(struct device *dev, | 682 | static ssize_t nouveau_hwmon_show_name(struct device *dev, |
475 | struct device_attribute *attr, | 683 | struct device_attribute *attr, |
476 | char *buf) | 684 | char *buf) |
@@ -665,8 +873,15 @@ static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR, | |||
665 | 873 | ||
666 | static struct attribute *hwmon_attributes[] = { | 874 | static struct attribute *hwmon_attributes[] = { |
667 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 875 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
876 | &sensor_dev_attr_temp1_auto_point1_pwm.dev_attr.attr, | ||
877 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, | ||
878 | &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr, | ||
668 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 879 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
880 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, | ||
669 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 881 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
882 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | ||
883 | &sensor_dev_attr_temp1_emergency.dev_attr.attr, | ||
884 | &sensor_dev_attr_temp1_emergency_hyst.dev_attr.attr, | ||
670 | &sensor_dev_attr_name.dev_attr.attr, | 885 | &sensor_dev_attr_name.dev_attr.attr, |
671 | &sensor_dev_attr_update_rate.dev_attr.attr, | 886 | &sensor_dev_attr_update_rate.dev_attr.attr, |
672 | NULL | 887 | NULL |