diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-01-24 13:01:07 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-01-24 17:41:34 +0000 |
commit | 7e13ad896484a0165a68197a2e64091ea28c9602 (patch) | |
tree | a20b339f718dd71ca66899a60a970230acc5963a /drivers/gpu/drm/i915/i915_switcheroo.c | |
parent | 7a2c65dd32b1cfa8bae55250dfdfe3d049e2f336 (diff) | |
download | linux-7e13ad896484a0165a68197a2e64091ea28c9602.tar.gz linux-7e13ad896484a0165a68197a2e64091ea28c9602.tar.bz2 linux-7e13ad896484a0165a68197a2e64091ea28c9602.zip |
drm: Avoid drm_global_mutex for simple inc/dec of dev->open_count
Since drm_global_mutex is a true global mutex across devices, we don't
want to acquire it unless absolutely necessary. For maintaining the
device local open_count, we can use atomic operations on the counter
itself, except when making the transition to/from 0. Here, we tackle the
easy portion of delaying acquiring the drm_global_mutex for the final
release by using atomic_dec_and_mutex_lock(), leaving the global
serialisation across the device opens.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Hellström (VMware) <thomas_os@shipmail.org>
Reviewed-by: Thomas Hellström <thellstrom@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200124130107.125404-1-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_switcheroo.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_switcheroo.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/i915_switcheroo.c b/drivers/gpu/drm/i915/i915_switcheroo.c index 39c79e1c5b52..ed69b5d4a375 100644 --- a/drivers/gpu/drm/i915/i915_switcheroo.c +++ b/drivers/gpu/drm/i915/i915_switcheroo.c @@ -43,7 +43,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev) * locking inversion with the driver load path. And the access here is * completely racy anyway. So don't bother with locking for now. */ - return i915 && i915->drm.open_count == 0; + return i915 && atomic_read(&i915->drm.open_count) == 0; } static const struct vga_switcheroo_client_ops i915_switcheroo_ops = { |