Skip to contentSkip to conversation

drm: introduce pcie gen2 link speed check

PATCH In review Dave Airlie 3 participants 7 messages Jun 26, 2012

Subsystems (3)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

PATCH 1/3 drm: introduce pcie gen2 link speed check

From: Dave Airlie <[email protected]>

PCI express gen2.0 can support 5GT link speeds, this add code to decide if this can be used for the device. We currently disable it for via/serverengines root ports due to known issues.

---
 drivers/gpu/drm/drm_pci.c |   37 +++++++++++++++++++++++++++++++++++++
 include/drm/drmP.h        |    2 +-
 2 files changed, 38 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_pci.c +37 -0
index 13f3d93..e4918de 100644
@@ -465,3 +465,40 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
 	DRM_INFO("Module unloaded\n");
 }
 EXPORT_SYMBOL(drm_pci_exit);
+
+int drm_pcie_is_5gt_link_speed_capable(struct drm_device *dev)
+{
+	struct pci_dev *root;
+	int pos;
+	u32 reg32;
+
+	if (!dev->pdev)
+		return -EINVAL;
+
+	if (!pci_is_pcie(dev->pdev))
+		return -EINVAL;
+
+	root = dev->pdev->bus->self;
+
+	pos = pci_pcie_cap(root);
+	if (!pos)
+		return -EINVAL;
+
+	pci_read_config_dword(root, pos + PCI_EXP_LNKCAP, &reg32);
+
+	reg32 &= PCI_EXP_LNKCAP_SLS;
+
+	/* we've been informed via and serverworks don't make the cut */
+	if (root->vendor == PCI_VENDOR_ID_VIA || root->vendor == PCI_VENDOR_ID_SERVERWORKS)
+		return -EINVAL;
+
+	DRM_INFO("probing gen 2 caps for device %x:%x = %x\n", root->vendor, root->device, reg32);
+	if (reg32 == 0x1)
+		return -EINVAL;
+
+	if (reg32 == 0x2)
+		return 0;
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(drm_pcie_is_5gt_link_speed_capable);
include/drm/drmP.h +1 -1
index 31ad880..57d3e85 100644
@@ -1760,7 +1760,7 @@ extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
 extern int drm_get_pci_dev(struct pci_dev *pdev,
 			   const struct pci_device_id *ent,
 			   struct drm_driver *driver);
-
+extern int drm_pcie_is_5gt_link_speed_capable(struct drm_device *dev);
 
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
Signature · 1 line
1.7.7.6
author maintainer
#1 lore raw

PATCH 2/3 drm/radeon: enable pcie gen2 on SI.

From: Dave Airlie <[email protected]>

This patch assumes SI is the same as NI wrt gen2 enabling, and just calls the evergreen code.

---
 drivers/gpu/drm/radeon/si.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/si.c +3 -1
index 34603b3c8..406efa8 100644
@@ -61,7 +61,7 @@ extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
 extern void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save);
 extern void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save);
 extern u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev);
-
+extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
 /* get temperature in millidegrees */
 int si_get_temp(struct radeon_device *rdev)
 {
@@ -3650,6 +3650,8 @@ static int si_startup(struct radeon_device *rdev)
 	struct radeon_ring *ring;
 	int r;
 
+	evergreen_pcie_gen2_enable(rdev);
+
 	if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
 	    !rdev->rlc_fw || !rdev->mc_fw) {
 		r = si_init_microcode(rdev);
Signature · 1 line
1.7.7.6
author maintainer
#2 lore raw

PATCH 3/3 drm/radeon: try to enable pcie gen2 where possible.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This attempts to enable PCIE gen2 where possible, disabling via radeon.pcie_gen2 in case of regression, so we can test it.

---
 drivers/gpu/drm/radeon/evergreen.c  |    5 +++++
 drivers/gpu/drm/radeon/r600.c       |    5 +++++
 drivers/gpu/drm/radeon/radeon_drv.c |    4 ++--
 drivers/gpu/drm/radeon/rv770.c      |    5 +++++
 4 files changed, 17 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +5 -0
index f716e08..3a422a3 100644
@@ -3295,6 +3295,11 @@ void evergreen_pcie_gen2_enable(struct radeon_device *rdev)
 	if (ASIC_IS_X2(rdev))
 		return;
 
+	if (radeon_pcie_gen2 == -1 && drm_pcie_is_5gt_link_speed_capable(rdev->ddev) != 0)
+		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_OTHER_SIDE_EVER_SENT_GEN2) ||
 	    (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
drivers/gpu/drm/radeon/r600.c +5 -0
index 43d0c41..d7b62dc 100644
@@ -3683,6 +3683,11 @@ static void r600_pcie_gen2_enable(struct radeon_device *rdev)
 	if (rdev->family <= CHIP_R600)
 		return;
 
+	if (radeon_pcie_gen2 == -1 && drm_pcie_is_5gt_link_speed_capable(rdev->ddev) != 0)
+		return;
+
+	DRM_INFO("enabling PCIE gen 2 link speeds (disable with radeon.pcie_gen2=0\n");
+
 	/* 55 nm r6xx asics */
 	if ((rdev->family == CHIP_RV670) ||
 	    (rdev->family == CHIP_RV620) ||
drivers/gpu/drm/radeon/radeon_drv.c +2 -2
index 2c4d53f..042fcff 100644
@@ -133,7 +133,7 @@ int radeon_tv = 1;
 int radeon_audio = 0;
 int radeon_disp_priority = 0;
 int radeon_hw_i2c = 0;
-int radeon_pcie_gen2 = 0;
+int radeon_pcie_gen2 = -1;
 int radeon_msi = -1;
 int radeon_lockup_timeout = 10000;
 
@@ -179,7 +179,7 @@ module_param_named(disp_priority, radeon_disp_priority, int, 0444);
 MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
 module_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
 
-MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (1 = enable)");
+MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable)");
 module_param_named(pcie_gen2, radeon_pcie_gen2, int, 0444);
 
 MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
drivers/gpu/drm/radeon/rv770.c +5 -0
index b4f51c5..965745c 100644
@@ -1135,6 +1135,11 @@ static void rv770_pcie_gen2_enable(struct radeon_device *rdev)
 	if (ASIC_IS_X2(rdev))
 		return;
 
+	if (radeon_pcie_gen2 == -1 && drm_pcie_is_5gt_link_speed_capable(rdev->ddev) != 0)
+		return;
+
+	DRM_INFO("enabling PCIE gen 2 link speeds (disable with radeon.pcie_gen2=0\n");
+
 	/* advertise upconfig capability */
 	link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL);
 	link_width_cntl &= ~LC_UPCONFIGURE_DIS;
