Skip to content

Commit 7cd9beb

Browse files
committed
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "Misc i915, vmwgfx and radeon fixes along with a fix for one of those recursive sleep mutex debug cases in the mst code" * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: drm/vmwgfx: Fix an issue with the device losing its irq line on module unload drm/vmwgfx: Correctly NULLify dma buffer pointer on failure drm/vmwgfx: Reorder device takedown somewhat drm/vmwgfx: Fix a couple of lock dependency violations drm/radeon: drop setting UPLL to sleep mode drm/radeon: fix wait to actually occur after the signaling callback drm/i915: Prevent TLB error on first execution on SNB drm/i915: Do both mt and gen6 style forcewake reset on ivb probe drm/i915: Make WAIT_IOCTL negative timeouts be indefinite again drm/i915: use in_interrupt() not in_irq() to check context drm/mst: fix recursive sleep warning on qlock drm: Don't assign fbs for universal cursor support to files
2 parents 60b3e7b + e2cdcaf commit 7cd9beb

File tree

10 files changed

+155
-110
lines changed

10 files changed

+155
-110
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
#include "drm_crtc_internal.h"
4444
#include "drm_internal.h"
4545

46-
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
47-
struct drm_mode_fb_cmd2 *r,
48-
struct drm_file *file_priv);
46+
static struct drm_framebuffer *
47+
internal_framebuffer_create(struct drm_device *dev,
48+
struct drm_mode_fb_cmd2 *r,
49+
struct drm_file *file_priv);
4950

5051
/* Avoid boilerplate. I'm tired of typing. */
5152
#define DRM_ENUM_NAME_FN(fnname, list) \
@@ -2908,13 +2909,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
29082909
*/
29092910
if (req->flags & DRM_MODE_CURSOR_BO) {
29102911
if (req->handle) {
2911-
fb = add_framebuffer_internal(dev, &fbreq, file_priv);
2912+
fb = internal_framebuffer_create(dev, &fbreq, file_priv);
29122913
if (IS_ERR(fb)) {
29132914
DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n");
29142915
return PTR_ERR(fb);
29152916
}
2916-
2917-
drm_framebuffer_reference(fb);
29182917
} else {
29192918
fb = NULL;
29202919
}
@@ -3267,9 +3266,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
32673266
return 0;
32683267
}
32693268

3270-
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
3271-
struct drm_mode_fb_cmd2 *r,
3272-
struct drm_file *file_priv)
3269+
static struct drm_framebuffer *
3270+
internal_framebuffer_create(struct drm_device *dev,
3271+
struct drm_mode_fb_cmd2 *r,
3272+
struct drm_file *file_priv)
32733273
{
32743274
struct drm_mode_config *config = &dev->mode_config;
32753275
struct drm_framebuffer *fb;
@@ -3301,12 +3301,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
33013301
return fb;
33023302
}
33033303

3304-
mutex_lock(&file_priv->fbs_lock);
3305-
r->fb_id = fb->base.id;
3306-
list_add(&fb->filp_head, &file_priv->fbs);
3307-
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
3308-
mutex_unlock(&file_priv->fbs_lock);
3309-
33103304
return fb;
33113305
}
33123306

@@ -3328,15 +3322,24 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
33283322
int drm_mode_addfb2(struct drm_device *dev,
33293323
void *data, struct drm_file *file_priv)
33303324
{
3325+
struct drm_mode_fb_cmd2 *r = data;
33313326
struct drm_framebuffer *fb;
33323327

33333328
if (!drm_core_check_feature(dev, DRIVER_MODESET))
33343329
return -EINVAL;
33353330

3336-
fb = add_framebuffer_internal(dev, data, file_priv);
3331+
fb = internal_framebuffer_create(dev, r, file_priv);
33373332
if (IS_ERR(fb))
33383333
return PTR_ERR(fb);
33393334

3335+
/* Transfer ownership to the filp for reaping on close */
3336+
3337+
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
3338+
mutex_lock(&file_priv->fbs_lock);
3339+
r->fb_id = fb->base.id;
3340+
list_add(&fb->filp_head, &file_priv->fbs);
3341+
mutex_unlock(&file_priv->fbs_lock);
3342+
33403343
return 0;
33413344
}
33423345

drivers/gpu/drm/drm_dp_mst_topology.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,14 @@ static bool check_txmsg_state(struct drm_dp_mst_topology_mgr *mgr,
733733
struct drm_dp_sideband_msg_tx *txmsg)
734734
{
735735
bool ret;
736-
mutex_lock(&mgr->qlock);
736+
737+
/*
738+
* All updates to txmsg->state are protected by mgr->qlock, and the two
739+
* cases we check here are terminal states. For those the barriers
740+
* provided by the wake_up/wait_event pair are enough.
741+
*/
737742
ret = (txmsg->state == DRM_DP_SIDEBAND_TX_RX ||
738743
txmsg->state == DRM_DP_SIDEBAND_TX_TIMEOUT);
739-
mutex_unlock(&mgr->qlock);
740744
return ret;
741745
}
742746

