History

drm/amdgpu: Add kgd kfd interface get_tile_config() v2

v2: * Removed amdgpu_amdkfd prefix from static functions * Documented get_tile_config in kgd_kfd_interface.h

Yong Zhao committed 9 years ago

Commit fb31a0c1 parent 6a1c9513 files · +66 −0Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +26 −0
  2. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +26 −0
  3. drivers/gpu/drm/amd/include/kgd_kfd_interface.h +14 −0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c+26−0
@@ -138,6 +138,31 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); · 137 unmodified lines
138138 static void set_scratch_backing_va(struct kgd_dev *kgd,
139139 uint64_t va, uint32_t vmid);
140140
141+/* Because of REG_GET_FIELD() being used, we put this function in the
142+ * asic specific file.
143+ */
144+static int get_tile_config(struct kgd_dev *kgd,
145+ struct tile_config *config)
146+{
147+ struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
148+
149+ config->gb_addr_config = adev->gfx.config.gb_addr_config;
150+ config->num_banks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
151+ MC_ARB_RAMCFG, NOOFBANK);
152+ config->num_ranks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
153+ MC_ARB_RAMCFG, NOOFRANKS);
154+
155+ config->tile_config_ptr = adev->gfx.config.tile_mode_array;
156+ config->num_tile_configs =
157+ ARRAY_SIZE(adev->gfx.config.tile_mode_array);
158+ config->macro_tile_config_ptr =
159+ adev->gfx.config.macrotile_mode_array;
160+ config->num_macro_tile_configs =
161+ ARRAY_SIZE(adev->gfx.config.macrotile_mode_array);
162+
163+ return 0;
164+}
165+
141166 static const struct kfd2kgd_calls kfd2kgd = {
142167 .init_gtt_mem_allocation = alloc_gtt_mem,
143168 .free_gtt_mem = free_gtt_mem,
@@ -163,6 +188,7 @@ static const struct kfd2kgd_calls kfd2kgd = { · 19 unmodified lines
163188 .write_vmid_invalidate_request = write_vmid_invalidate_request,
164189 .get_fw_version = get_fw_version,
165190 .set_scratch_backing_va = set_scratch_backing_va,
191+ .get_tile_config = get_tile_config,
166192 };
167193
168194 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c+26−0
@@ -97,6 +97,31 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); · 96 unmodified lines
9797 static void set_scratch_backing_va(struct kgd_dev *kgd,
9898 uint64_t va, uint32_t vmid);
9999
100+/* Because of REG_GET_FIELD() being used, we put this function in the
101+ * asic specific file.
102+ */
103+static int get_tile_config(struct kgd_dev *kgd,
104+ struct tile_config *config)
105+{
106+ struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
107+
108+ config->gb_addr_config = adev->gfx.config.gb_addr_config;
109+ config->num_banks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
110+ MC_ARB_RAMCFG, NOOFBANK);
111+ config->num_ranks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
112+ MC_ARB_RAMCFG, NOOFRANKS);
113+
114+ config->tile_config_ptr = adev->gfx.config.tile_mode_array;
115+ config->num_tile_configs =
116+ ARRAY_SIZE(adev->gfx.config.tile_mode_array);
117+ config->macro_tile_config_ptr =
118+ adev->gfx.config.macrotile_mode_array;
119+ config->num_macro_tile_configs =
120+ ARRAY_SIZE(adev->gfx.config.macrotile_mode_array);
121+
122+ return 0;
123+}
124+
100125 static const struct kfd2kgd_calls kfd2kgd = {
101126 .init_gtt_mem_allocation = alloc_gtt_mem,
102127 .free_gtt_mem = free_gtt_mem,
@@ -124,6 +149,7 @@ static const struct kfd2kgd_calls kfd2kgd = { · 21 unmodified lines
124149 .write_vmid_invalidate_request = write_vmid_invalidate_request,
125150 .get_fw_version = get_fw_version,
126151 .set_scratch_backing_va = set_scratch_backing_va,
152+ .get_tile_config = get_tile_config,
127153 };
128154
129155 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
drivers/gpu/drm/amd/include/kgd_kfd_interface.h+14−0
@@ -87,6 +87,17 @@ struct kgd2kfd_shared_resources { · 86 unmodified lines
8787 size_t doorbell_start_offset;
8888 };
8989
90+struct tile_config {
91+ uint32_t *tile_config_ptr;
92+ uint32_t *macro_tile_config_ptr;
93+ uint32_t num_tile_configs;
94+ uint32_t num_macro_tile_configs;
95+
96+ uint32_t gb_addr_config;
97+ uint32_t num_banks;
98+ uint32_t num_ranks;
99+};
100+
90101 /**
91102 * struct kfd2kgd_calls
92103 *
@@ -131,6 +142,8 @@ struct kgd2kfd_shared_resources { · 38 unmodified lines
131142 * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
132143 * Only used for no cp scheduling mode
133144 *
145+ * @get_tile_config: Returns GPU-specific tiling mode information
146+ *
134147 * This structure contains function pointers to services that the kgd driver
135148 * provides to amdkfd driver.
136149 *
@@ -204,6 +217,7 @@ struct kfd2kgd_calls { · 67 unmodified lines
204217 enum kgd_engine_type type);
205218 void (*set_scratch_backing_va)(struct kgd_dev *kgd,
206219 uint64_t va, uint32_t vmid);
220+ int (*get_tile_config)(struct kgd_dev *kgd, struct tile_config *config);
207221 };
208222
209223 /**