| .. | .. |
|---|
| 29 | 29 | #include <linux/module.h> |
|---|
| 30 | 30 | #include <linux/stat.h> |
|---|
| 31 | 31 | #include <linux/sysfs.h> |
|---|
| 32 | | -#include "intel_drv.h" |
|---|
| 32 | + |
|---|
| 33 | +#include "gt/intel_rc6.h" |
|---|
| 34 | +#include "gt/intel_rps.h" |
|---|
| 35 | +#include "gt/sysfs_engines.h" |
|---|
| 36 | + |
|---|
| 33 | 37 | #include "i915_drv.h" |
|---|
| 38 | +#include "i915_sysfs.h" |
|---|
| 39 | +#include "intel_pm.h" |
|---|
| 40 | +#include "intel_sideband.h" |
|---|
| 34 | 41 | |
|---|
| 35 | 42 | static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev) |
|---|
| 36 | 43 | { |
|---|
| .. | .. |
|---|
| 42 | 49 | static u32 calc_residency(struct drm_i915_private *dev_priv, |
|---|
| 43 | 50 | i915_reg_t reg) |
|---|
| 44 | 51 | { |
|---|
| 45 | | - u64 res; |
|---|
| 52 | + intel_wakeref_t wakeref; |
|---|
| 53 | + u64 res = 0; |
|---|
| 46 | 54 | |
|---|
| 47 | | - intel_runtime_pm_get(dev_priv); |
|---|
| 48 | | - res = intel_rc6_residency_us(dev_priv, reg); |
|---|
| 49 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 55 | + with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) |
|---|
| 56 | + res = intel_rc6_residency_us(&dev_priv->gt.rc6, reg); |
|---|
| 50 | 57 | |
|---|
| 51 | 58 | return DIV_ROUND_CLOSEST_ULL(res, 1000); |
|---|
| 52 | 59 | } |
|---|
| .. | .. |
|---|
| 139 | 146 | }; |
|---|
| 140 | 147 | #endif |
|---|
| 141 | 148 | |
|---|
| 142 | | -static int l3_access_valid(struct drm_i915_private *dev_priv, loff_t offset) |
|---|
| 149 | +static int l3_access_valid(struct drm_i915_private *i915, loff_t offset) |
|---|
| 143 | 150 | { |
|---|
| 144 | | - if (!HAS_L3_DPF(dev_priv)) |
|---|
| 151 | + if (!HAS_L3_DPF(i915)) |
|---|
| 145 | 152 | return -EPERM; |
|---|
| 146 | 153 | |
|---|
| 147 | | - if (offset % 4 != 0) |
|---|
| 154 | + if (!IS_ALIGNED(offset, sizeof(u32))) |
|---|
| 148 | 155 | return -EINVAL; |
|---|
| 149 | 156 | |
|---|
| 150 | 157 | if (offset >= GEN7_L3LOG_SIZE) |
|---|
| .. | .. |
|---|
| 159 | 166 | loff_t offset, size_t count) |
|---|
| 160 | 167 | { |
|---|
| 161 | 168 | struct device *kdev = kobj_to_dev(kobj); |
|---|
| 162 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 163 | | - struct drm_device *dev = &dev_priv->drm; |
|---|
| 169 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 164 | 170 | int slice = (int)(uintptr_t)attr->private; |
|---|
| 165 | 171 | int ret; |
|---|
| 166 | 172 | |
|---|
| 167 | | - count = round_down(count, 4); |
|---|
| 168 | | - |
|---|
| 169 | | - ret = l3_access_valid(dev_priv, offset); |
|---|
| 173 | + ret = l3_access_valid(i915, offset); |
|---|
| 170 | 174 | if (ret) |
|---|
| 171 | 175 | return ret; |
|---|
| 172 | 176 | |
|---|
| 177 | + count = round_down(count, sizeof(u32)); |
|---|
| 173 | 178 | count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count); |
|---|
| 179 | + memset(buf, 0, count); |
|---|
| 174 | 180 | |
|---|
| 175 | | - ret = i915_mutex_lock_interruptible(dev); |
|---|
| 176 | | - if (ret) |
|---|
| 177 | | - return ret; |
|---|
| 178 | | - |
|---|
| 179 | | - if (dev_priv->l3_parity.remap_info[slice]) |
|---|
| 181 | + spin_lock(&i915->gem.contexts.lock); |
|---|
| 182 | + if (i915->l3_parity.remap_info[slice]) |
|---|
| 180 | 183 | memcpy(buf, |
|---|
| 181 | | - dev_priv->l3_parity.remap_info[slice] + (offset/4), |
|---|
| 184 | + i915->l3_parity.remap_info[slice] + offset / sizeof(u32), |
|---|
| 182 | 185 | count); |
|---|
| 183 | | - else |
|---|
| 184 | | - memset(buf, 0, count); |
|---|
| 185 | | - |
|---|
| 186 | | - mutex_unlock(&dev->struct_mutex); |
|---|
| 186 | + spin_unlock(&i915->gem.contexts.lock); |
|---|
| 187 | 187 | |
|---|
| 188 | 188 | return count; |
|---|
| 189 | 189 | } |
|---|
| .. | .. |
|---|
| 194 | 194 | loff_t offset, size_t count) |
|---|
| 195 | 195 | { |
|---|
| 196 | 196 | struct device *kdev = kobj_to_dev(kobj); |
|---|
| 197 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 198 | | - struct drm_device *dev = &dev_priv->drm; |
|---|
| 199 | | - struct i915_gem_context *ctx; |
|---|
| 197 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 200 | 198 | int slice = (int)(uintptr_t)attr->private; |
|---|
| 201 | | - u32 **remap_info; |
|---|
| 199 | + u32 *remap_info, *freeme = NULL; |
|---|
| 200 | + struct i915_gem_context *ctx; |
|---|
| 202 | 201 | int ret; |
|---|
| 203 | 202 | |
|---|
| 204 | | - ret = l3_access_valid(dev_priv, offset); |
|---|
| 203 | + ret = l3_access_valid(i915, offset); |
|---|
| 205 | 204 | if (ret) |
|---|
| 206 | 205 | return ret; |
|---|
| 207 | 206 | |
|---|
| 208 | | - ret = i915_mutex_lock_interruptible(dev); |
|---|
| 209 | | - if (ret) |
|---|
| 210 | | - return ret; |
|---|
| 207 | + if (count < sizeof(u32)) |
|---|
| 208 | + return -EINVAL; |
|---|
| 211 | 209 | |
|---|
| 212 | | - remap_info = &dev_priv->l3_parity.remap_info[slice]; |
|---|
| 213 | | - if (!*remap_info) { |
|---|
| 214 | | - *remap_info = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL); |
|---|
| 215 | | - if (!*remap_info) { |
|---|
| 216 | | - ret = -ENOMEM; |
|---|
| 217 | | - goto out; |
|---|
| 218 | | - } |
|---|
| 210 | + remap_info = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL); |
|---|
| 211 | + if (!remap_info) |
|---|
| 212 | + return -ENOMEM; |
|---|
| 213 | + |
|---|
| 214 | + spin_lock(&i915->gem.contexts.lock); |
|---|
| 215 | + |
|---|
| 216 | + if (i915->l3_parity.remap_info[slice]) { |
|---|
| 217 | + freeme = remap_info; |
|---|
| 218 | + remap_info = i915->l3_parity.remap_info[slice]; |
|---|
| 219 | + } else { |
|---|
| 220 | + i915->l3_parity.remap_info[slice] = remap_info; |
|---|
| 219 | 221 | } |
|---|
| 220 | 222 | |
|---|
| 221 | | - /* TODO: Ideally we really want a GPU reset here to make sure errors |
|---|
| 223 | + count = round_down(count, sizeof(u32)); |
|---|
| 224 | + memcpy(remap_info + offset / sizeof(u32), buf, count); |
|---|
| 225 | + |
|---|
| 226 | + /* NB: We defer the remapping until we switch to the context */ |
|---|
| 227 | + list_for_each_entry(ctx, &i915->gem.contexts.list, link) |
|---|
| 228 | + ctx->remap_slice |= BIT(slice); |
|---|
| 229 | + |
|---|
| 230 | + spin_unlock(&i915->gem.contexts.lock); |
|---|
| 231 | + kfree(freeme); |
|---|
| 232 | + |
|---|
| 233 | + /* |
|---|
| 234 | + * TODO: Ideally we really want a GPU reset here to make sure errors |
|---|
| 222 | 235 | * aren't propagated. Since I cannot find a stable way to reset the GPU |
|---|
| 223 | 236 | * at this point it is left as a TODO. |
|---|
| 224 | 237 | */ |
|---|
| 225 | | - memcpy(*remap_info + (offset/4), buf, count); |
|---|
| 226 | 238 | |
|---|
| 227 | | - /* NB: We defer the remapping until we switch to the context */ |
|---|
| 228 | | - list_for_each_entry(ctx, &dev_priv->contexts.list, link) |
|---|
| 229 | | - ctx->remap_slice |= (1<<slice); |
|---|
| 230 | | - |
|---|
| 231 | | - ret = count; |
|---|
| 232 | | - |
|---|
| 233 | | -out: |
|---|
| 234 | | - mutex_unlock(&dev->struct_mutex); |
|---|
| 235 | | - |
|---|
| 236 | | - return ret; |
|---|
| 239 | + return count; |
|---|
| 237 | 240 | } |
|---|
| 238 | 241 | |
|---|
| 239 | 242 | static const struct bin_attribute dpf_attrs = { |
|---|
| .. | .. |
|---|
| 257 | 260 | static ssize_t gt_act_freq_mhz_show(struct device *kdev, |
|---|
| 258 | 261 | struct device_attribute *attr, char *buf) |
|---|
| 259 | 262 | { |
|---|
| 260 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 261 | | - int ret; |
|---|
| 263 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 264 | + struct intel_rps *rps = &i915->gt.rps; |
|---|
| 262 | 265 | |
|---|
| 263 | | - intel_runtime_pm_get(dev_priv); |
|---|
| 264 | | - |
|---|
| 265 | | - mutex_lock(&dev_priv->pcu_lock); |
|---|
| 266 | | - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
|---|
| 267 | | - u32 freq; |
|---|
| 268 | | - freq = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
|---|
| 269 | | - ret = intel_gpu_freq(dev_priv, (freq >> 8) & 0xff); |
|---|
| 270 | | - } else { |
|---|
| 271 | | - ret = intel_gpu_freq(dev_priv, |
|---|
| 272 | | - intel_get_cagf(dev_priv, |
|---|
| 273 | | - I915_READ(GEN6_RPSTAT1))); |
|---|
| 274 | | - } |
|---|
| 275 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 276 | | - |
|---|
| 277 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 278 | | - |
|---|
| 279 | | - return snprintf(buf, PAGE_SIZE, "%d\n", ret); |
|---|
| 266 | + return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 267 | + intel_rps_read_actual_frequency(rps)); |
|---|
| 280 | 268 | } |
|---|
| 281 | 269 | |
|---|
| 282 | 270 | static ssize_t gt_cur_freq_mhz_show(struct device *kdev, |
|---|
| 283 | 271 | struct device_attribute *attr, char *buf) |
|---|
| 284 | 272 | { |
|---|
| 285 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 273 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 274 | + struct intel_rps *rps = &i915->gt.rps; |
|---|
| 286 | 275 | |
|---|
| 287 | 276 | return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 288 | | - intel_gpu_freq(dev_priv, |
|---|
| 289 | | - dev_priv->gt_pm.rps.cur_freq)); |
|---|
| 277 | + intel_gpu_freq(rps, rps->cur_freq)); |
|---|
| 290 | 278 | } |
|---|
| 291 | 279 | |
|---|
| 292 | 280 | static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
|---|
| 293 | 281 | { |
|---|
| 294 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 282 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 283 | + struct intel_rps *rps = &i915->gt.rps; |
|---|
| 295 | 284 | |
|---|
| 296 | 285 | return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 297 | | - intel_gpu_freq(dev_priv, |
|---|
| 298 | | - dev_priv->gt_pm.rps.boost_freq)); |
|---|
| 286 | + intel_gpu_freq(rps, rps->boost_freq)); |
|---|
| 299 | 287 | } |
|---|
| 300 | 288 | |
|---|
| 301 | 289 | static ssize_t gt_boost_freq_mhz_store(struct device *kdev, |
|---|
| .. | .. |
|---|
| 303 | 291 | const char *buf, size_t count) |
|---|
| 304 | 292 | { |
|---|
| 305 | 293 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 306 | | - struct intel_rps *rps = &dev_priv->gt_pm.rps; |
|---|
| 294 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 307 | 295 | bool boost = false; |
|---|
| 308 | 296 | ssize_t ret; |
|---|
| 309 | 297 | u32 val; |
|---|
| .. | .. |
|---|
| 313 | 301 | return ret; |
|---|
| 314 | 302 | |
|---|
| 315 | 303 | /* Validate against (static) hardware limits */ |
|---|
| 316 | | - val = intel_freq_opcode(dev_priv, val); |
|---|
| 304 | + val = intel_freq_opcode(rps, val); |
|---|
| 317 | 305 | if (val < rps->min_freq || val > rps->max_freq) |
|---|
| 318 | 306 | return -EINVAL; |
|---|
| 319 | 307 | |
|---|
| 320 | | - mutex_lock(&dev_priv->pcu_lock); |
|---|
| 308 | + mutex_lock(&rps->lock); |
|---|
| 321 | 309 | if (val != rps->boost_freq) { |
|---|
| 322 | 310 | rps->boost_freq = val; |
|---|
| 323 | 311 | boost = atomic_read(&rps->num_waiters); |
|---|
| 324 | 312 | } |
|---|
| 325 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 313 | + mutex_unlock(&rps->lock); |
|---|
| 326 | 314 | if (boost) |
|---|
| 327 | 315 | schedule_work(&rps->work); |
|---|
| 328 | 316 | |
|---|
| .. | .. |
|---|
| 333 | 321 | struct device_attribute *attr, char *buf) |
|---|
| 334 | 322 | { |
|---|
| 335 | 323 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 324 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 336 | 325 | |
|---|
| 337 | 326 | return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 338 | | - intel_gpu_freq(dev_priv, |
|---|
| 339 | | - dev_priv->gt_pm.rps.efficient_freq)); |
|---|
| 327 | + intel_gpu_freq(rps, rps->efficient_freq)); |
|---|
| 340 | 328 | } |
|---|
| 341 | 329 | |
|---|
| 342 | 330 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
|---|
| 343 | 331 | { |
|---|
| 344 | 332 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 333 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 345 | 334 | |
|---|
| 346 | 335 | return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 347 | | - intel_gpu_freq(dev_priv, |
|---|
| 348 | | - dev_priv->gt_pm.rps.max_freq_softlimit)); |
|---|
| 336 | + intel_gpu_freq(rps, rps->max_freq_softlimit)); |
|---|
| 349 | 337 | } |
|---|
| 350 | 338 | |
|---|
| 351 | 339 | static ssize_t gt_max_freq_mhz_store(struct device *kdev, |
|---|
| .. | .. |
|---|
| 353 | 341 | const char *buf, size_t count) |
|---|
| 354 | 342 | { |
|---|
| 355 | 343 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 356 | | - struct intel_rps *rps = &dev_priv->gt_pm.rps; |
|---|
| 357 | | - u32 val; |
|---|
| 344 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 358 | 345 | ssize_t ret; |
|---|
| 346 | + u32 val; |
|---|
| 359 | 347 | |
|---|
| 360 | 348 | ret = kstrtou32(buf, 0, &val); |
|---|
| 361 | 349 | if (ret) |
|---|
| 362 | 350 | return ret; |
|---|
| 363 | 351 | |
|---|
| 364 | | - intel_runtime_pm_get(dev_priv); |
|---|
| 352 | + mutex_lock(&rps->lock); |
|---|
| 365 | 353 | |
|---|
| 366 | | - mutex_lock(&dev_priv->pcu_lock); |
|---|
| 367 | | - |
|---|
| 368 | | - val = intel_freq_opcode(dev_priv, val); |
|---|
| 369 | | - |
|---|
| 354 | + val = intel_freq_opcode(rps, val); |
|---|
| 370 | 355 | if (val < rps->min_freq || |
|---|
| 371 | 356 | val > rps->max_freq || |
|---|
| 372 | 357 | val < rps->min_freq_softlimit) { |
|---|
| 373 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 374 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 375 | | - return -EINVAL; |
|---|
| 358 | + ret = -EINVAL; |
|---|
| 359 | + goto unlock; |
|---|
| 376 | 360 | } |
|---|
| 377 | 361 | |
|---|
| 378 | 362 | if (val > rps->rp0_freq) |
|---|
| 379 | 363 | DRM_DEBUG("User requested overclocking to %d\n", |
|---|
| 380 | | - intel_gpu_freq(dev_priv, val)); |
|---|
| 364 | + intel_gpu_freq(rps, val)); |
|---|
| 381 | 365 | |
|---|
| 382 | 366 | rps->max_freq_softlimit = val; |
|---|
| 383 | 367 | |
|---|
| .. | .. |
|---|
| 385 | 369 | rps->min_freq_softlimit, |
|---|
| 386 | 370 | rps->max_freq_softlimit); |
|---|
| 387 | 371 | |
|---|
| 388 | | - /* We still need *_set_rps to process the new max_delay and |
|---|
| 372 | + /* |
|---|
| 373 | + * We still need *_set_rps to process the new max_delay and |
|---|
| 389 | 374 | * update the interrupt limits and PMINTRMSK even though |
|---|
| 390 | | - * frequency request may be unchanged. */ |
|---|
| 391 | | - ret = intel_set_rps(dev_priv, val); |
|---|
| 375 | + * frequency request may be unchanged. |
|---|
| 376 | + */ |
|---|
| 377 | + intel_rps_set(rps, val); |
|---|
| 392 | 378 | |
|---|
| 393 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 394 | | - |
|---|
| 395 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 379 | +unlock: |
|---|
| 380 | + mutex_unlock(&rps->lock); |
|---|
| 396 | 381 | |
|---|
| 397 | 382 | return ret ?: count; |
|---|
| 398 | 383 | } |
|---|
| .. | .. |
|---|
| 400 | 385 | static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
|---|
| 401 | 386 | { |
|---|
| 402 | 387 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 388 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 403 | 389 | |
|---|
| 404 | 390 | return snprintf(buf, PAGE_SIZE, "%d\n", |
|---|
| 405 | | - intel_gpu_freq(dev_priv, |
|---|
| 406 | | - dev_priv->gt_pm.rps.min_freq_softlimit)); |
|---|
| 391 | + intel_gpu_freq(rps, rps->min_freq_softlimit)); |
|---|
| 407 | 392 | } |
|---|
| 408 | 393 | |
|---|
| 409 | 394 | static ssize_t gt_min_freq_mhz_store(struct device *kdev, |
|---|
| .. | .. |
|---|
| 411 | 396 | const char *buf, size_t count) |
|---|
| 412 | 397 | { |
|---|
| 413 | 398 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 414 | | - struct intel_rps *rps = &dev_priv->gt_pm.rps; |
|---|
| 415 | | - u32 val; |
|---|
| 399 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 416 | 400 | ssize_t ret; |
|---|
| 401 | + u32 val; |
|---|
| 417 | 402 | |
|---|
| 418 | 403 | ret = kstrtou32(buf, 0, &val); |
|---|
| 419 | 404 | if (ret) |
|---|
| 420 | 405 | return ret; |
|---|
| 421 | 406 | |
|---|
| 422 | | - intel_runtime_pm_get(dev_priv); |
|---|
| 407 | + mutex_lock(&rps->lock); |
|---|
| 423 | 408 | |
|---|
| 424 | | - mutex_lock(&dev_priv->pcu_lock); |
|---|
| 425 | | - |
|---|
| 426 | | - val = intel_freq_opcode(dev_priv, val); |
|---|
| 427 | | - |
|---|
| 409 | + val = intel_freq_opcode(rps, val); |
|---|
| 428 | 410 | if (val < rps->min_freq || |
|---|
| 429 | 411 | val > rps->max_freq || |
|---|
| 430 | 412 | val > rps->max_freq_softlimit) { |
|---|
| 431 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 432 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 433 | | - return -EINVAL; |
|---|
| 413 | + ret = -EINVAL; |
|---|
| 414 | + goto unlock; |
|---|
| 434 | 415 | } |
|---|
| 435 | 416 | |
|---|
| 436 | 417 | rps->min_freq_softlimit = val; |
|---|
| .. | .. |
|---|
| 439 | 420 | rps->min_freq_softlimit, |
|---|
| 440 | 421 | rps->max_freq_softlimit); |
|---|
| 441 | 422 | |
|---|
| 442 | | - /* We still need *_set_rps to process the new min_delay and |
|---|
| 423 | + /* |
|---|
| 424 | + * We still need *_set_rps to process the new min_delay and |
|---|
| 443 | 425 | * update the interrupt limits and PMINTRMSK even though |
|---|
| 444 | | - * frequency request may be unchanged. */ |
|---|
| 445 | | - ret = intel_set_rps(dev_priv, val); |
|---|
| 426 | + * frequency request may be unchanged. |
|---|
| 427 | + */ |
|---|
| 428 | + intel_rps_set(rps, val); |
|---|
| 446 | 429 | |
|---|
| 447 | | - mutex_unlock(&dev_priv->pcu_lock); |
|---|
| 448 | | - |
|---|
| 449 | | - intel_runtime_pm_put(dev_priv); |
|---|
| 430 | +unlock: |
|---|
| 431 | + mutex_unlock(&rps->lock); |
|---|
| 450 | 432 | |
|---|
| 451 | 433 | return ret ?: count; |
|---|
| 452 | 434 | } |
|---|
| .. | .. |
|---|
| 468 | 450 | static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
|---|
| 469 | 451 | { |
|---|
| 470 | 452 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 471 | | - struct intel_rps *rps = &dev_priv->gt_pm.rps; |
|---|
| 453 | + struct intel_rps *rps = &dev_priv->gt.rps; |
|---|
| 472 | 454 | u32 val; |
|---|
| 473 | 455 | |
|---|
| 474 | 456 | if (attr == &dev_attr_gt_RP0_freq_mhz) |
|---|
| 475 | | - val = intel_gpu_freq(dev_priv, rps->rp0_freq); |
|---|
| 457 | + val = intel_gpu_freq(rps, rps->rp0_freq); |
|---|
| 476 | 458 | else if (attr == &dev_attr_gt_RP1_freq_mhz) |
|---|
| 477 | | - val = intel_gpu_freq(dev_priv, rps->rp1_freq); |
|---|
| 459 | + val = intel_gpu_freq(rps, rps->rp1_freq); |
|---|
| 478 | 460 | else if (attr == &dev_attr_gt_RPn_freq_mhz) |
|---|
| 479 | | - val = intel_gpu_freq(dev_priv, rps->min_freq); |
|---|
| 461 | + val = intel_gpu_freq(rps, rps->min_freq); |
|---|
| 480 | 462 | else |
|---|
| 481 | 463 | BUG(); |
|---|
| 482 | 464 | |
|---|
| 483 | 465 | return snprintf(buf, PAGE_SIZE, "%d\n", val); |
|---|
| 484 | 466 | } |
|---|
| 485 | 467 | |
|---|
| 486 | | -static const struct attribute *gen6_attrs[] = { |
|---|
| 468 | +static const struct attribute * const gen6_attrs[] = { |
|---|
| 487 | 469 | &dev_attr_gt_act_freq_mhz.attr, |
|---|
| 488 | 470 | &dev_attr_gt_cur_freq_mhz.attr, |
|---|
| 489 | 471 | &dev_attr_gt_boost_freq_mhz.attr, |
|---|
| .. | .. |
|---|
| 495 | 477 | NULL, |
|---|
| 496 | 478 | }; |
|---|
| 497 | 479 | |
|---|
| 498 | | -static const struct attribute *vlv_attrs[] = { |
|---|
| 480 | +static const struct attribute * const vlv_attrs[] = { |
|---|
| 499 | 481 | &dev_attr_gt_act_freq_mhz.attr, |
|---|
| 500 | 482 | &dev_attr_gt_cur_freq_mhz.attr, |
|---|
| 501 | 483 | &dev_attr_gt_boost_freq_mhz.attr, |
|---|
| .. | .. |
|---|
| 516 | 498 | { |
|---|
| 517 | 499 | |
|---|
| 518 | 500 | struct device *kdev = kobj_to_dev(kobj); |
|---|
| 519 | | - struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 520 | | - struct drm_i915_error_state_buf error_str; |
|---|
| 521 | | - struct i915_gpu_state *gpu; |
|---|
| 522 | | - ssize_t ret; |
|---|
| 501 | + struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); |
|---|
| 502 | + struct i915_gpu_coredump *gpu; |
|---|
| 503 | + ssize_t ret = 0; |
|---|
| 523 | 504 | |
|---|
| 524 | | - ret = i915_error_state_buf_init(&error_str, dev_priv, count, off); |
|---|
| 525 | | - if (ret) |
|---|
| 526 | | - return ret; |
|---|
| 505 | + /* |
|---|
| 506 | + * FIXME: Concurrent clients triggering resets and reading + clearing |
|---|
| 507 | + * dumps can cause inconsistent sysfs reads when a user calls in with a |
|---|
| 508 | + * non-zero offset to complete a prior partial read but the |
|---|
| 509 | + * gpu_coredump has been cleared or replaced. |
|---|
| 510 | + */ |
|---|
| 527 | 511 | |
|---|
| 528 | | - gpu = i915_first_error_state(dev_priv); |
|---|
| 529 | | - ret = i915_error_state_to_str(&error_str, gpu); |
|---|
| 530 | | - if (ret) |
|---|
| 531 | | - goto out; |
|---|
| 512 | + gpu = i915_first_error_state(i915); |
|---|
| 513 | + if (IS_ERR(gpu)) { |
|---|
| 514 | + ret = PTR_ERR(gpu); |
|---|
| 515 | + } else if (gpu) { |
|---|
| 516 | + ret = i915_gpu_coredump_copy_to_buffer(gpu, buf, off, count); |
|---|
| 517 | + i915_gpu_coredump_put(gpu); |
|---|
| 518 | + } else { |
|---|
| 519 | + const char *str = "No error state collected\n"; |
|---|
| 520 | + size_t len = strlen(str); |
|---|
| 532 | 521 | |
|---|
| 533 | | - ret = count < error_str.bytes ? count : error_str.bytes; |
|---|
| 534 | | - memcpy(buf, error_str.buf, ret); |
|---|
| 535 | | - |
|---|
| 536 | | -out: |
|---|
| 537 | | - i915_gpu_state_put(gpu); |
|---|
| 538 | | - i915_error_state_buf_release(&error_str); |
|---|
| 522 | + if (off < len) { |
|---|
| 523 | + ret = min_t(size_t, count, len - off); |
|---|
| 524 | + memcpy(buf, str + off, ret); |
|---|
| 525 | + } |
|---|
| 526 | + } |
|---|
| 539 | 527 | |
|---|
| 540 | 528 | return ret; |
|---|
| 541 | 529 | } |
|---|
| .. | .. |
|---|
| 547 | 535 | struct device *kdev = kobj_to_dev(kobj); |
|---|
| 548 | 536 | struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); |
|---|
| 549 | 537 | |
|---|
| 550 | | - DRM_DEBUG_DRIVER("Resetting error state\n"); |
|---|
| 538 | + drm_dbg(&dev_priv->drm, "Resetting error state\n"); |
|---|
| 551 | 539 | i915_reset_error_state(dev_priv); |
|---|
| 552 | 540 | |
|---|
| 553 | 541 | return count; |
|---|
| .. | .. |
|---|
| 586 | 574 | ret = sysfs_merge_group(&kdev->kobj, |
|---|
| 587 | 575 | &rc6_attr_group); |
|---|
| 588 | 576 | if (ret) |
|---|
| 589 | | - DRM_ERROR("RC6 residency sysfs setup failed\n"); |
|---|
| 577 | + drm_err(&dev_priv->drm, |
|---|
| 578 | + "RC6 residency sysfs setup failed\n"); |
|---|
| 590 | 579 | } |
|---|
| 591 | 580 | if (HAS_RC6p(dev_priv)) { |
|---|
| 592 | 581 | ret = sysfs_merge_group(&kdev->kobj, |
|---|
| 593 | 582 | &rc6p_attr_group); |
|---|
| 594 | 583 | if (ret) |
|---|
| 595 | | - DRM_ERROR("RC6p residency sysfs setup failed\n"); |
|---|
| 584 | + drm_err(&dev_priv->drm, |
|---|
| 585 | + "RC6p residency sysfs setup failed\n"); |
|---|
| 596 | 586 | } |
|---|
| 597 | 587 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
|---|
| 598 | 588 | ret = sysfs_merge_group(&kdev->kobj, |
|---|
| 599 | 589 | &media_rc6_attr_group); |
|---|
| 600 | 590 | if (ret) |
|---|
| 601 | | - DRM_ERROR("Media RC6 residency sysfs setup failed\n"); |
|---|
| 591 | + drm_err(&dev_priv->drm, |
|---|
| 592 | + "Media RC6 residency sysfs setup failed\n"); |
|---|
| 602 | 593 | } |
|---|
| 603 | 594 | #endif |
|---|
| 604 | 595 | if (HAS_L3_DPF(dev_priv)) { |
|---|
| 605 | 596 | ret = device_create_bin_file(kdev, &dpf_attrs); |
|---|
| 606 | 597 | if (ret) |
|---|
| 607 | | - DRM_ERROR("l3 parity sysfs setup failed\n"); |
|---|
| 598 | + drm_err(&dev_priv->drm, |
|---|
| 599 | + "l3 parity sysfs setup failed\n"); |
|---|
| 608 | 600 | |
|---|
| 609 | 601 | if (NUM_L3_SLICES(dev_priv) > 1) { |
|---|
| 610 | 602 | ret = device_create_bin_file(kdev, |
|---|
| 611 | 603 | &dpf_attrs_1); |
|---|
| 612 | 604 | if (ret) |
|---|
| 613 | | - DRM_ERROR("l3 parity slice 1 setup failed\n"); |
|---|
| 605 | + drm_err(&dev_priv->drm, |
|---|
| 606 | + "l3 parity slice 1 setup failed\n"); |
|---|
| 614 | 607 | } |
|---|
| 615 | 608 | } |
|---|
| 616 | 609 | |
|---|
| .. | .. |
|---|
| 620 | 613 | else if (INTEL_GEN(dev_priv) >= 6) |
|---|
| 621 | 614 | ret = sysfs_create_files(&kdev->kobj, gen6_attrs); |
|---|
| 622 | 615 | if (ret) |
|---|
| 623 | | - DRM_ERROR("RPS sysfs setup failed\n"); |
|---|
| 616 | + drm_err(&dev_priv->drm, "RPS sysfs setup failed\n"); |
|---|
| 624 | 617 | |
|---|
| 625 | 618 | i915_setup_error_capture(kdev); |
|---|
| 619 | + |
|---|
| 620 | + intel_engines_add_sysfs(dev_priv); |
|---|
| 626 | 621 | } |
|---|
| 627 | 622 | |
|---|
| 628 | 623 | void i915_teardown_sysfs(struct drm_i915_private *dev_priv) |
|---|