diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_debugfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 5bf7bf57c641..a8ab6263e0d7 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1408,6 +1408,85 @@ static const struct file_operations i915_max_freq_fops = { | |||
1408 | .llseek = default_llseek, | 1408 | .llseek = default_llseek, |
1409 | }; | 1409 | }; |
1410 | 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 | |||
1411 | /* 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 |
1412 | * allocated we need to hook into the minor for release. */ | 1491 | * allocated we need to hook into the minor for release. */ |
1413 | static int | 1492 | static int |
@@ -1522,6 +1601,21 @@ static int i915_max_freq_create(struct dentry *root, struct drm_minor *minor) | |||
1522 | return drm_add_fake_info_node(minor, ent, &i915_max_freq_fops); | 1601 | return drm_add_fake_info_node(minor, ent, &i915_max_freq_fops); |
1523 | } | 1602 | } |
1524 | 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 | |||
1525 | static struct drm_info_list i915_debugfs_list[] = { | 1619 | static struct drm_info_list i915_debugfs_list[] = { |
1526 | {"i915_capabilities", i915_capabilities, 0}, | 1620 | {"i915_capabilities", i915_capabilities, 0}, |
1527 | {"i915_gem_objects", i915_gem_object_info, 0}, | 1621 | {"i915_gem_objects", i915_gem_object_info, 0}, |
@@ -1578,6 +1672,9 @@ int i915_debugfs_init(struct drm_minor *minor) | |||
1578 | ret = i915_max_freq_create(minor->debugfs_root, minor); | 1672 | ret = i915_max_freq_create(minor->debugfs_root, minor); |
1579 | if (ret) | 1673 | if (ret) |
1580 | return ret; | 1674 | return ret; |
1675 | ret = i915_cache_sharing_create(minor->debugfs_root, minor); | ||
1676 | if (ret) | ||
1677 | return ret; | ||
1581 | 1678 | ||
1582 | return drm_debugfs_create_files(i915_debugfs_list, | 1679 | return drm_debugfs_create_files(i915_debugfs_list, |
1583 | I915_DEBUGFS_ENTRIES, | 1680 | I915_DEBUGFS_ENTRIES, |
@@ -1594,6 +1691,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) | |||
1594 | 1, minor); | 1691 | 1, minor); |
1595 | drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops, | 1692 | drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops, |
1596 | 1, minor); | 1693 | 1, minor); |
1694 | drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops, | ||
1695 | 1, minor); | ||
1597 | } | 1696 | } |
1598 | 1697 | ||
1599 | #endif /* CONFIG_DEBUG_FS */ | 1698 | #endif /* CONFIG_DEBUG_FS */ |