<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
p.emailquote, li.emailquote, div.emailquote
{mso-style-name:emailquote;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:1.0pt;
margin-bottom:.0001pt;
border:none;
padding:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks. Updated patch sent out.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Alex<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Zhu, Rex
<br>
<b>Sent:</b> Tuesday, April 18, 2017 2:11 AM<br>
<b>To:</b> Alex Deucher; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Deucher, Alexander<br>
<b>Subject:</b> Re: [PATCH 12/12] drm/amdgpu/gfx9: Switch baremetal to use KIQ for compute ring management. (v3)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div id="x_divRplyFwdMsg">
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">+static int gfx_v9_0_kiq_kcq_disable(struct amdgpu_device *adev)</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">...............</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">+ DRM_ERROR("KCQ
</span><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#D05C12">enable</span><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black"> failed (scratch(0x%04X)=0x%08X)\n",</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">should be disable here.</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">Best Regards</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">Rex</span><span style="font-family:"Calibri","sans-serif";color:black"><o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"> amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>>
on behalf of Alex Deucher <<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a>><br>
<b>Sent:</b> Tuesday, April 18, 2017 6:00:47 AM<br>
<b>To:</b> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Cc:</b> Deucher, Alexander<br>
<b>Subject:</b> [PATCH 12/12] drm/amdgpu/gfx9: Switch baremetal to use KIQ for compute ring management. (v3)</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">KIQ is the Kernel Interface Queue for managing the MEC. Rather than setting<br>
up rings via direct MMIO of ring registers, the rings are configured via<br>
special packets sent to the KIQ. The allows the MEC to better manage shared<br>
resources and certain power events. It also reduces the code paths in the<br>
driver to support and is required for MEC powergating.<br>
<br>
v2: drop gfx_v9_0_cp_compute_fini() as well<br>
v3: rebase on latest changes derived from gfx8, add unmap queues on<br>
hw_fini<br>
<br>
Signed-off-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com">alexander.deucher@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 374 ++++++++--------------------------<br>
1 file changed, 81 insertions(+), 293 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index f86a7f6..ef7a3ee 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -1113,23 +1113,21 @@ static int gfx_v9_0_sw_init(void *handle)<br>
return r;<br>
}<br>
<br>
- if (amdgpu_sriov_vf(adev)) {<br>
- r = gfx_v9_0_kiq_init(adev);<br>
- if (r) {<br>
- DRM_ERROR("Failed to init KIQ BOs!\n");<br>
- return r;<br>
- }<br>
+ r = gfx_v9_0_kiq_init(adev);<br>
+ if (r) {<br>
+ DRM_ERROR("Failed to init KIQ BOs!\n");<br>
+ return r;<br>
+ }<br>
<br>
- kiq = &adev->gfx.kiq;<br>
- r = gfx_v9_0_kiq_init_ring(adev, &kiq->ring, &kiq->irq);<br>
- if (r)<br>
- return r;<br>
+ kiq = &adev->gfx.kiq;<br>
+ r = gfx_v9_0_kiq_init_ring(adev, &kiq->ring, &kiq->irq);<br>
+ if (r)<br>
+ return r;<br>
<br>
- /* create MQD for all compute queues as wel as KIQ for SRIOV case */<br>
- r = gfx_v9_0_compute_mqd_sw_init(adev);<br>
- if (r)<br>
- return r;<br>
- }<br>
+ /* create MQD for all compute queues as wel as KIQ for SRIOV case */<br>
+ r = gfx_v9_0_compute_mqd_sw_init(adev);<br>
+ if (r)<br>
+ return r;<br>
<br>
/* reserve GDS, GWS and OA resource for gfx */<br>
r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,<br>
@@ -1176,11 +1174,9 @@ static int gfx_v9_0_sw_fini(void *handle)<br>
for (i = 0; i < adev->gfx.num_compute_rings; i++)<br>
amdgpu_ring_fini(&adev->gfx.compute_ring[i]);<br>
<br>
- if (amdgpu_sriov_vf(adev)) {<br>
- gfx_v9_0_compute_mqd_sw_fini(adev);<br>
- gfx_v9_0_kiq_free_ring(&adev->gfx.kiq.ring, &adev->gfx.kiq.irq);<br>
- gfx_v9_0_kiq_fini(adev);<br>
- }<br>
+ gfx_v9_0_compute_mqd_sw_fini(adev);<br>
+ gfx_v9_0_kiq_free_ring(&adev->gfx.kiq.ring, &adev->gfx.kiq.irq);<br>
+ gfx_v9_0_kiq_fini(adev);<br>
<br>
gfx_v9_0_mec_fini(adev);<br>
gfx_v9_0_ngg_fini(adev);<br>
@@ -1736,13 +1732,6 @@ static void gfx_v9_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)<br>
udelay(50);<br>
}<br>
<br>
-static int gfx_v9_0_cp_compute_start(struct amdgpu_device *adev)<br>
-{<br>
- gfx_v9_0_cp_compute_enable(adev, true);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
static int gfx_v9_0_cp_compute_load_microcode(struct amdgpu_device *adev)<br>
{<br>
const struct gfx_firmware_header_v1_0 *mec_hdr;<br>
@@ -1785,45 +1774,6 @@ static int gfx_v9_0_cp_compute_load_microcode(struct amdgpu_device *adev)<br>
return 0;<br>
}<br>
<br>
-static void gfx_v9_0_cp_compute_fini(struct amdgpu_device *adev)<br>
-{<br>
- int i, r;<br>
-<br>
- for (i = 0; i < adev->gfx.num_compute_rings; i++) {<br>
- struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];<br>
-<br>
- if (ring->mqd_obj) {<br>
- r = amdgpu_bo_reserve(ring->mqd_obj, false);<br>
- if (unlikely(r != 0))<br>
- dev_warn(adev->dev, "(%d) reserve MQD bo failed\n", r);<br>
-<br>
- amdgpu_bo_unpin(ring->mqd_obj);<br>
- amdgpu_bo_unreserve(ring->mqd_obj);<br>
-<br>
- amdgpu_bo_unref(&ring->mqd_obj);<br>
- ring->mqd_obj = NULL;<br>
- }<br>
- }<br>
-}<br>
-<br>
-static int gfx_v9_0_init_queue(struct amdgpu_ring *ring);<br>
-<br>
-static int gfx_v9_0_cp_compute_resume(struct amdgpu_device *adev)<br>
-{<br>
- int i, r;<br>
- for (i = 0; i < adev->gfx.num_compute_rings; i++) {<br>
- struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];<br>
- if (gfx_v9_0_init_queue(ring))<br>
- dev_warn(adev->dev, "compute queue %d init failed!\n", i);<br>
- }<br>
-<br>
- r = gfx_v9_0_cp_compute_start(adev);<br>
- if (r)<br>
- return r;<br>
-<br>
- return 0;<br>
-}<br>
-<br>
/* KIQ functions */<br>
static void gfx_v9_0_kiq_setting(struct amdgpu_ring *ring)<br>
{<br>
@@ -1914,6 +1864,56 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev)<br>
return r;<br>
}<br>
<br>
+static int gfx_v9_0_kiq_kcq_disable(struct amdgpu_device *adev)<br>
+{<br>
+ struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;<br>
+ uint32_t scratch, tmp = 0;<br>
+ int r, i;<br>
+<br>
+ r = amdgpu_gfx_scratch_get(adev, &scratch);<br>
+ if (r) {<br>
+ DRM_ERROR("Failed to get scratch reg (%d).\n", r);<br>
+ return r;<br>
+ }<br>
+ WREG32(scratch, 0xCAFEDEAD);<br>
+<br>
+ r = amdgpu_ring_alloc(kiq_ring, 6 + 3);<br>
+ if (r) {<br>
+ DRM_ERROR("Failed to lock KIQ (%d).\n", r);<br>
+ amdgpu_gfx_scratch_free(adev, scratch);<br>
+ return r;<br>
+ }<br>
+ /* unmap queues */<br>
+ amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));<br>
+ amdgpu_ring_write(kiq_ring,<br>
+ PACKET3_UNMAP_QUEUES_ACTION(1)| /* RESET_QUEUES */<br>
+ PACKET3_UNMAP_QUEUES_QUEUE_SEL(2)); /* select all queues */<br>
+ amdgpu_ring_write(kiq_ring, 0);<br>
+ amdgpu_ring_write(kiq_ring, 0);<br>
+ amdgpu_ring_write(kiq_ring, 0);<br>
+ amdgpu_ring_write(kiq_ring, 0);<br>
+ /* write to scratch for completion */<br>
+ amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));<br>
+ amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));<br>
+ amdgpu_ring_write(kiq_ring, 0xDEADBEEF);<br>
+ amdgpu_ring_commit(kiq_ring);<br>
+<br>
+ for (i = 0; i < adev->usec_timeout; i++) {<br>
+ tmp = RREG32(scratch);<br>
+ if (tmp == 0xDEADBEEF)<br>
+ break;<br>
+ DRM_UDELAY(1);<br>
+ }<br>
+ if (i >= adev->usec_timeout) {<br>
+ DRM_ERROR("KCQ enable failed (scratch(0x%04X)=0x%08X)\n",<br>
+ scratch, tmp);<br>
+ r = -EINVAL;<br>
+ }<br>
+ amdgpu_gfx_scratch_free(adev, scratch);<br>
+<br>
+ return r;<br>
+}<br>
+<br>
static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)<br>
{<br>
struct amdgpu_device *adev = ring->adev;<br>
@@ -2194,7 +2194,7 @@ static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring)<br>
struct v9_mqd *mqd = ring->mqd_ptr;<br>
int mqd_idx = ring - &adev->gfx.compute_ring[0];<br>
<br>
- if (!adev->gfx.in_reset) {<br>
+ if (!adev->gfx.in_reset && !adev->gfx.in_suspend) {<br>
memset((void *)mqd, 0, sizeof(*mqd));<br>
mutex_lock(&adev->srbm_mutex);<br>
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);<br>
@@ -2285,10 +2285,7 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)<br>
if (r)<br>
return r;<br>
<br>
- if (amdgpu_sriov_vf(adev))<br>
- r = gfx_v9_0_kiq_resume(adev);<br>
- else<br>
- r = gfx_v9_0_cp_compute_resume(adev);<br>
+ r = gfx_v9_0_kiq_resume(adev);<br>
if (r)<br>
return r;<br>
<br>
@@ -2298,6 +2295,13 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)<br>
ring->ready = false;<br>
return r;<br>
}<br>
+<br>
+ ring = &adev->gfx.kiq.ring;<br>
+ ring->ready = true;<br>
+ r = amdgpu_ring_test_ring(ring);<br>
+ if (r)<br>
+ ring->ready = false;<br>
+<br>
for (i = 0; i < adev->gfx.num_compute_rings; i++) {<br>
ring = &adev->gfx.compute_ring[i];<br>
<br>
@@ -2307,14 +2311,6 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)<br>
ring->ready = false;<br>
}<br>
<br>
- if (amdgpu_sriov_vf(adev)) {<br>
- ring = &adev->gfx.kiq.ring;<br>
- ring->ready = true;<br>
- r = amdgpu_ring_test_ring(ring);<br>
- if (r)<br>
- ring->ready = false;<br>
- }<br>
-<br>
gfx_v9_0_enable_gui_idle_interrupt(adev, true);<br>
<br>
return 0;<br>
@@ -2360,9 +2356,9 @@ static int gfx_v9_0_hw_fini(void *handle)<br>
pr_debug("For SRIOV client, shouldn't do anything.\n");<br>
return 0;<br>
}<br>
+ gfx_v9_0_kiq_kcq_disable(adev);<br>
gfx_v9_0_cp_enable(adev, false);<br>
gfx_v9_0_rlc_stop(adev);<br>
- gfx_v9_0_cp_compute_fini(adev);<br>
<br>
return 0;<br>
}<br>
@@ -2371,14 +2367,18 @@ static int gfx_v9_0_suspend(void *handle)<br>
{<br>
struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
<br>
+ adev->gfx.in_suspend = true;<br>
return gfx_v9_0_hw_fini(adev);<br>
}<br>
<br>
static int gfx_v9_0_resume(void *handle)<br>
{<br>
struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+ int r;<br>
<br>
- return gfx_v9_0_hw_init(adev);<br>
+ r = gfx_v9_0_hw_init(adev);<br>
+ adev->gfx.in_suspend = false;<br>
+ return r;<br>
}<br>
<br>
static bool gfx_v9_0_is_idle(void *handle)<br>
@@ -3753,218 +3753,6 @@ static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,<br>
return 0;<br>
}<br>
<br>
-static int gfx_v9_0_init_queue(struct amdgpu_ring *ring)<br>
-{<br>
- int r, j;<br>
- u32 tmp;<br>
- bool use_doorbell = true;<br>
- u64 hqd_gpu_addr;<br>
- u64 mqd_gpu_addr;<br>
- u64 eop_gpu_addr;<br>
- u64 wb_gpu_addr;<br>
- u32 *buf;<br>
- struct v9_mqd *mqd;<br>
- struct amdgpu_device *adev;<br>
-<br>
- adev = ring->adev;<br>
- if (ring->mqd_obj == NULL) {<br>
- r = amdgpu_bo_create(adev,<br>
- sizeof(struct v9_mqd),<br>
- PAGE_SIZE,true,<br>
- AMDGPU_GEM_DOMAIN_GTT, 0, NULL,<br>
- NULL, &ring->mqd_obj);<br>
- if (r) {<br>
- dev_warn(adev->dev, "(%d) create MQD bo failed\n", r);<br>
- return r;<br>
- }<br>
- }<br>
-<br>
- r = amdgpu_bo_reserve(ring->mqd_obj, false);<br>
- if (unlikely(r != 0)) {<br>
- gfx_v9_0_cp_compute_fini(adev);<br>
- return r;<br>
- }<br>
-<br>
- r = amdgpu_bo_pin(ring->mqd_obj, AMDGPU_GEM_DOMAIN_GTT,<br>
- &mqd_gpu_addr);<br>
- if (r) {<br>
- dev_warn(adev->dev, "(%d) pin MQD bo failed\n", r);<br>
- gfx_v9_0_cp_compute_fini(adev);<br>
- return r;<br>
- }<br>
- r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&buf);<br>
- if (r) {<br>
- dev_warn(adev->dev, "(%d) map MQD bo failed\n", r);<br>
- gfx_v9_0_cp_compute_fini(adev);<br>
- return r;<br>
- }<br>
-<br>
- /* init the mqd struct */<br>
- memset(buf, 0, sizeof(struct v9_mqd));<br>
-<br>
- mqd = (struct v9_mqd *)buf;<br>
- mqd->header = 0xC0310800;<br>
- mqd->compute_pipelinestat_enable = 0x00000001;<br>
- mqd->compute_static_thread_mgmt_se0 = 0xffffffff;<br>
- mqd->compute_static_thread_mgmt_se1 = 0xffffffff;<br>
- mqd->compute_static_thread_mgmt_se2 = 0xffffffff;<br>
- mqd->compute_static_thread_mgmt_se3 = 0xffffffff;<br>
- mqd->compute_misc_reserved = 0x00000003;<br>
- mutex_lock(&adev->srbm_mutex);<br>
- soc15_grbm_select(adev, ring->me,<br>
- ring->pipe,<br>
- ring->queue, 0);<br>
- /* disable wptr polling */<br>
- WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0);<br>
-<br>
- /* write the EOP addr */<br>
- BUG_ON(ring->me != 1 || ring->pipe != 0); /* can't handle other cases eop address */<br>
- eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + (ring->queue * MEC_HPD_SIZE);<br>
- eop_gpu_addr >>= 8;<br>
-<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR, lower_32_bits(eop_gpu_addr));<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI, upper_32_bits(eop_gpu_addr));<br>
- mqd->cp_hqd_eop_base_addr_lo = lower_32_bits(eop_gpu_addr);<br>
- mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_gpu_addr);<br>
-<br>
- /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,<br>
- (order_base_2(MEC_HPD_SIZE / 4) - 1));<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL, tmp);<br>
-<br>
- /* enable doorbell? */<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);<br>
- if (use_doorbell)<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);<br>
- else<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 0);<br>
-<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, tmp);<br>
- mqd->cp_hqd_pq_doorbell_control = tmp;<br>
-<br>
- /* disable the queue if it's active */<br>
- ring->wptr = 0;<br>
- mqd->cp_hqd_dequeue_request = 0;<br>
- mqd->cp_hqd_pq_rptr = 0;<br>
- mqd->cp_hqd_pq_wptr_lo = 0;<br>
- mqd->cp_hqd_pq_wptr_hi = 0;<br>
- if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);<br>
- for (j = 0; j < adev->usec_timeout; j++) {<br>
- if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))<br>
- break;<br>
- udelay(1);<br>
- }<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, mqd->cp_hqd_pq_wptr_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, mqd->cp_hqd_pq_wptr_hi);<br>
- }<br>
-<br>
- /* set the pointer to the MQD */<br>
- mqd->cp_mqd_base_addr_lo = mqd_gpu_addr & 0xfffffffc;<br>
- mqd->cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr);<br>
- WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi);<br>
-<br>
- /* set MQD vmid to 0 */<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_MQD_CONTROL);<br>
- tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);<br>
- WREG32_SOC15(GC, 0, mmCP_MQD_CONTROL, tmp);<br>
- mqd->cp_mqd_control = tmp;<br>
-<br>
- /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */<br>
- hqd_gpu_addr = ring->gpu_addr >> 8;<br>
- mqd->cp_hqd_pq_base_lo = hqd_gpu_addr;<br>
- mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi);<br>
-<br>
- /* set up the HQD, this is similar to CP_RB0_CNTL */<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,<br>
- (order_base_2(ring->ring_size / 4) - 1));<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,<br>
- ((order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1) << 8));<br>
-#ifdef __BIG_ENDIAN<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1);<br>
-#endif<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ROQ_PQ_IB_FLIP, 0);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL, tmp);<br>
- mqd->cp_hqd_pq_control = tmp;<br>
-<br>
- /* set the wb address wether it's enabled or not */<br>
- wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);<br>
- mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr & 0xfffffffc;<br>
- mqd->cp_hqd_pq_rptr_report_addr_hi =<br>
- upper_32_bits(wb_gpu_addr) & 0xffff;<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR,<br>
- mqd->cp_hqd_pq_rptr_report_addr_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI,<br>
- mqd->cp_hqd_pq_rptr_report_addr_hi);<br>
-<br>
- /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */<br>
- wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);<br>
- mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr & 0xfffffffc;<br>
- mqd->cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff;<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR,<br>
- mqd->cp_hqd_pq_wptr_poll_addr_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,<br>
- mqd->cp_hqd_pq_wptr_poll_addr_hi);<br>
-<br>
- /* enable the doorbell if requested */<br>
- if (use_doorbell) {<br>
- WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,<br>
- (AMDGPU_DOORBELL64_KIQ * 2) << 2);<br>
- WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,<br>
- (AMDGPU_DOORBELL64_MEC_RING7 * 2) << 2);<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,<br>
- DOORBELL_OFFSET, ring->doorbell_index);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_SOURCE, 0);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_HIT, 0);<br>
- mqd->cp_hqd_pq_doorbell_control = tmp;<br>
-<br>
- } else {<br>
- mqd->cp_hqd_pq_doorbell_control = 0;<br>
- }<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,<br>
- mqd->cp_hqd_pq_doorbell_control);<br>
-<br>
- /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, mqd->cp_hqd_pq_wptr_lo);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, mqd->cp_hqd_pq_wptr_hi);<br>
-<br>
- /* set the vmid for the queue */<br>
- mqd->cp_hqd_vmid = 0;<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_VMID, mqd->cp_hqd_vmid);<br>
-<br>
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE);<br>
- tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE, tmp);<br>
- mqd->cp_hqd_persistent_state = tmp;<br>
-<br>
- /* activate the queue */<br>
- mqd->cp_hqd_active = 1;<br>
- WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, mqd->cp_hqd_active);<br>
-<br>
- soc15_grbm_select(adev, 0, 0, 0, 0);<br>
- mutex_unlock(&adev->srbm_mutex);<br>
-<br>
- amdgpu_bo_kunmap(ring->mqd_obj);<br>
- amdgpu_bo_unreserve(ring->mqd_obj);<br>
-<br>
- if (use_doorbell)<br>
- WREG32_FIELD15(GC, 0, CP_PQ_STATUS, DOORBELL_ENABLE, 1);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
const struct amdgpu_ip_block_version gfx_v9_0_ip_block =<br>
{<br>
.type = AMD_IP_BLOCK_TYPE_GFX,<br>
-- <br>
2.5.5<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>