<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Good point, I wasn't ware that the pm
mutex still existed and is taken under all code flows.<br>
<br>
Christian.<br>
<br>
Am 06.01.2017 um 14:42 schrieb StDenis, Tom:<br>
</div>
<blockquote
cite="mid:CY4PR12MB1768DCF4453B731FDD726447F7630@CY4PR12MB1768.namprd12.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;"
dir="ltr">
<p>There's already the adev->pm.mutex which is held while
gating/ungating blocks. There's no need for a second mutex
right?</p>
<p><br>
</p>
<p>Tom</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font
style="font-size:11pt" color="#000000" face="Calibri,
sans-serif"><b>From:</b> amd-gfx
<a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx-bounces@lists.freedesktop.org"><amd-gfx-bounces@lists.freedesktop.org></a> on behalf
of Christian König <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a><br>
<b>Sent:</b> Friday, January 6, 2017 07:52<br>
<b>To:</b> Huang, Ray; Deucher, Alexander;
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Cc:</b> Kuehling, Felix; Zhang, Hawking; Zhu, Rex;
Fu, Ping; Mao, David<br>
<b>Subject:</b> Re: [PART1 PATCH v3 7/8] drm/amdgpu: add
get clockgating_state method for uvd v5&v6</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Am 06.01.2017 um 11:51 schrieb
Huang Rui:<br>
> Signed-off-by: Huang Rui <a class="moz-txt-link-rfc2396E" href="mailto:ray.huang@amd.com"><ray.huang@amd.com></a><br>
> ---<br>
><br>
> Changes from V2 -> V3:<br>
> - add mutex to protect the is_powergated flag.<br>
><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++<br>
> drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 37
+++++++++++++++++++++++++++++++++--<br>
> drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 37
+++++++++++++++++++++++++++++++++--<br>
> 3 files changed, 72 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> index 530549b..afb3ded 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> @@ -1183,6 +1183,8 @@ struct amdgpu_uvd {<br>
> bool use_ctx_buf;<br>
> struct amd_sched_entity entity;<br>
> uint32_t srbm_soft_reset;<br>
> + bool is_powergated;<br>
> + struct mutex pg_mutex;<br>
<br>
You are missing a mutex_init for pg_mutex, probably best
to put this <br>
into amdgpu_uvd_sw_init().<br>
<br>
Apart from that the patch looks good to me now.<br>
<br>
Regards,<br>
Christian.<br>
<br>
> };<br>
> <br>
> /*<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c<br>
> index 03a35d9..bf797b8 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c<br>
> @@ -781,16 +781,48 @@ static int
uvd_v5_0_set_powergating_state(void *handle,<br>
> * the smc and the hw blocks<br>
> */<br>
> struct amdgpu_device *adev = (struct
amdgpu_device *)handle;<br>
> + int ret = 0;<br>
> <br>
> if (!(adev->pg_flags &
AMD_PG_SUPPORT_UVD))<br>
> return 0;<br>
> <br>
> + mutex_lock(&adev->uvd.pg_mutex);<br>
> +<br>
> if (state == AMD_PG_STATE_GATE) {<br>
> + adev->uvd.is_powergated = true;<br>
> uvd_v5_0_stop(adev);<br>
> - return 0;<br>
> } else {<br>
> - return uvd_v5_0_start(adev);<br>
> + ret = uvd_v5_0_start(adev);<br>
> + if (ret)<br>
> + goto out;<br>
> + adev->uvd.is_powergated = false;<br>
> + }<br>
> +<br>
> +out:<br>
> + mutex_unlock(&adev->uvd.pg_mutex);<br>
> +<br>
> + return ret;<br>
> +}<br>
> +<br>
> +static void uvd_v5_0_get_clockgating_state(void
*handle, u32 *flags)<br>
> +{<br>
> + struct amdgpu_device *adev = (struct
amdgpu_device *)handle;<br>
> + int data;<br>
> +<br>
> + mutex_lock(&adev->uvd.pg_mutex);<br>
> +<br>
> + if (adev->uvd.is_powergated) {<br>
> + DRM_INFO("Cannot get clockgating
state when UVD is powergated.\n");<br>
> + goto out;<br>
> }<br>
> +<br>
> + /* AMD_CG_SUPPORT_UVD_MGCG */<br>
> + data = RREG32(mmUVD_CGC_CTRL);<br>
> + if (data &
UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)<br>
> + *flags |= AMD_CG_SUPPORT_UVD_MGCG;<br>
> +<br>
> +out:<br>
> + mutex_unlock(&adev->uvd.pg_mutex);<br>
> }<br>
> <br>
> static const struct amd_ip_funcs
uvd_v5_0_ip_funcs = {<br>
> @@ -808,6 +840,7 @@ static const struct
amd_ip_funcs uvd_v5_0_ip_funcs = {<br>
> .soft_reset = uvd_v5_0_soft_reset,<br>
> .set_clockgating_state =
uvd_v5_0_set_clockgating_state,<br>
> .set_powergating_state =
uvd_v5_0_set_powergating_state,<br>
> + .get_clockgating_state =
uvd_v5_0_get_clockgating_state,<br>
> };<br>
> <br>
> static const struct amdgpu_ring_funcs
uvd_v5_0_ring_funcs = {<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c<br>
> index 8779d4b..0ec692d 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c<br>
> @@ -987,18 +987,50 @@ static int
uvd_v6_0_set_powergating_state(void *handle,<br>
> * the smc and the hw blocks<br>
> */<br>
> struct amdgpu_device *adev = (struct
amdgpu_device *)handle;<br>
> + int ret = 0;<br>
> <br>
> if (!(adev->pg_flags &
AMD_PG_SUPPORT_UVD))<br>
> return 0;<br>
> <br>
> WREG32(mmUVD_POWER_STATUS,
UVD_POWER_STATUS__UVD_PG_EN_MASK);<br>
> <br>
> + mutex_lock(&adev->uvd.pg_mutex);<br>
> +<br>
> if (state == AMD_PG_STATE_GATE) {<br>
> + adev->uvd.is_powergated = true;<br>
> uvd_v6_0_stop(adev);<br>
> - return 0;<br>
> } else {<br>
> - return uvd_v6_0_start(adev);<br>
> + ret = uvd_v6_0_start(adev);<br>
> + if (ret)<br>
> + goto out;<br>
> + adev->uvd.is_powergated = false;<br>
> + }<br>
> +<br>
> +out:<br>
> + mutex_unlock(&adev->uvd.pg_mutex);<br>
> +<br>
> + return ret;<br>
> +}<br>
> +<br>
> +static void uvd_v6_0_get_clockgating_state(void
*handle, u32 *flags)<br>
> +{<br>
> + struct amdgpu_device *adev = (struct
amdgpu_device *)handle;<br>
> + int data;<br>
> +<br>
> + mutex_lock(&adev->uvd.pg_mutex);<br>
> +<br>
> + if (adev->uvd.is_powergated) {<br>
> + DRM_INFO("Cannot get clockgating
state when UVD is powergated.\n");<br>
> + goto out;<br>
> }<br>
> +<br>
> + /* AMD_CG_SUPPORT_UVD_MGCG */<br>
> + data = RREG32(mmUVD_CGC_CTRL);<br>
> + if (data &
UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)<br>
> + *flags |= AMD_CG_SUPPORT_UVD_MGCG;<br>
> +<br>
> +out:<br>
> + mutex_unlock(&adev->uvd.pg_mutex);<br>
> }<br>
> <br>
> static const struct amd_ip_funcs
uvd_v6_0_ip_funcs = {<br>
> @@ -1019,6 +1051,7 @@ static const struct
amd_ip_funcs uvd_v6_0_ip_funcs = {<br>
> .post_soft_reset = uvd_v6_0_post_soft_reset,<br>
> .set_clockgating_state =
uvd_v6_0_set_clockgating_state,<br>
> .set_powergating_state =
uvd_v6_0_set_powergating_state,<br>
> + .get_clockgating_state =
uvd_v6_0_get_clockgating_state,<br>
> };<br>
> <br>
> static const struct amdgpu_ring_funcs
uvd_v6_0_ring_phys_funcs = {<br>
<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a moz-do-not-send="true"
href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
id="LPlnk851602" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_14837099174670.7732004508767665"
style="margin-bottom: 20px; overflow: auto; width:
100%; text-indent: 0px;">
<table
id="LPContainer_14837099174620.9257069430170277"
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);"
cellspacing="0">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td
id="TextCell_14837099174640.8034805271988259"
colspan="2" style="vertical-align: top;
position: relative; padding: 0px; display:
table-cell;">
<div
id="LPTitle_14837099174640.500860546474154"
style="top: 0px; color: rgb(59, 87, 119);
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 moz-do-not-send="true"
id="LPUrlAnchor_14837099174650.4952875786439821"
href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
target="_blank" style="text-decoration:
none;">amd-gfx Info Page -
lists.freedesktop.org</a></div>
<div
id="LPMetadata_14837099174650.6970539461685066"
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_14837099174660.9659595296758496"
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;">
To see the collection of prior postings to
the list, visit the amd-gfx Archives. Using
amd-gfx: To post a message to all the list
members, send email ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>