sysrq.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * MIPS specific sysrq operations.
  3. *
  4. * Copyright (C) 2015 Imagination Technologies Ltd.
  5. */
  6. #include <linux/init.h>
  7. #include <linux/smp.h>
  8. #include <linux/spinlock.h>
  9. #include <linux/sysrq.h>
  10. #include <linux/workqueue.h>
  11. #include <asm/cpu-features.h>
  12. #include <asm/mipsregs.h>
  13. #include <asm/tlbdebug.h>
  14. /*
  15. * Dump TLB entries on all CPUs.
  16. */
  17. static DEFINE_SPINLOCK(show_lock);
  18. static void sysrq_tlbdump_single(void *dummy)
  19. {
  20. const int field = 2 * sizeof(unsigned long);
  21. unsigned long flags;
  22. spin_lock_irqsave(&show_lock, flags);
  23. pr_info("CPU%d:\n", smp_processor_id());
  24. pr_info("Index : %0x\n", read_c0_index());
  25. pr_info("Pagemask: %0x\n", read_c0_pagemask());
  26. pr_info("EntryHi : %0*lx\n", field, read_c0_entryhi());
  27. pr_info("EntryLo0: %0*lx\n", field, read_c0_entrylo0());
  28. pr_info("EntryLo1: %0*lx\n", field, read_c0_entrylo1());
  29. pr_info("Wired : %0x\n", read_c0_wired());
  30. pr_info("Pagegrain: %0x\n", read_c0_pagegrain());
  31. if (cpu_has_htw) {
  32. pr_info("PWField : %0*lx\n", field, read_c0_pwfield());
  33. pr_info("PWSize : %0*lx\n", field, read_c0_pwsize());
  34. pr_info("PWCtl : %0x\n", read_c0_pwctl());
  35. }
  36. pr_info("\n");
  37. dump_tlb_all();
  38. pr_info("\n");
  39. spin_unlock_irqrestore(&show_lock, flags);
  40. }
  41. #ifdef CONFIG_SMP
  42. static void sysrq_tlbdump_othercpus(struct work_struct *dummy)
  43. {
  44. smp_call_function(sysrq_tlbdump_single, NULL, 0);
  45. }
  46. static DECLARE_WORK(sysrq_tlbdump, sysrq_tlbdump_othercpus);
  47. #endif
  48. static void sysrq_handle_tlbdump(int key)
  49. {
  50. sysrq_tlbdump_single(NULL);
  51. #ifdef CONFIG_SMP
  52. schedule_work(&sysrq_tlbdump);
  53. #endif
  54. }
  55. static struct sysrq_key_op sysrq_tlbdump_op = {
  56. .handler = sysrq_handle_tlbdump,
  57. .help_msg = "show-tlbs(x)",
  58. .action_msg = "Show TLB entries",
  59. .enable_mask = SYSRQ_ENABLE_DUMP,
  60. };
  61. static int __init mips_sysrq_init(void)
  62. {
  63. return register_sysrq_key('x', &sysrq_tlbdump_op);
  64. }
  65. arch_initcall(mips_sysrq_init);