msm_memshare.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _LINUX_MEM_SHARE_H
  7. #define _LINUX_MEM_SHARE_H
  8. #define MEM_SHARE_SERVICE_SVC_ID 0x00000034
  9. #define MEM_SHARE_SERVICE_INS_ID 1
  10. #define MEM_SHARE_SERVICE_VERS 1
  11. #define MEMORY_CMA 1
  12. #define MEMORY_NON_CMA 0
  13. #define MAX_CLIENTS 10
  14. #define GPS 0
  15. #define CHECK 0
  16. #define FREE 1
  17. #define MEMSHARE_GUARD_BYTES (4*1024)
  18. struct memshare_hyp_mapping {
  19. u32 num_vmids;
  20. u32 vmids[2];
  21. u32 perms[2];
  22. };
  23. struct mem_blocks {
  24. /* Client Id information */
  25. uint32_t client_id;
  26. /* Peripheral associated with client */
  27. uint32_t peripheral;
  28. /* Sequence Id */
  29. uint32_t sequence_id;
  30. /* CMA or Non-CMA region */
  31. uint32_t memory_type;
  32. /* Guaranteed Memory */
  33. uint32_t guarantee;
  34. /* Memory alloted or not */
  35. uint32_t allotted;
  36. /* Memory allocation request received or not */
  37. uint32_t alloc_request;
  38. /* Allocation on request from a client*/
  39. uint32_t client_request;
  40. /* Guard band around the allotted region*/
  41. uint32_t guard_band;
  42. /* mapping to be assigned to memory region */
  43. struct memshare_hyp_mapping hyp_map_info;
  44. /* Size required for client */
  45. uint32_t size;
  46. /* Available memory size for client */
  47. uint32_t init_size;
  48. /*
  49. * start address of the memory block reserved by server memory
  50. * subsystem to client
  51. */
  52. phys_addr_t phy_addr;
  53. /* Virtual address for the physical address allocated */
  54. void *virtual_addr;
  55. /* Release memory only when XPU is released*/
  56. uint8_t free_memory;
  57. /* Need Hypervisor mapping*/
  58. uint8_t hyp_mapping;
  59. };
  60. int memshare_alloc(struct device *dev,
  61. unsigned int block_size,
  62. struct mem_blocks *pblk);
  63. void memshare_free(unsigned int block_size,
  64. struct mem_blocks *pblk);
  65. #endif /* _LINUX_MEM_SHARE_H */