Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-12 Thread Ville Syrjälä
On Wed, Aug 12, 2015 at 03:14:53PM +0100, Chris Wilson wrote:
> On Wed, Aug 12, 2015 at 04:45:39PM +0300, Ville Syrjälä wrote:
> > > - /*
> > > -  * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but
> > > -  * for DP the encoder type can be set by the caller to
> > > -  * INTEL_OUTPUT_UNKNOWN for DDI, so don't rewrite it.
> > > -  */
> > > - if (type == DRM_MODE_CONNECTOR_eDP)
> > > - intel_encoder->type = INTEL_OUTPUT_EDP;
> > 
> > aux (and IIRC pps setup on vlv/chv) needs is_edp() to work. So I think
> > this would break stuff.
> 
> Hmm, I was hoping that all the additional setup we do in init for edp
> would be enough for it to use any and all sidebands as necessary.

It might work by accident at least on some machines since BIOSen seem to
leave the vdd force enabled for eDP panels even if the port isn't
active. But if that's not the case, then we'd fail to power up the panel
before attempting the initial aux communication, and the eDP probe
would fail.

> 
> The fallout will be that we simply cannot reuse the false eDP link as a
> plain DP and just establish one HDMI connector for the port. Or maybe it
> is still recoverable?

If we can keep is_edp() returning true during the edp init, things should 
work OK.

For vlv/chv we might need to poke at the pps (maybe just
vlv_detach_power_sequencer() would be enough) to make normal DP work
without the pps preventing the port from powering up. That should be
testable by pretending the VBT is lying about a DP port being an eDP port.

-- 
Ville Syrjälä
Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-12 Thread Chris Wilson
On Wed, Aug 12, 2015 at 04:45:39PM +0300, Ville Syrjälä wrote:
> > -   /*
> > -* For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but
> > -* for DP the encoder type can be set by the caller to
> > -* INTEL_OUTPUT_UNKNOWN for DDI, so don't rewrite it.
> > -*/
> > -   if (type == DRM_MODE_CONNECTOR_eDP)
> > -   intel_encoder->type = INTEL_OUTPUT_EDP;
> 
> aux (and IIRC pps setup on vlv/chv) needs is_edp() to work. So I think
> this would break stuff.

Hmm, I was hoping that all the additional setup we do in init for edp
would be enough for it to use any and all sidebands as necessary.

