diff options
author | Dave Airlie <airlied@redhat.com> | 2013-10-11 00:07:25 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-10-22 04:37:40 -0400 |
commit | 5bdebb183c9702a8c57a01dff09337be3de337a6 (patch) | |
tree | e4ae9a441e4b2c4739902e4914852696accf1682 /drivers/gpu/drm/i915/i915_sysfs.c | |
parent | 14c8d110e083d3a09ccf8cfe18ad22fe1450c2e9 (diff) |
drm/sysfs: sort out minor and connector device object lifetimes.
So drm was abusing device lifetimes, by having embedded device structures
in the minor and connector it meant that the lifetime of the internal drm
objects (drm_minor and drm_connector) were tied to the lifetime of the device
files in sysfs, so if something kept those files opened the current code
would kfree the objects and things would go downhill from there.
Now in reality there is no need for these lifetimes to be so intertwined,
especailly with hotplugging of devices where we wish to remove the sysfs
and userspace facing pieces before we can unwind the internal objects due
to open userspace files or mmaps, so split the objects out so the struct
device is no longer embedded and do what fbdev does and just allocate
and remove the sysfs inodes separately.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_sysfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_sysfs.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 3ae47951c1bd..1beec51b8e26 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "intel_drv.h" | 32 | #include "intel_drv.h" |
33 | #include "i915_drv.h" | 33 | #include "i915_drv.h" |
34 | 34 | ||
35 | #define dev_to_drm_minor(d) container_of((d), struct drm_minor, kdev) | 35 | #define dev_to_drm_minor(d) dev_get_drvdata((d)) |
36 | 36 | ||
37 | #ifdef CONFIG_PM | 37 | #ifdef CONFIG_PM |
38 | static u32 calc_residency(struct drm_device *dev, const u32 reg) | 38 | static u32 calc_residency(struct drm_device *dev, const u32 reg) |
@@ -75,7 +75,7 @@ show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf) | |||
75 | static ssize_t | 75 | static ssize_t |
76 | show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 76 | show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
77 | { | 77 | { |
78 | struct drm_minor *dminor = dev_to_drm_minor(kdev); | 78 | struct drm_minor *dminor = dev_get_drvdata(kdev); |
79 | u32 rc6_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6); | 79 | u32 rc6_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6); |
80 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); | 80 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); |
81 | } | 81 | } |
@@ -543,19 +543,19 @@ void i915_setup_sysfs(struct drm_device *dev) | |||
543 | 543 | ||
544 | #ifdef CONFIG_PM | 544 | #ifdef CONFIG_PM |
545 | if (INTEL_INFO(dev)->gen >= 6) { | 545 | if (INTEL_INFO(dev)->gen >= 6) { |
546 | ret = sysfs_merge_group(&dev->primary->kdev.kobj, | 546 | ret = sysfs_merge_group(&dev->primary->kdev->kobj, |
547 | &rc6_attr_group); | 547 | &rc6_attr_group); |
548 | if (ret) | 548 | if (ret) |
549 | DRM_ERROR("RC6 residency sysfs setup failed\n"); | 549 | DRM_ERROR("RC6 residency sysfs setup failed\n"); |
550 | } | 550 | } |
551 | #endif | 551 | #endif |
552 | if (HAS_L3_DPF(dev)) { | 552 | if (HAS_L3_DPF(dev)) { |
553 | ret = device_create_bin_file(&dev->primary->kdev, &dpf_attrs); | 553 | ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs); |
554 | if (ret) | 554 | if (ret) |
555 | DRM_ERROR("l3 parity sysfs setup failed\n"); | 555 | DRM_ERROR("l3 parity sysfs setup failed\n"); |
556 | 556 | ||
557 | if (NUM_L3_SLICES(dev) > 1) { | 557 | if (NUM_L3_SLICES(dev) > 1) { |
558 | ret = device_create_bin_file(&dev->primary->kdev, | 558 | ret = device_create_bin_file(dev->primary->kdev, |
559 | &dpf_attrs_1); | 559 | &dpf_attrs_1); |
560 | if (ret) | 560 | if (ret) |
561 | DRM_ERROR("l3 parity slice 1 setup failed\n"); | 561 | DRM_ERROR("l3 parity slice 1 setup failed\n"); |
@@ -564,13 +564,13 @@ void i915_setup_sysfs(struct drm_device *dev) | |||
564 | 564 | ||
565 | ret = 0; | 565 | ret = 0; |
566 | if (IS_VALLEYVIEW(dev)) | 566 | if (IS_VALLEYVIEW(dev)) |
567 | ret = sysfs_create_files(&dev->primary->kdev.kobj, vlv_attrs); | 567 | ret = sysfs_create_files(&dev->primary->kdev->kobj, vlv_attrs); |
568 | else if (INTEL_INFO(dev)->gen >= 6) | 568 | else if (INTEL_INFO(dev)->gen >= 6) |
569 | ret = sysfs_create_files(&dev->primary->kdev.kobj, gen6_attrs); | 569 | ret = sysfs_create_files(&dev->primary->kdev->kobj, gen6_attrs); |
570 | if (ret) | 570 | if (ret) |
571 | DRM_ERROR("RPS sysfs setup failed\n"); | 571 | DRM_ERROR("RPS sysfs setup failed\n"); |
572 | 572 | ||
573 | ret = sysfs_create_bin_file(&dev->primary->kdev.kobj, | 573 | ret = sysfs_create_bin_file(&dev->primary->kdev->kobj, |
574 | &error_state_attr); | 574 | &error_state_attr); |
575 | if (ret) | 575 | if (ret) |
576 | DRM_ERROR("error_state sysfs setup failed\n"); | 576 | DRM_ERROR("error_state sysfs setup failed\n"); |
@@ -578,14 +578,14 @@ void i915_setup_sysfs(struct drm_device *dev) | |||
578 | 578 | ||
579 | void i915_teardown_sysfs(struct drm_device *dev) | 579 | void i915_teardown_sysfs(struct drm_device *dev) |
580 | { | 580 | { |
581 | sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr); | 581 | sysfs_remove_bin_file(&dev->primary->kdev->kobj, &error_state_attr); |
582 | if (IS_VALLEYVIEW(dev)) | 582 | if (IS_VALLEYVIEW(dev)) |
583 | sysfs_remove_files(&dev->primary->kdev.kobj, vlv_attrs); | 583 | sysfs_remove_files(&dev->primary->kdev->kobj, vlv_attrs); |
584 | else | 584 | else |
585 | sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs); | 585 | sysfs_remove_files(&dev->primary->kdev->kobj, gen6_attrs); |
586 | device_remove_bin_file(&dev->primary->kdev, &dpf_attrs_1); | 586 | device_remove_bin_file(dev->primary->kdev, &dpf_attrs_1); |
587 | device_remove_bin_file(&dev->primary->kdev, &dpf_attrs); | 587 | device_remove_bin_file(dev->primary->kdev, &dpf_attrs); |
588 | #ifdef CONFIG_PM | 588 | #ifdef CONFIG_PM |
589 | sysfs_unmerge_group(&dev->primary->kdev.kobj, &rc6_attr_group); | 589 | sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6_attr_group); |
590 | #endif | 590 | #endif |
591 | } | 591 | } |