<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">will remove repeated assignment to mc_addr in verion 2.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards</p>
<p style="margin-top:0;margin-bottom:0">Rex </p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Rex Zhu <Rex.Zhu@amd.com><br>
<b>Sent:</b> Monday, March 5, 2018 6:43 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH 2/3] drm/amd/pp: Delete the wrap layer of smu_allocate/free_memory</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">use amdgpu_bo_create/free_kernel directly.<br>
<br>
Change-Id: I74f20353edd4e0df6328db66914cd9eabb60e1d7<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/inc/smumgr.h | 7 -<br>
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 39 +++---<br>
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.h | 11 +-<br>
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c | 53 +++----<br>
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.h | 11 +-<br>
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | 52 +++----<br>
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h | 11 +-<br>
drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | 51 -------<br>
.../gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | 155 ++++++++++-----------<br>
.../gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h | 11 +-<br>
10 files changed, 176 insertions(+), 225 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h<br>
index e1f6e83..8872c5c 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h<br>
@@ -106,13 +106,6 @@ enum SMU_MAC_DEFINITION {<br>
extern int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,<br>
uint16_t msg, uint32_t parameter);<br>
<br>
-extern int smu_allocate_memory(void *device, uint32_t size,<br>
- enum cgs_gpu_mem_type type,<br>
- uint32_t byte_align, uint64_t *mc_addr,<br>
- void **kptr, void *handle);<br>
-<br>
-extern int smu_free_memory(void *device, void *handle);<br>
-<br>
extern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr);<br>
<br>
extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type);<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c<br>
index 7fe4c11..0d2892d 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c<br>
@@ -750,7 +750,6 @@ static int cz_start_smu(struct pp_hwmgr *hwmgr)<br>
<br>
static int cz_smu_init(struct pp_hwmgr *hwmgr)<br>
{<br>
- uint64_t mc_addr = 0;<br>
int ret = 0;<br>
struct cz_smumgr *cz_smu;<br>
<br>
@@ -768,31 +767,31 @@ static int cz_smu_init(struct pp_hwmgr *hwmgr)<br>
ALIGN(sizeof(struct SMU8_MultimediaPowerLogData), 32) +<br>
ALIGN(sizeof(struct SMU8_Fusion_ClkTable), 32);<br>
<br>
- ret = smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
cz_smu->toc_buffer.data_size,<br>
- CGS_GPU_MEM_TYPE__GART_CACHEABLE,<br>
PAGE_SIZE,<br>
- &mc_addr,<br>
- &cz_smu->toc_buffer.kaddr,<br>
- &cz_smu->toc_buffer.handle);<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &cz_smu->toc_buffer.handle,<br>
+ &cz_smu->toc_buffer.mc_addr,<br>
+ &cz_smu->toc_buffer.kaddr);<br>
if (ret != 0)<br>
return -1;<br>
<br>
- cz_smu->toc_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);<br>
- cz_smu->toc_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);<br>
+ cz_smu->toc_buffer.mc_addr_high = smu_upper_32_bits(cz_smu->toc_buffer.mc_addr);<br>
+ cz_smu->toc_buffer.mc_addr_low = smu_lower_32_bits(cz_smu->toc_buffer.mc_addr);<br>
<br>
- ret = smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
cz_smu->smu_buffer.data_size,<br>
- CGS_GPU_MEM_TYPE__GART_CACHEABLE,<br>
PAGE_SIZE,<br>
- &mc_addr,<br>
- &cz_smu->smu_buffer.kaddr,<br>
- &cz_smu->smu_buffer.handle);<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &cz_smu->smu_buffer.handle,<br>
+ &cz_smu->toc_buffer.mc_addr,<br>
+ &cz_smu->smu_buffer.kaddr);<br>
if (ret != 0)<br>
return -1;<br>
<br>
- cz_smu->smu_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);<br>
- cz_smu->smu_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);<br>
+ cz_smu->smu_buffer.mc_addr_high = smu_upper_32_bits(cz_smu->toc_buffer.mc_addr);<br>
+ cz_smu->smu_buffer.mc_addr_low = smu_lower_32_bits(cz_smu->toc_buffer.mc_addr);<br>
<br>
if (0 != cz_smu_populate_single_scratch_entry(hwmgr,<br>
CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH,<br>
@@ -845,10 +844,12 @@ static int cz_smu_fini(struct pp_hwmgr *hwmgr)<br>
<br>
cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;<br>
if (cz_smu) {<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- cz_smu->toc_buffer.handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- cz_smu->smu_buffer.handle);<br>
+ amdgpu_bo_free_kernel(&cz_smu->toc_buffer.handle,<br>
+ &cz_smu->toc_buffer.mc_addr,<br>
+ &cz_smu->toc_buffer.kaddr);<br>
+ amdgpu_bo_free_kernel(&cz_smu->smu_buffer.handle,<br>
+ &cz_smu->toc_buffer.mc_addr,<br>
+ &cz_smu->smu_buffer.kaddr);<br>
kfree(cz_smu);<br>
}<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.h<br>
index 756b2c4..0faaecb 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.h<br>
@@ -60,11 +60,16 @@ enum cz_scratch_entry {<br>
<br>
struct cz_buffer_entry {<br>
uint32_t data_size;<br>
- uint32_t mc_addr_low;<br>
- uint32_t mc_addr_high;<br>
+ union {<br>
+ struct {<br>
+ uint32_t mc_addr_low;<br>
+ uint32_t mc_addr_high;<br>
+ };<br>
+ uint64_t mc_addr;<br>
+ };<br>
void *kaddr;<br>
enum cz_scratch_entry firmware_ID;<br>
- unsigned long handle; /* as bo handle used when release bo */<br>
+ struct amdgpu_bo *handle; /* as bo handle used when release bo */<br>
};<br>
<br>
struct cz_register_index_data_pair {<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c<br>
index 2d662b4..9379857 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c<br>
@@ -292,10 +292,12 @@ static int rv_smu_fini(struct pp_hwmgr *hwmgr)<br>
if (priv) {<br>
rv_smc_disable_sdma(hwmgr);<br>
rv_smc_disable_vcn(hwmgr);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- priv->smu_tables.entry[WMTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- priv->smu_tables.entry[CLOCKTABLE].handle);<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[WMTABLE].handle,<br>
+ &priv->smu_tables.entry[WMTABLE].table_addr,<br>
+ (void **)(priv->smu_tables.entry[WMTABLE].table));<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[CLOCKTABLE].handle,<br>
+ &priv->smu_tables.entry[CLOCKTABLE].table_addr,<br>
+ (void **)(priv->smu_tables.entry[CLOCKTABLE].table));<br>
kfree(hwmgr->smu_backend);<br>
hwmgr->smu_backend = NULL;<br>
}<br>
@@ -328,7 +330,8 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)<br>
struct rv_smumgr *priv;<br>
uint64_t mc_addr;<br>
void *kaddr = NULL;<br>
- unsigned long handle;<br>
+ struct amdgpu_bo *handle;<br>
+ int r;<br>
<br>
priv = kzalloc(sizeof(struct rv_smumgr), GFP_KERNEL);<br>
<br>
@@ -338,19 +341,16 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)<br>
hwmgr->smu_backend = priv;<br>
<br>
/* allocate space for watermarks table */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(Watermarks_t),<br>
- CGS_GPU_MEM_TYPE__GART_CACHEABLE,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
+ &kaddr);<br>
<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[rv_smu_init] Out of memory for wmtable.",<br>
- kfree(hwmgr->smu_backend);<br>
- hwmgr->smu_backend = NULL;<br>
- return -EINVAL);<br>
+ if (r)<br>
+ return -EINVAL;<br>
<br>
priv->smu_tables.entry[WMTABLE].version = 0x01;<br>
priv->smu_tables.entry[WMTABLE].size = sizeof(Watermarks_t);<br>
@@ -359,25 +359,25 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)<br>
smu_upper_32_bits(mc_addr);<br>
priv->smu_tables.entry[WMTABLE].table_addr_low =<br>
smu_lower_32_bits(mc_addr);<br>
+ priv->smu_tables.entry[WMTABLE].table_addr = mc_addr;<br>
priv->smu_tables.entry[WMTABLE].table = kaddr;<br>
priv->smu_tables.entry[WMTABLE].handle = handle;<br>
<br>
/* allocate space for watermarks table */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(DpmClocks_t),<br>
- CGS_GPU_MEM_TYPE__GART_CACHEABLE,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[rv_smu_init] Out of memory for CLOCKTABLE.",<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle);<br>
- kfree(hwmgr->smu_backend);<br>
- hwmgr->smu_backend = NULL;<br>
- return -EINVAL);<br>
+ &kaddr);<br>
+<br>
+ if (r) {<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[WMTABLE].handle,<br>
+ &priv->smu_tables.entry[WMTABLE].table_addr,<br>
+ (void **)(&priv->smu_tables.entry[WMTABLE].table));<br>
+ return -EINVAL;<br>
+ }<br>
<br>
priv->smu_tables.entry[CLOCKTABLE].version = 0x01;<br>
priv->smu_tables.entry[CLOCKTABLE].size = sizeof(DpmClocks_t);<br>
@@ -386,6 +386,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)<br>
smu_upper_32_bits(mc_addr);<br>
priv->smu_tables.entry[CLOCKTABLE].table_addr_low =<br>
smu_lower_32_bits(mc_addr);<br>
+ priv->smu_tables.entry[CLOCKTABLE].table_addr = mc_addr;<br>
priv->smu_tables.entry[CLOCKTABLE].table = kaddr;<br>
priv->smu_tables.entry[CLOCKTABLE].handle = handle;<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.h<br>
index caebdbe..aa061e8 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.h<br>
@@ -37,10 +37,15 @@ struct smu_table_entry {<br>
uint32_t version;<br>
uint32_t size;<br>
uint32_t table_id;<br>
- uint32_t table_addr_high;<br>
- uint32_t table_addr_low;<br>
+ union {<br>
+ struct {<br>
+ uint32_t table_addr_high;<br>
+ uint32_t table_addr_low;<br>
+ };<br>
+ uint64_t table_addr;<br>
+ };<br>
uint8_t *table;<br>
- unsigned long handle;<br>
+ struct amdgpu_bo *handle;<br>
};<br>
<br>
struct smu_table_array {<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c<br>
index 311ff37..4f5de2e 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c<br>
@@ -587,7 +587,7 @@ int smu7_init(struct pp_hwmgr *hwmgr)<br>
struct smu7_smumgr *smu_data;<br>
uint8_t *internal_buf;<br>
uint64_t mc_addr = 0;<br>
-<br>
+ int r;<br>
/* Allocate memory for backend private data */<br>
smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);<br>
smu_data->header_buffer.data_size =<br>
@@ -595,47 +595,44 @@ int smu7_init(struct pp_hwmgr *hwmgr)<br>
<br>
/* Allocate FW image data structure and header buffer and<br>
* send the header buffer address to SMU */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
smu_data->header_buffer.data_size,<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &smu_data->header_buffer.handle,<br>
&mc_addr,<br>
- &smu_data->header_buffer.kaddr,<br>
- &smu_data->header_buffer.handle);<br>
+ &smu_data->header_buffer.kaddr);<br>
+<br>
+ if (r)<br>
+ return -EINVAL;<br>
<br>
smu_data->header = smu_data->header_buffer.kaddr;<br>
smu_data->header_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);<br>
smu_data->header_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);<br>
-<br>
- PP_ASSERT_WITH_CODE((NULL != smu_data->header),<br>
- "Out of memory.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)smu_data->header_buffer.handle);<br>
- return -EINVAL);<br>
+ smu_data->header_buffer.mc_addr = mc_addr;<br>
<br>
if (cgs_is_virtualization_enabled(hwmgr->device))<br>
return 0;<br>
<br>
smu_data->smu_buffer.data_size = 200*4096;<br>
- smu_allocate_memory(hwmgr->device,<br>
+ r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
smu_data->smu_buffer.data_size,<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &smu_data->smu_buffer.handle,<br>
&mc_addr,<br>
- &smu_data->smu_buffer.kaddr,<br>
- &smu_data->smu_buffer.handle);<br>
+ &smu_data->smu_buffer.kaddr);<br>
<br>
+ if (r) {<br>
+ amdgpu_bo_free_kernel(&smu_data->header_buffer.handle,<br>
+ &smu_data->header_buffer.mc_addr,<br>
+ &smu_data->header_buffer.kaddr);<br>
+ return -EINVAL;<br>
+ }<br>
internal_buf = smu_data->smu_buffer.kaddr;<br>
smu_data->smu_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);<br>
smu_data->smu_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);<br>
-<br>
- PP_ASSERT_WITH_CODE((NULL != internal_buf),<br>
- "Out of memory.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)smu_data->smu_buffer.handle);<br>
- return -EINVAL);<br>
+ smu_data->smu_buffer.mc_addr = mc_addr;<br>
<br>
if (smum_is_hw_avfs_present(hwmgr))<br>
smu_data->avfs.avfs_btc_status = AVFS_BTC_BOOT;<br>
@@ -650,9 +647,14 @@ int smu7_smu_fini(struct pp_hwmgr *hwmgr)<br>
{<br>
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);<br>
<br>
- smu_free_memory(hwmgr->device, (void *) smu_data->header_buffer.handle);<br>
+ amdgpu_bo_free_kernel(&smu_data->header_buffer.handle,<br>
+ &smu_data->header_buffer.mc_addr,<br>
+ &smu_data->header_buffer.kaddr);<br>
+<br>
if (!cgs_is_virtualization_enabled(hwmgr->device))<br>
- smu_free_memory(hwmgr->device, (void *) smu_data->smu_buffer.handle);<br>
+ amdgpu_bo_free_kernel(&smu_data->smu_buffer.handle,<br>
+ &smu_data->smu_buffer.mc_addr,<br>
+ &smu_data->smu_buffer.kaddr);<br>
<br>
kfree(hwmgr->smu_backend);<br>
hwmgr->smu_backend = NULL;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h<br>
index c87263b..af161f1 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h<br>
@@ -31,10 +31,15 @@<br>
<br>
struct smu7_buffer_entry {<br>
uint32_t data_size;<br>
- uint32_t mc_addr_low;<br>
- uint32_t mc_addr_high;<br>
+ union {<br>
+ struct {<br>
+ uint32_t mc_addr_low;<br>
+ uint32_t mc_addr_high;<br>
+ };<br>
+ uint64_t mc_addr;<br>
+ };<br>
void *kaddr;<br>
- unsigned long handle;<br>
+ struct amdgpu_bo *handle;<br>
};<br>
<br>
struct smu7_avfs {<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c<br>
index 43b1010..3645127 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c<br>
@@ -144,57 +144,6 @@ int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,<br>
hwmgr, msg, parameter);<br>
}<br>
<br>
-int smu_allocate_memory(void *device, uint32_t size,<br>
- enum cgs_gpu_mem_type type,<br>
- uint32_t byte_align, uint64_t *mc_addr,<br>
- void **kptr, void *handle)<br>
-{<br>
- int ret = 0;<br>
- cgs_handle_t cgs_handle;<br>
-<br>
- if (device == NULL || handle == NULL ||<br>
- mc_addr == NULL || kptr == NULL)<br>
- return -EINVAL;<br>
-<br>
- ret = cgs_alloc_gpu_mem(device, type, size, byte_align,<br>
- (cgs_handle_t *)handle);<br>
- if (ret)<br>
- return -ENOMEM;<br>
-<br>
- cgs_handle = *(cgs_handle_t *)handle;<br>
-<br>
- ret = cgs_gmap_gpu_mem(device, cgs_handle, mc_addr);<br>
- if (ret)<br>
- goto error_gmap;<br>
-<br>
- ret = cgs_kmap_gpu_mem(device, cgs_handle, kptr);<br>
- if (ret)<br>
- goto error_kmap;<br>
-<br>
- return 0;<br>
-<br>
-error_kmap:<br>
- cgs_gunmap_gpu_mem(device, cgs_handle);<br>
-<br>
-error_gmap:<br>
- cgs_free_gpu_mem(device, cgs_handle);<br>
- return ret;<br>
-}<br>
-<br>
-int smu_free_memory(void *device, void *handle)<br>
-{<br>
- cgs_handle_t cgs_handle = (cgs_handle_t)handle;<br>
-<br>
- if (device == NULL || handle == NULL)<br>
- return -EINVAL;<br>
-<br>
- cgs_kunmap_gpu_mem(device, cgs_handle);<br>
- cgs_gunmap_gpu_mem(device, cgs_handle);<br>
- cgs_free_gpu_mem(device, cgs_handle);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
int smum_init_smc_table(struct pp_hwmgr *hwmgr)<br>
{<br>
if (NULL != hwmgr->smumgr_funcs->init_smc_table)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c<br>
index 68db582..214486c 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c<br>
@@ -381,7 +381,8 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
struct vega10_smumgr *priv;<br>
uint64_t mc_addr;<br>
void *kaddr = NULL;<br>
- unsigned long handle, tools_size;<br>
+ unsigned long tools_size;<br>
+ struct amdgpu_bo *handle;<br>
int ret;<br>
struct cgs_firmware_info info = {0};<br>
<br>
@@ -399,20 +400,16 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
hwmgr->smu_backend = priv;<br>
<br>
/* allocate space for pptable */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(PPTable_t),<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[vega10_smu_init] Out of memory for pptable.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)handle);<br>
- return -EINVAL);<br>
+ &kaddr);<br>
+<br>
+ if (ret)<br>
+ return -EINVAL;<br>
<br>
priv->smu_tables.entry[PPTABLE].version = 0x01;<br>
priv->smu_tables.entry[PPTABLE].size = sizeof(PPTable_t);<br>
@@ -421,26 +418,21 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
smu_upper_32_bits(mc_addr);<br>
priv->smu_tables.entry[PPTABLE].table_addr_low =<br>
smu_lower_32_bits(mc_addr);<br>
+ priv->smu_tables.entry[PPTABLE].mc_addr = mc_addr;<br>
priv->smu_tables.entry[PPTABLE].table = kaddr;<br>
priv->smu_tables.entry[PPTABLE].handle = handle;<br>
<br>
/* allocate space for watermarks table */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(Watermarks_t),<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[vega10_smu_init] Out of memory for wmtable.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)handle);<br>
- return -EINVAL);<br>
+ &kaddr);<br>
+<br>
+ if (ret)<br>
+ goto err0;<br>
<br>
priv->smu_tables.entry[WMTABLE].version = 0x01;<br>
priv->smu_tables.entry[WMTABLE].size = sizeof(Watermarks_t);<br>
@@ -453,24 +445,16 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
priv->smu_tables.entry[WMTABLE].handle = handle;<br>
<br>
/* allocate space for AVFS table */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(AvfsTable_t),<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[vega10_smu_init] Out of memory for avfs table.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)handle);<br>
- return -EINVAL);<br>
+ &kaddr);<br>
+<br>
+ if (ret)<br>
+ goto err1;<br>
<br>
priv->smu_tables.entry[AVFSTABLE].version = 0x01;<br>
priv->smu_tables.entry[AVFSTABLE].size = sizeof(AvfsTable_t);<br>
@@ -484,50 +468,27 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
<br>
tools_size = 0x19000;<br>
if (tools_size) {<br>
- smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
tools_size,<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- if (kaddr) {<br>
- priv->smu_tables.entry[TOOLSTABLE].version = 0x01;<br>
- priv->smu_tables.entry[TOOLSTABLE].size = tools_size;<br>
- priv->smu_tables.entry[TOOLSTABLE].table_id = TABLE_PMSTATUSLOG;<br>
- priv->smu_tables.entry[TOOLSTABLE].table_addr_high =<br>
- smu_upper_32_bits(mc_addr);<br>
- priv->smu_tables.entry[TOOLSTABLE].table_addr_low =<br>
- smu_lower_32_bits(mc_addr);<br>
- priv->smu_tables.entry[TOOLSTABLE].table = kaddr;<br>
- priv->smu_tables.entry[TOOLSTABLE].handle = handle;<br>
- }<br>
+ &kaddr);<br>
+ if (ret)<br>
+ goto err2;<br>
}<br>
<br>
/* allocate space for AVFS Fuse table */<br>
- smu_allocate_memory(hwmgr->device,<br>
+ ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,<br>
sizeof(AvfsFuseOverride_t),<br>
- CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,<br>
PAGE_SIZE,<br>
+ AMDGPU_GEM_DOMAIN_VRAM,<br>
+ &handle,<br>
&mc_addr,<br>
- &kaddr,<br>
- &handle);<br>
-<br>
- PP_ASSERT_WITH_CODE(kaddr,<br>
- "[vega10_smu_init] Out of memory for avfs fuse table.",<br>
- kfree(hwmgr->smu_backend);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[AVFSTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[TOOLSTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)handle);<br>
- return -EINVAL);<br>
+ &kaddr);<br>
+ if (ret)<br>
+ goto err3;<br>
<br>
priv->smu_tables.entry[AVFSFUSETABLE].version = 0x01;<br>
priv->smu_tables.entry[AVFSFUSETABLE].size = sizeof(AvfsFuseOverride_t);<br>
@@ -540,6 +501,25 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)<br>
priv->smu_tables.entry[AVFSFUSETABLE].handle = handle;<br>
<br>
return 0;<br>
+<br>
+err3:<br>
+ if (priv->smu_tables.entry[TOOLSTABLE].table)<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[TOOLSTABLE].handle,<br>
+ &priv->smu_tables.entry[TOOLSTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[TOOLSTABLE].table));<br>
+err2:<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[AVFSTABLE].handle,<br>
+ &priv->smu_tables.entry[AVFSTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[AVFSTABLE].table));<br>
+err1:<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[WMTABLE].handle,<br>
+ &priv->smu_tables.entry[WMTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[WMTABLE].table));<br>
+err0:<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[PPTABLE].handle,<br>
+ &priv->smu_tables.entry[PPTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[PPTABLE].table));<br>
+ return -EINVAL;<br>
}<br>
<br>
static int vega10_smu_fini(struct pp_hwmgr *hwmgr)<br>
@@ -548,17 +528,22 @@ static int vega10_smu_fini(struct pp_hwmgr *hwmgr)<br>
(struct vega10_smumgr *)(hwmgr->smu_backend);<br>
<br>
if (priv) {<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[AVFSTABLE].handle);<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[PPTABLE].handle,<br>
+ &priv->smu_tables.entry[PPTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[PPTABLE].table));<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[WMTABLE].handle,<br>
+ &priv->smu_tables.entry[WMTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[WMTABLE].table));<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[AVFSTABLE].handle,<br>
+ &priv->smu_tables.entry[AVFSTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[AVFSTABLE].table));<br>
if (priv->smu_tables.entry[TOOLSTABLE].table)<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[TOOLSTABLE].handle);<br>
- cgs_free_gpu_mem(hwmgr->device,<br>
- (cgs_handle_t)priv->smu_tables.entry[AVFSFUSETABLE].handle);<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[TOOLSTABLE].handle,<br>
+ &priv->smu_tables.entry[TOOLSTABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[TOOLSTABLE].table));<br>
+ amdgpu_bo_free_kernel(&priv->smu_tables.entry[AVFSFUSETABLE].handle,<br>
+ &priv->smu_tables.entry[AVFSFUSETABLE].mc_addr,<br>
+ (void **)(&priv->smu_tables.entry[AVFSFUSETABLE].table));<br>
kfree(hwmgr->smu_backend);<br>
hwmgr->smu_backend = NULL;<br>
}<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h<br>
index 0695455..ffb5e69 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h<br>
@@ -38,10 +38,15 @@ struct smu_table_entry {<br>
uint32_t version;<br>
uint32_t size;<br>
uint32_t table_id;<br>
- uint32_t table_addr_high;<br>
- uint32_t table_addr_low;<br>
+ union {<br>
+ struct {<br>
+ uint32_t table_addr_high;<br>
+ uint32_t table_addr_low;<br>
+ };<br>
+ uint64_t mc_addr;<br>
+ };<br>
uint8_t *table;<br>
- unsigned long handle;<br>
+ struct amdgpu_bo *handle;<br>
};<br>
<br>
struct smu_table_array {<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk707558" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15202544609090.9970841315769015" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15202544608950.6218897203626461" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_15202544608990.9893083421755928" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15202544609000.4448100284698653"></div>
<div id="LPTitle_15202544609010.3296051160437019" style="top: 0px; color: rgb(0, 120, 215); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15202544609030.9465562156380234" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="text-decoration: none;">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15202544609040.11314540810545926" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
lists.freedesktop.org</div>
<div id="LPDescription_15202544609060.9678970493348933" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>