The fallout will be that we simply cannot reuse the false eDP link as a
plain DP and just establish one HDMI connector for the port. Or maybe it
is still recoverable?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-12 Thread Ville Syrjälä
On Sun, Aug 09, 2015 at 01:12:53PM +0100, Chris Wilson wrote:
> We follow the VBT as to whether a DDI port is used for eDP and if so, do
> not attach a HDMI encoder to it. However there are machines for which
> the VBT eDP flag is a lie (shocking!) and we fail to detect a eDP link.
> Furthermore, on those machines the HDMI is connected to that DDI port
> but we ignore it.
> 
> If we reorder our port initialisation to try the eDP setup first and
> if that fails we can treat it as a normal DP port along with a HDMI
> output. To accomplish this, we have to delay registering the DP
> connector/encoder until after we establish its final type.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331
> Signed-off-by: Chris Wilson 
> Cc: Jesse Barnes 
> ---
>  drivers/gpu/drm/i915/intel_display.c |  27 
>  drivers/gpu/drm/i915/intel_dp.c  | 127 
> +--
>  drivers/gpu/drm/i915/intel_drv.h |   6 +-
>  3 files changed, 79 insertions(+), 81 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index 0bcd1b1aba4f..aab8dfd1f8a5 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct drm_device 
> *dev)
>  {
>   struct drm_i915_private *dev_priv = dev->dev_private;
>   struct intel_encoder *encoder;
> - bool dpd_is_edp = false;
>  
>   intel_lvds_init(dev);
>  
> @@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct drm_device 
> *dev)
>   intel_ddi_init(dev, PORT_D);
>   } else if (HAS_PCH_SPLIT(dev)) {
>   int found;
> - dpd_is_edp = intel_dp_is_edp(dev, PORT_D);
>  
>   if (has_edp_a(dev))
>   intel_dp_init(dev, DP_A, PORT_A);
>  
> + found = 0;
> + /* PCH SDVOB multiplex with HDMIB */
>   if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
> - /* PCH SDVOB multiplex with HDMIB */
>   found = intel_sdvo_init(dev, PCH_SDVOB, true);
>   if (!found)
>   intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
> - if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
> - intel_dp_init(dev, PCH_DP_B, PORT_B);
>   }
> + if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
> + intel_dp_init(dev, PCH_DP_B, PORT_B);
>  
> - if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> - intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
> -
> - if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
> - intel_hdmi_init(dev, PCH_HDMID, PORT_D);
> -
> + found = 0;
>   if (I915_READ(PCH_DP_C) & DP_DETECTED)
> - intel_dp_init(dev, PCH_DP_C, PORT_C);
> + found = intel_dp_init(dev, PCH_DP_C, PORT_C);
> + if (found != DRM_MODE_CONNECTOR_eDP &&
> + I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> + intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
>  
> + found = 0;
>   if (I915_READ(PCH_DP_D) & DP_DETECTED)
> - intel_dp_init(dev, PCH_DP_D, PORT_D);
> + found = intel_dp_init(dev, PCH_DP_D, PORT_D);
> + if (found != DRM_MODE_CONNECTOR_eDP &&
> + I915_READ(PCH_HDMID) & SDVO_DETECTED)
> + intel_hdmi_init(dev, PCH_HDMID, PORT_D);
>   } else if (IS_VALLEYVIEW(dev)) {
>   /*
>* The DP_DETECTED bit is the latched state of the DDC
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 1e64a8c1e7cb..8adf500f3989 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -1031,14 +1031,13 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct 
> drm_dp_aux_msg *msg)
>   return ret;
>  }
>  
> -static void
> +static int
>  intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector 
> *connector)
>  {
>   struct drm_device *dev = intel_dp_to_dev(intel_dp);
>   struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
>   enum port port = intel_dig_port->port;
>   const char *name = NULL;
> - int ret;
>  
>   switch (port) {
>   case PORT_A:
> @@ -1080,20 +1079,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct 
> intel_connector *connector)
>   DRM_DEBUG_KMS("registering %s bus for %s\n", name,
> connector->base.kdev->kobj.name);
>  
> - ret = drm_dp_aux_register(&intel_dp->aux);
> - if (ret < 0) {
> - DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
> -   name, ret);
> - return;
> - }
> -
> - ret = sysfs_create_link(&connector->base.kdev->kobj,
> -

Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-10 Thread Chris Wilson
On Mon, Aug 10, 2015 at 04:05:31PM +0530, Sivakumar Thulasimani wrote:
> Chris,
> After asking few people found that the simplest explanation and
> plausible root cause
> being that PORT D is set for both eDP and HDMI :). in which case the
> proper fix is  to
> check in intel_dp_is_edp, if PORT D is again set for any other
> display and return false
> if that is the case

The only difference between that and my patch is that you would not
expose the DP link if the VBT flagged it as eDP.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-10 Thread Sivakumar Thulasimani

Chris,
After asking few people found that the simplest explanation and 
plausible root cause
being that PORT D is set for both eDP and HDMI :). in which case the 
proper fix is  to
check in intel_dp_is_edp, if PORT D is again set for any other display 
and return false

if that is the case
or
have a quirk for this config since this seems to be reported atleast for 
now as suggested

by Lukas

i would recommend the first method, if we confirm the root cause is as 
explained above.


On 8/10/2015 11:35 AM, Sivakumar Thulasimani wrote:

hi Mengdong,
is there any reason why you cannot modify VBT ? unless it is 
shipped version you

can just flash the modified VBT along with BIOS.

Chris,
i would be even more surprised if VBIOS/GOP can enable some 
display when it is
configured incorrectly in VBT. Give me a day to check with someone if 
this is even

possible in that level.

On 8/10/2015 8:00 AM, Lin, Mengdong wrote:

-Original Message-
From: Intel-gfx [mailto:intel-gfx-boun...@lists.freedesktop.org] On 
Behalf Of

Lukas Wunner
Hi,

On Sun, Aug 09, 2015 at 01:12:53PM +0100, Chris Wilson wrote:

We follow the VBT as to whether a DDI port is used for eDP and if so,
do not attach a HDMI encoder to it. However there are machines for
which the VBT eDP flag is a lie (shocking!) and we fail to detect a 
eDP link.

Furthermore, on those machines the HDMI is connected to that DDI port
but we ignore it.

If we reorder our port initialisation to try the eDP setup first and
if that fails we can treat it as a normal DP port along with a HDMI
output. To accomplish this, we have to delay registering the DP
connector/encoder until after we establish its final type.

Sorry to jump in. Could this help another use case as below ?

We have some Bytrail machine (Bayley Bay), we applied HW rework to 
disable eDP connectivity to DDI1 and enable DP on DDI 1.
But we found the i915 driver still take this DDI as eDP, not DP. we 
suspect it's because VBT still takes it as DP and so i915 driver just 
follows.


If we don't want to revise VBT in BIOS after every rework, is there 
any other way to let i915 detect this is a DP link?


Thanks
Mengdong


Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331

The existing code seems very carefully crafted, taking into account the
differences betweem various GPU generations etc, shuffling that around
might risk breakage. FWIW, I'm wondering if just adding a quirk for 
this single

Dell workstation might be justified?

Best regards,

Lukas



Signed-off-by: Chris Wilson 
Cc: Jesse Barnes 
---
  drivers/gpu/drm/i915/intel_display.c |  27 
  drivers/gpu/drm/i915/intel_dp.c  | 127

+--

  drivers/gpu/drm/i915/intel_drv.h |   6 +-
  3 files changed, 79 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c
b/drivers/gpu/drm/i915/intel_display.c
index 0bcd1b1aba4f..aab8dfd1f8a5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct
drm_device *dev)  {
  struct drm_i915_private *dev_priv = dev->dev_private;
  struct intel_encoder *encoder;
-bool dpd_is_edp = false;

  intel_lvds_init(dev);

@@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct

drm_device *dev)

  intel_ddi_init(dev, PORT_D);
  } else if (HAS_PCH_SPLIT(dev)) {
  int found;
-dpd_is_edp = intel_dp_is_edp(dev, PORT_D);

  if (has_edp_a(dev))
  intel_dp_init(dev, DP_A, PORT_A);

+found = 0;
+/* PCH SDVOB multiplex with HDMIB */
  if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
-/* PCH SDVOB multiplex with HDMIB */
  found = intel_sdvo_init(dev, PCH_SDVOB, true);
  if (!found)
  intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
-if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
-intel_dp_init(dev, PCH_DP_B, PORT_B);
  }
