diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index a6f0f0ce7..067625863 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -49,6 +49,9 @@ nvgpu-y += common/bus/bus_gk20a.o \
# Linux specific parts of nvgpu.
nvgpu-y += \
+ os/linux/os_ops.o \
+ os/linux/os_ops_gm20b.o \
+ os/linux/os_ops_gp10b.o \
os/linux/kmem.o \
os/linux/timers.o \
os/linux/ioctl.o \
diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c
index 850f6debb..30cd0bff5 100644
--- a/drivers/gpu/nvgpu/os/linux/cde.c
+++ b/drivers/gpu/nvgpu/os/linux/cde.c
@@ -1791,24 +1791,3 @@ int gk20a_mark_compressible_write(struct gk20a *g, u32 buffer_fd,
dma_buf_put(dmabuf);
return 0;
}
-
-int nvgpu_cde_init_ops(struct nvgpu_os_linux *l)
-{
- struct gk20a *g = &l->g;
- u32 ver = g->params.gpu_arch + g->params.gpu_impl;
-
- switch (ver) {
- case GK20A_GPUID_GM20B:
- case GK20A_GPUID_GM20B_B:
- l->ops.cde = gm20b_cde_ops.cde;
- break;
- case NVGPU_GPUID_GP10B:
- l->ops.cde = gp10b_cde_ops.cde;
- break;
- default:
- /* CDE is optional, so today ignoring unknown chip is fine */
- break;
- }
-
- return 0;
-}
diff --git a/drivers/gpu/nvgpu/os/linux/cde_gm20b.c b/drivers/gpu/nvgpu/os/linux/cde_gm20b.c
index 1cd15c54e..7f71b7400 100644
--- a/drivers/gpu/nvgpu/os/linux/cde_gm20b.c
+++ b/drivers/gpu/nvgpu/os/linux/cde_gm20b.c
@@ -1,7 +1,7 @@
/*
* GM20B CDE
*
- * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -35,10 +35,10 @@ enum programs {
PROG_PASSTHROUGH = 6,
};
-static void gm20b_cde_get_program_numbers(struct gk20a *g,
- u32 block_height_log2,
- u32 shader_parameter,
- int *hprog_out, int *vprog_out)
+void gm20b_cde_get_program_numbers(struct gk20a *g,
+ u32 block_height_log2,
+ u32 shader_parameter,
+ int *hprog_out, int *vprog_out)
{
int hprog = PROG_HPASS;
int vprog = (block_height_log2 >= 2) ?
@@ -56,9 +56,3 @@ static void gm20b_cde_get_program_numbers(struct gk20a *g,
*hprog_out = hprog;
*vprog_out = vprog;
}
-
-struct nvgpu_os_linux_ops gm20b_cde_ops = {
- .cde = {
- .get_program_numbers = gm20b_cde_get_program_numbers,
- },
-};
diff --git a/drivers/gpu/nvgpu/os/linux/cde_gm20b.h b/drivers/gpu/nvgpu/os/linux/cde_gm20b.h
index 640d6ab67..fac8aaff8 100644
--- a/drivers/gpu/nvgpu/os/linux/cde_gm20b.h
+++ b/drivers/gpu/nvgpu/os/linux/cde_gm20b.h
@@ -1,7 +1,7 @@
/*
* GM20B CDE
*
- * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,9 @@
#ifndef _NVHOST_GM20B_CDE
#define _NVHOST_GM20B_CDE
-#include "os_linux.h"
-
-extern struct nvgpu_os_linux_ops gm20b_cde_ops;
+void gm20b_cde_get_program_numbers(struct gk20a *g,
+ u32 block_height_log2,
+ u32 shader_parameter,
+ int *hprog_out, int *vprog_out);
#endif
diff --git a/drivers/gpu/nvgpu/os/linux/cde_gp10b.c b/drivers/gpu/nvgpu/os/linux/cde_gp10b.c
index 5c0e79a77..f22f4b68c 100644
--- a/drivers/gpu/nvgpu/os/linux/cde_gp10b.c
+++ b/drivers/gpu/nvgpu/os/linux/cde_gp10b.c
@@ -151,11 +151,3 @@ int gp10b_populate_scatter_buffer(struct gk20a *g,
return 0;
}
-
-struct nvgpu_os_linux_ops gp10b_cde_ops = {
- .cde = {
- .get_program_numbers = gp10b_cde_get_program_numbers,
- .need_scatter_buffer = gp10b_need_scatter_buffer,
- .populate_scatter_buffer = gp10b_populate_scatter_buffer,
- },
-};
diff --git a/drivers/gpu/nvgpu/os/linux/cde_gp10b.h b/drivers/gpu/nvgpu/os/linux/cde_gp10b.h
index 52e9f2928..3ecca2ab1 100644
--- a/drivers/gpu/nvgpu/os/linux/cde_gp10b.h
+++ b/drivers/gpu/nvgpu/os/linux/cde_gp10b.h
@@ -1,7 +1,7 @@
/*
* GP10B CDE
*
- * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,14 @@
#include "os_linux.h"
-extern struct nvgpu_os_linux_ops gp10b_cde_ops;
-
+void gp10b_cde_get_program_numbers(struct gk20a *g,
+ u32 block_height_log2,
+ u32 shader_parameter,
+ int *hprog_out, int *vprog_out);
+bool gp10b_need_scatter_buffer(struct gk20a *g);
+int gp10b_populate_scatter_buffer(struct gk20a *g,
+ struct sg_table *sgt,
+ size_t surface_size,
+ void *scatter_buffer_ptr,
+ size_t scatter_buffer_size);
#endif
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index c07faf086..3be879bee 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -56,6 +56,7 @@
#include "ioctl.h"
#include "os_linux.h"
+#include "os_ops.h"
#include "ctxsw_trace.h"
#include "driver_common.h"
#include "channel.h"
@@ -183,17 +184,6 @@ static int gk20a_restore_registers(struct gk20a *g)
return 0;
}
-static int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l)
-{
- int err = 0;
-
-#ifdef CONFIG_NVGPU_SUPPORT_CDE
- err = nvgpu_cde_init_ops(l);
-#endif
-
- return err;
-}
-
int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
{
struct gk20a *g = &l->g;
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.c b/drivers/gpu/nvgpu/os/linux/os_ops.c
new file mode 100644
index 000000000..14f92787d
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "os_linux.h"
+
+#include "os_ops_gm20b.h"
+#include "os_ops_gp10b.h"
+
+int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l)
+{
+ struct gk20a *g = &l->g;
+ u32 ver = g->params.gpu_arch + g->params.gpu_impl;
+
+ switch (ver) {
+ case GK20A_GPUID_GM20B:
+ case GK20A_GPUID_GM20B_B:
+ nvgpu_gm20b_init_os_ops(l);
+ break;
+ case NVGPU_GPUID_GP10B:
+ nvgpu_gp10b_init_os_ops(l);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.h b/drivers/gpu/nvgpu/os/linux/os_ops.h
new file mode 100644
index 000000000..af3ce0a7b
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __LINUX_OS_OPS_H
+#define __LINUX_OS_OPS_H
+
+int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l);
+
+#endif
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c
new file mode 100644
index 000000000..7db004eb9
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "os_linux.h"
+
+#include "cde_gm20b.h"
+
+static struct nvgpu_os_linux_ops gm20b_os_linux_ops = {
+#ifdef CONFIG_NVGPU_SUPPORT_CDE
+ .cde = {
+ .get_program_numbers = gm20b_cde_get_program_numbers,
+ },
+#endif
+};
+
+void nvgpu_gm20b_init_os_ops(struct nvgpu_os_linux *l)
+{
+#ifdef CONFIG_NVGPU_SUPPORT_CDE
+ l->ops.cde = gm20b_os_linux_ops.cde;
+#endif
+}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h
new file mode 100644
index 000000000..7d27e4014
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __LINUX_OS_OPS_GM20B_H
+#define __LINUX_OS_OPS_GM20B_H
+
+void nvgpu_gm20b_init_os_ops(struct nvgpu_os_linux *l);
+
+#endif
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c
new file mode 100644
index 000000000..984dcdc08
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "os_linux.h"
+
+#include "cde_gp10b.h"
+
+static struct nvgpu_os_linux_ops gp10b_os_linux_ops = {
+#ifdef CONFIG_NVGPU_SUPPORT_CDE
+ .cde = {
+ .get_program_numbers = gp10b_cde_get_program_numbers,
+ .need_scatter_buffer = gp10b_need_scatter_buffer,
+ .populate_scatter_buffer = gp10b_populate_scatter_buffer,
+ },
+#endif
+};
+
+void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l)
+{
+#ifdef CONFIG_NVGPU_SUPPORT_CDE
+ l->ops.cde = gp10b_os_linux_ops.cde;
+#endif
+}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h
new file mode 100644
index 000000000..0be1bca1e
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __LINUX_OS_OPS_GP10B_H
+#define __LINUX_OS_OPS_GP10B_H
+
+void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l);
+
+#endif