@@ -1363,12 +1367,13 @@ static int process_single_tx_qlock(struct drm_dp_mst_topology_mgr *mgr,
13631367
return 0;
13641368
}
13651369

1366-
/* must be called holding qlock */
13671370
static void process_single_down_tx_qlock(struct drm_dp_mst_topology_mgr *mgr)
13681371
{
13691372
struct drm_dp_sideband_msg_tx *txmsg;
13701373
int ret;
13711374

1375+
WARN_ON(!mutex_is_locked(&mgr->qlock));
1376+
13721377
/* construct a chunk from the first msg in the tx_msg queue */
13731378
if (list_empty(&mgr->tx_msg_downq)) {
13741379
mgr->tx_down_in_progress = false;

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,9 +2936,9 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
29362936
req = obj->last_read_req;
29372937

29382938
/* Do this after OLR check to make sure we make forward progress polling
2939-
* on this IOCTL with a timeout <=0 (like busy ioctl)
2939+
* on this IOCTL with a timeout == 0 (like busy ioctl)
29402940
*/
2941-
if (args->timeout_ns <= 0) {
2941+
if (args->timeout_ns == 0) {
29422942
ret = -ETIME;
29432943
goto out;
29442944
}
@@ -2948,7 +2948,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
29482948
i915_gem_request_reference(req);
29492949
mutex_unlock(&dev->struct_mutex);
29502950

2951-
ret = __i915_wait_request(req, reset_counter, true, &args->timeout_ns,
2951+
ret = __i915_wait_request(req, reset_counter, true,
2952+
args->timeout_ns > 0 ? &args->timeout_ns : NULL,
29522953
file->driver_priv);
29532954
mutex_lock(&dev->struct_mutex);
29542955
i915_gem_request_unreference(req);
@@ -4792,6 +4793,9 @@ i915_gem_init_hw(struct drm_device *dev)
47924793
if (INTEL_INFO(dev)->gen < 6 && !intel_enable_gtt())
47934794
return -EIO;
47944795

4796+
/* Double layer security blanket, see i915_gem_init() */
4797+
intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
4798+
47954799
if (dev_priv->ellc_size)
47964800
I915_WRITE(HSW_IDICR, I915_READ(HSW_IDICR) | IDIHASHMSK(0xf));
47974801

@@ -4824,7 +4828,7 @@ i915_gem_init_hw(struct drm_device *dev)
48244828
for_each_ring(ring, dev_priv, i) {
48254829
ret = ring->init_hw(ring);
48264830
if (ret)
4827-
return ret;
4831+
goto out;
48284832
}
48294833

48304834
for (i = 0; i < NUM_L3_SLICES(dev); i++)
@@ -4841,9 +4845,11 @@ i915_gem_init_hw(struct drm_device *dev)
48414845
DRM_ERROR("Context enable failed %d\n", ret);
48424846
i915_gem_cleanup_ringbuffer(dev);
48434847

4844-
return ret;
4848+
goto out;
48454849
}
48464850

4851+
out:
4852+
intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
48474853
return ret;
48484854
}
48494855

@@ -4877,6 +4883,14 @@ int i915_gem_init(struct drm_device *dev)
48774883
dev_priv->gt.stop_ring = intel_logical_ring_stop;
48784884
}
48794885

4886+
/* This is just a security blanket to placate dragons.
4887+
* On some systems, we very sporadically observe that the first TLBs
4888+
* used by the CS may be stale, despite us poking the TLB reset. If
4889+
* we hold the forcewake during initialisation these problems
4890+
* just magically go away.
4891+
*/
4892+
intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
4893+
48804894
ret = i915_gem_init_userptr(dev);
48814895
if (ret)
48824896
goto out_unlock;
@@ -4903,6 +4917,7 @@ int i915_gem_init(struct drm_device *dev)
49034917
}
49044918

49054919
out_unlock:
4920+
intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
49064921
mutex_unlock(&dev->struct_mutex);
49074922

49084923
return ret;

drivers/gpu/drm/i915/intel_display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9716,7 +9716,7 @@ void intel_check_page_flip(struct drm_device *dev, int pipe)
97169716
struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
97179717
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
97189718

9719-
WARN_ON(!in_irq());
9719+
WARN_ON(!in_interrupt());
97209720

97219721
if (crtc == NULL)
97229722
return;

drivers/gpu/drm/i915/intel_uncore.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,14 @@ static void intel_uncore_fw_domains_init(struct drm_device *dev)
10481048

