mmio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Ke Yu
  25. * Kevin Tian <[email protected]>
  26. * Dexuan Cui
  27. *
  28. * Contributors:
  29. * Tina Zhang <[email protected]>
  30. * Min He <[email protected]>
  31. * Niu Bing <[email protected]>
  32. * Zhi Wang <[email protected]>
  33. *
  34. */
  35. #ifndef _GVT_MMIO_H_
  36. #define _GVT_MMIO_H_
  37. #include <linux/types.h>
  38. struct intel_gvt;
  39. struct intel_vgpu;
  40. #define D_BDW (1 << 0)
  41. #define D_SKL (1 << 1)
  42. #define D_KBL (1 << 2)
  43. #define D_BXT (1 << 3)
  44. #define D_CFL (1 << 4)
  45. #define D_GEN9PLUS (D_SKL | D_KBL | D_BXT | D_CFL)
  46. #define D_GEN8PLUS (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL)
  47. #define D_SKL_PLUS (D_SKL | D_KBL | D_BXT | D_CFL)
  48. #define D_BDW_PLUS (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL)
  49. #define D_PRE_SKL (D_BDW)
  50. #define D_ALL (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL)
  51. typedef int (*gvt_mmio_func)(struct intel_vgpu *, unsigned int, void *,
  52. unsigned int);
  53. struct intel_gvt_mmio_info {
  54. u32 offset;
  55. u64 ro_mask;
  56. u32 device;
  57. gvt_mmio_func read;
  58. gvt_mmio_func write;
  59. u32 addr_range;
  60. struct hlist_node node;
  61. };
  62. const struct intel_engine_cs *
  63. intel_gvt_render_mmio_to_engine(struct intel_gvt *gvt, unsigned int reg);
  64. unsigned long intel_gvt_get_device_type(struct intel_gvt *gvt);
  65. int intel_gvt_setup_mmio_info(struct intel_gvt *gvt);
  66. void intel_gvt_clean_mmio_info(struct intel_gvt *gvt);
  67. int intel_gvt_for_each_tracked_mmio(struct intel_gvt *gvt,
  68. int (*handler)(struct intel_gvt *gvt, u32 offset, void *data),
  69. void *data);
  70. struct intel_gvt_mmio_info *intel_gvt_find_mmio_info(struct intel_gvt *gvt,
  71. unsigned int offset);
  72. int intel_vgpu_init_mmio(struct intel_vgpu *vgpu);
  73. void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr);
  74. void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu);
  75. int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa);
  76. int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa,
  77. void *p_data, unsigned int bytes);
  78. int intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, u64 pa,
  79. void *p_data, unsigned int bytes);
  80. int intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
  81. void *p_data, unsigned int bytes);
  82. int intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
  83. void *p_data, unsigned int bytes);
  84. bool intel_gvt_in_force_nonpriv_whitelist(struct intel_gvt *gvt,
  85. unsigned int offset);
  86. int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,
  87. void *pdata, unsigned int bytes, bool is_read);
  88. int intel_vgpu_mask_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
  89. void *p_data, unsigned int bytes);
  90. void intel_gvt_restore_fence(struct intel_gvt *gvt);
  91. void intel_gvt_restore_mmio(struct intel_gvt *gvt);
  92. #endif