summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2017-08-18 06:52:29 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-22 06:53:51 -0400
commit81868a187fa3b217368206f17b19309846e8e7fb (patch)
tree2b59e33b61cc6e206f7781f3b4ab44c5c7b6d721 /drivers/gpu/nvgpu/gk20a/channel_gk20a.c
parent5f010177de985c901c33c914efe70a8498a5974f (diff)
gpu: nvgpu: Nvgpu abstraction for linux barriers.
construct wrapper nvgpu_* methods to replace mb,rmb,wmb,smp_mb,smp_rmb,smp_wmb,read_barrier_depends and smp_read_barrier_depends. NVGPU-122 Change-Id: I8d24dd70fef5cb0fadaacc15f3ab11531667a0df Signed-off-by: Debarshi <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1541199 Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Sourab Gupta <sourabg@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 5f81b441..0c1b06e9 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -35,6 +35,7 @@
35#include <nvgpu/enabled.h> 35#include <nvgpu/enabled.h>
36#include <nvgpu/debug.h> 36#include <nvgpu/debug.h>
37#include <nvgpu/ltc.h> 37#include <nvgpu/ltc.h>
38#include <nvgpu/barrier.h>
38 39
39#include "gk20a.h" 40#include "gk20a.h"
40#include "ctxsw_trace_gk20a.h" 41#include "ctxsw_trace_gk20a.h"
@@ -245,9 +246,9 @@ void gk20a_channel_abort_clean_up(struct channel_gk20a *ch)
245 246
246 /* 247 /*
247 * ensure put is read before any subsequent reads. 248 * ensure put is read before any subsequent reads.
248 * see corresponding wmb in gk20a_channel_add_job() 249 * see corresponding nvgpu_smp_wmb in gk20a_channel_add_job()
249 */ 250 */
250 rmb(); 251 nvgpu_smp_rmb();
251 252
252 while (tmp_get != put) { 253 while (tmp_get != put) {
253 job = &ch->joblist.pre_alloc.jobs[tmp_get]; 254 job = &ch->joblist.pre_alloc.jobs[tmp_get];
@@ -618,7 +619,7 @@ unbind:
618 /* make sure we catch accesses of unopened channels in case 619 /* make sure we catch accesses of unopened channels in case
619 * there's non-refcounted channel pointers hanging around */ 620 * there's non-refcounted channel pointers hanging around */
620 ch->g = NULL; 621 ch->g = NULL;
621 wmb(); 622 nvgpu_smp_wmb();
622 623
623 /* ALWAYS last */ 624 /* ALWAYS last */
624 free_channel(f, ch); 625 free_channel(f, ch);
@@ -880,7 +881,7 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g,
880 * gk20a_free_channel() */ 881 * gk20a_free_channel() */
881 ch->referenceable = true; 882 ch->referenceable = true;
882 nvgpu_atomic_set(&ch->ref_count, 1); 883 nvgpu_atomic_set(&ch->ref_count, 1);
883 wmb(); 884 nvgpu_smp_wmb();
884 885
885 return ch; 886 return ch;
886} 887}
@@ -993,9 +994,9 @@ int gk20a_channel_alloc_priv_cmdbuf(struct channel_gk20a *c, u32 orig_size,
993 994
994 /* 995 /*
995 * commit the previous writes before making the entry valid. 996 * commit the previous writes before making the entry valid.
996 * see the corresponding rmb() in gk20a_free_priv_cmdbuf(). 997 * see the corresponding nvgpu_smp_rmb() in gk20a_free_priv_cmdbuf().
997 */ 998 */
998 wmb(); 999 nvgpu_smp_wmb();
999 1000
1000 e->valid = true; 1001 e->valid = true;
1001 gk20a_dbg_fn("done"); 1002 gk20a_dbg_fn("done");
@@ -1025,9 +1026,10 @@ static int channel_gk20a_alloc_job(struct channel_gk20a *c,
1025 1026
1026 /* 1027 /*
1027 * ensure all subsequent reads happen after reading get. 1028 * ensure all subsequent reads happen after reading get.
1028 * see corresponding wmb in gk20a_channel_clean_up_jobs() 1029 * see corresponding nvgpu_smp_wmb in
1030 * gk20a_channel_clean_up_jobs()
1029 */ 1031 */
1030 rmb(); 1032 nvgpu_smp_rmb();
1031 1033
1032 if (CIRC_SPACE(put, get, c->joblist.pre_alloc.length)) 1034 if (CIRC_SPACE(put, get, c->joblist.pre_alloc.length))
1033 *job_out = &c->joblist.pre_alloc.jobs[put]; 1035 *job_out = &c->joblist.pre_alloc.jobs[put];
@@ -1137,7 +1139,7 @@ bool channel_gk20a_is_prealloc_enabled(struct channel_gk20a *c)
1137{ 1139{
1138 bool pre_alloc_enabled = c->joblist.pre_alloc.enabled; 1140 bool pre_alloc_enabled = c->joblist.pre_alloc.enabled;
1139 1141
1140 rmb(); 1142 nvgpu_smp_rmb();
1141 return pre_alloc_enabled; 1143 return pre_alloc_enabled;
1142} 1144}
1143 1145
@@ -1194,9 +1196,10 @@ static int channel_gk20a_prealloc_resources(struct channel_gk20a *c,
1194 1196
1195 /* 1197 /*
1196 * commit the previous writes before setting the flag. 1198 * commit the previous writes before setting the flag.
1197 * see corresponding rmb in channel_gk20a_is_prealloc_enabled() 1199 * see corresponding nvgpu_smp_rmb in
1200 * channel_gk20a_is_prealloc_enabled()
1198 */ 1201 */
1199 wmb(); 1202 nvgpu_smp_wmb();
1200 c->joblist.pre_alloc.enabled = true; 1203 c->joblist.pre_alloc.enabled = true;
1201 1204
1202 return 0; 1205 return 0;
@@ -1218,9 +1221,10 @@ static void channel_gk20a_free_prealloc_resources(struct channel_gk20a *c)
1218 1221
1219 /* 1222 /*
1220 * commit the previous writes before disabling the flag. 1223 * commit the previous writes before disabling the flag.
1221 * see corresponding rmb in channel_gk20a_is_prealloc_enabled() 1224 * see corresponding nvgpu_smp_rmb in
1225 * channel_gk20a_is_prealloc_enabled()
1222 */ 1226 */
1223 wmb(); 1227 nvgpu_smp_wmb();
1224 c->joblist.pre_alloc.enabled = false; 1228 c->joblist.pre_alloc.enabled = false;
1225} 1229}
1226 1230
@@ -1741,8 +1745,8 @@ static int __gk20a_channel_worker_wakeup(struct gk20a *g)
1741 /* 1745 /*
1742 * Currently, the only work type is associated with a lock, which deals 1746 * Currently, the only work type is associated with a lock, which deals
1743 * with any necessary barriers. If a work type with no locking were 1747 * with any necessary barriers. If a work type with no locking were
1744 * added, a a wmb() would be needed here. See ..worker_pending() for a 1748 * added, a nvgpu_smp_wmb() would be needed here. See
1745 * pair. 1749 * ..worker_pending() for a pair.
1746 */ 1750 */
1747 1751
1748 put = nvgpu_atomic_inc_return(&g->channel_worker.put); 1752 put = nvgpu_atomic_inc_return(&g->channel_worker.put);
@@ -1764,8 +1768,9 @@ static bool __gk20a_channel_worker_pending(struct gk20a *g, int get)
1764 bool pending = nvgpu_atomic_read(&g->channel_worker.put) != get; 1768 bool pending = nvgpu_atomic_read(&g->channel_worker.put) != get;
1765 1769
1766 /* 1770 /*
1767 * This would be the place for a rmb() pairing a wmb() for a wakeup 1771 * This would be the place for a nvgpu_smp_rmb() pairing
1768 * if we had any work with no implicit barriers caused by locking. 1772 * a nvgpu_smp_wmb() for a wakeup if we had any work with
1773 * no implicit barriers caused by locking.
1769 */ 1774 */
1770 1775
1771 return pending; 1776 return pending;
@@ -1939,7 +1944,7 @@ int gk20a_free_priv_cmdbuf(struct channel_gk20a *c, struct priv_cmd_entry *e)
1939 1944
1940 if (e->valid) { 1945 if (e->valid) {
1941 /* read the entry's valid flag before reading its contents */ 1946 /* read the entry's valid flag before reading its contents */
1942 rmb(); 1947 nvgpu_smp_rmb();
1943 if ((q->get != e->off) && e->off != 0) 1948 if ((q->get != e->off) && e->off != 0)
1944 nvgpu_err(g, "requests out-of-order, ch=%d", 1949 nvgpu_err(g, "requests out-of-order, ch=%d",
1945 c->chid); 1950 c->chid);
@@ -1984,10 +1989,11 @@ static int gk20a_channel_add_job(struct channel_gk20a *c,
1984 1989
1985 /* 1990 /*
1986 * ensure all pending write complete before adding to the list. 1991 * ensure all pending write complete before adding to the list.
1987 * see corresponding rmb in gk20a_channel_clean_up_jobs() & 1992 * see corresponding nvgpu_smp_rmb in
1993 * gk20a_channel_clean_up_jobs() &
1988 * gk20a_channel_abort_clean_up() 1994 * gk20a_channel_abort_clean_up()
1989 */ 1995 */
1990 wmb(); 1996 nvgpu_smp_wmb();
1991 channel_gk20a_joblist_add(c, job); 1997 channel_gk20a_joblist_add(c, job);
1992 1998
1993 if (!pre_alloc_enabled) 1999 if (!pre_alloc_enabled)
@@ -2061,10 +2067,10 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c,
2061 2067
2062 /* 2068 /*
2063 * ensure that all subsequent reads occur after checking 2069 * ensure that all subsequent reads occur after checking
2064 * that we have a valid node. see corresponding wmb in 2070 * that we have a valid node. see corresponding nvgpu_smp_wmb in
2065 * gk20a_channel_add_job(). 2071 * gk20a_channel_add_job().
2066 */ 2072 */
2067 rmb(); 2073 nvgpu_smp_rmb();
2068 job = channel_gk20a_joblist_peek(c); 2074 job = channel_gk20a_joblist_peek(c);
2069 channel_gk20a_joblist_unlock(c); 2075 channel_gk20a_joblist_unlock(c);
2070 2076
@@ -2127,9 +2133,9 @@ static void gk20a_channel_clean_up_jobs(struct channel_gk20a *c,
2127 2133
2128 /* 2134 /*
2129 * ensure all pending writes complete before freeing up the job. 2135 * ensure all pending writes complete before freeing up the job.
2130 * see corresponding rmb in channel_gk20a_alloc_job(). 2136 * see corresponding nvgpu_smp_rmb in channel_gk20a_alloc_job().
2131 */ 2137 */
2132 wmb(); 2138 nvgpu_smp_wmb();
2133 2139
2134 channel_gk20a_free_job(c, job); 2140 channel_gk20a_free_job(c, job);
2135 job_finished = 1; 2141 job_finished = 1;