+if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
+intel_dp_init(dev, PCH_DP_B, PORT_B);

-if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
-intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
-
-if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
-intel_hdmi_init(dev, PCH_HDMID, PORT_D);
-
+found = 0;
  if (I915_READ(PCH_DP_C) & DP_DETECTED)
-intel_dp_init(dev, PCH_DP_C, PORT_C);
+found = intel_dp_init(dev, PCH_DP_C, PORT_C);
+if (found != DRM_MODE_CONNECTOR_eDP &&
+I915_READ(PCH_HDMIC) & SDVO_DETECTED)
+intel_hdmi_init(dev, PCH_HDMIC, PORT_C);

+found = 0;
  if (I915_READ(PCH_DP_D) & DP_DETECTED)
-intel_dp_init(dev, PCH_DP_D, PORT_D);
+found = intel_dp_init(dev, PCH_DP_D, PORT_D);
+if (found != DRM_MODE_CONNECTOR_eDP &&
+I915_READ(PCH_HDMID) & SDVO_DETECTED)
+intel

Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-09 Thread Sivakumar Thulasimani

hi Mengdong,
is there any reason why you cannot modify VBT ? unless it is 
shipped version you

can just flash the modified VBT along with BIOS.

Chris,
i would be even more surprised if VBIOS/GOP can enable some display 
when it is
configured incorrectly in VBT. Give me a day to check with someone if 
this is even

possible in that level.

On 8/10/2015 8:00 AM, Lin, Mengdong wrote:

-Original Message-
From: Intel-gfx [mailto:intel-gfx-boun...@lists.freedesktop.org] On Behalf Of
Lukas Wunner
Hi,

