diff options
author | Dave Airlie <airlied@redhat.com> | 2014-08-04 19:04:59 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-08-04 19:04:59 -0400 |
commit | 5d42f82a9b8c5168d75cf59307cd271feca94464 (patch) | |
tree | a7049189a2c814589b3ad7e6e776fb736f980967 /drivers/gpu/drm/i915/i915_gem_stolen.c | |
parent | c759606c96dc052373d4c36ea383595da46b04e9 (diff) | |
parent | 19583ca584d6f574384e17fe7613dfaeadcdc4a6 (diff) |
Merge tag 'v3.16' into drm-next
Linux 3.16
backmerge requested by i915, nouveau and radeon authors
Conflicts:
drivers/gpu/drm/i915/i915_gem_render_state.c
drivers/gpu/drm/i915/intel_drv.h
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_stolen.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_stolen.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index b695d184c487..21c025a209c0 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c | |||
@@ -74,6 +74,50 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) | |||
74 | if (base == 0) | 74 | if (base == 0) |
75 | return 0; | 75 | return 0; |
76 | 76 | ||
77 | /* make sure we don't clobber the GTT if it's within stolen memory */ | ||
78 | if (INTEL_INFO(dev)->gen <= 4 && !IS_G33(dev) && !IS_G4X(dev)) { | ||
79 | struct { | ||
80 | u32 start, end; | ||
81 | } stolen[2] = { | ||
82 | { .start = base, .end = base + dev_priv->gtt.stolen_size, }, | ||
83 | { .start = base, .end = base + dev_priv->gtt.stolen_size, }, | ||
84 | }; | ||
85 | u64 gtt_start, gtt_end; | ||
86 | |||
87 | gtt_start = I915_READ(PGTBL_CTL); | ||
88 | if (IS_GEN4(dev)) | ||
89 | gtt_start = (gtt_start & PGTBL_ADDRESS_LO_MASK) | | ||
90 | (gtt_start & PGTBL_ADDRESS_HI_MASK) << 28; | ||
91 | else | ||
92 | gtt_start &= PGTBL_ADDRESS_LO_MASK; | ||
93 | gtt_end = gtt_start + gtt_total_entries(dev_priv->gtt) * 4; | ||
94 | |||
95 | if (gtt_start >= stolen[0].start && gtt_start < stolen[0].end) | ||
96 | stolen[0].end = gtt_start; | ||
97 | if (gtt_end > stolen[1].start && gtt_end <= stolen[1].end) | ||
98 | stolen[1].start = gtt_end; | ||
99 | |||
100 | /* pick the larger of the two chunks */ | ||
101 | if (stolen[0].end - stolen[0].start > | ||
102 | stolen[1].end - stolen[1].start) { | ||
103 | base = stolen[0].start; | ||
104 | dev_priv->gtt.stolen_size = stolen[0].end - stolen[0].start; | ||
105 | } else { | ||
106 | base = stolen[1].start; | ||
107 | dev_priv->gtt.stolen_size = stolen[1].end - stolen[1].start; | ||
108 | } | ||
109 | |||
110 | if (stolen[0].start != stolen[1].start || | ||
111 | stolen[0].end != stolen[1].end) { | ||
112 | DRM_DEBUG_KMS("GTT within stolen memory at 0x%llx-0x%llx\n", | ||
113 | (unsigned long long) gtt_start, | ||
114 | (unsigned long long) gtt_end - 1); | ||
115 | DRM_DEBUG_KMS("Stolen memory adjusted to 0x%x-0x%x\n", | ||
116 | base, base + (u32) dev_priv->gtt.stolen_size - 1); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | |||
77 | /* Verify that nothing else uses this physical address. Stolen | 121 | /* Verify that nothing else uses this physical address. Stolen |
78 | * memory should be reserved by the BIOS and hidden from the | 122 | * memory should be reserved by the BIOS and hidden from the |
79 | * kernel. So if the region is already marked as busy, something | 123 | * kernel. So if the region is already marked as busy, something |