diff mbox

drm/radeon: check if pcie gen 2 is already enabled

Message ID 1349732933-8679-1-git-send-email-alexdeucher@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Deucher Oct. 8, 2012, 9:48 p.m. UTC
From: Alex Deucher <alexander.deucher@amd.com>

If so, skip enabling it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/evergreen.c |    8 ++++++--
 drivers/gpu/drm/radeon/r600.c      |    7 ++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

Comments

Paul Menzel Oct. 9, 2012, 6:26 a.m. UTC | #1
Am Montag, den 08.10.2012, 17:48 -0400 schrieb alexdeucher@gmail.com:
> From: Alex Deucher <alexander.deucher@amd.com>
> 
> If so, skip enabling it.

Does that fix any error/problem or is it just for speed reasons?

> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/radeon/evergreen.c |    8 ++++++--
>  drivers/gpu/drm/radeon/r600.c      |    7 ++++++-
>  2 files changed, 12 insertions(+), 3 deletions(-)

[…]


Thanks,

Paul
Rafał Miłecki Oct. 9, 2012, 7:05 a.m. UTC | #2
2012/10/8  <alexdeucher@gmail.com>:
> +       if (speed_cntl & LC_CURRENT_DATA_RATE) {
> +               DRM_INFO("PCIE gen 2 link speeds already enabled\n");
> +               return;
> +       } else
> +               DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
> +

See documentation/CodingStyle:

> This does not apply if only one branch of a conditional statement is a single
> statement; in the latter case use braces in both branches:

Your else should use braces :)
Alex Deucher Oct. 9, 2012, 1:02 p.m. UTC | #3
On Tue, Oct 9, 2012 at 2:26 AM, Paul Menzel
<paulepanter@users.sourceforge.net> wrote:
> Am Montag, den 08.10.2012, 17:48 -0400 schrieb alexdeucher@gmail.com:
>> From: Alex Deucher <alexander.deucher@amd.com>
>>
>> If so, skip enabling it.
>
> Does that fix any error/problem or is it just for speed reasons?

It doesn't fix anything that I know of.  Just speed.

Alex

>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>> ---
>>  drivers/gpu/drm/radeon/evergreen.c |    8 ++++++--
>>  drivers/gpu/drm/radeon/r600.c      |    7 ++++++-
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>
> […]
>
>
> Thanks,
>
> Paul
Alex Deucher Oct. 9, 2012, 1:02 p.m. UTC | #4
On Tue, Oct 9, 2012 at 3:05 AM, Rafa? Mi?ecki <zajec5@gmail.com> wrote:
> 2012/10/8  <alexdeucher@gmail.com>:
>> +       if (speed_cntl & LC_CURRENT_DATA_RATE) {
>> +               DRM_INFO("PCIE gen 2 link speeds already enabled\n");
>> +               return;
>> +       } else
>> +               DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
>> +
>
> See documentation/CodingStyle:
>
>> This does not apply if only one branch of a conditional statement is a single
>> statement; in the latter case use braces in both branches:
>
> Your else should use braces :)

I'll fix that up.

Alex
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a1f49c5..888c798 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3431,9 +3431,13 @@  void evergreen_pcie_gen2_enable(struct radeon_device *rdev)
 	if (!(mask & DRM_PCIE_SPEED_50))
 		return;
 
-	DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
-
 	speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
+	if (speed_cntl & LC_CURRENT_DATA_RATE) {
+		DRM_INFO("PCIE gen 2 link speeds already enabled\n");
+		return;
+	} else
+		DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
+
 	if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) ||
 	    (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
 
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 70c800f..20e4fad 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3703,7 +3703,12 @@  static void r600_pcie_gen2_enable(struct radeon_device *rdev)
 	if (!(mask & DRM_PCIE_SPEED_50))
 		return;
 
-	DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
+	speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
+	if (speed_cntl & LC_CURRENT_DATA_RATE) {
+		DRM_INFO("PCIE gen 2 link speeds already enabled\n");
+		return;
+	} else
+		DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
 
 	/* 55 nm r6xx asics */
 	if ((rdev->family == CHIP_RV670) ||