rgx_heap_firmware.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*************************************************************************/ /*!
  2. @File
  3. @Title RGX FW heap definitions
  4. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  5. @License Dual MIT/GPLv2
  6. The contents of this file are subject to the MIT license as set out below.
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. Alternatively, the contents of this file may be used under the terms of
  16. the GNU General Public License Version 2 ("GPL") in which case the provisions
  17. of GPL are applicable instead of those above.
  18. If you wish to allow use of your version of this file only under the terms of
  19. GPL, and not to allow others to use your version of this file under the terms
  20. of the MIT license, indicate your decision by deleting the provisions above
  21. and replace them with the notice and other provisions required by GPL as set
  22. out in the file called "GPL-COPYING" included in this distribution. If you do
  23. not delete the provisions above, a recipient may use your version of this file
  24. under the terms of either the MIT license or GPL.
  25. This License is also included in this distribution in the file called
  26. "MIT-COPYING".
  27. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  28. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  29. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  30. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  31. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  32. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  33. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  34. */ /**************************************************************************/
  35. #if !defined(RGX_HEAP_FIRMWARE_H)
  36. #define RGX_HEAP_FIRMWARE_H
  37. /* Start at 903GiB. Size of 32MB per OSID (see rgxheapconfig.h)
  38. * NOTE:
  39. * The firmware heaps bases and sizes are defined here to
  40. * simplify #include dependencies, see rgxheapconfig.h
  41. * for the full RGX virtual address space layout.
  42. */
  43. /*
  44. * The Config heap holds initialisation data shared between the
  45. * the driver and firmware (e.g. pointers to the KCCB and FWCCB).
  46. * The Main Firmware heap size is adjusted accordingly but most
  47. * of the map / unmap functions must take into consideration
  48. * the entire range (i.e. main and config heap).
  49. */
  50. #define RGX_FIRMWARE_NUMBER_OF_FW_HEAPS (2)
  51. #define RGX_FIRMWARE_HEAP_SHIFT RGX_FW_HEAP_SHIFT
  52. #define RGX_FIRMWARE_RAW_HEAP_BASE (0xE1C0000000ULL)
  53. #define RGX_FIRMWARE_RAW_HEAP_SIZE (IMG_UINT32_C(1) << RGX_FIRMWARE_HEAP_SHIFT)
  54. /* To enable the firmware to compute the exact address of structures allocated by the KM
  55. * in the Fw Config subheap, regardless of the KM's page size (and PMR granularity),
  56. * objects allocated consecutively but from different PMRs (due to differing memalloc flags)
  57. * are allocated with a 64kb offset. This way, all structures will be located at the same base
  58. * addresses when the KM is running with a page size of 4k, 16k or 64k. */
  59. #define RGX_FIRMWARE_CONFIG_HEAP_ALLOC_GRANULARITY (IMG_UINT32_C(0x10000))
  60. /* Ensure the heap can hold 3 PMRs of maximum supported granularity (192KB):
  61. * 1st PMR: RGXFWIF_CONNECTION_CTL
  62. * 2nd PMR: RGXFWIF_OSINIT
  63. * 3rd PMR: RGXFWIF_SYSINIT */
  64. #define RGX_FIRMWARE_CONFIG_HEAP_SIZE (3*RGX_FIRMWARE_CONFIG_HEAP_ALLOC_GRANULARITY)
  65. #define RGX_FIRMWARE_META_MAIN_HEAP_SIZE (RGX_FIRMWARE_RAW_HEAP_SIZE - RGX_FIRMWARE_CONFIG_HEAP_SIZE)
  66. /*
  67. * MIPS FW needs space in the Main heap to map GPU memory.
  68. * This space is taken from the MAIN heap, to avoid creating a new heap.
  69. */
  70. #define RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_NORMAL (IMG_UINT32_C(0x100000)) /* 1MB */
  71. #define RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_BRN65101 (IMG_UINT32_C(0x400000)) /* 4MB */
  72. #define RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE_NORMAL (RGX_FIRMWARE_RAW_HEAP_SIZE - RGX_FIRMWARE_CONFIG_HEAP_SIZE - \
  73. RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_NORMAL)
  74. #define RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE_BRN65101 (RGX_FIRMWARE_RAW_HEAP_SIZE - RGX_FIRMWARE_CONFIG_HEAP_SIZE - \
  75. RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_BRN65101)
  76. #if !defined(__KERNEL__)
  77. #if defined(FIX_HW_BRN_65101)
  78. #define RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_BRN65101
  79. #define RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE_BRN65101
  80. #include "img_defs.h"
  81. static_assert((RGX_FIRMWARE_RAW_HEAP_SIZE) >= IMG_UINT32_C(0x800000), "MIPS GPU map size cannot be increased due to BRN65101 with a small FW heap");
  82. #else
  83. #define RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE RGX_FIRMWARE_MIPS_GPU_MAP_RESERVED_SIZE_NORMAL
  84. #define RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE RGX_FIRMWARE_MIPS_MAIN_HEAP_SIZE_NORMAL
  85. #endif
  86. #endif /* !defined(__KERNEL__) */
  87. /* Host sub-heap order: MAIN + CONFIG */
  88. #define RGX_FIRMWARE_HOST_MAIN_HEAP_BASE RGX_FIRMWARE_RAW_HEAP_BASE
  89. #define RGX_FIRMWARE_HOST_CONFIG_HEAP_BASE (RGX_FIRMWARE_HOST_MAIN_HEAP_BASE + \
  90. RGX_FIRMWARE_RAW_HEAP_SIZE - \
  91. RGX_FIRMWARE_CONFIG_HEAP_SIZE)
  92. /* Guest sub-heap order: CONFIG + MAIN */
  93. #define RGX_FIRMWARE_GUEST_CONFIG_HEAP_BASE RGX_FIRMWARE_RAW_HEAP_BASE
  94. #define RGX_FIRMWARE_GUEST_MAIN_HEAP_BASE (RGX_FIRMWARE_GUEST_CONFIG_HEAP_BASE + \
  95. RGX_FIRMWARE_CONFIG_HEAP_SIZE)
  96. /*
  97. * The maximum configurable size via RGX_FW_HEAP_SHIFT is 32MiB (1<<25) and
  98. * the minimum is 4MiB (1<<22); the default firmware heap size is set to
  99. * maximum 32MiB.
  100. */
  101. #if defined(RGX_FW_HEAP_SHIFT) && (RGX_FW_HEAP_SHIFT < 22 || RGX_FW_HEAP_SHIFT > 25)
  102. #error "RGX_FW_HEAP_SHIFT is outside valid range [22, 25]"
  103. #endif
  104. #endif /* RGX_HEAP_FIRMWARE_H */