highmem.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * High memory support for Xtensa architecture
  3. *
  4. * This file is subject to the terms and conditions of the GNU General
  5. * Public License. See the file "COPYING" in the main directory of
  6. * this archive for more details.
  7. *
  8. * Copyright (C) 2014 Cadence Design Systems Inc.
  9. */
  10. #include <linux/export.h>
  11. #include <linux/highmem.h>
  12. #include <asm/tlbflush.h>
  13. #if DCACHE_WAY_SIZE > PAGE_SIZE
  14. unsigned int last_pkmap_nr_arr[DCACHE_N_COLORS];
  15. wait_queue_head_t pkmap_map_wait_arr[DCACHE_N_COLORS];
  16. static void __init kmap_waitqueues_init(void)
  17. {
  18. unsigned int i;
  19. for (i = 0; i < ARRAY_SIZE(pkmap_map_wait_arr); ++i)
  20. init_waitqueue_head(pkmap_map_wait_arr + i);
  21. }
  22. static inline enum fixed_addresses kmap_idx(int type, unsigned long color)
  23. {
  24. int idx = (type + KM_MAX_IDX * smp_processor_id()) * DCACHE_N_COLORS;
  25. /*
  26. * The fixmap operates top down, so the color offset needs to be
  27. * reverse as well.
  28. */
  29. return idx + DCACHE_N_COLORS - 1 - color;
  30. }
  31. enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn)
  32. {
  33. return kmap_idx(type, DCACHE_ALIAS(pfn << PAGE_SHIFT));
  34. }
  35. enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr)
  36. {
  37. return kmap_idx(type, DCACHE_ALIAS(addr));
  38. }
  39. #else
  40. static inline void kmap_waitqueues_init(void) { }
  41. #endif
  42. void __init kmap_init(void)
  43. {
  44. /* Check if this memory layout is broken because PKMAP overlaps
  45. * page table.
  46. */
  47. BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE);
  48. kmap_waitqueues_init();
  49. }