Signature · 1 line
1.7.7.6
Reviewed-by on v1 1/3
#3 lore raw
In reply to Dave Airlie
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

PCI express gen2.0 can support 5GT link speeds, this add code to decide if this can be used for the device. We currently disable it for via/serverengines root ports due to known issues.

            ^^^^^^^^^^^^^

Patch says ServerWorks. SE is Emulex, SW is Broadcom.

Seems a little like core PCIE functionality, but apparently we're the first ones to want it so we can refactor later.

For the series:

- ajax

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#4 lore raw
Quoted 9 lines · Adam Jackson
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

PCI express gen2.0 can support 5GT link speeds, this add code to decide if this can be used for the device. We currently disable it for via/serverengines root ports due to known issues.

            ^^^^^^^^^^^^^

Patch says ServerWorks.  SE is Emulex, SW is Broadcom.

Oops, good point, will fix commit message,

thanks,
Dave.

Quoted 9 lines

Seems a little like core PCIE functionality, but apparently we're the first ones to want it so we can refactor later.

For the series:

- ajax

Reviewed-by on v1 1/3
#5 lore raw
In reply to Dave Airlie
Quoted 7 lines · Dave Airlie

From: Dave Airlie <[email protected]>

PCI express gen2.0 can support 5GT link speeds, this add code to decide if this can be used for the device. We currently disable it for via/serverengines root ports due to known issues.

I need to double check that SI works the same as NI, but 1 and 3 are:

Quoted 70 lines

---
 drivers/gpu/drm/drm_pci.c |   37 +++++++++++++++++++++++++++++++++++++ include/drm/drmP.h        |    2 +-

 2 files changed, 38 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_pci.c +37 -0
index 13f3d93..e4918de 100644
@@ -465,3 +465,40 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
        DRM_INFO("Module unloaded\n");
  }
  EXPORT_SYMBOL(drm_pci_exit);
+
+int drm_pcie_is_5gt_link_speed_capable(struct drm_device *dev)
+{
+       struct pci_dev *root;
+       int pos;
+       u32 reg32;
+
+       if (!dev->pdev)
+               return -EINVAL;
+
+       if (!pci_is_pcie(dev->pdev))
+               return -EINVAL;
+
+       root = dev->pdev->bus->self;
+
+       pos = pci_pcie_cap(root);
+       if (!pos)
+               return -EINVAL;
+
+       pci_read_config_dword(root, pos + PCI_EXP_LNKCAP, &reg32);
+
+       reg32 &= PCI_EXP_LNKCAP_SLS;
+
+       /* we've been informed via and serverworks don't make the cut */
+       if (root->vendor == PCI_VENDOR_ID_VIA || root->vendor == PCI_VENDOR_ID_SERVERWORKS)
+               return -EINVAL;
+
+       DRM_INFO("probing gen 2 caps for device %x:%x = %x\n", root->vendor, root->device, reg32);
+       if (reg32 == 0x1)
+               return -EINVAL;
+
+       if (reg32 == 0x2)
+               return 0;
+
+       return -EINVAL;
+}
+EXPORT_SYMBOL(drm_pcie_is_5gt_link_speed_capable);
include/drm/drmP.h +1 -2
index 31ad880..57d3e85 100644
@@ -1760,7 +1760,7 @@ extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
  extern int drm_get_pci_dev(struct pci_dev *pdev,
                           const struct pci_device_id *ent,
                           struct drm_driver *driver);
-
+extern int drm_pcie_is_5gt_link_speed_capable(struct drm_device *dev);
 
  /* platform section */
  extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
--

1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#6 lore raw
Quoted 11 lines · Alex Deucher
Quoted 7 lines · Dave Airlie

From: Dave Airlie <[email protected]>

PCI express gen2.0 can support 5GT link speeds, this add code to decide if this can be used for the device. We currently disable it for via/serverengines root ports due to known issues.

I need to double check that SI works the same as NI, but 1 and 3 are:

Yeah after thinking about is SI might support 3.0 so it might be different alright.

I also need to change the drm interface for 3.0.

Dave.