On Sun, Aug 09, 2015 at 01:12:53PM +0100, Chris Wilson wrote:

We follow the VBT as to whether a DDI port is used for eDP and if so,
do not attach a HDMI encoder to it. However there are machines for
which the VBT eDP flag is a lie (shocking!) and we fail to detect a eDP link.
Furthermore, on those machines the HDMI is connected to that DDI port
but we ignore it.

If we reorder our port initialisation to try the eDP setup first and
if that fails we can treat it as a normal DP port along with a HDMI
output. To accomplish this, we have to delay registering the DP
connector/encoder until after we establish its final type.

Sorry to jump in. Could this help another use case as below ?

We have some Bytrail machine (Bayley Bay), we applied HW rework to disable eDP 
connectivity to DDI1 and enable DP on DDI 1.
But we found the i915 driver still take this DDI as eDP, not DP. we suspect 
it's because VBT still takes it as DP and so i915 driver just follows.

If we don't want to revise VBT in BIOS after every rework, is there any other 
way to let i915 detect this is a DP link?

Thanks
Mengdong


Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331

The existing code seems very carefully crafted, taking into account the
differences betweem various GPU generations etc, shuffling that around
might risk breakage. FWIW, I'm wondering if just adding a quirk for this single
Dell workstation might be justified?

Best regards,

Lukas



Signed-off-by: Chris Wilson 
Cc: Jesse Barnes 
---
  drivers/gpu/drm/i915/intel_display.c |  27 
  drivers/gpu/drm/i915/intel_dp.c  | 127

+--

  drivers/gpu/drm/i915/intel_drv.h |   6 +-
  3 files changed, 79 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c
b/drivers/gpu/drm/i915/intel_display.c
index 0bcd1b1aba4f..aab8dfd1f8a5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct
drm_device *dev)  {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *encoder;
-   bool dpd_is_edp = false;

intel_lvds_init(dev);

@@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct

drm_device *dev)

intel_ddi_init(dev, PORT_D);
} else if (HAS_PCH_SPLIT(dev)) {
int found;
-   dpd_is_edp = intel_dp_is_edp(dev, PORT_D);

if (has_edp_a(dev))
intel_dp_init(dev, DP_A, PORT_A);

+   found = 0;
+   /* PCH SDVOB multiplex with HDMIB */
if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
-   /* PCH SDVOB multiplex with HDMIB */
found = intel_sdvo_init(dev, PCH_SDVOB, true);
if (!found)
intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
-   if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
-   intel_dp_init(dev, PCH_DP_B, PORT_B);
}
+   if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
+   intel_dp_init(dev, PCH_DP_B, PORT_B);

-   if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
-   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
-
-   if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
-   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
-
+   found = 0;
if (I915_READ(PCH_DP_C) & DP_DETECTED)
-   intel_dp_init(dev, PCH_DP_C, PORT_C);
+   found = intel_dp_init(dev, PCH_DP_C, PORT_C);
+   if (found != DRM_MODE_CONNECTOR_eDP &&
+   I915_READ(PCH_HDMIC) & SDVO_DETECTED)
+   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);