10491049
/* We need to init first for ECOBUS access and then
10501050
* determine later if we want to reinit, in case of MT access is
1051-
* not working
1051+
* not working. In this stage we don't know which flavour this
1052+
* ivb is, so it is better to reset also the gen6 fw registers
1053+
* before the ecobus check.
10521054
*/
1055+
1056+
__raw_i915_write32(dev_priv, FORCEWAKE, 0);
1057+
__raw_posting_read(dev_priv, ECOBUS);
1058+
10531059
fw_domain_init(dev_priv, FW_DOMAIN_ID_RENDER,
10541060
FORCEWAKE_MT, FORCEWAKE_MT_ACK);
10551061

drivers/gpu/drm/radeon/radeon_fence.c

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,37 +1030,59 @@ static inline bool radeon_test_signaled(struct radeon_fence *fence)
10301030
return test_bit(FENCE_FLAG_SIGNALED_BIT, &fence->base.flags);
10311031
}
10321032

1033+
struct radeon_wait_cb {
1034+
struct fence_cb base;
1035+
struct task_struct *task;
1036+
};
1037+
1038+
static void
1039+
radeon_fence_wait_cb(struct fence *fence, struct fence_cb *cb)
1040+
{
1041+
struct radeon_wait_cb *wait =
1042+
container_of(cb, struct radeon_wait_cb, base);
1043+
1044+
wake_up_process(wait->task);
1045+
}
1046+
10331047
static signed long radeon_fence_default_wait(struct fence *f, bool intr,
10341048
signed long t)
10351049
{
10361050
struct radeon_fence *fence = to_radeon_fence(f);
10371051
struct radeon_device *rdev = fence->rdev;
1038-
bool signaled;
1052+
struct radeon_wait_cb cb;
10391053

1040-
fence_enable_sw_signaling(&fence->base);
1054+
cb.task = current;
10411055

1042-
/*
1043-
* This function has to return -EDEADLK, but cannot hold
1044-
* exclusive_lock during the wait because some callers
1045-
* may already hold it. This means checking needs_reset without
1046-
* lock, and not fiddling with any gpu internals.
1047-
*
1048-
* The callback installed with fence_enable_sw_signaling will
1049-
* run before our wait_event_*timeout call, so we will see
1050-
* both the signaled fence and the changes to needs_reset.
1051-
*/
1056+
if (fence_add_callback(f, &cb.base, radeon_fence_wait_cb))
1057+
return t;
1058+
1059+
while (t > 0) {
1060+
if (intr)
1061+
set_current_state(TASK_INTERRUPTIBLE);
1062+
else
1063+
set_current_state(TASK_UNINTERRUPTIBLE);
1064+
1065+
/*
1066+
* radeon_test_signaled must be called after
1067+
* set_current_state to prevent a race with wake_up_process
1068+
*/
1069+
if (radeon_test_signaled(fence))
1070+
break;
1071+
1072+
if (rdev->needs_reset) {
1073+
t = -EDEADLK;
1074+
break;
1075+
}
1076+
1077+
t = schedule_timeout(t);
1078+
1079+
if (t > 0 && intr && signal_pending(current))
1080+
t = -ERESTARTSYS;
1081+
}
1082+
1083+
__set_current_state(TASK_RUNNING);
1084+
fence_remove_callback(f, &cb.base);
10521085

1053-
if (intr)
1054-
t = wait_event_interruptible_timeout(rdev->fence_queue,
1055-
((signaled = radeon_test_signaled(fence)) ||
1056-
rdev->needs_reset), t);
1057-
else
1058-
t = wait_event_timeout(rdev->fence_queue,
1059-
((signaled = radeon_test_signaled(fence)) ||
1060-
rdev->needs_reset), t);
1061-
1062-
if (t > 0 && !signaled)
1063-
return -EDEADLK;
10641086
return t;
10651087
}
10661088

drivers/gpu/drm/radeon/si.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7130,8 +7130,7 @@ int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk)
71307130
WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_BYPASS_EN_MASK, ~UPLL_BYPASS_EN_MASK);
71317131

71327132
if (!vclk || !dclk) {
7133-
/* keep the Bypass mode, put PLL to sleep */
7134-
WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_SLEEP_MASK, ~UPLL_SLEEP_MASK);
7133+
/* keep the Bypass mode */
71357134
return 0;
71367135
}
71377136

@@ -7147,8 +7146,7 @@ int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk)
71477146
/* set VCO_MODE to 1 */
71487147
WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_VCO_MODE_MASK, ~UPLL_VCO_MODE_MASK);
71497148

7150-
/* toggle UPLL_SLEEP to 1 then back to 0 */
7151-
WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_SLEEP_MASK, ~UPLL_SLEEP_MASK);
7149+
/* disable sleep mode */
71527150
WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_SLEEP_MASK);
71537151

71547152
/* deassert UPLL_RESET */

0 commit comments

Comments
 (0)