[PATCH] drm: fix missing modeset lock from sysfs path

2015-09-29 Thread Jani Nikula
On Mon, 28 Sep 2015, Jens Axboe  wrote:
> Hi,
>
> Running 4.3-rc on a new laptop, and I notice that I get these whenever
> powertop --auto-tune is run:
>
> [14954.927920] [ cut here ]
> [14954.927926] WARNING: CPU: 1 PID: 14297 at drivers/gpu/drm/drm_atomic.c:889 
> drm_atomic_get_property+0x232/0x2b0()
> [14954.927927] Modules linked in: msr drbg ctr ccm cmac uvcvideo hid_generic 
> videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev usbhid 
> btusb btintel arc4 iwlmvm mac80211 joydev snd_hda_codec_realtek 
> snd_hda_codec_generic x86_pkg_temp_thermal snd_hda_codec_hdmi 
> intel_powerclamp kvm_intel dell_laptop dell_wmi dcdbas snd_hda_intel 
> hid_multitouch kvm sparse_keymap iwlwifi snd_hda_codec snd_hwdep snd_hda_core 
> aesni_intel aes_x86_64 glue_helper ehci_pci lrw gf128mul xhci_pci ablk_helper 
> cfg80211 cryptd xhci_hcd ehci_hcd snd_pcm int3403_thermal snd_seq_midi bnep 
> snd_seq_midi_event rfcomm snd_rawmidi bluetooth snd_seq snd_timer 
> snd_seq_device processor_thermal_device snd intel_soc_dts_iosf iosf_mbi 
> i2c_hid hid i2c_designware_platform i2c_designware_core int3402_thermal 
> int3400_thermal int340x_thermal_zone acpi_thermal_rel soundcore binfmt_misc 
> nls_iso8859_1 nls_cp437 fuse vfat fat
> [14954.927963] CPU: 1 PID: 14297 Comm: powertop Tainted: G U  W   
> 4.3.0-rc3+ #177
> [14954.927964] Hardware name: Dell Inc. XPS 13 9343/0310JH, BIOS A05 
> 07/14/2015
> [14954.927965]  81a7c2db 8800032e3c88 812923a9 
> 
> [14954.927967]  8800032e3cc0 81050aa6 880215577028 
> 88021551df80
> [14954.927968]  880215577000 880133e2ea80 88020ea59000 
> 8800032e3cd0
> [14954.927970] Call Trace:
> [14954.927974]  [] dump_stack+0x4b/0x72
> [14954.927976]  [] warn_slowpath_common+0x86/0xc0
> [14954.927978]  [] warn_slowpath_null+0x1a/0x20
> [14954.927980]  [] drm_atomic_get_property+0x232/0x2b0
> [14954.927982]  [] drm_object_property_get_value+0x6c/0x70
> [14954.927984]  [] dpms_show+0x2f/0x70
> [14954.927987]  [] dev_attr_show+0x20/0x50
> [14954.927989]  [] sysfs_kf_seq_show+0xa3/0x140
> [14954.927990]  [] kernfs_seq_show+0x20/0x30
> [14954.927993]  [] seq_read+0xcd/0x370
> [14954.927994]  [] kernfs_fop_read+0x107/0x160
> [14954.927996]  [] __vfs_read+0x28/0xd0
> [14954.927999]  [] ? security_file_permission+0xa3/0xc0
> [14954.928001]  [] ? rw_verify_area+0x53/0xf0
> [14954.928002]  [] vfs_read+0x86/0x130
> [14954.928004]  [] SyS_read+0x46/0xa0
> [14954.928007]  [] entry_SYSCALL_64_fastpath+0x12/0x6a
> [14954.928008] ---[ end trace b1d297c2aeff3470 ]---
>
> Looks like we're missing a modeset lock/unlock around the property
> retrieval from the sysfs path. Below patch works for me.

Daniel's alternative at

http://mid.gmane.org/1443513413-28873-1-git-send-email-daniel.vetter at ffwll.ch

>
> Signed-off-by: Jens Axboe 
>
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 0f6cd33b531f..2b62166f6b2a 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -239,9 +239,12 @@ static ssize_t dpms_show(struct device *device,
>   uint64_t dpms_status;
>   int ret;
>  
> + drm_modeset_lock(>mode_config.connection_mutex, NULL);
>   ret = drm_object_property_get_value(>base,
>   dev->mode_config.dpms_property,
>   _status);
> + drm_modeset_unlock(>mode_config.connection_mutex);
> +
>   if (ret)
>   return 0;
>  
>
> -- 
> Jens Axboe
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH] drm: fix missing modeset lock from sysfs path

