drm/amd/amdgpu: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
Subsystems (2)
cover drm/amd/amdgpu: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
According to the TODO list of the DRM subsystem, replace the deprecated drm_modeset_*_all() with DRM_MODESET_LOCK_ALL_*().
Fabio M. De Francesco (2):
drm/amd/amdgpu/amdgpu_device.c: Replace drm_modeset_*_all with
DRM_MODESET_LOCK_ALL_*
drm/amd/amdgpu/amdgpu_drv.c: Replace drm_modeset_*_all with
DRM_MODESET_LOCK_ALL_*
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18 ++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++++-- 2 files changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 drm/amd/amdgpu/amdgpu_device.c: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
Replace the deprecated API with new helpers, according to the TODO list of the DRM subsystem.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -6
@@ -32,6 +32,7 @@#include <linux/slab.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_drv.h> #include <drm/drm_probe_helper.h> #include <drm/amdgpu_drm.h> #include <linux/vgaarb.h>
@@ -3694,14 +3695,17 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)if (!amdgpu_device_has_dc_support (adev)) {/* turn off display hw */ -drm_modeset_lock_all (dev); +struct drm_modeset_acquire_ctx ctx; +int ret; + +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter)drm_helper_connector_dpms (connector,DRM_MODE_DPMS_OFF );drm_connector_list_iter_end (&iter); -drm_modeset_unlock_all (dev); -/* unpin the front buffers and cursors */ +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); +/* unpin the front buffers and cursors */ list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct amdgpu_crtc *amdgpu_crtc =to_amdgpu_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb;
@@ -3830,19 +3834,21 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)/* blat the mode back in */ if (fbcon) {if (!amdgpu_device_has_dc_support (adev)) { +struct drm_modeset_acquire_ctx ctx; +int ret; +/* pre DCE11 */ drm_helper_resume_force_mode (dev);/* turn on display hw */ -drm_modeset_lock_all (dev); +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter)drm_helper_connector_dpms (connector,DRM_MODE_DPMS_ON );drm_connector_list_iter_end (&iter); - -drm_modeset_unlock_all (dev); +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); }amdgpu_fbdev_set_suspend (adev,0 ); }
Signature · 1 line
2.31.1
Re: [Outreachy kernel] [PATCH 1/2] drm/amd/amdgpu/amdgpu_device.c: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
Quoted 2 lines · Fabio M. De Francesco
Replace the deprecated API with new helpers, according to the TODO list of the DRM subsystem.
The commit message will perhaps not be very meaningful one year from now. You could say for example DRM_MODESET_LOCK_ALL_BEGIN was introduced in commit XXX (there is a proper format for referring to other commits) for what purpose. And then say that you are making the replacement.
Actually, I'm a little surprised to see something that looks like a function call be replaced by something that looks like a macro. Maybe it was a macro all along, and this is just making that more clear. In any case, if I were to look at this commit, I would appreciate a little more context information.
julia
Quoted 72 lines
Signed-off-by Fabio M. De Francesco <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12
-7@@ -32,6 +32,7 @@#include <linux/slab.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_drv.h> #include <drm/drm_probe_helper.h> #include <drm/amdgpu_drm.h> #include <linux/vgaarb.h> @@ -3694,14 +3695,17 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)if (!amdgpu_device_has_dc_support (adev)) {/* turn off display hw */ -drm_modeset_lock_all (dev); +struct drm_modeset_acquire_ctx ctx; +int ret; + +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter)drm_helper_connector_dpms (connector,DRM_MODE_DPMS_OFF );drm_connector_list_iter_end (&iter); -drm_modeset_unlock_all (dev); -/* unpin the front buffers and cursors */ +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); +/* unpin the front buffers and cursors */ list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct amdgpu_crtc *amdgpu_crtc =to_amdgpu_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb;@@ -3830,19 +3834,21 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)/* blat the mode back in */ if (fbcon) {if (!amdgpu_device_has_dc_support (adev)) { +struct drm_modeset_acquire_ctx ctx; +int ret; +/* pre DCE11 */ drm_helper_resume_force_mode (dev);/* turn on display hw */ -drm_modeset_lock_all (dev); +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter)drm_helper_connector_dpms (connector,DRM_MODE_DPMS_ON );drm_connector_list_iter_end (&iter); - -drm_modeset_unlock_all (dev); +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); }amdgpu_fbdev_set_suspend (adev,0 ); } --2.31.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20210419122059.738-2-fmdefrancesco%40gmail.com.
Re: [Outreachy kernel] [PATCH 1/2] drm/amd/amdgpu/amdgpu_device.c: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
Quoted 9 lines · CEST Julia Lawall
Quoted 2 lines · Fabio M. De Francesco
Replace the deprecated API with new helpers, according to the TODO list of the DRM subsystem.
The commit message will perhaps not be very meaningful one year from now. You could say for example
DRM_MODESET_LOCK_ALL_BEGINwas introduced in commit XXX (there is a proper format for referring to other commits) for what purpose. And then say that you are making the replacement.
Quoted 8 lines
Actually, I'm a little surprised to see something that looks like a function call be replaced by something that looks like a macro. Maybe it was a macro all along, and this is just making that more clear. In any case, if I were to look at this commit, I would appreciate a little more context information.
julia
I have made that message in line with an old commit (9bcaa3fe58ab) that had been taken by D. Vetter (the DRM maintainer). That message didn't explain more than referring to the TODO list. I try to stick with each subsystem's conventions.
However, I agree with you: referring to a TODO list, which some day will surely change, is not the best means to provide context information.
From that macro documentation (https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#c.DRM_MODESET_LOCK_ALL_BEGIN):
"DRM_MODESET_LOCK_ALL_BEGIN simplifies grabbing all modeset locks using a local context. This has the advantage of reducing boilerplate, [...]". (Please, note that I haven't copied the last part of the paragraph because it talks about checking the return value but I think it's useless because the only possible return value is 0).
If more context information is needed, I would add the above-mentioned note to my commit message and submit a v2 patch.
Is it the right way to solve the issue that you pointed out?
Thanks in advance,
Fabio
Quoted 36 lines
Quoted 36 lines
Signed-off-by Fabio M. De Francesco <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cindex6447cd6ca5a8..e1a71579f8e6100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -32,6 +32,7 @@#include <linux/slab.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_drv.h> #include <
drm/drm_probe_helper.h>
#include <drm/amdgpu_drm.h>
#include <linux/vgaarb.h>drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3694,14 +3695,17 @@ int amdgpu_device_suspend(struct drm_device *dev,bool fbcon)>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-1if (!amdgpu_device_has_dc_support (adev)) {/* turn off display hw */ -drm_modeset_lock_all (dev); +struct drm_modeset_acquire_ctx ctx; +int ret; + +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) · line 3704
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter) drm_helper_connector_dpms(connector,
DRM_MODE_DPMS_OFF);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-2drm_connector_list_iter_end (&iter); -drm_modeset_unlock_all (dev); -/* unpin the front buffers and cursors */ +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); +/* unpin the front buffers and cursors */ list_for_each_entry(crtc, &dev->mode_config.crtc_list,
head) {
Quoted 2 lines
Quoted 2 lines
struct
amdgpu_crtc*amdgpu_crtc=
to_amdgpu_crtc(crtc);
Quoted 14 lines
Quoted 1 line
struct
drm_framebuffer*fb = crtc->primary-fb;
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3830,19 +3834,21 @@ int amdgpu_device_resume(struct drm_device *dev,bool fbcon)>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0/* blat the mode back in */ if (fbcon) {if (!amdgpu_device_has_dc_support (adev)) { +struct drm_modeset_acquire_ctx ctx; +int ret; +
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1/* pre DCE11 */ drm_helper_resume_force_mode (dev);/* turn on display hw */ -drm_modeset_lock_all (dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0,
ret);
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drm_connector_list_iter_begin (dev, &iter); drm_for_each_connector_iter(connector,
&iter)
Quoted 2 lines
Quoted 2 lines
drm_helper_connector_dpms(connector,
Quoted 2 lines
Quoted 2 lines
DRM_MODE_DPMS_ON);
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2drm_connector_list_iter_end (&iter); - -drm_modeset_unlock_all (dev); +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); }amdgpu_fbdev_set_suspend (adev,0 );
Quoted 8 lines
Quoted 8 lines
}
--
2.31.1--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop
receiving
Quoted 5 lines
Quoted 5 lines
emails from it, send an email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/20210419122059.738-2-fmd
efrancesco%40gmail.com.
Re: [Outreachy kernel] [PATCH 1/2] drm/amd/amdgpu/amdgpu_device.c: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
Quoted 34 lines · Fabio M. De Francesco
Quoted 9 lines · CEST Julia Lawall
Quoted 2 lines · Fabio M. De Francesco
Replace the deprecated API with new helpers, according to the TODO list of the DRM subsystem.
The commit message will perhaps not be very meaningful one year from now. You could say for example
DRM_MODESET_LOCK_ALL_BEGINwas introduced in commit XXX (there is a proper format for referring to other commits) for what purpose. And then say that you are making the replacement.Quoted 8 lines
Actually, I'm a little surprised to see something that looks like a function call be replaced by something that looks like a macro. Maybe it was a macro all along, and this is just making that more clear. In any case, if I were to look at this commit, I would appreciate a little more context information.
julia
I have made that message in line with an old commit (
9bcaa3fe58ab) that had been taken by D. Vetter (the DRM maintainer). That message didn't explain more than referring to the TODO list. I try to stick with each subsystem's conventions.However, I agree with you: referring to a TODO list, which some day will surely change, is not the best means to provide context information.
From that macro documentation (https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#c.DRM_MODESET_LOCK_ALL_BEGIN):
"
DRM_MODESET_LOCK_ALL_BEGINsimplifies grabbing all modeset locks using a local context. This has the advantage of reducing boilerplate, [...]". (Please, note that I haven't copied the last part of the paragraph because it talks about checking the return value but I think it's useless because the only possible return value is 0).
Quoted 4 lines
If more context information is needed, I would add the above-mentioned note to my commit message and submit a v2 patch.
Is it the right way to solve the issue that you pointed out?
It seems find to include the information you propose.
thanks,
julia
Quoted 121 lines
Thanks in advance,
Fabio
Quoted 36 lines
Quoted 36 lines
Signed-off-by Fabio M. De Francesco <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cindex6447cd6ca5a8..e1a71579f8e6100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -32,6 +32,7 @@#include <linux/slab.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_drv.h> #include <
drm/drm_probe_helper.h>
#include <drm/amdgpu_drm.h>
#include <linux/vgaarb.h>drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3694,14 +3695,17 @@ int amdgpu_device_suspend(struct drm_device *dev,bool fbcon)>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-1if (!amdgpu_device_has_dc_support (adev)) {/* turn off display hw */ -drm_modeset_lock_all (dev); +struct drm_modeset_acquire_ctx ctx; +int ret; + +DRM_MODESET_LOCK_ALL_BEGIN (dev, ctx,0 , ret);Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) · line 3704
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter) drm_helper_connector_dpms(connector,
DRM_MODE_DPMS_OFF);Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-2drm_connector_list_iter_end (&iter); -drm_modeset_unlock_all (dev); -/* unpin the front buffers and cursors */ +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); +/* unpin the front buffers and cursors */ list_for_each_entry(crtc, &dev->mode_config.crtc_list,head) {
Quoted 2 lines
Quoted 2 lines
struct
amdgpu_crtc*amdgpu_crtc=
to_amdgpu_crtc(crtc);Quoted 14 lines
Quoted 1 line
struct
drm_framebuffer*fb = crtc->primary-fb;
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3830,19 +3834,21 @@ int amdgpu_device_resume(struct drm_device *dev,bool fbcon)>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0/* blat the mode back in */ if (fbcon) {if (!amdgpu_device_has_dc_support (adev)) { +struct drm_modeset_acquire_ctx ctx; +int ret; +Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1/* pre DCE11 */ drm_helper_resume_force_mode (dev);/* turn on display hw */ -drm_modeset_lock_all (dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0,ret);
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drm_connector_list_iter_begin (dev, &iter); drm_for_each_connector_iter(connector,&iter)
Quoted 2 lines
Quoted 2 lines
drm_helper_connector_dpms(connector,
Quoted 2 lines
Quoted 2 lines
DRM_MODE_DPMS_ON);Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2drm_connector_list_iter_end (&iter); - -drm_modeset_unlock_all (dev); +DRM_MODESET_LOCK_ALL_END (dev, ctx, ret); }amdgpu_fbdev_set_suspend (adev,0 );Quoted 8 lines
Quoted 8 lines
}
--
2.31.1--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stopreceiving
Quoted 5 lines
Quoted 5 lines
emails from it, send an email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/20210419122059.738-2-fmd
efrancesco%40gmail.com.
PATCH 2/2 drm/amd/amdgpu/amdgpu_drv.c: Replace drm_modeset_*_all with DRM_MODESET_LOCK_ALL_*
In reply to Fabio M. De FrancescoReplace the deprecated API with new helpers, according to the TODO list of the DRM subsystem.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -2
@@ -1438,8 +1438,10 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)if (amdgpu_device_has_dc_support (adev)) {struct drm_crtc *crtc; +struct drm_modeset_acquire_ctx ctx; +int ret_lock; -drm_modeset_lock_all (drm_dev); +DRM_MODESET_LOCK_ALL_BEGIN (drm_dev, ctx,0 , ret_lock);drm_for_each_crtc (crtc, drm_dev) {if (crtc->state->active) {
@@ -1448,7 +1450,7 @@ static int amdgpu_pmops_runtime_idle(struct device *dev) } } -drm_modeset_unlock_all (drm_dev); +DRM_MODESET_LOCK_ALL_END (drm_dev, ctx, ret_lock); }else {struct drm_connector *list_connector;
Signature · 1 line
2.31.1