aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2011-07-27 14:53:01 -0400
committerKeith Packard <keithp@keithp.com>2011-07-29 18:08:49 -0400
commit358733e9047cafcc185ca19b8c369c659ac0c4cf (patch)
treea4d3210cad82a3cc39d1a5b5ba8f0c6c6db0aa46 /drivers/gpu
parentb066254fee2b0b4d1323295f8ae34c9442222165 (diff)
drm/i915: add GPU max frequency control file
Mainly for use in debugging and benchmarking, this file allows the user to control the max frequency used by the GPU. Frequency may still vary based on workload (if the frequency is set to higher than the minimum) but won't go over the newly set value. Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 0a893f7400fa..782b781df9e0 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1300,6 +1300,76 @@ static const struct file_operations i915_wedged_fops = {
1300 .llseek = default_llseek, 1300 .llseek = default_llseek,
1301}; 1301};
1302 1302
1303static int
1304i915_max_freq_open(struct inode *inode,
1305 struct file *filp)
1306{
1307 filp->private_data = inode->i_private;
1308 return 0;
1309}
1310
1311static ssize_t
1312i915_max_freq_read(struct file *filp,
1313 char __user *ubuf,
1314 size_t max,
1315 loff_t *ppos)
1316{
1317 struct drm_device *dev = filp->private_data;
1318 drm_i915_private_t *dev_priv = dev->dev_private;
1319 char buf[80];
1320 int len;
1321
1322 len = snprintf(buf, sizeof (buf),
1323 "max freq: %d\n", dev_priv->max_delay * 50);
1324
1325 if (len > sizeof (buf))
1326 len = sizeof (buf);
1327
1328 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
1329}
1330
1331static ssize_t
1332i915_max_freq_write(struct file *filp,
1333 const char __user *ubuf,
1334 size_t cnt,
1335 loff_t *ppos)
1336{
1337 struct drm_device *dev = filp->private_data;
1338 struct drm_i915_private *dev_priv = dev->dev_private;
1339 char buf[20];
1340 int val = 1;
1341
1342 if (cnt > 0) {
1343 if (cnt > sizeof (buf) - 1)
1344 return -EINVAL;
1345
1346 if (copy_from_user(buf, ubuf, cnt))
1347 return -EFAULT;
1348 buf[cnt] = 0;
1349
1350 val = simple_strtoul(buf, NULL, 0);
1351 }
1352
1353 DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val);
1354
1355 /*
1356 * Turbo will still be enabled, but won't go above the set value.
1357 */
1358 dev_priv->max_delay = val / 50;
1359
1360 gen6_set_rps(dev, val / 50);
1361
1362 return cnt;
1363}
1364
1365static const struct file_operations i915_max_freq_fops = {
1366 .owner = THIS_MODULE,
1367 .open = i915_max_freq_open,
1368 .read = i915_max_freq_read,
1369 .write = i915_max_freq_write,
1370 .llseek = default_llseek,
1371};
1372
1303/* As the drm_debugfs_init() routines are called before dev->dev_private is 1373/* As the drm_debugfs_init() routines are called before dev->dev_private is
1304 * allocated we need to hook into the minor for release. */ 1374 * allocated we need to hook into the minor for release. */
1305static int 1375static int
@@ -1399,6 +1469,21 @@ static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
1399 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); 1469 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
1400} 1470}
1401 1471
1472static int i915_max_freq_create(struct dentry *root, struct drm_minor *minor)
1473{
1474 struct drm_device *dev = minor->dev;
1475 struct dentry *ent;
1476
1477 ent = debugfs_create_file("i915_max_freq",
1478 S_IRUGO | S_IWUSR,
1479 root, dev,
1480 &i915_max_freq_fops);
1481 if (IS_ERR(ent))
1482 return PTR_ERR(ent);
1483
1484 return drm_add_fake_info_node(minor, ent, &i915_max_freq_fops);
1485}
1486
1402static struct drm_info_list i915_debugfs_list[] = { 1487static struct drm_info_list i915_debugfs_list[] = {
1403 {"i915_capabilities", i915_capabilities, 0}, 1488 {"i915_capabilities", i915_capabilities, 0},
1404 {"i915_gem_objects", i915_gem_object_info, 0}, 1489 {"i915_gem_objects", i915_gem_object_info, 0},
@@ -1451,6 +1536,9 @@ int i915_debugfs_init(struct drm_minor *minor)
1451 ret = i915_forcewake_create(minor->debugfs_root, minor); 1536 ret = i915_forcewake_create(minor->debugfs_root, minor);
1452 if (ret) 1537 if (ret)
1453 return ret; 1538 return ret;
1539 ret = i915_max_freq_create(minor->debugfs_root, minor);
1540 if (ret)
1541 return ret;
1454 1542
1455 return drm_debugfs_create_files(i915_debugfs_list, 1543 return drm_debugfs_create_files(i915_debugfs_list,
1456 I915_DEBUGFS_ENTRIES, 1544 I915_DEBUGFS_ENTRIES,
@@ -1465,6 +1553,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor)
1465 1, minor); 1553 1, minor);
1466 drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, 1554 drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops,
1467 1, minor); 1555 1, minor);
1556 drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops,
1557 1, minor);
1468} 1558}
1469 1559
1470#endif /* CONFIG_DEBUG_FS */ 1560#endif /* CONFIG_DEBUG_FS */