Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * SN Platform GRU Driver |
| 3 | * |
| 4 | * FAULT HANDLER FOR GRU DETECTED TLB MISSES |
| 5 | * |
| 6 | * This file contains code that handles TLB misses within the GRU. |
| 7 | * These misses are reported either via interrupts or user polling of |
| 8 | * the user CB. |
| 9 | * |
| 10 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <linux/kernel.h> |
| 28 | #include <linux/errno.h> |
| 29 | #include <linux/spinlock.h> |
| 30 | #include <linux/mm.h> |
| 31 | #include <linux/hugetlb.h> |
| 32 | #include <linux/device.h> |
| 33 | #include <linux/io.h> |
| 34 | #include <linux/uaccess.h> |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 35 | #include <linux/security.h> |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 36 | #include <asm/pgtable.h> |
| 37 | #include "gru.h" |
| 38 | #include "grutables.h" |
| 39 | #include "grulib.h" |
| 40 | #include "gru_instructions.h" |
| 41 | #include <asm/uv/uv_hub.h> |
| 42 | |
| 43 | /* |
| 44 | * Test if a physical address is a valid GRU GSEG address |
| 45 | */ |
| 46 | static inline int is_gru_paddr(unsigned long paddr) |
| 47 | { |
| 48 | return paddr >= gru_start_paddr && paddr < gru_end_paddr; |
| 49 | } |
| 50 | |
| 51 | /* |
| 52 | * Find the vma of a GRU segment. Caller must hold mmap_sem. |
| 53 | */ |
| 54 | struct vm_area_struct *gru_find_vma(unsigned long vaddr) |
| 55 | { |
| 56 | struct vm_area_struct *vma; |
| 57 | |
| 58 | vma = find_vma(current->mm, vaddr); |
| 59 | if (vma && vma->vm_start <= vaddr && vma->vm_ops == &gru_vm_ops) |
| 60 | return vma; |
| 61 | return NULL; |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * Find and lock the gts that contains the specified user vaddr. |
| 66 | * |
| 67 | * Returns: |
| 68 | * - *gts with the mmap_sem locked for read and the GTS locked. |
| 69 | * - NULL if vaddr invalid OR is not a valid GSEG vaddr. |
| 70 | */ |
| 71 | |
| 72 | static struct gru_thread_state *gru_find_lock_gts(unsigned long vaddr) |
| 73 | { |
| 74 | struct mm_struct *mm = current->mm; |
| 75 | struct vm_area_struct *vma; |
| 76 | struct gru_thread_state *gts = NULL; |
| 77 | |
| 78 | down_read(&mm->mmap_sem); |
| 79 | vma = gru_find_vma(vaddr); |
| 80 | if (vma) |
| 81 | gts = gru_find_thread_state(vma, TSID(vaddr, vma)); |
| 82 | if (gts) |
| 83 | mutex_lock(>s->ts_ctxlock); |
| 84 | else |
| 85 | up_read(&mm->mmap_sem); |
| 86 | return gts; |
| 87 | } |
| 88 | |
| 89 | static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr) |
| 90 | { |
| 91 | struct mm_struct *mm = current->mm; |
| 92 | struct vm_area_struct *vma; |
Jack Steiner | e006043 | 2009-12-15 16:48:10 -0800 | [diff] [blame] | 93 | struct gru_thread_state *gts = ERR_PTR(-EINVAL); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 94 | |
| 95 | down_write(&mm->mmap_sem); |
| 96 | vma = gru_find_vma(vaddr); |
Jack Steiner | e006043 | 2009-12-15 16:48:10 -0800 | [diff] [blame] | 97 | if (!vma) |
| 98 | goto err; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 99 | |
Jack Steiner | e006043 | 2009-12-15 16:48:10 -0800 | [diff] [blame] | 100 | gts = gru_alloc_thread_state(vma, TSID(vaddr, vma)); |
| 101 | if (IS_ERR(gts)) |
| 102 | goto err; |
| 103 | mutex_lock(>s->ts_ctxlock); |
| 104 | downgrade_write(&mm->mmap_sem); |
| 105 | return gts; |
| 106 | |
| 107 | err: |
| 108 | up_write(&mm->mmap_sem); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 109 | return gts; |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * Unlock a GTS that was previously locked with gru_find_lock_gts(). |
| 114 | */ |
| 115 | static void gru_unlock_gts(struct gru_thread_state *gts) |
| 116 | { |
| 117 | mutex_unlock(>s->ts_ctxlock); |
| 118 | up_read(¤t->mm->mmap_sem); |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Set a CB.istatus to active using a user virtual address. This must be done |
| 123 | * just prior to a TFH RESTART. The new cb.istatus is an in-cache status ONLY. |
| 124 | * If the line is evicted, the status may be lost. The in-cache update |
| 125 | * is necessary to prevent the user from seeing a stale cb.istatus that will |
| 126 | * change as soon as the TFH restart is complete. Races may cause an |
| 127 | * occasional failure to clear the cb.istatus, but that is ok. |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 128 | */ |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 129 | static void gru_cb_set_istatus_active(struct gru_instruction_bits *cbk) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 130 | { |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 131 | if (cbk) { |
| 132 | cbk->istatus = CBS_ACTIVE; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Convert a interrupt IRQ to a pointer to the GRU GTS that caused the |
| 138 | * interrupt. Interrupts are always sent to a cpu on the blade that contains the |
| 139 | * GRU (except for headless blades which are not currently supported). A blade |
| 140 | * has N grus; a block of N consecutive IRQs is assigned to the GRUs. The IRQ |
| 141 | * number uniquely identifies the GRU chiplet on the local blade that caused the |
| 142 | * interrupt. Always called in interrupt context. |
| 143 | */ |
| 144 | static inline struct gru_state *irq_to_gru(int irq) |
| 145 | { |
| 146 | return &gru_base[uv_numa_blade_id()]->bs_grus[irq - IRQ_GRU]; |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Read & clear a TFM |
| 151 | * |
| 152 | * The GRU has an array of fault maps. A map is private to a cpu |
| 153 | * Only one cpu will be accessing a cpu's fault map. |
| 154 | * |
| 155 | * This function scans the cpu-private fault map & clears all bits that |
| 156 | * are set. The function returns a bitmap that indicates the bits that |
| 157 | * were cleared. Note that sense the maps may be updated asynchronously by |
| 158 | * the GRU, atomic operations must be used to clear bits. |
| 159 | */ |
| 160 | static void get_clear_fault_map(struct gru_state *gru, |
Jack Steiner | 4a7a17c | 2009-06-17 16:28:25 -0700 | [diff] [blame] | 161 | struct gru_tlb_fault_map *imap, |
| 162 | struct gru_tlb_fault_map *dmap) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 163 | { |
| 164 | unsigned long i, k; |
| 165 | struct gru_tlb_fault_map *tfm; |
| 166 | |
| 167 | tfm = get_tfm_for_cpu(gru, gru_cpu_fault_map_id()); |
| 168 | prefetchw(tfm); /* Helps on hardware, required for emulator */ |
| 169 | for (i = 0; i < BITS_TO_LONGS(GRU_NUM_CBE); i++) { |
| 170 | k = tfm->fault_bits[i]; |
| 171 | if (k) |
| 172 | k = xchg(&tfm->fault_bits[i], 0UL); |
Jack Steiner | 4a7a17c | 2009-06-17 16:28:25 -0700 | [diff] [blame] | 173 | imap->fault_bits[i] = k; |
| 174 | k = tfm->done_bits[i]; |
| 175 | if (k) |
| 176 | k = xchg(&tfm->done_bits[i], 0UL); |
| 177 | dmap->fault_bits[i] = k; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | /* |
| 181 | * Not functionally required but helps performance. (Required |
| 182 | * on emulator) |
| 183 | */ |
| 184 | gru_flush_cache(tfm); |
| 185 | } |
| 186 | |
| 187 | /* |
| 188 | * Atomic (interrupt context) & non-atomic (user context) functions to |
| 189 | * convert a vaddr into a physical address. The size of the page |
| 190 | * is returned in pageshift. |
| 191 | * returns: |
| 192 | * 0 - successful |
| 193 | * < 0 - error code |
| 194 | * 1 - (atomic only) try again in non-atomic context |
| 195 | */ |
| 196 | static int non_atomic_pte_lookup(struct vm_area_struct *vma, |
| 197 | unsigned long vaddr, int write, |
| 198 | unsigned long *paddr, int *pageshift) |
| 199 | { |
| 200 | struct page *page; |
| 201 | |
| 202 | /* ZZZ Need to handle HUGE pages */ |
| 203 | if (is_vm_hugetlb_page(vma)) |
| 204 | return -EFAULT; |
| 205 | *pageshift = PAGE_SHIFT; |
| 206 | if (get_user_pages |
| 207 | (current, current->mm, vaddr, 1, write, 0, &page, NULL) <= 0) |
| 208 | return -EFAULT; |
| 209 | *paddr = page_to_phys(page); |
| 210 | put_page(page); |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | /* |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 215 | * atomic_pte_lookup |
| 216 | * |
| 217 | * Convert a user virtual address to a physical address |
| 218 | * Only supports Intel large pages (2MB only) on x86_64. |
| 219 | * ZZZ - hugepage support is incomplete |
Jack Steiner | 923f7f6 | 2008-10-15 22:05:13 -0700 | [diff] [blame] | 220 | * |
| 221 | * NOTE: mmap_sem is already held on entry to this function. This |
| 222 | * guarantees existence of the page tables. |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 223 | */ |
| 224 | static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr, |
| 225 | int write, unsigned long *paddr, int *pageshift) |
| 226 | { |
| 227 | pgd_t *pgdp; |
| 228 | pmd_t *pmdp; |
| 229 | pud_t *pudp; |
| 230 | pte_t pte; |
| 231 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 232 | pgdp = pgd_offset(vma->vm_mm, vaddr); |
| 233 | if (unlikely(pgd_none(*pgdp))) |
| 234 | goto err; |
| 235 | |
| 236 | pudp = pud_offset(pgdp, vaddr); |
| 237 | if (unlikely(pud_none(*pudp))) |
| 238 | goto err; |
| 239 | |
| 240 | pmdp = pmd_offset(pudp, vaddr); |
| 241 | if (unlikely(pmd_none(*pmdp))) |
| 242 | goto err; |
| 243 | #ifdef CONFIG_X86_64 |
| 244 | if (unlikely(pmd_large(*pmdp))) |
| 245 | pte = *(pte_t *) pmdp; |
| 246 | else |
| 247 | #endif |
| 248 | pte = *pte_offset_kernel(pmdp, vaddr); |
| 249 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 250 | if (unlikely(!pte_present(pte) || |
| 251 | (write && (!pte_write(pte) || !pte_dirty(pte))))) |
| 252 | return 1; |
| 253 | |
| 254 | *paddr = pte_pfn(pte) << PAGE_SHIFT; |
Jack Steiner | 023a407 | 2008-12-09 10:51:32 -0600 | [diff] [blame] | 255 | #ifdef CONFIG_HUGETLB_PAGE |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 256 | *pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT; |
Jack Steiner | 023a407 | 2008-12-09 10:51:32 -0600 | [diff] [blame] | 257 | #else |
| 258 | *pageshift = PAGE_SHIFT; |
| 259 | #endif |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 260 | return 0; |
| 261 | |
| 262 | err: |
| 263 | local_irq_enable(); |
| 264 | return 1; |
| 265 | } |
| 266 | |
Jack Steiner | ecdaf2b | 2009-04-02 16:59:09 -0700 | [diff] [blame] | 267 | static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr, |
| 268 | int write, int atomic, unsigned long *gpa, int *pageshift) |
| 269 | { |
| 270 | struct mm_struct *mm = gts->ts_mm; |
| 271 | struct vm_area_struct *vma; |
| 272 | unsigned long paddr; |
| 273 | int ret, ps; |
| 274 | |
| 275 | vma = find_vma(mm, vaddr); |
| 276 | if (!vma) |
| 277 | goto inval; |
| 278 | |
| 279 | /* |
| 280 | * Atomic lookup is faster & usually works even if called in non-atomic |
| 281 | * context. |
| 282 | */ |
| 283 | rmb(); /* Must/check ms_range_active before loading PTEs */ |
| 284 | ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &ps); |
| 285 | if (ret) { |
| 286 | if (atomic) |
| 287 | goto upm; |
| 288 | if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps)) |
| 289 | goto inval; |
| 290 | } |
| 291 | if (is_gru_paddr(paddr)) |
| 292 | goto inval; |
| 293 | paddr = paddr & ~((1UL << ps) - 1); |
| 294 | *gpa = uv_soc_phys_ram_to_gpa(paddr); |
| 295 | *pageshift = ps; |
| 296 | return 0; |
| 297 | |
| 298 | inval: |
| 299 | return -1; |
| 300 | upm: |
| 301 | return -2; |
| 302 | } |
| 303 | |
| 304 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 305 | /* |
| 306 | * Drop a TLB entry into the GRU. The fault is described by info in an TFH. |
| 307 | * Input: |
| 308 | * cb Address of user CBR. Null if not running in user context |
| 309 | * Return: |
| 310 | * 0 = dropin, exception, or switch to UPM successful |
| 311 | * 1 = range invalidate active |
| 312 | * < 0 = error code |
| 313 | * |
| 314 | */ |
| 315 | static int gru_try_dropin(struct gru_thread_state *gts, |
| 316 | struct gru_tlb_fault_handle *tfh, |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 317 | struct gru_instruction_bits *cbk) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 318 | { |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 319 | int pageshift = 0, asid, write, ret, atomic = !cbk; |
Jack Steiner | ecdaf2b | 2009-04-02 16:59:09 -0700 | [diff] [blame] | 320 | unsigned long gpa = 0, vaddr = 0; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * NOTE: The GRU contains magic hardware that eliminates races between |
| 324 | * TLB invalidates and TLB dropins. If an invalidate occurs |
| 325 | * in the window between reading the TFH and the subsequent TLB dropin, |
| 326 | * the dropin is ignored. This eliminates the need for additional locks. |
| 327 | */ |
| 328 | |
| 329 | /* |
| 330 | * Error if TFH state is IDLE or FMM mode & the user issuing a UPM call. |
| 331 | * Might be a hardware race OR a stupid user. Ignore FMM because FMM |
| 332 | * is a transient state. |
| 333 | */ |
Jack Steiner | 270952a | 2009-06-17 16:28:27 -0700 | [diff] [blame] | 334 | if (tfh->status != TFHSTATUS_EXCEPTION) { |
| 335 | gru_flush_cache(tfh); |
Jack Steiner | 67bf04a | 2009-12-15 16:48:11 -0800 | [diff] [blame^] | 336 | sync_core(); |
Jack Steiner | 270952a | 2009-06-17 16:28:27 -0700 | [diff] [blame] | 337 | if (tfh->status != TFHSTATUS_EXCEPTION) |
| 338 | goto failnoexception; |
| 339 | STAT(tfh_stale_on_fault); |
| 340 | } |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 341 | if (tfh->state == TFHSTATE_IDLE) |
| 342 | goto failidle; |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 343 | if (tfh->state == TFHSTATE_MISS_FMM && cbk) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 344 | goto failfmm; |
| 345 | |
| 346 | write = (tfh->cause & TFHCAUSE_TLB_MOD) != 0; |
| 347 | vaddr = tfh->missvaddr; |
| 348 | asid = tfh->missasid; |
| 349 | if (asid == 0) |
| 350 | goto failnoasid; |
| 351 | |
| 352 | rmb(); /* TFH must be cache resident before reading ms_range_active */ |
| 353 | |
| 354 | /* |
| 355 | * TFH is cache resident - at least briefly. Fail the dropin |
| 356 | * if a range invalidate is active. |
| 357 | */ |
| 358 | if (atomic_read(>s->ts_gms->ms_range_active)) |
| 359 | goto failactive; |
| 360 | |
Jack Steiner | ecdaf2b | 2009-04-02 16:59:09 -0700 | [diff] [blame] | 361 | ret = gru_vtop(gts, vaddr, write, atomic, &gpa, &pageshift); |
| 362 | if (ret == -1) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 363 | goto failinval; |
Jack Steiner | ecdaf2b | 2009-04-02 16:59:09 -0700 | [diff] [blame] | 364 | if (ret == -2) |
| 365 | goto failupm; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 366 | |
Jack Steiner | 7b8274e | 2009-04-02 16:59:12 -0700 | [diff] [blame] | 367 | if (!(gts->ts_sizeavail & GRU_SIZEAVAIL(pageshift))) { |
| 368 | gts->ts_sizeavail |= GRU_SIZEAVAIL(pageshift); |
Jack Steiner | 99f7c22 | 2009-12-15 16:48:06 -0800 | [diff] [blame] | 369 | if (atomic || !gru_update_cch(gts)) { |
Jack Steiner | 7b8274e | 2009-04-02 16:59:12 -0700 | [diff] [blame] | 370 | gts->ts_force_cch_reload = 1; |
| 371 | goto failupm; |
| 372 | } |
| 373 | } |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 374 | gru_cb_set_istatus_active(cbk); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 375 | tfh_write_restart(tfh, gpa, GAA_RAM, vaddr, asid, write, |
| 376 | GRU_PAGESIZE(pageshift)); |
| 377 | STAT(tlb_dropin); |
| 378 | gru_dbg(grudev, |
| 379 | "%s: tfh 0x%p, vaddr 0x%lx, asid 0x%x, ps %d, gpa 0x%lx\n", |
| 380 | ret ? "non-atomic" : "atomic", tfh, vaddr, asid, |
| 381 | pageshift, gpa); |
| 382 | return 0; |
| 383 | |
| 384 | failnoasid: |
| 385 | /* No asid (delayed unload). */ |
| 386 | STAT(tlb_dropin_fail_no_asid); |
| 387 | gru_dbg(grudev, "FAILED no_asid tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr); |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 388 | if (!cbk) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 389 | tfh_user_polling_mode(tfh); |
| 390 | else |
| 391 | gru_flush_cache(tfh); |
| 392 | return -EAGAIN; |
| 393 | |
| 394 | failupm: |
| 395 | /* Atomic failure switch CBR to UPM */ |
| 396 | tfh_user_polling_mode(tfh); |
| 397 | STAT(tlb_dropin_fail_upm); |
| 398 | gru_dbg(grudev, "FAILED upm tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr); |
| 399 | return 1; |
| 400 | |
| 401 | failfmm: |
| 402 | /* FMM state on UPM call */ |
Jack Steiner | fe5bb6b | 2009-04-02 16:59:04 -0700 | [diff] [blame] | 403 | gru_flush_cache(tfh); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 404 | STAT(tlb_dropin_fail_fmm); |
| 405 | gru_dbg(grudev, "FAILED fmm tfh: 0x%p, state %d\n", tfh, tfh->state); |
| 406 | return 0; |
| 407 | |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 408 | failnoexception: |
| 409 | /* TFH status did not show exception pending */ |
| 410 | gru_flush_cache(tfh); |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 411 | if (cbk) |
| 412 | gru_flush_cache(cbk); |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 413 | STAT(tlb_dropin_fail_no_exception); |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 414 | gru_dbg(grudev, "FAILED non-exception tfh: 0x%p, status %d, state %d\n", |
| 415 | tfh, tfh->status, tfh->state); |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 416 | return 0; |
| 417 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 418 | failidle: |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 419 | /* TFH state was idle - no miss pending */ |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 420 | gru_flush_cache(tfh); |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 421 | if (cbk) |
| 422 | gru_flush_cache(cbk); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 423 | STAT(tlb_dropin_fail_idle); |
| 424 | gru_dbg(grudev, "FAILED idle tfh: 0x%p, state %d\n", tfh, tfh->state); |
| 425 | return 0; |
| 426 | |
| 427 | failinval: |
| 428 | /* All errors (atomic & non-atomic) switch CBR to EXCEPTION state */ |
| 429 | tfh_exception(tfh); |
| 430 | STAT(tlb_dropin_fail_invalid); |
| 431 | gru_dbg(grudev, "FAILED inval tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr); |
| 432 | return -EFAULT; |
| 433 | |
| 434 | failactive: |
| 435 | /* Range invalidate active. Switch to UPM iff atomic */ |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 436 | if (!cbk) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 437 | tfh_user_polling_mode(tfh); |
| 438 | else |
| 439 | gru_flush_cache(tfh); |
| 440 | STAT(tlb_dropin_fail_range_active); |
| 441 | gru_dbg(grudev, "FAILED range active: tfh 0x%p, vaddr 0x%lx\n", |
| 442 | tfh, vaddr); |
| 443 | return 1; |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | * Process an external interrupt from the GRU. This interrupt is |
| 448 | * caused by a TLB miss. |
| 449 | * Note that this is the interrupt handler that is registered with linux |
| 450 | * interrupt handlers. |
| 451 | */ |
| 452 | irqreturn_t gru_intr(int irq, void *dev_id) |
| 453 | { |
| 454 | struct gru_state *gru; |
Jack Steiner | 4a7a17c | 2009-06-17 16:28:25 -0700 | [diff] [blame] | 455 | struct gru_tlb_fault_map imap, dmap; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 456 | struct gru_thread_state *gts; |
| 457 | struct gru_tlb_fault_handle *tfh = NULL; |
| 458 | int cbrnum, ctxnum; |
| 459 | |
| 460 | STAT(intr); |
| 461 | |
| 462 | gru = irq_to_gru(irq); |
| 463 | if (!gru) { |
| 464 | dev_err(grudev, "GRU: invalid interrupt: cpu %d, irq %d\n", |
| 465 | raw_smp_processor_id(), irq); |
| 466 | return IRQ_NONE; |
| 467 | } |
Jack Steiner | 4a7a17c | 2009-06-17 16:28:25 -0700 | [diff] [blame] | 468 | get_clear_fault_map(gru, &imap, &dmap); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 469 | |
Jack Steiner | 4a7a17c | 2009-06-17 16:28:25 -0700 | [diff] [blame] | 470 | for_each_cbr_in_tfm(cbrnum, dmap.fault_bits) { |
| 471 | complete(gru->gs_blade->bs_async_wq); |
| 472 | gru_dbg(grudev, "gid %d, cbr_done %d, done %d\n", |
| 473 | gru->gs_gid, cbrnum, gru->gs_blade->bs_async_wq->done); |
| 474 | } |
| 475 | |
| 476 | for_each_cbr_in_tfm(cbrnum, imap.fault_bits) { |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 477 | tfh = get_tfh_by_index(gru, cbrnum); |
| 478 | prefetchw(tfh); /* Helps on hdw, required for emulator */ |
| 479 | |
| 480 | /* |
| 481 | * When hardware sets a bit in the faultmap, it implicitly |
| 482 | * locks the GRU context so that it cannot be unloaded. |
| 483 | * The gts cannot change until a TFH start/writestart command |
| 484 | * is issued. |
| 485 | */ |
| 486 | ctxnum = tfh->ctxnum; |
| 487 | gts = gru->gs_gts[ctxnum]; |
| 488 | |
| 489 | /* |
| 490 | * This is running in interrupt context. Trylock the mmap_sem. |
| 491 | * If it fails, retry the fault in user context. |
| 492 | */ |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 493 | if (!gts->ts_force_cch_reload && |
| 494 | down_read_trylock(>s->ts_mm->mmap_sem)) { |
Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 495 | gts->ustats.fmm_tlbdropin++; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 496 | gru_try_dropin(gts, tfh, NULL); |
| 497 | up_read(>s->ts_mm->mmap_sem); |
| 498 | } else { |
| 499 | tfh_user_polling_mode(tfh); |
Jack Steiner | 4388460 | 2009-04-02 16:59:05 -0700 | [diff] [blame] | 500 | STAT(intr_mm_lock_failed); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 501 | } |
| 502 | } |
| 503 | return IRQ_HANDLED; |
| 504 | } |
| 505 | |
| 506 | |
| 507 | static int gru_user_dropin(struct gru_thread_state *gts, |
| 508 | struct gru_tlb_fault_handle *tfh, |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 509 | void *cb) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 510 | { |
| 511 | struct gru_mm_struct *gms = gts->ts_gms; |
| 512 | int ret; |
| 513 | |
Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 514 | gts->ustats.upm_tlbdropin++; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 515 | while (1) { |
| 516 | wait_event(gms->ms_wait_queue, |
| 517 | atomic_read(&gms->ms_range_active) == 0); |
| 518 | prefetchw(tfh); /* Helps on hdw, required for emulator */ |
| 519 | ret = gru_try_dropin(gts, tfh, cb); |
| 520 | if (ret <= 0) |
| 521 | return ret; |
| 522 | STAT(call_os_wait_queue); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | /* |
| 527 | * This interface is called as a result of a user detecting a "call OS" bit |
| 528 | * in a user CB. Normally means that a TLB fault has occurred. |
| 529 | * cb - user virtual address of the CB |
| 530 | */ |
| 531 | int gru_handle_user_call_os(unsigned long cb) |
| 532 | { |
| 533 | struct gru_tlb_fault_handle *tfh; |
| 534 | struct gru_thread_state *gts; |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 535 | void *cbk; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 536 | int ucbnum, cbrnum, ret = -EINVAL; |
| 537 | |
| 538 | STAT(call_os); |
| 539 | gru_dbg(grudev, "address 0x%lx\n", cb); |
| 540 | |
| 541 | /* sanity check the cb pointer */ |
| 542 | ucbnum = get_cb_number((void *)cb); |
| 543 | if ((cb & (GRU_HANDLE_STRIDE - 1)) || ucbnum >= GRU_NUM_CB) |
| 544 | return -EINVAL; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 545 | |
| 546 | gts = gru_find_lock_gts(cb); |
| 547 | if (!gts) |
| 548 | return -EINVAL; |
| 549 | |
Jack Steiner | fe5bb6b | 2009-04-02 16:59:04 -0700 | [diff] [blame] | 550 | if (ucbnum >= gts->ts_cbr_au_count * GRU_CBR_AU_SIZE) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 551 | goto exit; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 552 | |
Jack Steiner | 55484c4 | 2009-12-15 16:48:05 -0800 | [diff] [blame] | 553 | gru_check_context_placement(gts); |
Jack Steiner | fe5bb6b | 2009-04-02 16:59:04 -0700 | [diff] [blame] | 554 | |
Jack Steiner | 7b8274e | 2009-04-02 16:59:12 -0700 | [diff] [blame] | 555 | /* |
| 556 | * CCH may contain stale data if ts_force_cch_reload is set. |
| 557 | */ |
| 558 | if (gts->ts_gru && gts->ts_force_cch_reload) { |
Jack Steiner | 7b8274e | 2009-04-02 16:59:12 -0700 | [diff] [blame] | 559 | gts->ts_force_cch_reload = 0; |
Jack Steiner | 99f7c22 | 2009-12-15 16:48:06 -0800 | [diff] [blame] | 560 | gru_update_cch(gts); |
Jack Steiner | 7b8274e | 2009-04-02 16:59:12 -0700 | [diff] [blame] | 561 | } |
| 562 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 563 | ret = -EAGAIN; |
| 564 | cbrnum = thread_cbr_number(gts, ucbnum); |
Jack Steiner | 99f7c22 | 2009-12-15 16:48:06 -0800 | [diff] [blame] | 565 | if (gts->ts_gru) { |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 566 | tfh = get_tfh_by_index(gts->ts_gru, cbrnum); |
Jack Steiner | b61fc69 | 2009-12-15 16:48:03 -0800 | [diff] [blame] | 567 | cbk = get_gseg_base_address_cb(gts->ts_gru->gs_gru_base_vaddr, |
| 568 | gts->ts_ctxnum, ucbnum); |
| 569 | ret = gru_user_dropin(gts, tfh, cbk); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 570 | } |
| 571 | exit: |
| 572 | gru_unlock_gts(gts); |
| 573 | return ret; |
| 574 | } |
| 575 | |
| 576 | /* |
| 577 | * Fetch the exception detail information for a CB that terminated with |
| 578 | * an exception. |
| 579 | */ |
| 580 | int gru_get_exception_detail(unsigned long arg) |
| 581 | { |
| 582 | struct control_block_extended_exc_detail excdet; |
| 583 | struct gru_control_block_extended *cbe; |
| 584 | struct gru_thread_state *gts; |
| 585 | int ucbnum, cbrnum, ret; |
| 586 | |
| 587 | STAT(user_exception); |
| 588 | if (copy_from_user(&excdet, (void __user *)arg, sizeof(excdet))) |
| 589 | return -EFAULT; |
| 590 | |
| 591 | gru_dbg(grudev, "address 0x%lx\n", excdet.cb); |
| 592 | gts = gru_find_lock_gts(excdet.cb); |
| 593 | if (!gts) |
| 594 | return -EINVAL; |
| 595 | |
Jack Steiner | fe5bb6b | 2009-04-02 16:59:04 -0700 | [diff] [blame] | 596 | ucbnum = get_cb_number((void *)excdet.cb); |
| 597 | if (ucbnum >= gts->ts_cbr_au_count * GRU_CBR_AU_SIZE) { |
| 598 | ret = -EINVAL; |
| 599 | } else if (gts->ts_gru) { |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 600 | cbrnum = thread_cbr_number(gts, ucbnum); |
| 601 | cbe = get_cbe_by_index(gts->ts_gru, cbrnum); |
Jack Steiner | 1a2c09e | 2009-06-17 16:28:28 -0700 | [diff] [blame] | 602 | gru_flush_cache(cbe); /* CBE not coherent */ |
Jack Steiner | 67bf04a | 2009-12-15 16:48:11 -0800 | [diff] [blame^] | 603 | sync_core(); /* make sure we are have current data */ |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 604 | excdet.opc = cbe->opccpy; |
| 605 | excdet.exopc = cbe->exopccpy; |
| 606 | excdet.ecause = cbe->ecause; |
| 607 | excdet.exceptdet0 = cbe->idef1upd; |
| 608 | excdet.exceptdet1 = cbe->idef3upd; |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 609 | excdet.cbrstate = cbe->cbrstate; |
| 610 | excdet.cbrexecstatus = cbe->cbrexecstatus; |
Jack Steiner | 1a2c09e | 2009-06-17 16:28:28 -0700 | [diff] [blame] | 611 | gru_flush_cache(cbe); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 612 | ret = 0; |
| 613 | } else { |
| 614 | ret = -EAGAIN; |
| 615 | } |
| 616 | gru_unlock_gts(gts); |
| 617 | |
Jack Steiner | cd1334f | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 618 | gru_dbg(grudev, |
| 619 | "cb 0x%lx, op %d, exopc %d, cbrstate %d, cbrexecstatus 0x%x, ecause 0x%x, " |
| 620 | "exdet0 0x%lx, exdet1 0x%x\n", |
| 621 | excdet.cb, excdet.opc, excdet.exopc, excdet.cbrstate, excdet.cbrexecstatus, |
| 622 | excdet.ecause, excdet.exceptdet0, excdet.exceptdet1); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 623 | if (!ret && copy_to_user((void __user *)arg, &excdet, sizeof(excdet))) |
| 624 | ret = -EFAULT; |
| 625 | return ret; |
| 626 | } |
| 627 | |
| 628 | /* |
| 629 | * User request to unload a context. Content is saved for possible reload. |
| 630 | */ |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 631 | static int gru_unload_all_contexts(void) |
| 632 | { |
| 633 | struct gru_thread_state *gts; |
| 634 | struct gru_state *gru; |
Jack Steiner | e1c3219 | 2009-04-02 16:59:10 -0700 | [diff] [blame] | 635 | int gid, ctxnum; |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 636 | |
| 637 | if (!capable(CAP_SYS_ADMIN)) |
| 638 | return -EPERM; |
Jack Steiner | e1c3219 | 2009-04-02 16:59:10 -0700 | [diff] [blame] | 639 | foreach_gid(gid) { |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 640 | gru = GID_TO_GRU(gid); |
| 641 | spin_lock(&gru->gs_lock); |
| 642 | for (ctxnum = 0; ctxnum < GRU_NUM_CCH; ctxnum++) { |
| 643 | gts = gru->gs_gts[ctxnum]; |
| 644 | if (gts && mutex_trylock(>s->ts_ctxlock)) { |
| 645 | spin_unlock(&gru->gs_lock); |
| 646 | gru_unload_context(gts, 1); |
Jack Steiner | d57c82b | 2009-06-17 16:28:20 -0700 | [diff] [blame] | 647 | mutex_unlock(>s->ts_ctxlock); |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 648 | spin_lock(&gru->gs_lock); |
| 649 | } |
| 650 | } |
| 651 | spin_unlock(&gru->gs_lock); |
| 652 | } |
| 653 | return 0; |
| 654 | } |
| 655 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 656 | int gru_user_unload_context(unsigned long arg) |
| 657 | { |
| 658 | struct gru_thread_state *gts; |
| 659 | struct gru_unload_context_req req; |
| 660 | |
| 661 | STAT(user_unload_context); |
| 662 | if (copy_from_user(&req, (void __user *)arg, sizeof(req))) |
| 663 | return -EFAULT; |
| 664 | |
| 665 | gru_dbg(grudev, "gseg 0x%lx\n", req.gseg); |
| 666 | |
Jack Steiner | bb04aa7 | 2009-04-02 16:59:07 -0700 | [diff] [blame] | 667 | if (!req.gseg) |
| 668 | return gru_unload_all_contexts(); |
| 669 | |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 670 | gts = gru_find_lock_gts(req.gseg); |
| 671 | if (!gts) |
| 672 | return -EINVAL; |
| 673 | |
| 674 | if (gts->ts_gru) |
| 675 | gru_unload_context(gts, 1); |
| 676 | gru_unlock_gts(gts); |
| 677 | |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | /* |
| 682 | * User request to flush a range of virtual addresses from the GRU TLB |
| 683 | * (Mainly for testing). |
| 684 | */ |
| 685 | int gru_user_flush_tlb(unsigned long arg) |
| 686 | { |
| 687 | struct gru_thread_state *gts; |
| 688 | struct gru_flush_tlb_req req; |
Jack Steiner | 1926ee8 | 2009-06-17 16:28:33 -0700 | [diff] [blame] | 689 | struct gru_mm_struct *gms; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 690 | |
| 691 | STAT(user_flush_tlb); |
| 692 | if (copy_from_user(&req, (void __user *)arg, sizeof(req))) |
| 693 | return -EFAULT; |
| 694 | |
| 695 | gru_dbg(grudev, "gseg 0x%lx, vaddr 0x%lx, len 0x%lx\n", req.gseg, |
| 696 | req.vaddr, req.len); |
| 697 | |
| 698 | gts = gru_find_lock_gts(req.gseg); |
| 699 | if (!gts) |
| 700 | return -EINVAL; |
| 701 | |
Jack Steiner | 1926ee8 | 2009-06-17 16:28:33 -0700 | [diff] [blame] | 702 | gms = gts->ts_gms; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 703 | gru_unlock_gts(gts); |
Jack Steiner | 1926ee8 | 2009-06-17 16:28:33 -0700 | [diff] [blame] | 704 | gru_flush_tlb_range(gms, req.vaddr, req.len); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | /* |
Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 710 | * Fetch GSEG statisticss |
| 711 | */ |
| 712 | long gru_get_gseg_statistics(unsigned long arg) |
| 713 | { |
| 714 | struct gru_thread_state *gts; |
| 715 | struct gru_get_gseg_statistics_req req; |
| 716 | |
| 717 | if (copy_from_user(&req, (void __user *)arg, sizeof(req))) |
| 718 | return -EFAULT; |
| 719 | |
Jack Steiner | 091f1a1 | 2009-12-15 16:48:02 -0800 | [diff] [blame] | 720 | /* |
| 721 | * The library creates arrays of contexts for threaded programs. |
| 722 | * If no gts exists in the array, the context has never been used & all |
| 723 | * statistics are implicitly 0. |
| 724 | */ |
Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 725 | gts = gru_find_lock_gts(req.gseg); |
| 726 | if (gts) { |
| 727 | memcpy(&req.stats, >s->ustats, sizeof(gts->ustats)); |
| 728 | gru_unlock_gts(gts); |
| 729 | } else { |
| 730 | memset(&req.stats, 0, sizeof(gts->ustats)); |
| 731 | } |
| 732 | |
| 733 | if (copy_to_user((void __user *)arg, &req, sizeof(req))) |
| 734 | return -EFAULT; |
| 735 | |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | /* |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 740 | * Register the current task as the user of the GSEG slice. |
| 741 | * Needed for TLB fault interrupt targeting. |
| 742 | */ |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 743 | int gru_set_context_option(unsigned long arg) |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 744 | { |
| 745 | struct gru_thread_state *gts; |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 746 | struct gru_set_context_option_req req; |
| 747 | int ret = 0; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 748 | |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 749 | STAT(set_context_option); |
| 750 | if (copy_from_user(&req, (void __user *)arg, sizeof(req))) |
| 751 | return -EFAULT; |
| 752 | gru_dbg(grudev, "op %d, gseg 0x%lx, value1 0x%lx\n", req.op, req.gseg, req.val1); |
| 753 | |
| 754 | gts = gru_alloc_locked_gts(req.gseg); |
Jack Steiner | 7f2251b | 2009-12-15 16:48:08 -0800 | [diff] [blame] | 755 | if (IS_ERR(gts)) |
| 756 | return PTR_ERR(gts); |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 757 | |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 758 | switch (req.op) { |
Jack Steiner | 518e5cd | 2009-12-15 16:48:04 -0800 | [diff] [blame] | 759 | case sco_blade_chiplet: |
| 760 | /* Select blade/chiplet for GRU context */ |
| 761 | if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] || |
| 762 | req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) { |
| 763 | ret = -EINVAL; |
| 764 | } else { |
| 765 | gts->ts_user_blade_id = req.val1; |
| 766 | gts->ts_user_chiplet_id = req.val0; |
Jack Steiner | 55484c4 | 2009-12-15 16:48:05 -0800 | [diff] [blame] | 767 | gru_check_context_placement(gts); |
Jack Steiner | 518e5cd | 2009-12-15 16:48:04 -0800 | [diff] [blame] | 768 | } |
| 769 | break; |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 770 | case sco_gseg_owner: |
| 771 | /* Register the current task as the GSEG owner */ |
| 772 | gts->ts_tgid_owner = current->tgid; |
| 773 | break; |
Jack Steiner | b1b19fc | 2009-06-17 16:28:33 -0700 | [diff] [blame] | 774 | case sco_cch_req_slice: |
| 775 | /* Set the CCH slice option */ |
| 776 | gts->ts_cch_req_slice = req.val1 & 3; |
| 777 | break; |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 778 | default: |
| 779 | ret = -EINVAL; |
| 780 | } |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 781 | gru_unlock_gts(gts); |
| 782 | |
Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 783 | return ret; |
Jack Steiner | 1425864 | 2008-07-29 22:33:57 -0700 | [diff] [blame] | 784 | } |