23 #include <linux/kernel.h>
28 #include <linux/bitops.h>
29 #include <asm/uv/uv_hub.h>
35 #define CCH_LOCK_ATTEMPTS 10
37 static int gru_user_copy_handle(
void __user **
dp,
void *
s)
45 static int gru_dump_context_data(
void *grubase,
47 void __user *ubuf,
int ctxnum,
int dsrcnt,
50 void *
cb, *cbe, *tfh, *gseg;
61 if (gru_user_copy_handle(&ubuf, cb))
65 if (gru_user_copy_handle(&ubuf, cbe + i * GRU_HANDLE_STRIDE))
77 static int gru_dump_tfm(
struct gru_state *gru,
78 void __user *ubuf,
void __user *ubufend)
84 if (bytes > ubufend - ubuf)
89 if (gru_user_copy_handle(&ubuf, tfm))
98 static int gru_dump_tgh(
struct gru_state *gru,
99 void __user *ubuf,
void __user *ubufend)
105 if (bytes > ubufend - ubuf)
110 if (gru_user_copy_handle(&ubuf, tgh))
119 static int gru_dump_context(
struct gru_state *gru,
int ctxnum,
120 void __user *ubuf,
void __user *ubufend,
char data_opt,
121 char lock_cch,
char flush_cbrs)
127 int try, cch_locked, cbrcnt = 0, dsrcnt = 0, bytes = 0, ret = 0;
132 cch = get_cch(grubase, ctxnum);
134 cch_locked = trylock_cch_handle(cch);
142 if (gru_user_copy_handle(&ubuf, cch))
146 bytes =
sizeof(
hdr) + GRU_CACHE_LINE_BYTES;
148 if (cch_locked || !lock_cch) {
149 gts = gru->
gs_gts[ctxnum];
160 bytes += (3 * cbrcnt + dsrcnt) * GRU_CACHE_LINE_BYTES;
161 if (bytes > ubufend - ubuf)
164 ret = gru_dump_context_data(grubase, cch, ubuf, ctxnum,
168 unlock_cch_handle(cch);
177 hdr.cch_locked = cch_locked;
181 return ret ? ret :
bytes;
184 unlock_cch_handle(cch);
207 ret = gru_dump_tfm(gru, ubuf, ubufend);
212 ret = gru_dump_tgh(gru, ubuf, ubufend);
219 ret = gru_dump_context(gru, ctxnum, ubuf, ubufend,