+   found = 0;
if (I915_READ(PCH_DP_D) & DP_DETECTED)
-   intel_dp_init(dev, PCH_DP_D, PORT_D);
+   found = intel_dp_init(dev, PCH_DP_D, PORT_D);
+   if (found != DRM_MODE_CONNECTOR_eDP &&
+   I915_READ(PCH_HDMID) & SDVO_DETECTED)
+   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
} else if (IS_VALLEYVIEW(dev)) {
/*
 * The DP_DETECTED bit is the latched state of the DDC diff 
--git
a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/d

Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-09 Thread Lin, Mengdong
> -Original Message-
> From: Intel-gfx [mailto:intel-gfx-boun...@lists.freedesktop.org] On Behalf Of
> Lukas Wunner

> Hi,
> 
> On Sun, Aug 09, 2015 at 01:12:53PM +0100, Chris Wilson wrote:
> > We follow the VBT as to whether a DDI port is used for eDP and if so,
> > do not attach a HDMI encoder to it. However there are machines for
> > which the VBT eDP flag is a lie (shocking!) and we fail to detect a eDP 
> > link.
> > Furthermore, on those machines the HDMI is connected to that DDI port
> > but we ignore it.
> >
> > If we reorder our port initialisation to try the eDP setup first and
> > if that fails we can treat it as a normal DP port along with a HDMI
> > output. To accomplish this, we have to delay registering the DP
> > connector/encoder until after we establish its final type.

Sorry to jump in. Could this help another use case as below ?

We have some Bytrail machine (Bayley Bay), we applied HW rework to disable eDP 
connectivity to DDI1 and enable DP on DDI 1.
But we found the i915 driver still take this DDI as eDP, not DP. we suspect 
it's because VBT still takes it as DP and so i915 driver just follows.

If we don't want to revise VBT in BIOS after every rework, is there any other 
way to let i915 detect this is a DP link?

Thanks
Mengdong

> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331
> 
> The existing code seems very carefully crafted, taking into account the
> differences betweem various GPU generations etc, shuffling that around
> might risk breakage. FWIW, I'm wondering if just adding a quirk for this 
> single
> Dell workstation might be justified?
> 
> Best regards,
> 
> Lukas
> 
> 
> > Signed-off-by: Chris Wilson 
> > Cc: Jesse Barnes 
> > ---
> >  drivers/gpu/drm/i915/intel_display.c |  27 
> >  drivers/gpu/drm/i915/intel_dp.c  | 127
> +--
> >  drivers/gpu/drm/i915/intel_drv.h |   6 +-
> >  3 files changed, 79 insertions(+), 81 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_display.c
> > b/drivers/gpu/drm/i915/intel_display.c
> > index 0bcd1b1aba4f..aab8dfd1f8a5 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct
> > drm_device *dev)  {
> > struct drm_i915_private *dev_priv = dev->dev_private;
> > struct intel_encoder *encoder;
> > -   bool dpd_is_edp = false;
> >
> > intel_lvds_init(dev);
> >
> > @@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct
> drm_device *dev)
> > intel_ddi_init(dev, PORT_D);
> > } else if (HAS_PCH_SPLIT(dev)) {
> > int found;
> > -   dpd_is_edp = intel_dp_is_edp(dev, PORT_D);
> >
> > if (has_edp_a(dev))
> > intel_dp_init(dev, DP_A, PORT_A);
> >
> > +   found = 0;
> > +   /* PCH SDVOB multiplex with HDMIB */
> > if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
> > -   /* PCH SDVOB multiplex with HDMIB */
> > found = intel_sdvo_init(dev, PCH_SDVOB, true);
> > if (!found)
> > intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
> > -   if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
> > -   intel_dp_init(dev, PCH_DP_B, PORT_B);
> > }
> > +   if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
> > +   intel_dp_init(dev, PCH_DP_B, PORT_B);
> >
> > -   if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> > -   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
> > -
> > -   if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
> > -   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
> > -
> > +   found = 0;
> > if (I915_READ(PCH_DP_C) & DP_DETECTED)
> > -   intel_dp_init(dev, PCH_DP_C, PORT_C);
> > +   found = intel_dp_init(dev, PCH_DP_C, PORT_C);
> > +   if (found != DRM_MODE_CONNECTOR_eDP &&
> > +   I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> > +   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
> >
> > +   found = 0;
> > if (I915_READ(PCH_DP_D) & DP_DETECTED)
> > -   intel_dp_init(dev, PCH_DP_D, PORT_D);
> > +   found = intel_dp_init(dev, PCH_DP_D, PORT_D);
> > +   if (found != DRM_MODE_CONNECTOR_eDP &&
> > +   I915_READ(PCH_HDMID) & SDVO_DETECTED)
> > +   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
> > } else if (IS_VALLEYVIEW(dev)) {
> > /*
> >  * The DP_DETECTED bit is the latched state of the DDC diff 
> > --git
> > a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index 1e64a8c1e7cb..8adf500f3989 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -1031,14 +1031,13 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux,

Re: [Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-09 Thread Lukas Wunner
Hi,

On Sun, Aug 09, 2015 at 01:12:53PM +0100, Chris Wilson wrote:
> We follow the VBT as to whether a DDI port is used for eDP and if so, do
> not attach a HDMI encoder to it. However there are machines for which
> the VBT eDP flag is a lie (shocking!) and we fail to detect a eDP link.
> Furthermore, on those machines the HDMI is connected to that DDI port
> but we ignore it.
> 
> If we reorder our port initialisation to try the eDP setup first and
> if that fails we can treat it as a normal DP port along with a HDMI
> output. To accomplish this, we have to delay registering the DP
> connector/encoder until after we establish its final type.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331

The existing code seems very carefully crafted, taking into account
the differences betweem various GPU generations etc, shuffling that
around might risk breakage. FWIW, I'm wondering if just adding a quirk
for this single Dell workstation might be justified?

Best regards,

Lukas


> Signed-off-by: Chris Wilson 
> Cc: Jesse Barnes 
> ---
>  drivers/gpu/drm/i915/intel_display.c |  27 
>  drivers/gpu/drm/i915/intel_dp.c  | 127 
> +--
>  drivers/gpu/drm/i915/intel_drv.h |   6 +-
>  3 files changed, 79 insertions(+), 81 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index 0bcd1b1aba4f..aab8dfd1f8a5 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct drm_device 
> *dev)
>  {
>   struct drm_i915_private *dev_priv = dev->dev_private;
>   struct intel_encoder *encoder;
> - bool dpd_is_edp = false;
>  
>   intel_lvds_init(dev);
>  
> @@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct drm_device 
> *dev)
>   intel_ddi_init(dev, PORT_D);
>   } else if (HAS_PCH_SPLIT(dev)) {
>   int found;
> - dpd_is_edp = intel_dp_is_edp(dev, PORT_D);
>  
>   if (has_edp_a(dev))
>   intel_dp_init(dev, DP_A, PORT_A);
>  
> + found = 0;
> + /* PCH SDVOB multiplex with HDMIB */
>   if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
> - /* PCH SDVOB multiplex with HDMIB */
>   found = intel_sdvo_init(dev, PCH_SDVOB, true);
>   if (!found)
>   intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
> - if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
> - intel_dp_init(dev, PCH_DP_B, PORT_B);
>   }
> + if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
> + intel_dp_init(dev, PCH_DP_B, PORT_B);
>  
> - if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> - intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
> -
> - if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
> - intel_hdmi_init(dev, PCH_HDMID, PORT_D);
> -
> + found = 0;
>   if (I915_READ(PCH_DP_C) & DP_DETECTED)
> - intel_dp_init(dev, PCH_DP_C, PORT_C);
> + found = intel_dp_init(dev, PCH_DP_C, PORT_C);
> + if (found != DRM_MODE_CONNECTOR_eDP &&
> + I915_READ(PCH_HDMIC) & SDVO_DETECTED)
> + intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
>  
> + found = 0;
>   if (I915_READ(PCH_DP_D) & DP_DETECTED)
> - intel_dp_init(dev, PCH_DP_D, PORT_D);
> + found = intel_dp_init(dev, PCH_DP_D, PORT_D);
> + if (found != DRM_MODE_CONNECTOR_eDP &&
> + I915_READ(PCH_HDMID) & SDVO_DETECTED)
> + intel_hdmi_init(dev, PCH_HDMID, PORT_D);
>   } else if (IS_VALLEYVIEW(dev)) {
>   /*
>* The DP_DETECTED bit is the latched state of the DDC
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 1e64a8c1e7cb..8adf500f3989 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -1031,14 +1031,13 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct 
> drm_dp_aux_msg *msg)
>   return ret;
>  }
>  
> -static void
> +static int
>  intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector 
> *connector)
>  {
>   struct drm_device *dev = intel_dp_to_dev(intel_dp);
>   struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
>   enum port port = intel_dig_port->port;
>   const char *name = NULL;
> - int ret;
>  
>   switch (port) {
>   case PORT_A:
> @@ -1080,20 +1079,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct 
> intel_connector *connector)
>   DRM_DEBUG_KMS("registering %s bus for %s\n", name,
> connector->base.kdev->kobj.name);
>  
> - 

[Intel-gfx] [PATCH] drm/i915: Retry port as HDMI if dp_is_edp turns out to be false

2015-08-09 Thread Chris Wilson
We follow the VBT as to whether a DDI port is used for eDP and if so, do
not attach a HDMI encoder to it. However there are machines for which
the VBT eDP flag is a lie (shocking!) and we fail to detect a eDP link.
Furthermore, on those machines the HDMI is connected to that DDI port
but we ignore it.

If we reorder our port initialisation to try the eDP setup first and
if that fails we can treat it as a normal DP port along with a HDMI
output. To accomplish this, we have to delay registering the DP
connector/encoder until after we establish its final type.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88331
Signed-off-by: Chris Wilson 
Cc: Jesse Barnes 
---
 drivers/gpu/drm/i915/intel_display.c |  27 
 drivers/gpu/drm/i915/intel_dp.c  | 127 +--
 drivers/gpu/drm/i915/intel_drv.h |   6 +-
 3 files changed, 79 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 0bcd1b1aba4f..aab8dfd1f8a5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13941,7 +13941,6 @@ static void intel_setup_outputs(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *encoder;
-   bool dpd_is_edp = false;
 
intel_lvds_init(dev);
 
@@ -13983,31 +13982,33 @@ static void intel_setup_outputs(struct drm_device 
*dev)
intel_ddi_init(dev, PORT_D);
} else if (HAS_PCH_SPLIT(dev)) {
int found;
-   dpd_is_edp = intel_dp_is_edp(dev, PORT_D);
 
if (has_edp_a(dev))
intel_dp_init(dev, DP_A, PORT_A);
 
+   found = 0;
+   /* PCH SDVOB multiplex with HDMIB */
if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
-   /* PCH SDVOB multiplex with HDMIB */
found = intel_sdvo_init(dev, PCH_SDVOB, true);
if (!found)
intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
-   if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
-   intel_dp_init(dev, PCH_DP_B, PORT_B);
}
+   if (!found && I915_READ(PCH_DP_B) & DP_DETECTED)
+   intel_dp_init(dev, PCH_DP_B, PORT_B);
 