2015-09-28 Thread Jens Axboe
Hi,

Running 4.3-rc on a new laptop, and I notice that I get these whenever
powertop --auto-tune is run:

[14954.927920] [ cut here ]
[14954.927926] WARNING: CPU: 1 PID: 14297 at drivers/gpu/drm/drm_atomic.c:889 
drm_atomic_get_property+0x232/0x2b0()
[14954.927927] Modules linked in: msr drbg ctr ccm cmac uvcvideo hid_generic 
videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev usbhid 
btusb btintel arc4 iwlmvm mac80211 joydev snd_hda_codec_realtek 
snd_hda_codec_generic x86_pkg_temp_thermal snd_hda_codec_hdmi intel_powerclamp 
kvm_intel dell_laptop dell_wmi dcdbas snd_hda_intel hid_multitouch kvm 
sparse_keymap iwlwifi snd_hda_codec snd_hwdep snd_hda_core aesni_intel 
aes_x86_64 glue_helper ehci_pci lrw gf128mul xhci_pci ablk_helper cfg80211 
cryptd xhci_hcd ehci_hcd snd_pcm int3403_thermal snd_seq_midi bnep 
snd_seq_midi_event rfcomm snd_rawmidi bluetooth snd_seq snd_timer 
snd_seq_device processor_thermal_device snd intel_soc_dts_iosf iosf_mbi i2c_hid 
hid i2c_designware_platform i2c_designware_core int3402_thermal int3400_thermal 
int340x_thermal_zone acpi_thermal_rel soundcore binfmt_misc nls_iso8859_1 
nls_cp437 fuse vfat fat
[14954.927963] CPU: 1 PID: 14297 Comm: powertop Tainted: G U  W   
4.3.0-rc3+ #177
[14954.927964] Hardware name: Dell Inc. XPS 13 9343/0310JH, BIOS A05 07/14/2015
[14954.927965]  81a7c2db 8800032e3c88 812923a9 

[14954.927967]  8800032e3cc0 81050aa6 880215577028 
88021551df80
[14954.927968]  880215577000 880133e2ea80 88020ea59000 
8800032e3cd0
[14954.927970] Call Trace:
[14954.927974]  [] dump_stack+0x4b/0x72
[14954.927976]  [] warn_slowpath_common+0x86/0xc0
[14954.927978]  [] warn_slowpath_null+0x1a/0x20
[14954.927980]  [] drm_atomic_get_property+0x232/0x2b0
[14954.927982]  [] drm_object_property_get_value+0x6c/0x70
[14954.927984]  [] dpms_show+0x2f/0x70
[14954.927987]  [] dev_attr_show+0x20/0x50
[14954.927989]  [] sysfs_kf_seq_show+0xa3/0x140
[14954.927990]  [] kernfs_seq_show+0x20/0x30
[14954.927993]  [] seq_read+0xcd/0x370
[14954.927994]  [] kernfs_fop_read+0x107/0x160
[14954.927996]  [] __vfs_read+0x28/0xd0
[14954.927999]  [] ? security_file_permission+0xa3/0xc0
[14954.928001]  [] ? rw_verify_area+0x53/0xf0
[14954.928002]  [] vfs_read+0x86/0x130
[14954.928004]  [] SyS_read+0x46/0xa0
[14954.928007]  [] entry_SYSCALL_64_fastpath+0x12/0x6a
[14954.928008] ---[ end trace b1d297c2aeff3470 ]---

Looks like we're missing a modeset lock/unlock around the property
retrieval from the sysfs path. Below patch works for me.

Signed-off-by: Jens Axboe 

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 0f6cd33b531f..2b62166f6b2a 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -239,9 +239,12 @@ static ssize_t dpms_show(struct device *device,
uint64_t dpms_status;
int ret;

+   drm_modeset_lock(>mode_config.connection_mutex, NULL);
ret = drm_object_property_get_value(>base,
dev->mode_config.dpms_property,
_status);
+   drm_modeset_unlock(>mode_config.connection_mutex);
+
if (ret)
return 0;


-- 
Jens Axboe