From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@linux.ie, sumit.semwal@linaro.org,
christian.koenig@amd.com, axboe@kernel.dk, oleg@redhat.com,
tglx@linutronix.de, dvyukov@google.com,
walter-zh.wu@mediatek.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
skhan@linuxfoundation.org, gregkh@linuxfoundation.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Intel-gfx] [PATCH v3 2/9] drm: hold master_lookup_lock when releasing a drm_file's master
Date: Wed, 18 Aug 2021 22:50:00 +0800 [thread overview]
Message-ID: <a69a6870-18fe-5bbc-074e-871753a8f593@gmail.com> (raw)
In-Reply-To: <YRzbTUM8ggXlIEyr@phenom.ffwll.local>
On 18/8/21 6:05 pm, Daniel Vetter wrote:
> On Wed, Aug 18, 2021 at 03:38:17PM +0800, Desmond Cheong Zhi Xi wrote:
>> When drm_file.master changes value, the corresponding
>> drm_device.master_lookup_lock should be held.
>>
>> In drm_master_release, a call to drm_master_put sets the
>> file_priv->master to NULL, so we protect this section with
>> drm_device.master_lookup_lock.
>>
>> Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
>
> At this points all refcounts to drm_file have disappeared, so yeah this is
> a lockless access, but also no one can observe it anymore. See also next
> patch.
>
> Hence I think the current code is fine.
> -Daniel
>
Ah ok got it, I didn't realize that. I'll drop patch 2 and 3 from the
series then.
>> ---
>> drivers/gpu/drm/drm_auth.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
>> index 8efb58aa7d95..8c0e0dba1611 100644
>> --- a/drivers/gpu/drm/drm_auth.c
>> +++ b/drivers/gpu/drm/drm_auth.c
>> @@ -373,8 +373,11 @@ void drm_master_release(struct drm_file *file_priv)
>> }
>>
>> /* drop the master reference held by the file priv */
>> - if (file_priv->master)
>> + if (file_priv->master) {
>> + spin_lock(&dev->master_lookup_lock);
>> drm_master_put(&file_priv->master);
>> + spin_unlock(&dev->master_lookup_lock);
>> + }
>> mutex_unlock(&dev->master_mutex);
>> }
>>
>> --
>> 2.25.1
>>
>
next prev parent reply other threads:[~2021-08-18 14:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 7:38 [Intel-gfx] [PATCH v3 0/9] drm, kernel: update locking for DRM Desmond Cheong Zhi Xi
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 1/9] drm: move master_lookup_lock into drm_device Desmond Cheong Zhi Xi
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 2/9] drm: hold master_lookup_lock when releasing a drm_file's master Desmond Cheong Zhi Xi
2021-08-18 10:05 ` Daniel Vetter
2021-08-18 14:50 ` Desmond Cheong Zhi Xi [this message]
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 3/9] drm: check for null master in drm_is_current_master_locked Desmond Cheong Zhi Xi
2021-08-18 10:04 ` Daniel Vetter
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 4/9] drm: fix potential null ptr dereferences in drm_{auth, ioctl} Desmond Cheong Zhi Xi
2021-08-18 10:11 ` Daniel Vetter
2021-08-18 15:37 ` Desmond Cheong Zhi Xi
2021-08-18 16:33 ` Daniel Vetter
2021-08-19 5:31 ` Desmond Cheong Zhi Xi
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 5/9] drm: protect magic_map, unique{_len} with master_lookup_lock Desmond Cheong Zhi Xi
2021-08-18 10:43 ` Daniel Vetter
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 6/9] drm: convert drm_device.master_mutex into a rwsem Desmond Cheong Zhi Xi
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 7/9] drm: update global mutex lock in the ioctl handler Desmond Cheong Zhi Xi
2021-08-18 11:02 ` Daniel Vetter
2021-08-19 10:52 ` Desmond Cheong Zhi Xi
2021-08-19 11:21 ` Daniel Vetter
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 8/9] kernel: export task_work_add Desmond Cheong Zhi Xi
2021-08-18 11:06 ` Daniel Vetter
2021-08-19 9:26 ` Christoph Hellwig
2021-08-19 9:40 ` Desmond Cheong Zhi Xi
2021-08-18 7:38 ` [Intel-gfx] [PATCH v3 9/9] drm: avoid races with modesetting rights Desmond Cheong Zhi Xi
2021-08-18 13:53 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm, kernel: update locking for DRM Patchwork
2021-08-19 11:09 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm, kernel: update locking for DRM (rev2) Patchwork
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=a69a6870-18fe-5bbc-074e-871753a8f593@gmail.com \
--to=desmondcheongzx@gmail.com \
--cc=airlied@linux.ie \
--cc=axboe@kernel.dk \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=oleg@redhat.com \
--cc=skhan@linuxfoundation.org \
--cc=sumit.semwal@linaro.org \
--cc=tglx@linutronix.de \
--cc=tzimmermann@suse.de \
--cc=walter-zh.wu@mediatek.com \
/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;
as well as URLs for NNTP newsgroup(s).