-   if (I915_READ(PCH_HDMIC) & SDVO_DETECTED)
-   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
-
-   if (!dpd_is_edp && I915_READ(PCH_HDMID) & SDVO_DETECTED)
-   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
-
+   found = 0;
if (I915_READ(PCH_DP_C) & DP_DETECTED)
-   intel_dp_init(dev, PCH_DP_C, PORT_C);
+   found = intel_dp_init(dev, PCH_DP_C, PORT_C);
+   if (found != DRM_MODE_CONNECTOR_eDP &&
+   I915_READ(PCH_HDMIC) & SDVO_DETECTED)
+   intel_hdmi_init(dev, PCH_HDMIC, PORT_C);
 
+   found = 0;
if (I915_READ(PCH_DP_D) & DP_DETECTED)
-   intel_dp_init(dev, PCH_DP_D, PORT_D);
+   found = intel_dp_init(dev, PCH_DP_D, PORT_D);
+   if (found != DRM_MODE_CONNECTOR_eDP &&
+   I915_READ(PCH_HDMID) & SDVO_DETECTED)
+   intel_hdmi_init(dev, PCH_HDMID, PORT_D);
} else if (IS_VALLEYVIEW(dev)) {
/*
 * The DP_DETECTED bit is the latched state of the DDC
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 1e64a8c1e7cb..8adf500f3989 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1031,14 +1031,13 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct 
drm_dp_aux_msg *msg)
return ret;
 }
 
-static void
+static int
 intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
 {
struct drm_device *dev = intel_dp_to_dev(intel_dp);
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
enum port port = intel_dig_port->port;
const char *name = NULL;
-   int ret;
 
switch (port) {
case PORT_A:
@@ -1080,20 +1079,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct 
intel_connector *connector)
DRM_DEBUG_KMS("registering %s bus for %s\n", name,
  connector->base.kdev->kobj.name);
 
-   ret = drm_dp_aux_register(&intel_dp->aux);
-   if (ret < 0) {
-   DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
- name, ret);
-   return;
-   }
-
-   ret = sysfs_create_link(&connector->base.kdev->kobj,
-   &intel_dp->aux.ddc.dev.kobj,
-   intel_dp->aux.ddc.dev.kobj.name);
-   if (ret < 0) {
-   DRM_ERROR("sysfs_create_link