summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp106/xve_gp106.c
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/xve_gp106.c
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/xve_gp106.c')
-rw-r--r--drivers/gpu/nvgpu/gp106/xve_gp106.c170
1 files changed, 6 insertions, 164 deletions
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}