drm/amd: Evict resources during PM ops prepare() callback
[linux-block.git] / drivers / gpu / drm / amd / amdgpu / amdgpu.h
index eaebd28845034b31426e4007e7cb8764d03260f1..17c4872a028774a48919bb5f320a0bce324c83e7 100644 (file)
@@ -245,6 +245,7 @@ extern int amdgpu_num_kcq;
 extern int amdgpu_vcnfw_log;
 extern int amdgpu_sg_display;
 extern int amdgpu_umsch_mm;
+extern int amdgpu_seamless;
 
 extern int amdgpu_user_partt_mode;
 
@@ -680,10 +681,15 @@ enum amd_hw_ip_block_type {
 #define HWIP_MAX_INSTANCE      44
 
 #define HW_ID_MAX              300
-#define IP_VERSION(mj, mn, rv) (((mj) << 16) | ((mn) << 8) | (rv))
-#define IP_VERSION_MAJ(ver) ((ver) >> 16)
-#define IP_VERSION_MIN(ver) (((ver) >> 8) & 0xFF)
-#define IP_VERSION_REV(ver) ((ver) & 0xFF)
+#define IP_VERSION_FULL(mj, mn, rv, var, srev) \
+       (((mj) << 24) | ((mn) << 16) | ((rv) << 8) | ((var) << 4) | (srev))
+#define IP_VERSION(mj, mn, rv)         IP_VERSION_FULL(mj, mn, rv, 0, 0)
+#define IP_VERSION_MAJ(ver)            ((ver) >> 24)
+#define IP_VERSION_MIN(ver)            (((ver) >> 16) & 0xFF)
+#define IP_VERSION_REV(ver)            (((ver) >> 8) & 0xFF)
+#define IP_VERSION_VARIANT(ver)                (((ver) >> 4) & 0xF)
+#define IP_VERSION_SUBREV(ver)         ((ver) & 0xF)
+#define IP_VERSION_MAJ_MIN_REV(ver)    ((ver) >> 8)
 
 struct amdgpu_ip_map_info {
        /* Map of logical to actual dev instances/mask */
@@ -764,8 +770,8 @@ struct amdgpu_mqd {
 
 #define AMDGPU_RESET_MAGIC_NUM 64
 #define AMDGPU_MAX_DF_PERFMONS 4
-#define AMDGPU_PRODUCT_NAME_LEN 64
 struct amdgpu_reset_domain;
+struct amdgpu_fru_info;
 
 /*
  * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
@@ -1049,11 +1055,7 @@ struct amdgpu_device {
 
        bool                            ucode_sysfs_en;
 
-       /* Chip product information */
-       char                            product_number[20];
-       char                            product_name[AMDGPU_PRODUCT_NAME_LEN];
-       char                            serial[20];
-
+       struct amdgpu_fru_info          *fru_info;
        atomic_t                        throttling_logging_enabled;
        struct ratelimit_state          throttling_logging_rs;
        uint32_t                        ras_hw_enabled;
@@ -1083,11 +1085,6 @@ struct amdgpu_device {
        uint32_t                        *reset_dump_reg_list;
        uint32_t                        *reset_dump_reg_value;
        int                             num_regs;
-#ifdef CONFIG_DEV_COREDUMP
-       struct amdgpu_task_info         reset_task_info;
-       bool                            reset_vram_lost;
-       struct timespec64               reset_time;
-#endif
 
        bool                            scpm_enabled;
        uint32_t                        scpm_status;
@@ -1102,7 +1099,26 @@ struct amdgpu_device {
        /* Debug */
        bool                            debug_vm;
        bool                            debug_largebar;
+       bool                            debug_disable_soft_recovery;
+};
+
+static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
+                                        uint8_t ip, uint8_t inst)
+{
+       /* This considers only major/minor/rev and ignores
+        * subrevision/variant fields.
+        */
+       return adev->ip_versions[ip][inst] & ~0xFFU;
+}
+
+#ifdef CONFIG_DEV_COREDUMP
+struct amdgpu_coredump_info {
+       struct amdgpu_device            *adev;
+       struct amdgpu_task_info         reset_task_info;
+       struct timespec64               reset_time;
+       bool                            reset_vram_lost;
 };
+#endif
 
 static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
 {
@@ -1301,15 +1317,13 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
        ((adev)->asic_funcs->update_umd_stable_pstate ? (adev)->asic_funcs->update_umd_stable_pstate((adev), (enter)) : 0)
 #define amdgpu_asic_query_video_codecs(adev, e, c) (adev)->asic_funcs->query_video_codecs((adev), (e), (c))
 
-#define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter));
+#define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter))
 
 #define BIT_MASK_UPPER(i) ((i) >= BITS_PER_LONG ? 0 : ~0UL << (i))
 #define for_each_inst(i, inst_mask)        \
        for (i = ffs(inst_mask); i-- != 0; \
             i = ffs(inst_mask & BIT_MASK_UPPER(i + 1)))
 
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-
 /* Common functions */
 bool amdgpu_device_has_job_running(struct amdgpu_device *adev);
 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
@@ -1319,6 +1333,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
 int amdgpu_device_pci_reset(struct amdgpu_device *adev);
 bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_device_seamless_boot_supported(struct amdgpu_device *adev);
 bool amdgpu_device_pcie_dynamic_switching_supported(void);
 bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
 bool amdgpu_device_aspm_support_quirk(void);
@@ -1393,6 +1408,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 void amdgpu_driver_release_kms(struct drm_device *dev);
 
 int amdgpu_device_ip_suspend(struct amdgpu_device *adev);
+int amdgpu_device_prepare(struct drm_device *dev);
 int amdgpu_device_suspend(struct drm_device *dev, bool fbcon);
 int amdgpu_device_resume(struct drm_device *dev, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc);