diff options
Diffstat (limited to 'drivers/misc/sgi-gru/gruhandles.h')
-rw-r--r-- | drivers/misc/sgi-gru/gruhandles.h | 176 |
1 files changed, 17 insertions, 159 deletions
diff --git a/drivers/misc/sgi-gru/gruhandles.h b/drivers/misc/sgi-gru/gruhandles.h index fb72a52a34a8..dfce8ea5da24 100644 --- a/drivers/misc/sgi-gru/gruhandles.h +++ b/drivers/misc/sgi-gru/gruhandles.h | |||
@@ -495,164 +495,22 @@ enum gru_cbr_state { | |||
495 | /* minimum TLB purge count to ensure a full purge */ | 495 | /* minimum TLB purge count to ensure a full purge */ |
496 | #define GRUMAXINVAL 1024UL | 496 | #define GRUMAXINVAL 1024UL |
497 | 497 | ||
498 | 498 | int cch_allocate(struct gru_context_configuration_handle *cch, | |
499 | /* Extract the status field from a kernel handle */ | 499 | int asidval, unsigned long cbrmap, unsigned long dsrmap); |
500 | #define GET_MSEG_HANDLE_STATUS(h) (((*(unsigned long *)(h)) >> 16) & 3) | 500 | |
501 | 501 | int cch_start(struct gru_context_configuration_handle *cch); | |
502 | static inline void start_instruction(void *h) | 502 | int cch_interrupt(struct gru_context_configuration_handle *cch); |
503 | { | 503 | int cch_deallocate(struct gru_context_configuration_handle *cch); |
504 | unsigned long *w0 = h; | 504 | int cch_interrupt_sync(struct gru_context_configuration_handle *cch); |
505 | 505 | int tgh_invalidate(struct gru_tlb_global_handle *tgh, unsigned long vaddr, | |
506 | wmb(); /* setting CMD bit must be last */ | 506 | unsigned long vaddrmask, int asid, int pagesize, int global, int n, |
507 | *w0 = *w0 | 1; | 507 | unsigned short ctxbitmap); |
508 | gru_flush_cache(h); | 508 | void tfh_write_only(struct gru_tlb_fault_handle *tfh, unsigned long pfn, |
509 | } | 509 | unsigned long vaddr, int asid, int dirty, int pagesize); |
510 | 510 | void tfh_write_restart(struct gru_tlb_fault_handle *tfh, unsigned long paddr, | |
511 | static inline int wait_instruction_complete(void *h) | 511 | int gaa, unsigned long vaddr, int asid, int dirty, int pagesize); |
512 | { | 512 | void tfh_restart(struct gru_tlb_fault_handle *tfh); |
513 | int status; | 513 | void tfh_user_polling_mode(struct gru_tlb_fault_handle *tfh); |
514 | 514 | void tfh_exception(struct gru_tlb_fault_handle *tfh); | |
515 | do { | ||
516 | cpu_relax(); | ||
517 | barrier(); | ||
518 | status = GET_MSEG_HANDLE_STATUS(h); | ||
519 | } while (status == CCHSTATUS_ACTIVE); | ||
520 | return status; | ||
521 | } | ||
522 | |||
523 | #if defined CONFIG_IA64 | ||
524 | static inline void cch_allocate_set_asids( | ||
525 | struct gru_context_configuration_handle *cch, int asidval) | ||
526 | { | ||
527 | int i; | ||
528 | |||
529 | for (i = 0; i <= RGN_HPAGE; i++) { /* assume HPAGE is last region */ | ||
530 | cch->asid[i] = (asidval++); | ||
531 | #if 0 | ||
532 | /* ZZZ hugepages not supported yet */ | ||
533 | if (i == RGN_HPAGE) | ||
534 | cch->sizeavail[i] = GRU_SIZEAVAIL(hpage_shift); | ||
535 | else | ||
536 | #endif | ||
537 | cch->sizeavail[i] = GRU_SIZEAVAIL(PAGE_SHIFT); | ||
538 | } | ||
539 | } | ||
540 | #elif defined CONFIG_X86_64 | ||
541 | static inline void cch_allocate_set_asids( | ||
542 | struct gru_context_configuration_handle *cch, int asidval) | ||
543 | { | ||
544 | int i; | ||
545 | |||
546 | for (i = 0; i < 8; i++) { | ||
547 | cch->asid[i] = asidval++; | ||
548 | cch->sizeavail[i] = GRU_SIZEAVAIL(PAGE_SHIFT) | | ||
549 | GRU_SIZEAVAIL(21); | ||
550 | } | ||
551 | } | ||
552 | #endif | ||
553 | |||
554 | static inline int cch_allocate(struct gru_context_configuration_handle *cch, | ||
555 | int asidval, unsigned long cbrmap, | ||
556 | unsigned long dsrmap) | ||
557 | { | ||
558 | cch_allocate_set_asids(cch, asidval); | ||
559 | cch->dsr_allocation_map = dsrmap; | ||
560 | cch->cbr_allocation_map = cbrmap; | ||
561 | cch->opc = CCHOP_ALLOCATE; | ||
562 | start_instruction(cch); | ||
563 | return wait_instruction_complete(cch); | ||
564 | } | ||
565 | |||
566 | static inline int cch_start(struct gru_context_configuration_handle *cch) | ||
567 | { | ||
568 | cch->opc = CCHOP_START; | ||
569 | start_instruction(cch); | ||
570 | return wait_instruction_complete(cch); | ||
571 | } | ||
572 | |||
573 | static inline int cch_interrupt(struct gru_context_configuration_handle *cch) | ||
574 | { | ||
575 | cch->opc = CCHOP_INTERRUPT; | ||
576 | start_instruction(cch); | ||
577 | return wait_instruction_complete(cch); | ||
578 | } | ||
579 | |||
580 | static inline int cch_deallocate(struct gru_context_configuration_handle *cch) | ||
581 | { | ||
582 | cch->opc = CCHOP_DEALLOCATE; | ||
583 | start_instruction(cch); | ||
584 | return wait_instruction_complete(cch); | ||
585 | } | ||
586 | |||
587 | static inline int cch_interrupt_sync(struct gru_context_configuration_handle | ||
588 | *cch) | ||
589 | { | ||
590 | cch->opc = CCHOP_INTERRUPT_SYNC; | ||
591 | start_instruction(cch); | ||
592 | return wait_instruction_complete(cch); | ||
593 | } | ||
594 | |||
595 | static inline int tgh_invalidate(struct gru_tlb_global_handle *tgh, | ||
596 | unsigned long vaddr, unsigned long vaddrmask, | ||
597 | int asid, int pagesize, int global, int n, | ||
598 | unsigned short ctxbitmap) | ||
599 | { | ||
600 | tgh->vaddr = vaddr; | ||
601 | tgh->asid = asid; | ||
602 | tgh->pagesize = pagesize; | ||
603 | tgh->n = n; | ||
604 | tgh->global = global; | ||
605 | tgh->vaddrmask = vaddrmask; | ||
606 | tgh->ctxbitmap = ctxbitmap; | ||
607 | tgh->opc = TGHOP_TLBINV; | ||
608 | start_instruction(tgh); | ||
609 | return wait_instruction_complete(tgh); | ||
610 | } | ||
611 | |||
612 | static inline void tfh_write_only(struct gru_tlb_fault_handle *tfh, | ||
613 | unsigned long pfn, unsigned long vaddr, | ||
614 | int asid, int dirty, int pagesize) | ||
615 | { | ||
616 | tfh->fillasid = asid; | ||
617 | tfh->fillvaddr = vaddr; | ||
618 | tfh->pfn = pfn; | ||
619 | tfh->dirty = dirty; | ||
620 | tfh->pagesize = pagesize; | ||
621 | tfh->opc = TFHOP_WRITE_ONLY; | ||
622 | start_instruction(tfh); | ||
623 | } | ||
624 | |||
625 | static inline void tfh_write_restart(struct gru_tlb_fault_handle *tfh, | ||
626 | unsigned long paddr, int gaa, | ||
627 | unsigned long vaddr, int asid, int dirty, | ||
628 | int pagesize) | ||
629 | { | ||
630 | tfh->fillasid = asid; | ||
631 | tfh->fillvaddr = vaddr; | ||
632 | tfh->pfn = paddr >> GRU_PADDR_SHIFT; | ||
633 | tfh->gaa = gaa; | ||
634 | tfh->dirty = dirty; | ||
635 | tfh->pagesize = pagesize; | ||
636 | tfh->opc = TFHOP_WRITE_RESTART; | ||
637 | start_instruction(tfh); | ||
638 | } | ||
639 | |||
640 | static inline void tfh_restart(struct gru_tlb_fault_handle *tfh) | ||
641 | { | ||
642 | tfh->opc = TFHOP_RESTART; | ||
643 | start_instruction(tfh); | ||
644 | } | ||
645 | |||
646 | static inline void tfh_user_polling_mode(struct gru_tlb_fault_handle *tfh) | ||
647 | { | ||
648 | tfh->opc = TFHOP_USER_POLLING_MODE; | ||
649 | start_instruction(tfh); | ||
650 | } | ||
651 | |||
652 | static inline void tfh_exception(struct gru_tlb_fault_handle *tfh) | ||
653 | { | ||
654 | tfh->opc = TFHOP_EXCEPTION; | ||
655 | start_instruction(tfh); | ||
656 | } | ||
657 | 515 | ||
658 | #endif /* __GRUHANDLES_H__ */ | 516 | #endif /* __GRUHANDLES_H__ */ |