adreno-smmu-priv.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020 Google, Inc
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_SMMU_PRIV_H
  7. #define __ADRENO_SMMU_PRIV_H
  8. #include <linux/io-pgtable.h>
  9. #include <linux/qcom-io-pgtable.h>
  10. /**
  11. * struct adreno_smmu_fault_info - container for key fault information
  12. *
  13. * @far: The faulting IOVA from ARM_SMMU_CB_FAR
  14. * @ttbr0: The current TTBR0 pagetable from ARM_SMMU_CB_TTBR0
  15. * @contextidr: The value of ARM_SMMU_CB_CONTEXTIDR
  16. * @fsr: The fault status from ARM_SMMU_CB_FSR
  17. * @fsynr0: The value of FSYNR0 from ARM_SMMU_CB_FSYNR0
  18. * @fsynr1: The value of FSYNR1 from ARM_SMMU_CB_FSYNR0
  19. * @cbfrsynra: The value of CBFRSYNRA from ARM_SMMU_GR1_CBFRSYNRA(idx)
  20. *
  21. * This struct passes back key page fault information to the GPU driver
  22. * through the get_fault_info function pointer.
  23. * The GPU driver can use this information to print informative
  24. * log messages and provide deeper GPU specific insight into the fault.
  25. */
  26. struct adreno_smmu_fault_info {
  27. u64 far;
  28. u64 ttbr0;
  29. u32 contextidr;
  30. u32 fsr;
  31. u32 fsynr0;
  32. u32 fsynr1;
  33. u32 cbfrsynra;
  34. };
  35. /**
  36. * struct adreno_smmu_priv - private interface between adreno-smmu and GPU
  37. *
  38. * @cookie: An opque token provided by adreno-smmu and passed
  39. * back into the callbacks
  40. * @get_ttbr1_cfg: Get the TTBR1 config for the GPUs context-bank
  41. * @set_ttbr0_cfg: Set the TTBR0 config for the GPUs context bank. A
  42. * NULL config disables TTBR0 translation, otherwise
  43. * TTBR0 translation is enabled with the specified cfg
  44. * @get_fault_info: Called by the GPU fault handler to get information about
  45. * the fault
  46. * @set_stall: Configure whether stall on fault (CFCFG) is enabled. Call
  47. * before set_ttbr0_cfg(). If stalling on fault is enabled,
  48. * the GPU driver must call resume_translation()
  49. * @resume_translation: Resume translation after a fault
  50. * @pgtbl_info: io-pagetables info for the GPUs context-bank
  51. *
  52. *
  53. * The GPU driver (drm/msm) and adreno-smmu work together for controlling
  54. * the GPU's SMMU instance. This is by necessity, as the GPU is directly
  55. * updating the SMMU for context switches, while on the other hand we do
  56. * not want to duplicate all of the initial setup logic from arm-smmu.
  57. *
  58. * This private interface is used for the two drivers to coordinate. The
  59. * cookie and callback functions are populated when the GPU driver attaches
  60. * it's domain.
  61. */
  62. struct adreno_smmu_priv {
  63. const void *cookie;
  64. const struct io_pgtable_cfg *(*get_ttbr1_cfg)(const void *cookie);
  65. int (*set_ttbr0_cfg)(const void *cookie, const struct io_pgtable_cfg *cfg);
  66. void (*get_fault_info)(const void *cookie, struct adreno_smmu_fault_info *info);
  67. void (*set_stall)(const void *cookie, bool enabled);
  68. void (*resume_translation)(const void *cookie, bool terminate);
  69. struct qcom_io_pgtable_info pgtbl_info;
  70. };
  71. #endif /* __ADRENO_SMMU_PRIV_H */