summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp106
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-08-08 13:53:25 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-12 16:00:19 -0400
commit89772b03cb093b3556dd4803e5a8deee60046ac9 (patch)
treec609de388b57161e9bb58ff21ef5aaf7ab663a5e /drivers/gpu/nvgpu/gp106
parentb610bb95108afe54895219e06859cf241fabc9db (diff)
gpu: nvgpu: Move XVE debugfs code to Linux module
Move XVE debugfs initialization code to live under common/linux. JIRA NVGPU-62 Change-Id: Ic6677511d249bc0a2455dde01db5b230afc70bb1 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1535133 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp106')
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp106/xve_gp106.c170
-rw-r--r--drivers/gpu/nvgpu/gp106/xve_gp106.h51
3 files changed, 8 insertions, 215 deletions
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
index 7e7fc195..b33e80ec 100644
--- a/drivers/gpu/nvgpu/gp106/hal_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -660,7 +660,6 @@ static const struct gpu_ops gp106_ops = {
660 }, 660 },
661#endif 661#endif
662 .xve = { 662 .xve = {
663 .sw_init = xve_sw_init_gp106,
664 .get_speed = xve_get_speed_gp106, 663 .get_speed = xve_get_speed_gp106,
665 .set_speed = xve_set_speed_gp106, 664 .set_speed = xve_set_speed_gp106,
666 .available_speeds = xve_available_speeds_gp106, 665 .available_speeds = xve_available_speeds_gp106,
@@ -673,6 +672,7 @@ static const struct gpu_ops gp106_ops = {
673#endif 672#endif
674 .enable_shadow_rom = xve_enable_shadow_rom_gp106, 673 .enable_shadow_rom = xve_enable_shadow_rom_gp106,
675 .disable_shadow_rom = xve_disable_shadow_rom_gp106, 674 .disable_shadow_rom = xve_disable_shadow_rom_gp106,
675 .get_link_control_status = xve_get_link_control_status,
676 }, 676 },
677 .falcon = { 677 .falcon = {
678 .falcon_hal_sw_init = gp106_falcon_hal_sw_init, 678 .falcon_hal_sw_init = gp106_falcon_hal_sw_init,
diff --git a/drivers/gpu/nvgpu/gp106/xve_gp106.c b/drivers/gpu/nvgpu/gp106/xve_gp106.c
index a3514fc0..3a84ca17 100644
--- a/drivers/gpu/nvgpu/gp106/xve_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/xve_gp106.c
@@ -14,17 +14,13 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#ifdef CONFIG_DEBUG_FS
18#include <linux/debugfs.h>
19#include <linux/uaccess.h>
20#endif
21
22#include "gk20a/gk20a.h" 17#include "gk20a/gk20a.h"
23#include "gm206/bios_gm206.h" 18#include "gm206/bios_gm206.h"
24#include "gp106/xve_gp106.h" 19#include "gp106/xve_gp106.h"
25#include "common/linux/os_linux.h" 20#include "common/linux/os_linux.h"
26 21
27#include <nvgpu/bug.h> 22#include <nvgpu/bug.h>
23#include <nvgpu/xve.h>
28 24
29#include <nvgpu/hw/gp106/hw_xp_gp106.h> 25#include <nvgpu/hw/gp106/hw_xp_gp106.h>
30#include <nvgpu/hw/gp106/hw_xve_gp106.h> 26#include <nvgpu/hw/gp106/hw_xve_gp106.h>
@@ -475,165 +471,6 @@ void xve_available_speeds_gp106(struct gk20a *g, u32 *speed_mask)
475 *speed_mask = GPU_XVE_SPEED_2P5 | GPU_XVE_SPEED_5P0; 471 *speed_mask = GPU_XVE_SPEED_2P5 | GPU_XVE_SPEED_5P0;
476} 472}
477 473
478#ifdef CONFIG_DEBUG_FS
479static ssize_t xve_link_speed_write(struct file *filp,
480 const char __user *buff,
481 size_t len, loff_t *off)
482{
483 struct gk20a *g = ((struct seq_file *)filp->private_data)->private;
484 char kbuff[16];
485 u32 buff_size, check_len;
486 u32 link_speed = 0;
487 int ret;
488
489 buff_size = min_t(size_t, 16, len);
490
491 memset(kbuff, 0, 16);
492 if (copy_from_user(kbuff, buff, buff_size))
493 return -EFAULT;
494
495 check_len = strlen("Gen1");
496 if (strncmp(kbuff, "Gen1", check_len) == 0)
497 link_speed = GPU_XVE_SPEED_2P5;
498 else if (strncmp(kbuff, "Gen2", check_len) == 0)
499 link_speed = GPU_XVE_SPEED_5P0;
500 else if (strncmp(kbuff, "Gen3", check_len) == 0)
501 link_speed = GPU_XVE_SPEED_8P0;
502 else
503 nvgpu_err(g, "%s: Unknown PCIe speed: %s",
504 __func__, kbuff);
505
506 if (!link_speed)
507 return -EINVAL;
508
509 /* Brief pause... To help rate limit this. */
510 nvgpu_msleep(250);
511
512 /*
513 * And actually set the speed. Yay.
514 */
515 ret = g->ops.xve.set_speed(g, link_speed);
516 if (ret)
517 return ret;
518
519 return len;
520}
521
522static int xve_link_speed_show(struct seq_file *s, void *unused)
523{
524 struct gk20a *g = s->private;
525 u32 speed;
526 int err;
527
528 err = g->ops.xve.get_speed(g, &speed);
529 if (err)
530 return err;
531
532 seq_printf(s, "Current PCIe speed:\n %s\n", xve_speed_to_str(speed));
533
534 return 0;
535}
536
537static int xve_link_speed_open(struct inode *inode, struct file *file)
538{
539 return single_open(file, xve_link_speed_show, inode->i_private);
540}
541
542static const struct file_operations xve_link_speed_fops = {
543 .open = xve_link_speed_open,
544 .read = seq_read,
545 .write = xve_link_speed_write,
546 .llseek = seq_lseek,
547 .release = single_release,
548};
549
550static int xve_available_speeds_show(struct seq_file *s, void *unused)
551{
552 struct gk20a *g = s->private;
553 u32 available_speeds;
554
555 g->ops.xve.available_speeds(g, &available_speeds);
556
557 seq_puts(s, "Available PCIe bus speeds:\n");
558 if (available_speeds & GPU_XVE_SPEED_2P5)
559 seq_puts(s, " Gen1\n");
560 if (available_speeds & GPU_XVE_SPEED_5P0)
561 seq_puts(s, " Gen2\n");
562 if (available_speeds & GPU_XVE_SPEED_8P0)
563 seq_puts(s, " Gen3\n");
564
565 return 0;
566}
567
568static int xve_available_speeds_open(struct inode *inode, struct file *file)
569{
570 return single_open(file, xve_available_speeds_show, inode->i_private);
571}
572
573static const struct file_operations xve_available_speeds_fops = {
574 .open = xve_available_speeds_open,
575 .read = seq_read,
576 .llseek = seq_lseek,
577 .release = single_release,
578};
579
580static int xve_link_control_status_show(struct seq_file *s, void *unused)
581{
582 struct gk20a *g = s->private;
583 u32 link_status;
584
585 link_status = g->ops.xve.xve_readl(g, xve_link_control_status_r());
586 seq_printf(s, "0x%08x\n", link_status);
587
588 return 0;
589}
590
591static int xve_link_control_status_open(struct inode *inode, struct file *file)
592{
593 return single_open(file, xve_link_control_status_show, inode->i_private);
594}
595
596static const struct file_operations xve_link_control_status_fops = {
597 .open = xve_link_control_status_open,
598 .read = seq_read,
599 .llseek = seq_lseek,
600 .release = single_release,
601};
602#endif
603
604int xve_sw_init_gp106(struct gk20a *g)
605{
606 int err = -ENODEV;
607#ifdef CONFIG_DEBUG_FS
608 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
609 struct dentry *gpu_root = l->debugfs;
610
611 l->debugfs_xve = debugfs_create_dir("xve", gpu_root);
612 if (IS_ERR_OR_NULL(l->debugfs_xve))
613 goto fail;
614
615 /*
616 * These are just debug nodes. If they fail to get made it's not worth
617 * worrying the higher level SW.
618 */
619 debugfs_create_file("link_speed", S_IRUGO,
620 l->debugfs_xve, g,
621 &xve_link_speed_fops);
622 debugfs_create_file("available_speeds", S_IRUGO,
623 l->debugfs_xve, g,
624 &xve_available_speeds_fops);
625 debugfs_create_file("link_control_status", S_IRUGO,
626 l->debugfs_xve, g,
627 &xve_link_control_status_fops);
628
629 err = 0;
630fail:
631 return err;
632#else
633 return err;
634#endif
635}
636
637#if defined(CONFIG_PCI_MSI) 474#if defined(CONFIG_PCI_MSI)
638void xve_rearm_msi_gp106(struct gk20a *g) 475void xve_rearm_msi_gp106(struct gk20a *g)
639{ 476{
@@ -653,3 +490,8 @@ void xve_disable_shadow_rom_gp106(struct gk20a *g)
653 g->ops.xve.xve_writel(g, xve_rom_ctrl_r(), 490 g->ops.xve.xve_writel(g, xve_rom_ctrl_r(),
654 xve_rom_ctrl_rom_shadow_disabled_f()); 491 xve_rom_ctrl_rom_shadow_disabled_f());
655} 492}
493
494u32 xve_get_link_control_status(struct gk20a *g)
495{
496 return g->ops.xve.xve_readl(g, xve_link_control_status_r());
497}
diff --git a/drivers/gpu/nvgpu/gp106/xve_gp106.h b/drivers/gpu/nvgpu/gp106/xve_gp106.h
index 37ead910..55192fc8 100644
--- a/drivers/gpu/nvgpu/gp106/xve_gp106.h
+++ b/drivers/gpu/nvgpu/gp106/xve_gp106.h
@@ -29,55 +29,6 @@ int gp106_init_xve_ops(struct gpu_ops *gops);
29#define GPU_XVE_TIMEOUT_MS 500 29#define GPU_XVE_TIMEOUT_MS 500
30 30
31/* 31/*
32 * For the available speeds bitmap.
33 */
34#define GPU_XVE_SPEED_2P5 (1 << 0)
35#define GPU_XVE_SPEED_5P0 (1 << 1)
36#define GPU_XVE_SPEED_8P0 (1 << 2)
37#define GPU_XVE_NR_SPEEDS 3
38
39#define GPU_XVE_SPEED_MASK (GPU_XVE_SPEED_2P5 | \
40 GPU_XVE_SPEED_5P0 | \
41 GPU_XVE_SPEED_8P0)
42
43/*
44 * The HW uses a 2 bit field where speed is defined by a number:
45 *
46 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_2P5 = 1
47 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_5P0 = 2
48 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_8P0 = 3
49 *
50 * This isn't ideal for a bitmap with available speeds. So the external
51 * APIs think about speeds as a bit in a bitmap and this function converts
52 * from those bits to the actual HW speed setting.
53 *
54 * @speed_bit must have only 1 bit set and must be one of the 3 available
55 * HW speeds. Not all chips support all speeds so use available_speeds() to
56 * determine what a given chip supports.
57 */
58static inline u32 xve_speed_to_hw_speed_setting(u32 speed_bit)
59{
60 if (!speed_bit ||
61 !is_power_of_2(speed_bit) ||
62 !(speed_bit & GPU_XVE_SPEED_MASK))
63 return -EINVAL;
64
65 return ilog2(speed_bit) + 1;
66}
67
68static inline const char *xve_speed_to_str(u32 speed)
69{
70 if (!speed || !is_power_of_2(speed) ||
71 !(speed & GPU_XVE_SPEED_MASK))
72 return "Unknown ???";
73
74 return speed & GPU_XVE_SPEED_2P5 ? "Gen1" :
75 speed & GPU_XVE_SPEED_5P0 ? "Gen2" :
76 speed & GPU_XVE_SPEED_8P0 ? "Gen3" :
77 "Unknown ???";
78}
79
80/*
81 * Debugging for the speed change. 32 * Debugging for the speed change.
82 */ 33 */
83enum xv_speed_change_steps { 34enum xv_speed_change_steps {
@@ -104,7 +55,7 @@ int xve_get_speed_gp106(struct gk20a *g, u32 *xve_link_speed);
104void xve_disable_aspm_gp106(struct gk20a *g); 55void xve_disable_aspm_gp106(struct gk20a *g);
105int xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed); 56int xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed);
106void xve_available_speeds_gp106(struct gk20a *g, u32 *speed_mask); 57void xve_available_speeds_gp106(struct gk20a *g, u32 *speed_mask);
107int xve_sw_init_gp106(struct gk20a *g); 58u32 xve_get_link_control_status(struct gk20a *g);
108#if defined(CONFIG_PCI_MSI) 59#if defined(CONFIG_PCI_MSI)
109void xve_rearm_msi_gp106(struct gk20a *g); 60void xve_rearm_msi_gp106(struct gk20a *g);
110#endif 61#endif