drm/exynos: Stop using drm_framebuffer_unregister_private
[linux/fpc-iii.git] / drivers / gpu / drm / amd / powerplay / smumgr / smu7_smumgr.c
blobf49b5487b951161cb488ab159092c172e4bfa72f
1 /*
2 * Copyright 2015 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "smumgr.h"
26 #include "smu_ucode_xfer_vi.h"
27 #include "smu/smu_7_1_3_d.h"
28 #include "smu/smu_7_1_3_sh_mask.h"
29 #include "ppatomctrl.h"
30 #include "pp_debug.h"
31 #include "cgs_common.h"
32 #include "smu7_ppsmc.h"
33 #include "smu7_smumgr.h"
35 #define SMU7_SMC_SIZE 0x20000
37 static int smu7_set_smc_sram_address(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t limit)
39 PP_ASSERT_WITH_CODE((0 == (3 & smc_addr)), "SMC address must be 4 byte aligned.", return -EINVAL);
40 PP_ASSERT_WITH_CODE((limit > (smc_addr + 3)), "SMC addr is beyond the SMC RAM area.", return -EINVAL);
42 cgs_write_register(smumgr->device, mmSMC_IND_INDEX_11, smc_addr);
43 SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_11, 0); /* on ci, SMC_IND_ACCESS_CNTL is different */
44 return 0;
48 int smu7_copy_bytes_from_smc(struct pp_smumgr *smumgr, uint32_t smc_start_address, uint32_t *dest, uint32_t byte_count, uint32_t limit)
50 uint32_t data;
51 uint32_t addr;
52 uint8_t *dest_byte;
53 uint8_t i, data_byte[4] = {0};
54 uint32_t *pdata = (uint32_t *)&data_byte;
56 PP_ASSERT_WITH_CODE((0 == (3 & smc_start_address)), "SMC address must be 4 byte aligned.", return -EINVAL);
57 PP_ASSERT_WITH_CODE((limit > (smc_start_address + byte_count)), "SMC address is beyond the SMC RAM area.", return -EINVAL);
59 addr = smc_start_address;
61 while (byte_count >= 4) {
62 smu7_read_smc_sram_dword(smumgr, addr, &data, limit);
64 *dest = PP_SMC_TO_HOST_UL(data);
66 dest += 1;
67 byte_count -= 4;
68 addr += 4;
71 if (byte_count) {
72 smu7_read_smc_sram_dword(smumgr, addr, &data, limit);
73 *pdata = PP_SMC_TO_HOST_UL(data);
74 /* Cast dest into byte type in dest_byte. This way, we don't overflow if the allocated memory is not 4-byte aligned. */
75 dest_byte = (uint8_t *)dest;
76 for (i = 0; i < byte_count; i++)
77 dest_byte[i] = data_byte[i];
80 return 0;
84 int smu7_copy_bytes_to_smc(struct pp_smumgr *smumgr, uint32_t smc_start_address,
85 const uint8_t *src, uint32_t byte_count, uint32_t limit)
87 int result;
88 uint32_t data = 0;
89 uint32_t original_data;
90 uint32_t addr = 0;
91 uint32_t extra_shift;
93 PP_ASSERT_WITH_CODE((0 == (3 & smc_start_address)), "SMC address must be 4 byte aligned.", return -EINVAL);
94 PP_ASSERT_WITH_CODE((limit > (smc_start_address + byte_count)), "SMC address is beyond the SMC RAM area.", return -EINVAL);
96 addr = smc_start_address;
98 while (byte_count >= 4) {
99 /* Bytes are written into the SMC addres space with the MSB first. */
100 data = src[0] * 0x1000000 + src[1] * 0x10000 + src[2] * 0x100 + src[3];
102 result = smu7_set_smc_sram_address(smumgr, addr, limit);
104 if (0 != result)
105 return result;
107 cgs_write_register(smumgr->device, mmSMC_IND_DATA_11, data);
109 src += 4;
110 byte_count -= 4;
111 addr += 4;
114 if (0 != byte_count) {
116 data = 0;
118 result = smu7_set_smc_sram_address(smumgr, addr, limit);
120 if (0 != result)
121 return result;
124 original_data = cgs_read_register(smumgr->device, mmSMC_IND_DATA_11);
126 extra_shift = 8 * (4 - byte_count);
128 while (byte_count > 0) {
129 /* Bytes are written into the SMC addres space with the MSB first. */
130 data = (0x100 * data) + *src++;
131 byte_count--;
134 data <<= extra_shift;
136 data |= (original_data & ~((~0UL) << extra_shift));
138 result = smu7_set_smc_sram_address(smumgr, addr, limit);
140 if (0 != result)
141 return result;
143 cgs_write_register(smumgr->device, mmSMC_IND_DATA_11, data);
146 return 0;
150 int smu7_program_jump_on_start(struct pp_smumgr *smumgr)
152 static const unsigned char data[4] = { 0xE0, 0x00, 0x80, 0x40 };
154 smu7_copy_bytes_to_smc(smumgr, 0x0, data, 4, sizeof(data)+1);
156 return 0;
159 bool smu7_is_smc_ram_running(struct pp_smumgr *smumgr)
161 return ((0 == SMUM_READ_VFPF_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, SMC_SYSCON_CLOCK_CNTL_0, ck_disable))
162 && (0x20100 <= cgs_read_ind_register(smumgr->device, CGS_IND_REG__SMC, ixSMC_PC_C)));
165 int smu7_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
167 int ret;
169 if (!smu7_is_smc_ram_running(smumgr))
170 return -EINVAL;
173 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
175 ret = SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP);
177 if (ret != 1)
178 printk("\n failed to send pre message %x ret is %d \n", msg, ret);
180 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
182 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
184 ret = SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP);
186 if (ret != 1)
187 printk("\n failed to send message %x ret is %d \n", msg, ret);
189 return 0;
192 int smu7_send_msg_to_smc_without_waiting(struct pp_smumgr *smumgr, uint16_t msg)
194 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
196 return 0;
199 int smu7_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, uint16_t msg, uint32_t parameter)
201 if (!smu7_is_smc_ram_running(smumgr)) {
202 return -EINVAL;
205 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
207 cgs_write_register(smumgr->device, mmSMC_MSG_ARG_0, parameter);
209 return smu7_send_msg_to_smc(smumgr, msg);
212 int smu7_send_msg_to_smc_with_parameter_without_waiting(struct pp_smumgr *smumgr, uint16_t msg, uint32_t parameter)
214 cgs_write_register(smumgr->device, mmSMC_MSG_ARG_0, parameter);
216 return smu7_send_msg_to_smc_without_waiting(smumgr, msg);
219 int smu7_send_msg_to_smc_offset(struct pp_smumgr *smumgr)
221 cgs_write_register(smumgr->device, mmSMC_MSG_ARG_0, 0x20000);
223 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, PPSMC_MSG_Test);
225 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
227 if (1 != SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP))
228 printk("Failed to send Message.\n");
230 return 0;
233 int smu7_wait_for_smc_inactive(struct pp_smumgr *smumgr)
235 if (!smu7_is_smc_ram_running(smumgr))
236 return -EINVAL;
238 SMUM_WAIT_VFPF_INDIRECT_FIELD(smumgr, SMC_IND, SMC_SYSCON_CLOCK_CNTL_0, cken, 0);
239 return 0;
243 enum cgs_ucode_id smu7_convert_fw_type_to_cgs(uint32_t fw_type)
245 enum cgs_ucode_id result = CGS_UCODE_ID_MAXIMUM;
247 switch (fw_type) {
248 case UCODE_ID_SMU:
249 result = CGS_UCODE_ID_SMU;
250 break;
251 case UCODE_ID_SMU_SK:
252 result = CGS_UCODE_ID_SMU_SK;
253 break;
254 case UCODE_ID_SDMA0:
255 result = CGS_UCODE_ID_SDMA0;
256 break;
257 case UCODE_ID_SDMA1:
258 result = CGS_UCODE_ID_SDMA1;
259 break;
260 case UCODE_ID_CP_CE:
261 result = CGS_UCODE_ID_CP_CE;
262 break;
263 case UCODE_ID_CP_PFP:
264 result = CGS_UCODE_ID_CP_PFP;
265 break;
266 case UCODE_ID_CP_ME:
267 result = CGS_UCODE_ID_CP_ME;
268 break;
269 case UCODE_ID_CP_MEC:
270 result = CGS_UCODE_ID_CP_MEC;
271 break;
272 case UCODE_ID_CP_MEC_JT1:
273 result = CGS_UCODE_ID_CP_MEC_JT1;
274 break;
275 case UCODE_ID_CP_MEC_JT2:
276 result = CGS_UCODE_ID_CP_MEC_JT2;
277 break;
278 case UCODE_ID_RLC_G:
279 result = CGS_UCODE_ID_RLC_G;
280 break;
281 case UCODE_ID_MEC_STORAGE:
282 result = CGS_UCODE_ID_STORAGE;
283 break;
284 default:
285 break;
288 return result;
292 int smu7_read_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t *value, uint32_t limit)
294 int result;
296 result = smu7_set_smc_sram_address(smumgr, smc_addr, limit);
298 if (result)
299 return result;
301 *value = cgs_read_register(smumgr->device, mmSMC_IND_DATA_11);
302 return 0;
305 int smu7_write_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t value, uint32_t limit)
307 int result;
309 result = smu7_set_smc_sram_address(smumgr, smc_addr, limit);
311 if (result)
312 return result;
314 cgs_write_register(smumgr->device, mmSMC_IND_DATA_11, value);
316 return 0;
319 /* Convert the firmware type to SMU type mask. For MEC, we need to check all MEC related type */
321 static uint32_t smu7_get_mask_for_firmware_type(uint32_t fw_type)
323 uint32_t result = 0;
325 switch (fw_type) {
326 case UCODE_ID_SDMA0:
327 result = UCODE_ID_SDMA0_MASK;
328 break;
329 case UCODE_ID_SDMA1:
330 result = UCODE_ID_SDMA1_MASK;
331 break;
332 case UCODE_ID_CP_CE:
333 result = UCODE_ID_CP_CE_MASK;
334 break;
335 case UCODE_ID_CP_PFP:
336 result = UCODE_ID_CP_PFP_MASK;
337 break;
338 case UCODE_ID_CP_ME:
339 result = UCODE_ID_CP_ME_MASK;
340 break;
341 case UCODE_ID_CP_MEC:
342 case UCODE_ID_CP_MEC_JT1:
343 case UCODE_ID_CP_MEC_JT2:
344 result = UCODE_ID_CP_MEC_MASK;
345 break;
346 case UCODE_ID_RLC_G:
347 result = UCODE_ID_RLC_G_MASK;
348 break;
349 default:
350 printk("UCode type is out of range! \n");
351 result = 0;
354 return result;
357 static int smu7_populate_single_firmware_entry(struct pp_smumgr *smumgr,
358 uint32_t fw_type,
359 struct SMU_Entry *entry)
361 int result = 0;
362 struct cgs_firmware_info info = {0};
364 result = cgs_get_firmware_info(smumgr->device,
365 smu7_convert_fw_type_to_cgs(fw_type),
366 &info);
368 if (!result) {
369 entry->version = info.fw_version;
370 entry->id = (uint16_t)fw_type;
371 entry->image_addr_high = smu_upper_32_bits(info.mc_addr);
372 entry->image_addr_low = smu_lower_32_bits(info.mc_addr);
373 entry->meta_data_addr_high = 0;
374 entry->meta_data_addr_low = 0;
376 /* digest need be excluded out */
377 if (cgs_is_virtualization_enabled(smumgr->device))
378 info.image_size -= 20;
379 entry->data_size_byte = info.image_size;
380 entry->num_register_entries = 0;
383 if (fw_type == UCODE_ID_RLC_G)
384 entry->flags = 1;
385 else
386 entry->flags = 0;
388 return 0;
391 int smu7_request_smu_load_fw(struct pp_smumgr *smumgr)
393 struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend);
394 uint32_t fw_to_load;
395 int result = 0;
396 struct SMU_DRAMData_TOC *toc;
398 if (!smumgr->reload_fw) {
399 printk(KERN_INFO "[ powerplay ] skip reloading...\n");
400 return 0;
403 if (smu_data->soft_regs_start)
404 cgs_write_ind_register(smumgr->device, CGS_IND_REG__SMC,
405 smu_data->soft_regs_start + smum_get_offsetof(smumgr,
406 SMU_SoftRegisters, UcodeLoadStatus),
407 0x0);
409 if (smumgr->chip_id > CHIP_TOPAZ) { /* add support for Topaz */
410 if (!cgs_is_virtualization_enabled(smumgr->device)) {
411 smu7_send_msg_to_smc_with_parameter(smumgr,
412 PPSMC_MSG_SMU_DRAM_ADDR_HI,
413 smu_data->smu_buffer.mc_addr_high);
414 smu7_send_msg_to_smc_with_parameter(smumgr,
415 PPSMC_MSG_SMU_DRAM_ADDR_LO,
416 smu_data->smu_buffer.mc_addr_low);
418 fw_to_load = UCODE_ID_RLC_G_MASK
419 + UCODE_ID_SDMA0_MASK
420 + UCODE_ID_SDMA1_MASK
421 + UCODE_ID_CP_CE_MASK
422 + UCODE_ID_CP_ME_MASK
423 + UCODE_ID_CP_PFP_MASK
424 + UCODE_ID_CP_MEC_MASK;
425 } else {
426 fw_to_load = UCODE_ID_RLC_G_MASK
427 + UCODE_ID_SDMA0_MASK
428 + UCODE_ID_SDMA1_MASK
429 + UCODE_ID_CP_CE_MASK
430 + UCODE_ID_CP_ME_MASK
431 + UCODE_ID_CP_PFP_MASK
432 + UCODE_ID_CP_MEC_MASK
433 + UCODE_ID_CP_MEC_JT1_MASK
434 + UCODE_ID_CP_MEC_JT2_MASK;
437 toc = (struct SMU_DRAMData_TOC *)smu_data->header;
438 toc->num_entries = 0;
439 toc->structure_version = 1;
441 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
442 UCODE_ID_RLC_G, &toc->entry[toc->num_entries++]),
443 "Failed to Get Firmware Entry.", return -EINVAL);
444 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
445 UCODE_ID_CP_CE, &toc->entry[toc->num_entries++]),
446 "Failed to Get Firmware Entry.", return -EINVAL);
447 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
448 UCODE_ID_CP_PFP, &toc->entry[toc->num_entries++]),
449 "Failed to Get Firmware Entry.", return -EINVAL);
450 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
451 UCODE_ID_CP_ME, &toc->entry[toc->num_entries++]),
452 "Failed to Get Firmware Entry.", return -EINVAL);
453 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
454 UCODE_ID_CP_MEC, &toc->entry[toc->num_entries++]),
455 "Failed to Get Firmware Entry.", return -EINVAL);
456 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
457 UCODE_ID_CP_MEC_JT1, &toc->entry[toc->num_entries++]),
458 "Failed to Get Firmware Entry.", return -EINVAL);
459 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
460 UCODE_ID_CP_MEC_JT2, &toc->entry[toc->num_entries++]),
461 "Failed to Get Firmware Entry.", return -EINVAL);
462 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
463 UCODE_ID_SDMA0, &toc->entry[toc->num_entries++]),
464 "Failed to Get Firmware Entry.", return -EINVAL);
465 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
466 UCODE_ID_SDMA1, &toc->entry[toc->num_entries++]),
467 "Failed to Get Firmware Entry.", return -EINVAL);
468 if (cgs_is_virtualization_enabled(smumgr->device))
469 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(smumgr,
470 UCODE_ID_MEC_STORAGE, &toc->entry[toc->num_entries++]),
471 "Failed to Get Firmware Entry.", return -EINVAL);
473 smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, smu_data->header_buffer.mc_addr_high);
474 smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, smu_data->header_buffer.mc_addr_low);
476 if (smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_LoadUcodes, fw_to_load))
477 printk(KERN_ERR "Fail to Request SMU Load uCode");
479 return result;
482 /* Check if the FW has been loaded, SMU will not return if loading has not finished. */
483 int smu7_check_fw_load_finish(struct pp_smumgr *smumgr, uint32_t fw_type)
485 struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend);
486 uint32_t fw_mask = smu7_get_mask_for_firmware_type(fw_type);
487 uint32_t ret;
489 ret = smum_wait_on_indirect_register(smumgr, mmSMC_IND_INDEX_11,
490 smu_data->soft_regs_start + smum_get_offsetof(smumgr,
491 SMU_SoftRegisters, UcodeLoadStatus),
492 fw_mask, fw_mask);
494 return ret;
497 int smu7_reload_firmware(struct pp_smumgr *smumgr)
499 return smumgr->smumgr_funcs->start_smu(smumgr);
502 static int smu7_upload_smc_firmware_data(struct pp_smumgr *smumgr, uint32_t length, uint32_t *src, uint32_t limit)
504 uint32_t byte_count = length;
506 PP_ASSERT_WITH_CODE((limit >= byte_count), "SMC address is beyond the SMC RAM area.", return -EINVAL);
508 cgs_write_register(smumgr->device, mmSMC_IND_INDEX_11, 0x20000);
509 SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_11, 1);
511 for (; byte_count >= 4; byte_count -= 4)
512 cgs_write_register(smumgr->device, mmSMC_IND_DATA_11, *src++);
514 SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_11, 0);
516 PP_ASSERT_WITH_CODE((0 == byte_count), "SMC size must be dividable by 4.", return -EINVAL);
518 return 0;
522 int smu7_upload_smu_firmware_image(struct pp_smumgr *smumgr)
524 int result = 0;
525 struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend);
527 struct cgs_firmware_info info = {0};
529 if (smu_data->security_hard_key == 1)
530 cgs_get_firmware_info(smumgr->device,
531 smu7_convert_fw_type_to_cgs(UCODE_ID_SMU), &info);
532 else
533 cgs_get_firmware_info(smumgr->device,
534 smu7_convert_fw_type_to_cgs(UCODE_ID_SMU_SK), &info);
536 result = smu7_upload_smc_firmware_data(smumgr, info.image_size, (uint32_t *)info.kptr, SMU7_SMC_SIZE);
538 return result;
542 int smu7_init(struct pp_smumgr *smumgr)
544 struct smu7_smumgr *smu_data;
545 uint8_t *internal_buf;
546 uint64_t mc_addr = 0;
548 /* Allocate memory for backend private data */
549 smu_data = (struct smu7_smumgr *)(smumgr->backend);
550 smu_data->header_buffer.data_size =
551 ((sizeof(struct SMU_DRAMData_TOC) / 4096) + 1) * 4096;
553 /* Allocate FW image data structure and header buffer and
554 * send the header buffer address to SMU */
555 smu_allocate_memory(smumgr->device,
556 smu_data->header_buffer.data_size,
557 CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,
558 PAGE_SIZE,
559 &mc_addr,
560 &smu_data->header_buffer.kaddr,
561 &smu_data->header_buffer.handle);
563 smu_data->header = smu_data->header_buffer.kaddr;
564 smu_data->header_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);
565 smu_data->header_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);
567 PP_ASSERT_WITH_CODE((NULL != smu_data->header),
568 "Out of memory.",
569 kfree(smumgr->backend);
570 cgs_free_gpu_mem(smumgr->device,
571 (cgs_handle_t)smu_data->header_buffer.handle);
572 return -EINVAL);
574 if (cgs_is_virtualization_enabled(smumgr->device))
575 return 0;
577 smu_data->smu_buffer.data_size = 200*4096;
578 smu_allocate_memory(smumgr->device,
579 smu_data->smu_buffer.data_size,
580 CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,
581 PAGE_SIZE,
582 &mc_addr,
583 &smu_data->smu_buffer.kaddr,
584 &smu_data->smu_buffer.handle);
586 internal_buf = smu_data->smu_buffer.kaddr;
587 smu_data->smu_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);
588 smu_data->smu_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);
590 PP_ASSERT_WITH_CODE((NULL != internal_buf),
591 "Out of memory.",
592 kfree(smumgr->backend);
593 cgs_free_gpu_mem(smumgr->device,
594 (cgs_handle_t)smu_data->smu_buffer.handle);
595 return -EINVAL);
597 return 0;
601 int smu7_smu_fini(struct pp_smumgr *smumgr)
603 if (smumgr->backend) {
604 kfree(smumgr->backend);
605 smumgr->backend = NULL;
607 cgs_rel_firmware(smumgr->device, CGS_UCODE_ID_SMU);
608 return 0;