mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michał Orzeł" <michalorzel.eng@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>, Sean Paul <seanpaul@chromium.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Dave Airlie <airlied@linux.ie>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: Replace drm_modeset_lock/unlock_all with DRM_MODESET_LOCK_ALL_* helpers
Date: Fri, 1 May 2020 17:49:33 +0200	[thread overview]
Message-ID: <520d517e-5e8f-a6c7-1c8a-38d1a368a79f@gmail.com> (raw)
In-Reply-To: <CAKMK7uEzTn2nKyEaxMcd6602tprwkdnBrmrFYO+_Hi7FY39jAw@mail.gmail.com>



On 30.04.2020 20:30, Daniel Vetter wrote:
> On Thu, Apr 30, 2020 at 5:38 PM Sean Paul <seanpaul@chromium.org> wrote:
>>
>> On Wed, Apr 29, 2020 at 4:57 AM Jani Nikula <jani.nikula@linux.intel.com> wrote:
>>>
>>> On Tue, 28 Apr 2020, Michal Orzel <michalorzel.eng@gmail.com> wrote:
>>>> As suggested by the TODO list for the kernel DRM subsystem, replace
>>>> the deprecated functions that take/drop modeset locks with new helpers.
>>>>
>>>> Signed-off-by: Michal Orzel <michalorzel.eng@gmail.com>
>>>> ---
>>>>  drivers/gpu/drm/drm_mode_object.c | 10 ++++++----
>>>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
>>>> index 35c2719..901b078 100644
>>>> --- a/drivers/gpu/drm/drm_mode_object.c
>>>> +++ b/drivers/gpu/drm/drm_mode_object.c
>>>> @@ -402,12 +402,13 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
>>>>  {
>>>>       struct drm_mode_obj_get_properties *arg = data;
>>>>       struct drm_mode_object *obj;
>>>> +     struct drm_modeset_acquire_ctx ctx;
>>>>       int ret = 0;
>>>>
>>>>       if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>>>               return -EOPNOTSUPP;
>>>>
>>>> -     drm_modeset_lock_all(dev);
>>>> +     DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
>>>
>>> I cry a little every time I look at the DRM_MODESET_LOCK_ALL_BEGIN and
>>> DRM_MODESET_LOCK_ALL_END macros. :(
>>>
>>> Currently only six users... but there are ~60 calls to
>>> drm_modeset_lock_all{,_ctx} that I presume are to be replaced. I wonder
>>> if this will come back and haunt us.
>>>
>>
>> What's the alternative? Seems like the options without the macros is
>> to use incorrect scope or have a bunch of retry/backoff cargo-cult
>> everywhere (and hope the copy source is done correctly).
> 
> Yeah Sean & me had a bunch of bikesheds and this is the least worst
> option we could come up with. You can't make it a function because of
> the control flow. You don't want to open code this because it's tricky
> to get right, if all you want is to just grab all locks. But it is
> magic hidden behind a macro, which occasionally ends up hurting.
> -Daniel
So what are we doing with this problem? Should we replace at once approx. 60 calls?

Michal
> 
>> Sean
>>
>>> BR,
>>> Jani.
>>>
>>>
>>>>
>>>>       obj = drm_mode_object_find(dev, file_priv, arg->obj_id, arg->obj_type);
>>>>       if (!obj) {
>>>> @@ -427,7 +428,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
>>>>  out_unref:
>>>>       drm_mode_object_put(obj);
>>>>  out:
>>>> -     drm_modeset_unlock_all(dev);
>>>> +     DRM_MODESET_LOCK_ALL_END(ctx, ret);
>>>>       return ret;
>>>>  }
>>>>
>>>> @@ -449,12 +450,13 @@ static int set_property_legacy(struct drm_mode_object *obj,
>>>>  {
>>>>       struct drm_device *dev = prop->dev;
>>>>       struct drm_mode_object *ref;
>>>> +     struct drm_modeset_acquire_ctx ctx;
>>>>       int ret = -EINVAL;
>>>>
>>>>       if (!drm_property_change_valid_get(prop, prop_value, &ref))
>>>>               return -EINVAL;
>>>>
>>>> -     drm_modeset_lock_all(dev);
>>>> +     DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
>>>>       switch (obj->type) {
>>>>       case DRM_MODE_OBJECT_CONNECTOR:
>>>>               ret = drm_connector_set_obj_prop(obj, prop, prop_value);
>>>> @@ -468,7 +470,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
>>>>               break;
>>>>       }
>>>>       drm_property_change_valid_put(prop, ref);
>>>> -     drm_modeset_unlock_all(dev);
>>>> +     DRM_MODESET_LOCK_ALL_END(ctx, ret);
>>>>
>>>>       return ret;
>>>>  }
>>>
>>> --
>>> Jani Nikula, Intel Open Source Graphics Center
> 
> 
> 

  reply	other threads:[~2020-05-01 15:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 17:10 Michal Orzel
2020-04-29  8:57 ` Jani Nikula
2020-04-30  5:52   ` Michał Orzeł
2020-04-30 15:37   ` Sean Paul
2020-04-30 18:30     ` Daniel Vetter
2020-05-01 15:49       ` Michał Orzeł [this message]
2020-05-04 11:53         ` Daniel Vetter
2020-05-05  5:55           ` Michał Orzeł
2020-05-05  8:51             ` Daniel Vetter
  -- strict thread matches above, loose matches on Subject: below --
2020-04-26 10:01 Michal Orzel
2020-04-28 15:15 ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=520d517e-5e8f-a6c7-1c8a-38d1a368a79f@gmail.com \
    --to=michalorzel.eng@gmail.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=seanpaul@chromium.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome