<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; font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Reviewed-by: Rex Zhu<rezhu@amd.com></span><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;"><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Best Regards</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Rex</span><a class="i_Wm6 jZtLg _19Y0R _81eaS _1EhqP " title="rex.zhu@amd.com" target="_self" tabindex="0" aria-label="Email rex.zhu@amd.com" style="color: rgb(36, 136, 216) !important; box-sizing: content-box; background-color: rgb(255, 255, 255); font-family: "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;" id="LPlnk452588" previewremoved="true"></a></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 Alex Deucher <alexdeucher@gmail.com><br>
<b>Sent:</b> Thursday, March 1, 2018 10:04 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Deucher, Alexander; stable@vger.kernel.org<br>
<b>Subject:</b> [PATCH] drm/amdgpu: used cached pcie gen info for SI (v2)</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Rather than querying it every time we need it.<br>
Also fixes a crash in VM pass through if there is no<br>
root bridge because the cached value fetch already checks<br>
this properly.<br>
<br>
v2: fix includes<br>
<br>
Fixes: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=105244" id="LPlnk317240" previewremoved="true">
https://bugs.freedesktop.org/show_bug.cgi?id=105244</a><br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
Cc: stable@vger.kernel.org<br>
---<br>
drivers/gpu/drm/amd/amdgpu/si.c | 22 ++++++++--------<br>
drivers/gpu/drm/amd/amdgpu/si_dpm.c | 50 ++++++++++---------------------------<br>
2 files changed, 23 insertions(+), 49 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c<br>
index f20c4b7414e8..6e61b56bfbfc 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/si.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/si.c<br>
@@ -31,6 +31,7 @@<br>
#include "amdgpu_uvd.h"<br>
#include "amdgpu_vce.h"<br>
#include "atom.h"<br>
+#include "amd_pcie.h"<br>
#include "amdgpu_powerplay.h"<br>
#include "sid.h"<br>
#include "si_ih.h"<br>
@@ -1484,8 +1485,8 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)<br>
{<br>
struct pci_dev *root = adev->pdev->bus->self;<br>
int bridge_pos, gpu_pos;<br>
- u32 speed_cntl, mask, current_data_rate;<br>
- int ret, i;<br>
+ u32 speed_cntl, current_data_rate;<br>
+ int i;<br>
u16 tmp16;<br>
<br>
if (pci_is_root_bus(adev->pdev->bus))<br>
@@ -1497,23 +1498,20 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)<br>
if (adev->flags & AMD_IS_APU)<br>
return;<br>
<br>
- ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);<br>
- if (ret != 0)<br>
- return;<br>
-<br>
- if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80)))<br>
+ if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |<br>
+ CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))<br>
return;<br>
<br>
speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);<br>
current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >><br>
LC_CURRENT_DATA_RATE_SHIFT;<br>
- if (mask & DRM_PCIE_SPEED_80) {<br>
+ if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {<br>
if (current_data_rate == 2) {<br>
DRM_INFO("PCIE gen 3 link speeds already enabled\n");<br>
return;<br>
}<br>
DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n");<br>
- } else if (mask & DRM_PCIE_SPEED_50) {<br>
+ } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) {<br>
if (current_data_rate == 1) {<br>
DRM_INFO("PCIE gen 2 link speeds already enabled\n");<br>
return;<br>
@@ -1529,7 +1527,7 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)<br>
if (!gpu_pos)<br>
return;<br>
<br>
- if (mask & DRM_PCIE_SPEED_80) {<br>
+ if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {<br>
if (current_data_rate != 2) {<br>
u16 bridge_cfg, gpu_cfg;<br>
u16 bridge_cfg2, gpu_cfg2;<br>
@@ -1612,9 +1610,9 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)<br>
<br>
pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);<br>
tmp16 &= ~0xf;<br>
- if (mask & DRM_PCIE_SPEED_80)<br>
+ if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)<br>
tmp16 |= 3;<br>
- else if (mask & DRM_PCIE_SPEED_50)<br>
+ else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)<br>
tmp16 |= 2;<br>
else<br>
tmp16 |= 1;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c<br>
index 8138053fcef1..8137c02fd16a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c<br>
@@ -26,6 +26,7 @@<br>
#include "amdgpu_pm.h"<br>
#include "amdgpu_dpm.h"<br>
#include "amdgpu_atombios.h"<br>
+#include "amd_pcie.h"<br>
#include "sid.h"<br>
#include "r600_dpm.h"<br>
#include "si_dpm.h"<br>
@@ -3331,29 +3332,6 @@ static void btc_apply_voltage_delta_rules(struct amdgpu_device *adev,<br>
}<br>
}<br>
<br>
-static enum amdgpu_pcie_gen r600_get_pcie_gen_support(struct amdgpu_device *adev,<br>
- u32 sys_mask,<br>
- enum amdgpu_pcie_gen asic_gen,<br>
- enum amdgpu_pcie_gen default_gen)<br>
-{<br>
- switch (asic_gen) {<br>
- case AMDGPU_PCIE_GEN1:<br>
- return AMDGPU_PCIE_GEN1;<br>
- case AMDGPU_PCIE_GEN2:<br>
- return AMDGPU_PCIE_GEN2;<br>
- case AMDGPU_PCIE_GEN3:<br>
- return AMDGPU_PCIE_GEN3;<br>
- default:<br>
- if ((sys_mask & DRM_PCIE_SPEED_80) && (default_gen == AMDGPU_PCIE_GEN3))<br>
- return AMDGPU_PCIE_GEN3;<br>
- else if ((sys_mask & DRM_PCIE_SPEED_50) && (default_gen == AMDGPU_PCIE_GEN2))<br>
- return AMDGPU_PCIE_GEN2;<br>
- else<br>
- return AMDGPU_PCIE_GEN1;<br>
- }<br>
- return AMDGPU_PCIE_GEN1;<br>
-}<br>
-<br>
static void r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,<br>
u32 *p, u32 *u)<br>
{<br>
@@ -5028,10 +5006,11 @@ static int si_populate_smc_acpi_state(struct amdgpu_device *adev,<br>
table->ACPIState.levels[0].vddc.index,<br>
&table->ACPIState.levels[0].std_vddc);<br>
}<br>
- table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(adev,<br>
- si_pi->sys_pcie_mask,<br>
- si_pi->boot_pcie_gen,<br>
- AMDGPU_PCIE_GEN1);<br>
+ table->ACPIState.levels[0].gen2PCIE =<br>
+ (u8)amdgpu_get_pcie_gen_support(adev,<br>
+ si_pi->sys_pcie_mask,<br>
+ si_pi->boot_pcie_gen,<br>
+ AMDGPU_PCIE_GEN1);<br>
<br>
if (si_pi->vddc_phase_shed_control)<br>
si_populate_phase_shedding_value(adev,<br>
@@ -7168,10 +7147,10 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,<br>
pl->vddc = le16_to_cpu(clock_info->si.usVDDC);<br>
pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);<br>
pl->flags = le32_to_cpu(clock_info->si.ulFlags);<br>
- pl->pcie_gen = r600_get_pcie_gen_support(adev,<br>
- si_pi->sys_pcie_mask,<br>
- si_pi->boot_pcie_gen,<br>
- clock_info->si.ucPCIEGen);<br>
+ pl->pcie_gen = amdgpu_get_pcie_gen_support(adev,<br>
+ si_pi->sys_pcie_mask,<br>
+ si_pi->boot_pcie_gen,<br>
+ clock_info->si.ucPCIEGen);<br>
<br>
/* patch up vddc if necessary */<br>
ret = si_get_leakage_voltage_from_leakage_index(adev, pl->vddc,<br>
@@ -7326,7 +7305,6 @@ static int si_dpm_init(struct amdgpu_device *adev)<br>
struct si_power_info *si_pi;<br>
struct atom_clock_dividers dividers;<br>
int ret;<br>
- u32 mask;<br>
<br>
si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);<br>
if (si_pi == NULL)<br>
@@ -7336,11 +7314,9 @@ static int si_dpm_init(struct amdgpu_device *adev)<br>
eg_pi = &ni_pi->eg;<br>
pi = &eg_pi->rv7xx;<br>
<br>
- ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);<br>
- if (ret)<br>
- si_pi->sys_pcie_mask = 0;<br>
- else<br>
- si_pi->sys_pcie_mask = mask;<br>
+ si_pi->sys_pcie_mask =<br>
+ (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) >><br>
+ CAIL_PCIE_LINK_SPEED_SUPPORT_SHIFT;<br>
si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;<br>
si_pi->boot_pcie_gen = si_get_current_pcie_speed(adev);<br>
<br>
-- <br>
2.13.6<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="LPlnk569804" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15200389369860.8099112469914744" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15200389369770.07540873504833634" 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_15200389369810.15734688362710525" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15200389369820.9499041851208263"></div>
<div id="LPTitle_15200389369820.031472893158088766" 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_15200389369840.11259246378743137" 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_15200389369840.057204491134174695" 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_15200389369850.3904603170324785" 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>