Rev 3243 | Rev 3746 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3243 | Rev 3480 | ||
---|---|---|---|
Line 126... | Line 126... | ||
126 | return ret; |
126 | return ret; |
127 | } |
127 | } |
Line 128... | Line 128... | ||
128 | 128 | ||
129 | static void do_destroy(struct i915_hw_context *ctx) |
129 | static void do_destroy(struct i915_hw_context *ctx) |
130 | { |
- | |
131 | struct drm_device *dev = ctx->obj->base.dev; |
- | |
132 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
133 | 130 | { |
|
134 | if (ctx->file_priv) |
131 | if (ctx->file_priv) |
135 | idr_remove(&ctx->file_priv->context_idr, ctx->id); |
- | |
136 | else |
- | |
Line 137... | Line 132... | ||
137 | BUG_ON(ctx != dev_priv->ring[RCS].default_context); |
132 | idr_remove(&ctx->file_priv->context_idr, ctx->id); |
138 | 133 | ||
139 | drm_gem_object_unreference(&ctx->obj->base); |
134 | drm_gem_object_unreference(&ctx->obj->base); |
Line 144... | Line 139... | ||
144 | create_hw_context(struct drm_device *dev, |
139 | create_hw_context(struct drm_device *dev, |
145 | struct drm_i915_file_private *file_priv) |
140 | struct drm_i915_file_private *file_priv) |
146 | { |
141 | { |
147 | struct drm_i915_private *dev_priv = dev->dev_private; |
142 | struct drm_i915_private *dev_priv = dev->dev_private; |
148 | struct i915_hw_context *ctx; |
143 | struct i915_hw_context *ctx; |
149 | int ret, id; |
144 | int ret; |
Line 150... | Line 145... | ||
150 | 145 | ||
151 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
146 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
152 | if (ctx == NULL) |
147 | if (ctx == NULL) |
Line 169... | Line 164... | ||
169 | if (file_priv == NULL) |
164 | if (file_priv == NULL) |
170 | return ctx; |
165 | return ctx; |
Line 171... | Line 166... | ||
171 | 166 | ||
Line 172... | Line -... | ||
172 | ctx->file_priv = file_priv; |
- | |
173 | 167 | ctx->file_priv = file_priv; |
|
174 | again: |
168 | |
175 | if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) { |
- | |
176 | ret = -ENOMEM; |
- | |
177 | DRM_DEBUG_DRIVER("idr allocation failed\n"); |
- | |
178 | goto err_out; |
- | |
179 | } |
- | |
180 | - | ||
181 | ret = idr_get_new_above(&file_priv->context_idr, ctx, |
169 | ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0, |
182 | DEFAULT_CONTEXT_ID + 1, &id); |
- | |
183 | if (ret == 0) |
- | |
184 | ctx->id = id; |
- | |
185 | - | ||
186 | if (ret == -EAGAIN) |
- | |
187 | goto again; |
170 | GFP_KERNEL); |
- | 171 | if (ret < 0) |
|
Line 188... | Line 172... | ||
188 | else if (ret) |
172 | goto err_out; |
Line 189... | Line 173... | ||
189 | goto err_out; |
173 | ctx->id = ret; |
190 | 174 | ||
Line 243... | Line 227... | ||
243 | #endif |
227 | #endif |
Line 244... | Line 228... | ||
244 | 228 | ||
245 | void i915_gem_context_init(struct drm_device *dev) |
229 | void i915_gem_context_init(struct drm_device *dev) |
246 | { |
230 | { |
247 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
248 | uint32_t ctx_size; |
- | |
249 | - | ||
250 | dev_priv->hw_contexts_disabled = true; |
- | |
Line 251... | Line 231... | ||
251 | return; |
231 | struct drm_i915_private *dev_priv = dev->dev_private; |
252 | 232 | ||
253 | #if 0 |
233 | #if 0 |
254 | if (!HAS_HW_CONTEXTS(dev)) { |
234 | if (!HAS_HW_CONTEXTS(dev)) { |
Line 259... | Line 239... | ||
259 | /* If called from reset, or thaw... we've been here already */ |
239 | /* If called from reset, or thaw... we've been here already */ |
260 | if (dev_priv->hw_contexts_disabled || |
240 | if (dev_priv->hw_contexts_disabled || |
261 | dev_priv->ring[RCS].default_context) |
241 | dev_priv->ring[RCS].default_context) |
262 | return; |
242 | return; |
Line 263... | Line -... | ||
263 | - | ||
264 | ctx_size = get_context_size(dev); |
- | |
265 | dev_priv->hw_context_size = get_context_size(dev); |
243 | |
Line 266... | Line 244... | ||
266 | dev_priv->hw_context_size = round_up(dev_priv->hw_context_size, 4096); |
244 | dev_priv->hw_context_size = round_up(get_context_size(dev), 4096); |
267 | 245 | ||
268 | if (ctx_size <= 0 || ctx_size > (1<<20)) { |
246 | if (dev_priv->hw_context_size > (1<<20)) { |
269 | dev_priv->hw_contexts_disabled = true; |
247 | dev_priv->hw_contexts_disabled = true; |
Line 270... | Line 248... | ||
270 | return; |
248 | return; |