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

Alex Deucher alexdeucher at gmail.com
Tue Jun 26 08:33:20 PDT 2012


On Tue, Jun 26, 2012 at 10:50 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> 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.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>

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

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/drm_pci.c |   37 +++++++++++++++++++++++++++++++++++++
>  include/drm/drmP.h        |    2 +-
>  2 files changed, 38 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 13f3d93..e4918de 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -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);
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 31ad880..57d3e85 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -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
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


More information about the dri-devel mailing list