Permalink
Browse files

recommit the project

  • Loading branch information...
0 parents commit 479e9e744b7b1330f5589335fa7d0512f03c0e85 Shinpei Kato committed Nov 10, 2011
Showing with 74,473 additions and 0 deletions.
  1. +62 −0 common/gdev_api.h
  2. +45 −0 common/gdev_conf.h
  3. +69 −0 common/gdev_ioctl_def.h
  4. +131 −0 common/gdev_nvidia.c
  5. +327 −0 common/gdev_nvidia.h
  6. +76 −0 common/gdev_nvidia_def.h
  7. +127 −0 common/gdev_time.h
  8. +12 −0 driver/README
  9. +32 −0 driver/configure
  10. +5 −0 driver/gdev/Makefile
  11. +238 −0 driver/gdev/gdev_drv.c
  12. +119 −0 driver/gdev/gdev_drv.h
  13. +204 −0 driver/gdev/gdev_ioctl.c
  14. +41 −0 driver/gdev/gdev_ioctl.h
  15. +41 −0 driver/gdev/install.sh
  16. +40 −0 driver/pscnv/Makefile
  17. +13 −0 driver/pscnv/configure
  18. +63 −0 driver/pscnv/i2c/sil164.h
  19. +13 −0 driver/pscnv/kapitest.sh
  20. +23 −0 driver/pscnv/kapitest/Makefile
  21. +6 −0 driver/pscnv/kapitest/drm_connector_detect_1.c
  22. +6 −0 driver/pscnv/kapitest/drm_connector_detect_2.c
  23. +6 −0 driver/pscnv/kapitest/drm_gem_object_handle_count.c
  24. +7 −0 driver/pscnv/kapitest/drm_ioctl_def.c
  25. +7 −0 driver/pscnv/kapitest/drm_ioctl_def_drv.c
  26. +1 −0 driver/pscnv/kapitest/fail.c
  27. +7 −0 driver/pscnv/kapitest/gamma_set_5.c
  28. +7 −0 driver/pscnv/kapitest/gamma_set_6.c
  29. +8 −0 driver/pscnv/kapitest/getparam_bus_type.c
  30. +3 −0 driver/pscnv/kapitest/i2c_id.c
  31. +6 −0 driver/pscnv/kapitest/io_mapping_2.c
  32. +6 −0 driver/pscnv/kapitest/io_mapping_3.c
  33. +5 −0 driver/pscnv/kapitest/map_ofs.c
  34. +9 −0 driver/pscnv/kapitest/pci_driver.c
  35. +8 −0 driver/pscnv/kapitest/switcheroo_reprobe.c
  36. +296 −0 driver/pscnv/nouveau_acpi.c
  37. +158 −0 driver/pscnv/nouveau_backlight.c
  38. +6,933 −0 driver/pscnv/nouveau_bios.c
  39. +335 −0 driver/pscnv/nouveau_bios.h
  40. +477 −0 driver/pscnv/nouveau_calc.c
  41. +945 −0 driver/pscnv/nouveau_connector.c
  42. +61 −0 driver/pscnv/nouveau_connector.h
  43. +97 −0 driver/pscnv/nouveau_crtc.h
  44. +180 −0 driver/pscnv/nouveau_debugfs.c
  45. +106 −0 driver/pscnv/nouveau_display.c
  46. +172 −0 driver/pscnv/nouveau_dma.c
  47. +166 −0 driver/pscnv/nouveau_dma.h
  48. +638 −0 driver/pscnv/nouveau_dp.c
  49. +533 −0 driver/pscnv/nouveau_drv.c
  50. +1,234 −0 driver/pscnv/nouveau_drv.h
  51. +103 −0 driver/pscnv/nouveau_encoder.h
  52. +46 −0 driver/pscnv/nouveau_fb.h
  53. +444 −0 driver/pscnv/nouveau_fbcon.c
  54. +63 −0 driver/pscnv/nouveau_fbcon.h
  55. +136 −0 driver/pscnv/nouveau_grctx.h
  56. +1,086 −0 driver/pscnv/nouveau_hw.c
  57. +455 −0 driver/pscnv/nouveau_hw.h
  58. +323 −0 driver/pscnv/nouveau_i2c.c
  59. +58 −0 driver/pscnv/nouveau_i2c.h
  60. +70 −0 driver/pscnv/nouveau_ioc32.c
  61. +1,330 −0 driver/pscnv/nouveau_irq.c
  62. +182 −0 driver/pscnv/nouveau_mem.c
  63. +205 −0 driver/pscnv/nouveau_perf.c
  64. +548 −0 driver/pscnv/nouveau_pm.c
  65. +74 −0 driver/pscnv/nouveau_pm.h
  66. +862 −0 driver/pscnv/nouveau_reg.h
  67. +728 −0 driver/pscnv/nouveau_state.c
  68. +309 −0 driver/pscnv/nouveau_temp.c
  69. +212 −0 driver/pscnv/nouveau_volt.c
  70. +544 −0 driver/pscnv/nv04_dac.c
  71. +717 −0 driver/pscnv/nv04_dfp.c
  72. +81 −0 driver/pscnv/nv04_pm.c
  73. +46 −0 driver/pscnv/nv04_timer.c
  74. +254 −0 driver/pscnv/nv04_tv.c
  75. +92 −0 driver/pscnv/nv10_gpio.c
  76. +87 −0 driver/pscnv/nv50_calc.c
  77. +180 −0 driver/pscnv/nv50_chan.c
  78. +20 −0 driver/pscnv/nv50_chan.h
  79. +812 −0 driver/pscnv/nv50_crtc.c
  80. +158 −0 driver/pscnv/nv50_cursor.c
  81. +321 −0 driver/pscnv/nv50_dac.c
  82. +1,124 −0 driver/pscnv/nv50_display.c
  83. +49 −0 driver/pscnv/nv50_display.h
  84. +113 −0 driver/pscnv/nv50_evo.h
  85. +460 −0 driver/pscnv/nv50_fifo.c
  86. +111 −0 driver/pscnv/nv50_gpio.c
  87. +1,006 −0 driver/pscnv/nv50_graph.c
  88. +3,337 −0 driver/pscnv/nv50_grctx.c
  89. +134 −0 driver/pscnv/nv50_pm.c
  90. +343 −0 driver/pscnv/nv50_sor.c
  91. +557 −0 driver/pscnv/nv50_vm.c
  92. +31 −0 driver/pscnv/nv50_vm.h
  93. +285 −0 driver/pscnv/nv50_vram.c
  94. +264 −0 driver/pscnv/nv84_crypt.c
  95. +258 −0 driver/pscnv/nv98_crypt.c
  96. +699 −0 driver/pscnv/nv98_crypt.fuc
  97. +872 −0 driver/pscnv/nva3_copy.fuc
  98. +95 −0 driver/pscnv/nva3_pm.c
  99. +78 −0 driver/pscnv/nvc0_chan.c
  100. +14 −0 driver/pscnv/nvc0_chan.h
  101. +254 −0 driver/pscnv/nvc0_copy.c
  102. +527 −0 driver/pscnv/nvc0_copy.fuc.h
  103. +37 −0 driver/pscnv/nvc0_copy.h
  104. +2,999 −0 driver/pscnv/nvc0_ctxctl.h
  105. +426 −0 driver/pscnv/nvc0_fifo.c
  106. +1,138 −0 driver/pscnv/nvc0_graph.c
  107. +400 −0 driver/pscnv/nvc0_graph.fuc
  108. +79 −0 driver/pscnv/nvc0_graph.h
  109. +3,009 −0 driver/pscnv/nvc0_grctx.c
  110. +480 −0 driver/pscnv/nvc0_grgpc.fuc
  111. +811 −0 driver/pscnv/nvc0_grhub.fuc
  112. +2,819 −0 driver/pscnv/nvc0_pgraph.xml.h
  113. +446 −0 driver/pscnv/nvc0_vm.c
  114. +57 −0 driver/pscnv/nvc0_vm.h
  115. +115 −0 driver/pscnv/nvc0_vram.c
  116. +536 −0 driver/pscnv/nvreg.h
  117. +235 −0 driver/pscnv/pscnv_chan.c
  118. +81 −0 driver/pscnv/pscnv_chan.h
  119. +173 −0 driver/pscnv/pscnv_drm.h
  120. +33 −0 driver/pscnv/pscnv_engine.h
  121. +40 −0 driver/pscnv/pscnv_fifo.h
  122. +377 −0 driver/pscnv/pscnv_gdev.c
  123. +74 −0 driver/pscnv/pscnv_gem.c
  124. +37 −0 driver/pscnv/pscnv_gem.h
  125. +500 −0 driver/pscnv/pscnv_ioctl.c
  126. +36 −0 driver/pscnv/pscnv_ioctl.h
  127. 0 driver/pscnv/pscnv_kapi.h
  128. +192 −0 driver/pscnv/pscnv_mem.c
  129. +85 −0 driver/pscnv/pscnv_mem.h
  130. +321 −0 driver/pscnv/pscnv_mm.c
  131. +48 −0 driver/pscnv/pscnv_mm.h
  132. +94 −0 driver/pscnv/pscnv_ramht.c
  133. +41 −0 driver/pscnv/pscnv_ramht.h
  134. +81 −0 driver/pscnv/pscnv_sysram.c
  135. +487 −0 driver/pscnv/pscnv_tree.h
  136. +257 −0 driver/pscnv/pscnv_vm.c
  137. +84 −0 driver/pscnv/pscnv_vm.h
  138. +38 −0 runtime/configure
  139. +29 −0 runtime/kernel/Makefile
  140. +157 −0 runtime/kernel/gdev_lib.c
  141. +30 −0 runtime/kernel/gdev_lib.h
  142. +29 −0 runtime/user/gdev/Makefile
  143. +789 −0 runtime/user/gdev/drm.h
  144. +347 −0 runtime/user/gdev/drm_mode.h
  145. +94 −0 runtime/user/gdev/gdev_lib.c
  146. +113 −0 runtime/user/gdev/gdev_lib.h
  147. +193 −0 runtime/user/pscnv/libpscnv.c
  148. +41 −0 runtime/user/pscnv/libpscnv.h
  149. +158 −0 runtime/user/pscnv/libpscnv_ib.c
  150. +94 −0 runtime/user/pscnv/libpscnv_ib.h
  151. +157 −0 runtime/user/pscnv/pscnv_drm.h
  152. +296 −0 runtime/user/pscnv/pscnv_gdev.c
  153. +157 −0 tests/common/loadstore.c
  154. +257 −0 tests/common/matrixadd.c
  155. +10 −0 tests/common/matrixadd.cu
  156. BIN tests/common/matrixadd_fermi
  157. +83 −0 tests/common/memcpy.c
  158. +14 −0 tests/common/openclose.c
  159. +13 −0 tests/cuda/matrixmul/Makefile
  160. +194 −0 tests/cuda/matrixmul/main.c
  161. BIN tests/cuda/matrixmul/matrixmul_gpu.cubin
  162. +13 −0 tests/cuda/memcpy/Makefile
  163. +13 −0 tests/cuda/memcpy/Makefile.pathscale
  164. +160 −0 tests/cuda/memcpy/main.c
  165. BIN tests/cuda/memcpy/simple_example1.cubin
  166. +38 −0 tests/kernel/loadstore/Makefile
  167. +1 −0 tests/kernel/loadstore/loadstore.c
  168. +41 −0 tests/kernel/loadstore/main.c
  169. +38 −0 tests/kernel/memcpy/Makefile
  170. +65 −0 tests/kernel/memcpy/main.c
  171. +1 −0 tests/kernel/memcpy/memcpy.c
  172. +22 −0 tests/user/loadstore/Makefile
  173. +1 −0 tests/user/loadstore/loadstore.c
  174. +13 −0 tests/user/loadstore/main.c
  175. +22 −0 tests/user/matrixadd/Makefile
  176. +33 −0 tests/user/matrixadd/main.c
  177. +1 −0 tests/user/matrixadd/matrixadd.c
  178. +22 −0 tests/user/memcpy/Makefile
  179. +76 −0 tests/user/memcpy/main.c
  180. +1 −0 tests/user/memcpy/memcpy.c
  181. +22 −0 tests/user/openclose/Makefile
  182. +12 −0 tests/user/openclose/main.c
  183. +105 −0 tests/user/openclose/main.c~
  184. BIN tests/user/openclose/main.o
  185. +1 −0 tests/user/openclose/openclose.c
  186. BIN tests/user/openclose/openclose.o
  187. BIN tests/user/openclose/user_test
  188. +5,510 −0 traces/matrix_mul_nva3_dedmaed
  189. +13,080 −0 traces/matrix_mul_nvc4_dedmaed
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 Shinpei Kato
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GDEV_API_H__
+#define __GDEV_API_H__
+
+#ifdef __KERNEL__
+#include "gdev_drv.h"
+#else
+#include "gdev_lib.h"
+#endif
+#include "gdev_nvidia_def.h"
+/* add also:
+ * #include "gdev_amd_def.h"
+ * #include "gdev_intel_def.h"
+ */
+
+/**
+ * Gdev APIs:
+ */
+extern gdev_handle_t *gopen(int);
+extern int gclose(gdev_handle_t*);
+extern uint64_t gmalloc(gdev_handle_t*, uint64_t);
+extern void gfree(gdev_handle_t*, uint64_t);
+extern int gmemcpy_from_device(gdev_handle_t*, void*, uint64_t, uint64_t);
+extern int gmemcpy_user_from_device(gdev_handle_t*, void*, uint64_t, uint64_t);
+extern int gmemcpy_to_device(gdev_handle_t*, uint64_t, void*, uint64_t);
+extern int gmemcpy_user_to_device(gdev_handle_t*, uint64_t, void*, uint64_t);
+extern int gmemcpy_in_device(gdev_handle_t*, uint64_t, uint64_t, uint64_t);
+extern int glaunch(gdev_handle_t*, struct gdev_kernel*, uint32_t*);
+extern void gsync(gdev_handle_t*, uint32_t);
+extern int gquery(gdev_handle_t*, uint32_t, uint32_t*);
+extern int gtune(gdev_handle_t*, uint32_t, uint32_t);
+
+/**
+ * tuning types for Gdev resource management parameters.
+ */
+#define GDEV_TUNE_MEMCPY_PIPELINE_COUNT 1
+#define GDEV_TUNE_MEMCPY_CHUNK_SIZE 2
+
+#endif
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011 Shinpei Kato
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GDEV_CONF_H__
+#define __GDEV_CONF_H__
+
+#include "gdev_nvidia.h"
+// #include "gdev_amd.h"
+// #include "gdev_intel.h"
+
+#define GDEV_PIPELINE_MAX_COUNT 8
+#define GDEV_PIPELINE_MIN_COUNT 1
+#define GDEV_PIPELINE_DEFAULT_COUNT 1
+
+#define GDEV_CHUNK_MAX_SIZE 0x2000000 /* 32MB */
+#define GDEV_CHUNK_DEFAULT_SIZE 0x100000 /* 1MB */
+
+/* define this if you want to allocate a new bounce buffer every time
+ you copy data to/from device memory. */
+//#define GDEV_NO_STATIC_BOUNCE_BUFFER
+
+#define GDEV_DEBUG_PRINT 0
+
+#endif
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011 Shinpei Kato
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GDEV_IOCTL_DEF_H__
+#define __GDEV_IOCTL_DEF_H__
+
+/**
+ * user-space ioctl commands:
+ */
+#define GDEV_IOCTL_GMALLOC 0x100
+#define GDEV_IOCTL_GFREE 0x101
+#define GDEV_IOCTL_GMEMCPY_FROM_DEVICE 0x102
+#define GDEV_IOCTL_GMEMCPY_TO_DEVICE 0x103
+#define GDEV_IOCTL_GMEMCPY_IN_DEVICE 0x104
+#define GDEV_IOCTL_GLAUNCH 0x105
+#define GDEV_IOCTL_GSYNC 0x106
+#define GDEV_IOCTL_GQUERY 0x107
+#define GDEV_IOCTL_GTUNE 0x108
+
+typedef struct gdev_ioctl_mem {
+ uint64_t addr;
+ uint64_t size;
+} gdev_ioctl_mem_t;
+
+typedef struct gdev_ioctl_dma {
+ void *src_buf;
+ void *dst_buf;
+ uint64_t src_addr;
+ uint64_t dst_addr;
+ uint64_t size;
+} gdev_ioctl_dma_t;
+
+typedef struct gdev_ioctl_launch {
+ struct gdev_kernel *kernel;
+ uint32_t *id;
+} gdev_ioctl_launch_t;
+
+typedef struct gdev_ioctl_query {
+ uint32_t type;
+ uint32_t result;
+} gdev_ioctl_query_t;
+
+typedef struct gdev_ioctl_tune {
+ uint32_t type;
+ uint32_t value;
+} gdev_ioctl_tune_t;
+
+#endif
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2011 Shinpei Kato
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "gdev_nvidia.h"
+
+/* add the device memory object to the memory list. */
+void gdev_heap_add(gdev_mem_t *mem)
+{
+ gdev_vas_t *vas = mem->vas;
+
+ __gdev_list_add(&mem->list_entry, &vas->memlist);
+}
+
+/* delete the device memory object from the memory list. */
+void gdev_heap_del(gdev_mem_t *mem)
+{
+ __gdev_list_del(&mem->list_entry);
+}
+
+/* look up the memory object allocated at the specified address. */
+gdev_mem_t *gdev_heap_lookup(gdev_vas_t *vas, uint64_t addr)
+{
+ gdev_mem_t *mem;
+ gdev_list_t *entry = vas->memlist.next;
+
+ while (entry) {
+ mem = (gdev_mem_t *)entry->container;
+ if (mem && mem->addr == addr)
+ return mem;
+ entry = entry->next;
+ }
+
+ return NULL;
+}
+
+/* copy data of @size from @src_addr to @dst_addr. */
+uint32_t gdev_memcpy
+(gdev_ctx_t *ctx, uint64_t dst_addr, uint64_t src_addr, uint32_t size)
+{
+ gdev_vas_t *vas = ctx->vas;
+ gdev_device_t *gdev = vas->gdev;
+ struct gdev_compute *compute = gdev->compute;
+ uint32_t sequence = ++ctx->fence.sequence[GDEV_FENCE_DMA];
+
+ /* it's important to emit a fence *before* memcpy():
+ the EXEC method of the PCOPY and M2MF engines is associated with
+ the QUERY method, i.e., if QUERY is set, the sequence will be
+ written to the specified address when the data are transfered. */
+ compute->fence_write(ctx, GDEV_FENCE_DMA, sequence);
+ compute->memcpy(ctx, dst_addr, src_addr, size);
+
+ return sequence;
+}
+
+/* launch the kernel onto the GPU. */
+uint32_t gdev_launch(gdev_ctx_t *ctx, struct gdev_kernel *kern)
+{
+ gdev_vas_t *vas = ctx->vas;
+ gdev_device_t *gdev = vas->gdev;
+ struct gdev_compute *compute = gdev->compute;
+ uint32_t sequence = ++ctx->fence.sequence[GDEV_FENCE_COMPUTE];
+
+ /* it's important to emit a fence *after* launch():
+ the LAUNCH method of the PGRAPH engine is not associated with
+ the QUERY method, i.e., we have to submit the QUERY method
+ explicitly after the kernel is launched. */
+ compute->launch(ctx, kern);
+ compute->fence_write(ctx, GDEV_FENCE_COMPUTE, sequence);
+
+ return sequence;
+}
+
+/* barrier memory access. */
+void gdev_mb(gdev_ctx_t *ctx)
+{
+ gdev_vas_t *vas = ctx->vas;
+ gdev_device_t *gdev = vas->gdev;
+ struct gdev_compute *compute = gdev->compute;
+
+ compute->membar(ctx);
+}
+
+/* poll until the resource becomes available. */
+void gdev_poll(gdev_ctx_t *ctx, int type, uint32_t sequence)
+{
+ gdev_vas_t *vas = ctx->vas;
+ gdev_device_t *gdev = vas->gdev;
+ struct gdev_compute *compute = gdev->compute;
+ uint32_t poll_times = 0;
+ uint32_t val;
+
+ compute->fence_read(ctx, type, &val);
+
+ while (val < sequence || val > sequence + GDEV_FENCE_LIMIT) {
+ /* relax the polling after some time. */
+ if (poll_times > 0x80000000) {
+ SCHED_YIELD();
+ }
+ else if (poll_times == 0xffffffff) {
+ poll_times = 0;
+ }
+ poll_times++;
+ compute->fence_read(ctx, type, &val);
+ }
+
+ /* sequence rolls back to zero, if necessary. */
+ if (ctx->fence.sequence[type] == GDEV_FENCE_LIMIT) {
+ ctx->fence.sequence[type] = 0;
+ }
+}
Oops, something went wrong.

0 comments on commit 479e9e7

Please sign in to comment.