diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_debugfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index e2662497d50f..a8ab6263e0d7 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1338,6 +1338,155 @@ static const struct file_operations i915_wedged_fops = { | |||
1338 | .llseek = default_llseek, | 1338 | .llseek = default_llseek, |
1339 | }; | 1339 | }; |
1340 | 1340 | ||
1341 | static int | ||
1342 | i915_max_freq_open(struct inode *inode, | ||
1343 | struct file *filp) | ||
1344 | { | ||
1345 | filp->private_data = inode->i_private; | ||
1346 | return 0; | ||
1347 | } | ||
1348 | |||
1349 | static ssize_t | ||
1350 | i915_max_freq_read(struct file *filp, | ||
1351 | char __user *ubuf, | ||
1352 | size_t max, | ||
1353 | loff_t *ppos) | ||
1354 | { | ||
1355 | struct drm_device *dev = filp->private_data; | ||
1356 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
1357 | char buf[80]; | ||
1358 | int len; | ||
1359 | |||
1360 | len = snprintf(buf, sizeof (buf), | ||
1361 | "max freq: %d\n", dev_priv->max_delay * 50); | ||
1362 | |||
1363 | if (len > sizeof (buf)) | ||
1364 | len = sizeof (buf); | ||
1365 | |||
1366 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); | ||
1367 | } | ||
1368 | |||
1369 | static ssize_t | ||
1370 | i915_max_freq_write(struct file *filp, | ||
1371 | const char __user *ubuf, | ||
1372 | size_t cnt, | ||
1373 | loff_t *ppos) | ||
1374 | { | ||
1375 | struct drm_device *dev = filp->private_data; | ||
1376 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1377 | char buf[20]; | ||
1378 | int val = 1; | ||
1379 | |||
1380 | if (cnt > 0) { | ||
1381 | if (cnt > sizeof (buf) - 1) | ||
1382 | return -EINVAL; | ||
1383 | |||
1384 | if (copy_from_user(buf, ubuf, cnt)) | ||
1385 | return -EFAULT; | ||
1386 | buf[cnt] = 0; | ||
1387 | |||
1388 | val = simple_strtoul(buf, NULL, 0); | ||
1389 | } | ||
1390 | |||
1391 | DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val); | ||
1392 | |||
1393 | /* | ||
1394 | * Turbo will still be enabled, but won't go above the set value. | ||
1395 | */ | ||
1396 | dev_priv->max_delay = val / 50; | ||
1397 | |||
1398 | gen6_set_rps(dev, val / 50); | ||
1399 | |||
1400 | return cnt; | ||
1401 | } | ||
1402 | |||
1403 | static const struct file_operations i915_max_freq_fops = { | ||
1404 | .owner = THIS_MODULE, | ||
1405 | .open = i915_max_freq_open, | ||
1406 | .read = i915_max_freq_read, | ||
1407 | .write = i915_max_freq_write, | ||
1408 | .llseek = default_llseek, | ||
1409 | }; | ||
1410 | |||
1411 | static int | ||
1412 | i915_cache_sharing_open(struct inode *inode, | ||
1413 | struct file *filp) | ||
1414 | { | ||
1415 | filp->private_data = inode->i_private; | ||
1416 | return 0; | ||
1417 | } | ||
1418 | |||
1419 | static ssize_t | ||
1420 | i915_cache_sharing_read(struct file *filp, | ||
1421 | char __user *ubuf, | ||
1422 | size_t max, | ||
1423 | loff_t *ppos) | ||
1424 | { | ||
1425 | struct drm_device *dev = filp->private_data; | ||
1426 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
1427 | char buf[80]; | ||
1428 | u32 snpcr; | ||
1429 | int len; | ||
1430 | |||
1431 | mutex_lock(&dev_priv->dev->struct_mutex); | ||
1432 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); | ||
1433 | mutex_unlock(&dev_priv->dev->struct_mutex); | ||
1434 | |||
1435 | len = snprintf(buf, sizeof (buf), | ||
1436 | "%d\n", (snpcr & GEN6_MBC_SNPCR_MASK) >> | ||
1437 | GEN6_MBC_SNPCR_SHIFT); | ||
1438 | |||
1439 | if (len > sizeof (buf)) | ||
1440 | len = sizeof (buf); | ||
1441 | |||
1442 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); | ||
1443 | } | ||
1444 | |||
1445 | static ssize_t | ||
1446 | i915_cache_sharing_write(struct file *filp, | ||
1447 | const char __user *ubuf, | ||
1448 | size_t cnt, | ||
1449 | loff_t *ppos) | ||
1450 | { | ||
1451 | struct drm_device *dev = filp->private_data; | ||
1452 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1453 | char buf[20]; | ||
1454 | u32 snpcr; | ||
1455 | int val = 1; | ||
1456 | |||
1457 | if (cnt > 0) { | ||
1458 | if (cnt > sizeof (buf) - 1) | ||
1459 | return -EINVAL; | ||
1460 | |||
1461 | if (copy_from_user(buf, ubuf, cnt)) | ||
1462 | return -EFAULT; | ||
1463 | buf[cnt] = 0; | ||
1464 | |||
1465 | val = simple_strtoul(buf, NULL, 0); | ||
1466 | } | ||
1467 | |||
1468 | if (val < 0 || val > 3) | ||
1469 | return -EINVAL; | ||
1470 | |||
1471 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val); | ||
1472 | |||
1473 | /* Update the cache sharing policy here as well */ | ||
1474 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); | ||
1475 | snpcr &= ~GEN6_MBC_SNPCR_MASK; | ||
1476 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); | ||
1477 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); | ||
1478 | |||
1479 | return cnt; | ||
1480 | } | ||
1481 | |||
1482 | static const struct file_operations i915_cache_sharing_fops = { | ||
1483 | .owner = THIS_MODULE, | ||
1484 | .open = i915_cache_sharing_open, | ||
1485 | .read = i915_cache_sharing_read, | ||
1486 | .write = i915_cache_sharing_write, | ||
1487 | .llseek = default_llseek, | ||
1488 | }; | ||
1489 | |||
1341 | /* As the drm_debugfs_init() routines are called before dev->dev_private is | 1490 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
1342 | * allocated we need to hook into the minor for release. */ | 1491 | * allocated we need to hook into the minor for release. */ |
1343 | static int | 1492 | static int |
@@ -1437,6 +1586,36 @@ static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) | |||
1437 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); | 1586 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
1438 | } | 1587 | } |
1439 | 1588 | ||
1589 | static int i915_max_freq_create(struct dentry *root, struct drm_minor *minor) | ||
1590 | { | ||
1591 | struct drm_device *dev = minor->dev; | ||
1592 | struct dentry *ent; | ||
1593 | |||
1594 | ent = debugfs_create_file("i915_max_freq", | ||
1595 | S_IRUGO | S_IWUSR, | ||
1596 | root, dev, | ||
1597 | &i915_max_freq_fops); | ||
1598 | if (IS_ERR(ent)) | ||
1599 | return PTR_ERR(ent); | ||
1600 | |||
1601 | return drm_add_fake_info_node(minor, ent, &i915_max_freq_fops); | ||
1602 | } | ||
1603 | |||
1604 | static int i915_cache_sharing_create(struct dentry *root, struct drm_minor *minor) | ||
1605 | { | ||
1606 | struct drm_device *dev = minor->dev; | ||
1607 | struct dentry *ent; | ||
1608 | |||
1609 | ent = debugfs_create_file("i915_cache_sharing", | ||
1610 | S_IRUGO | S_IWUSR, | ||
1611 | root, dev, | ||
1612 | &i915_cache_sharing_fops); | ||
1613 | if (IS_ERR(ent)) | ||
1614 | return PTR_ERR(ent); | ||
1615 | |||
1616 | return drm_add_fake_info_node(minor, ent, &i915_cache_sharing_fops); | ||
1617 | } | ||
1618 | |||
1440 | static struct drm_info_list i915_debugfs_list[] = { | 1619 | static struct drm_info_list i915_debugfs_list[] = { |
1441 | {"i915_capabilities", i915_capabilities, 0}, | 1620 | {"i915_capabilities", i915_capabilities, 0}, |
1442 | {"i915_gem_objects", i915_gem_object_info, 0}, | 1621 | {"i915_gem_objects", i915_gem_object_info, 0}, |
@@ -1490,6 +1669,12 @@ int i915_debugfs_init(struct drm_minor *minor) | |||
1490 | ret = i915_forcewake_create(minor->debugfs_root, minor); | 1669 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
1491 | if (ret) | 1670 | if (ret) |
1492 | return ret; | 1671 | return ret; |
1672 | ret = i915_max_freq_create(minor->debugfs_root, minor); | ||
1673 | if (ret) | ||
1674 | return ret; | ||
1675 | ret = i915_cache_sharing_create(minor->debugfs_root, minor); | ||
1676 | if (ret) | ||
1677 | return ret; | ||
1493 | 1678 | ||
1494 | return drm_debugfs_create_files(i915_debugfs_list, | 1679 | return drm_debugfs_create_files(i915_debugfs_list, |
1495 | I915_DEBUGFS_ENTRIES, | 1680 | I915_DEBUGFS_ENTRIES, |
@@ -1504,6 +1689,10 @@ void i915_debugfs_cleanup(struct drm_minor *minor) | |||
1504 | 1, minor); | 1689 | 1, minor); |
1505 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, | 1690 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, |
1506 | 1, minor); | 1691 | 1, minor); |
1692 | drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops, | ||
1693 | 1, minor); | ||
1694 | drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops, | ||
1695 | 1, minor); | ||
1507 | } | 1696 | } |
1508 | 1697 | ||
1509 | #endif /* CONFIG_DEBUG_FS */ | 1698 | #endif /* CONFIG_DEBUG_FS */ |