Skip to contentSkip to conversation

drm: Try to fix encoder possible_clones/crtc

PATCH Superseded Ville Syrjala 3 participants 19 messages Jul 8, 2019 – Jul 9, 2019

Subsystems (9)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm: Try to fix encoder possible_clones/crtc

From: Ville Syrjälä <[email protected]>

Resurrecting my possible_clones/crtcs cleanup from ~1 year ago. Some prep work from the previous posting did get merged in the meantime.

I have a feeling the WARNs from the new validation code may end up triggering on some drivers, but I don't imagine this stuff would get fixed without inflicting a bit of pain.

Ville Syrjälä (14):
drm: Include the encoder itself in possible_clones drm/gma500: Sanitize possible_clones drm/sti: Remove pointless casts
drm/sti: Try to fix up the tvout possible clones drm/exynos: Use drm_encoder_mask() drm/imx: Remove the bogus possible_clones setup drm/i915: Polish possible_clones setup drm/i915: Populate possible_crtcs correctly drm/i915: Fix DP-MST crtc_mask
drm/i915: Clean up encoder->crtc_mask setup drm/i915: Simplfy LVDS crtc_mask setup drm/i915: s/crtc_mask/pipe_mask/
drm: Validate encoder->possible_clones
drm: Validate encoder->possible_crtcs

 drivers/gpu/drm/drm_encoder.c                | 63 ++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  5 +-
 drivers/gpu/drm/gma500/framebuffer.c         | 16 ++---
 drivers/gpu/drm/gma500/mdfld_dsi_dpi.c       |  4 +-
 drivers/gpu/drm/i915/display/icl_dsi.c       |  2 +-
 drivers/gpu/drm/i915/display/intel_crt.c     |  4 +-
 drivers/gpu/drm/i915/display/intel_ddi.c     |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c | 28 ++++++---
 drivers/gpu/drm/i915/display/intel_dp.c      |  6 +-
 drivers/gpu/drm/i915/display/intel_dp_mst.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_dvo.c     |  2 +-
 drivers/gpu/drm/i915/display/intel_hdmi.c    |  6 +-
 drivers/gpu/drm/i915/display/intel_lvds.c    |  8 +--
 drivers/gpu/drm/i915/display/intel_sdvo.c    |  2 +-
 drivers/gpu/drm/i915/display/intel_tv.c      |  3 +-
 drivers/gpu/drm/i915/display/vlv_dsi.c       |  6 +-
 drivers/gpu/drm/i915/intel_drv.h             |  5 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/sti/sti_tvout.c              | 16 +++--
 19 files changed, 129 insertions(+), 53 deletions(-)
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v2 1/14 drm: Include the encoder itself in possible_clones

From: Ville Syrjälä <[email protected]>

The docs say possible_clones should always include the encoder itself. Since most drivers don't want to deal with the complexities of cloning let's allow them to set possible_clones=0 and instead we'll fix that up in the core.

We can't put this special case into drm_encoder_init() because drivers will have to fill up possible_clones after adding all the relevant encoders. Otherwise they wouldn't know the proper encoder indexes to use. So we'll just do it just before registering the encoders.

TODO: Should we add the bit even if possible_clones was otherwise populated by the driver?

---
 drivers/gpu/drm/drm_encoder.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_encoder.c +15 -0
index 7fb47b7b8b44..e87e6fecc1fb 100644
@@ -65,11 +65,26 @@ static const struct drm_prop_enum_list drm_encoder_enum_list[] = {
 	{ DRM_MODE_ENCODER_DPI, "DPI" },
 };
 
+/*
+ * For some reason we want the encoder itself included in
+ * possible_clones. Make life easy for drivers by allowing them
+ * to leave possible_clones unset if no cloning is possible.
+ */
+static void fixup_possible_clones(struct drm_device *dev)
+{
+	struct drm_encoder *encoder;
+
+	drm_for_each_encoder(encoder, dev)
+		encoder->possible_clones |= drm_encoder_mask(encoder);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
 	int ret = 0;
 
+	fixup_possible_clones(dev);
+
 	drm_for_each_encoder(encoder, dev) {
 		if (encoder->funcs->late_register)
 			ret = encoder->funcs->late_register(encoder);
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 2/14 drm/gma500: Sanitize possible_clones

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

I doubt the DP+DP and SDVO+SDVO cloning works for this driver. i915 at least doesn't do those. Truthfully there could be some very specific circumstances where some of them would do doable, but genereally it's too much pain to deal with so we've chose not to bother. Let's use the same approach for gma500.

Also the LVDS+LVDS and DSI+DSI cases probably don't really exist as there is one of each at most.

This does mean we'll now leave possible_clones at 0 for these encoder types whereas previosuly we included the encoder itself in the bitmask. But that's fine as the core now treaks 0 as a special case and adds the encoder itself into the final bitmask reported to userspace.

Cc Patrik Jakobsson <[email protected]>
---
 drivers/gpu/drm/gma500/framebuffer.c   | 16 ++++++++--------
 drivers/gpu/drm/gma500/mdfld_dsi_dpi.c |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/gma500/framebuffer.c +8 -8
index 218f3bb15276..580a701fd91c 100644
@@ -584,31 +584,31 @@ static void psb_setup_outputs(struct drm_device *dev)
 			break;
 		case INTEL_OUTPUT_SDVO:
 			crtc_mask = dev_priv->ops->sdvo_mask;
-			clone_mask = (1 << INTEL_OUTPUT_SDVO);
+			clone_mask = 0;
 			break;
 		case INTEL_OUTPUT_LVDS:
-		        crtc_mask = dev_priv->ops->lvds_mask;
-			clone_mask = (1 << INTEL_OUTPUT_LVDS);
+			crtc_mask = dev_priv->ops->lvds_mask;
+			clone_mask = 0;
 			break;
 		case INTEL_OUTPUT_MIPI:
 			crtc_mask = (1 << 0);
-			clone_mask = (1 << INTEL_OUTPUT_MIPI);
+			clone_mask = 0;
 			break;
 		case INTEL_OUTPUT_MIPI2:
 			crtc_mask = (1 << 2);
-			clone_mask = (1 << INTEL_OUTPUT_MIPI2);
+			clone_mask = 0;
 			break;
 		case INTEL_OUTPUT_HDMI:
-		        crtc_mask = dev_priv->ops->hdmi_mask;
+			crtc_mask = dev_priv->ops->hdmi_mask;
 			clone_mask = (1 << INTEL_OUTPUT_HDMI);
 			break;
 		case INTEL_OUTPUT_DISPLAYPORT:
 			crtc_mask = (1 << 0) | (1 << 1);
-			clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT);
+			clone_mask = 0;
 			break;
 		case INTEL_OUTPUT_EDP:
 			crtc_mask = (1 << 1);
-			clone_mask = (1 << INTEL_OUTPUT_EDP);
+			clone_mask = 0;
 		}
 		encoder->possible_crtcs = crtc_mask;
 		encoder->possible_clones =
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c +2 -2
index d4c65f268922..187817e0c004 100644
@@ -1006,10 +1006,10 @@ struct mdfld_dsi_encoder *mdfld_dsi_dpi_init(struct drm_device *dev,
 	/*set possible crtcs and clones*/
 	if (dsi_connector->pipe) {
 		encoder->possible_crtcs = (1 << 2);
-		encoder->possible_clones = (1 << 1);
+		encoder->possible_clones = 0;
 	} else {
 		encoder->possible_crtcs = (1 << 0);
-		encoder->possible_clones = (1 << 0);
+		encoder->possible_clones = 0;
 	}
 
 	dsi_connector->base.encoder = &dpi_output->base.base;
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH v2 3/14 drm/sti: Remove pointless casts

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

There's no point in the cast for accessing the base class. Just take the address of the struct instead.

---
 drivers/gpu/drm/sti/sti_tvout.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_tvout.c +3 -3
index e1b3c8cb7287..42f4c264a783 100644
@@ -669,7 +669,7 @@ sti_tvout_create_dvo_encoder(struct drm_device *dev,
 
 	encoder->tvout = tvout;
 
-	drm_encoder = (struct drm_encoder *)encoder;
+	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
 	drm_encoder->possible_clones = 1 << 0;
@@ -722,7 +722,7 @@ static struct drm_encoder *sti_tvout_create_hda_encoder(struct drm_device *dev,
 
 	encoder->tvout = tvout;
 
-	drm_encoder = (struct drm_encoder *) encoder;
+	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
 	drm_encoder->possible_clones = 1 << 0;
@@ -771,7 +771,7 @@ static struct drm_encoder *sti_tvout_create_hdmi_encoder(struct drm_device *dev,
 
 	encoder->tvout = tvout;
 
-	drm_encoder = (struct drm_encoder *) encoder;
+	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
 	drm_encoder->possible_clones = 1 << 1;
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH v2 03/14] drm/sti: Remove pointless casts

Quoted 5 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

There's no point in the cast for accessing the base class. Just take the address of the struct instead.

Applied on drm-misc-next,
Thanks,

Benjamin

Quoted 41 lines
---
 drivers/gpu/drm/sti/sti_tvout.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_tvout.c +3 -4
index e1b3c8cb7287..42f4c264a783 100644
@@ -669,7 +669,7 @@ sti_tvout_create_dvo_encoder(struct drm_device *dev,
 
        encoder->tvout = tvout;
 
-       drm_encoder = (struct drm_encoder *)encoder;
+       drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
        drm_encoder->possible_clones = 1 << 0;
@@ -722,7 +722,7 @@ static struct drm_encoder *sti_tvout_create_hda_encoder(struct drm_device *dev,
 
        encoder->tvout = tvout;
 
-       drm_encoder = (struct drm_encoder *) encoder;
+       drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
        drm_encoder->possible_clones = 1 << 0;
@@ -771,7 +771,7 @@ static struct drm_encoder *sti_tvout_create_hdmi_encoder(struct drm_device *dev,
 
        encoder->tvout = tvout;
 
-       drm_encoder = (struct drm_encoder *) encoder;
+       drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
        drm_encoder->possible_clones = 1 << 1;
--
Quoted 2 lines

2.21.0

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

#5 lore raw

PATCH v2 4/14 drm/sti: Try to fix up the tvout possible clones

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

The current possible_clones setup doesn't look sensible. I'm assuming the 0 and 1 are supposed to refer to the indexes of the hdmi and hda encoders? So it kinda looks like we want hda+hdmi cloning, but then dvo also claims to be cloneable with hdmi, but hdmi won't recipricate.

Benjamin tells me all encoders should be cloneable with each other, so let's fix up the masks to indicate that.

---
 drivers/gpu/drm/sti/sti_tvout.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_tvout.c +7 -3
index 42f4c264a783..aba79c172512 100644
@@ -672,7 +672,6 @@ sti_tvout_create_dvo_encoder(struct drm_device *dev,
 	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-	drm_encoder->possible_clones = 1 << 0;
 
 	drm_encoder_init(dev, drm_encoder,
 			 &sti_tvout_encoder_funcs, DRM_MODE_ENCODER_LVDS,
@@ -725,7 +724,6 @@ static struct drm_encoder *sti_tvout_create_hda_encoder(struct drm_device *dev,
 	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-	drm_encoder->possible_clones = 1 << 0;
 
 	drm_encoder_init(dev, drm_encoder,
 			&sti_tvout_encoder_funcs, DRM_MODE_ENCODER_DAC, NULL);
@@ -774,7 +772,6 @@ static struct drm_encoder *sti_tvout_create_hdmi_encoder(struct drm_device *dev,
 	drm_encoder = &encoder->encoder;
 
 	drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-	drm_encoder->possible_clones = 1 << 1;
 
 	drm_encoder_init(dev, drm_encoder,
 			&sti_tvout_encoder_funcs, DRM_MODE_ENCODER_TMDS, NULL);
@@ -790,6 +787,13 @@ static void sti_tvout_create_encoders(struct drm_device *dev,
 	tvout->hdmi = sti_tvout_create_hdmi_encoder(dev, tvout);
 	tvout->hda = sti_tvout_create_hda_encoder(dev, tvout);
 	tvout->dvo = sti_tvout_create_dvo_encoder(dev, tvout);
+
+	tvout->hdmi->possible_clones = drm_encoder_mask(tvout->hdmi) |
+		drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
+	tvout->hda->possible_clones = drm_encoder_mask(tvout->hdmi) |
+		drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
+	tvout->dvo->possible_clones = drm_encoder_mask(tvout->hdmi) |
+		drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
 }
 
 static void sti_tvout_destroy_encoders(struct sti_tvout *tvout)
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH v2 04/14] drm/sti: Try to fix up the tvout possible clones

Quoted 11 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

The current possible_clones setup doesn't look sensible. I'm assuming the 0 and 1 are supposed to refer to the indexes of the hdmi and hda encoders? So it kinda looks like we want hda+hdmi cloning, but then dvo also claims to be cloneable with hdmi, but hdmi won't recipricate.

Benjamin tells me all encoders should be cloneable with each other, so let's fix up the masks to indicate that.

Applied on drm-misc-next,
Thanks,

Benjamin

Quoted 51 lines
---
 drivers/gpu/drm/sti/sti_tvout.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_tvout.c +7 -4
index 42f4c264a783..aba79c172512 100644
@@ -672,7 +672,6 @@ sti_tvout_create_dvo_encoder(struct drm_device *dev,
        drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-       drm_encoder->possible_clones = 1 << 0;
 
        drm_encoder_init(dev, drm_encoder,
                         &sti_tvout_encoder_funcs, DRM_MODE_ENCODER_LVDS,
@@ -725,7 +724,6 @@ static struct drm_encoder *sti_tvout_create_hda_encoder(struct drm_device *dev,
        drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-       drm_encoder->possible_clones = 1 << 0;
 
        drm_encoder_init(dev, drm_encoder,
                        &sti_tvout_encoder_funcs, DRM_MODE_ENCODER_DAC, NULL);
@@ -774,7 +772,6 @@ static struct drm_encoder *sti_tvout_create_hdmi_encoder(struct drm_device *dev,
        drm_encoder = &encoder->encoder;
 
        drm_encoder->possible_crtcs = ENCODER_CRTC_MASK;
-       drm_encoder->possible_clones = 1 << 1;
 
        drm_encoder_init(dev, drm_encoder,
                        &sti_tvout_encoder_funcs, DRM_MODE_ENCODER_TMDS, NULL);
@@ -790,6 +787,13 @@ static void sti_tvout_create_encoders(struct drm_device *dev,
        tvout->hdmi = sti_tvout_create_hdmi_encoder(dev, tvout);
        tvout->hda = sti_tvout_create_hda_encoder(dev, tvout);
        tvout->dvo = sti_tvout_create_dvo_encoder(dev, tvout);
+
+       tvout->hdmi->possible_clones = drm_encoder_mask(tvout->hdmi) |
+               drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
+       tvout->hda->possible_clones = drm_encoder_mask(tvout->hdmi) |
+               drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
+       tvout->dvo->possible_clones = drm_encoder_mask(tvout->hdmi) |
+               drm_encoder_mask(tvout->hda) | drm_encoder_mask(tvout->dvo);
 }
 
 static void sti_tvout_destroy_encoders(struct sti_tvout *tvout)
--
Quoted 2 lines

2.21.0

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

#7 lore raw

PATCH v2 5/14 drm/exynos: Use drm_encoder_mask()

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Replace the hand rolled encoder bitmask thing with drm_encoder_mask()

Cc Inki Dae <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +2 -3
index cc53dcad25e4..140ef553e156 100644
@@ -264,7 +264,7 @@ static int exynos_drm_bind(struct device *dev)
 	struct drm_encoder *encoder;
 	struct drm_device *drm;
 	unsigned int clone_mask;
-	int cnt, ret;
+	int ret;
 
 	drm = drm_dev_alloc(&exynos_drm_driver, dev);
 	if (IS_ERR(drm))
@@ -287,10 +287,9 @@ static int exynos_drm_bind(struct device *dev)
 	exynos_drm_mode_config_init(drm);
 
 	/* setup possible_clones. */
-	cnt = 0;
 	clone_mask = 0;
 	list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
-		clone_mask |= (1 << (cnt++));
+		clone_mask |= drm_encoder_mask(encoder);
 
 	list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
 		encoder->possible_clones = clone_mask;
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH v2 6/14 drm/imx: Remove the bogus possible_clones setup

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

It's not at all clear what cloning options this driver supports. So let's just clear possible_clones instead of setting it to some bogus value.

---
 drivers/gpu/drm/imx/imx-drm-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index bdefaa1635eb..bd650b0c27b2 100644
@@ -136,7 +136,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
 	encoder->possible_crtcs = crtc_mask;
 
 	/* FIXME: this is the mask of outputs which can clone this output. */
-	encoder->possible_clones = ~0;
+	encoder->possible_clones = 0;
 
 	return 0;
 }
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH v2 7/14 drm/i915: Polish possible_clones setup

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Replace the hand rolled stuff with drm_encoder_mask() when populating possible_clones, and rename the function to intel_encoder_possible_clones() to make it clear what it's used for.

---
 drivers/gpu/drm/i915/display/intel_display.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +5 -8
index f09eda75711a..503c20a3a49c 100644
@@ -15197,21 +15197,18 @@ int intel_get_pipe_from_crtc_id_ioctl(struct drm_device *dev, void *data,
 	return 0;
 }
 
-static int intel_encoder_clones(struct intel_encoder *encoder)
+static u32 intel_encoder_possible_clones(struct intel_encoder *encoder)
 {
 	struct drm_device *dev = encoder->base.dev;
 	struct intel_encoder *source_encoder;
-	int index_mask = 0;
-	int entry = 0;
+	u32 possible_clones = 0;
 
 	for_each_intel_encoder(dev, source_encoder) {
 		if (encoders_cloneable(encoder, source_encoder))
-			index_mask |= (1 << entry);
-
-		entry++;
+			possible_clones |= drm_encoder_mask(&source_encoder->base);
 	}
 
-	return index_mask;
+	return possible_clones;
 }
 
 static bool ilk_has_edp_a(struct drm_i915_private *dev_priv)
@@ -15505,7 +15502,7 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		encoder->base.possible_crtcs = encoder->crtc_mask;
 		encoder->base.possible_clones =
-			intel_encoder_clones(encoder);
+			intel_encoder_possible_clones(encoder);
 	}
 
 	intel_init_pch_refclk(dev_priv);
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH v2 8/14 drm/i915: Populate possible_crtcs correctly

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Don't advertize non-exisiting crtcs in the encoder possible_crtcs bitmask.

---
 drivers/gpu/drm/i915/display/intel_display.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_display.c +16 -1
index 503c20a3a49c..93fdd1cbd343 100644
@@ -15211,6 +15211,20 @@ static u32 intel_encoder_possible_clones(struct intel_encoder *encoder)
 	return possible_clones;
 }
 
+static u32 intel_encoder_possible_crtcs(struct intel_encoder *encoder)
+{
+	struct drm_device *dev = encoder->base.dev;
+	struct intel_crtc *crtc;
+	u32 possible_crtcs = 0;
+
+	for_each_intel_crtc(dev, crtc) {
+		if (encoder->crtc_mask & BIT(crtc->pipe))
+			possible_crtcs |= drm_crtc_mask(&crtc->base);
+	}
+
+	return possible_crtcs;
+}
+
 static bool ilk_has_edp_a(struct drm_i915_private *dev_priv)
 {
 	if (!IS_MOBILE(dev_priv))
@@ -15500,7 +15514,8 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv)
 	intel_psr_init(dev_priv);
 
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
-		encoder->base.possible_crtcs = encoder->crtc_mask;
+		encoder->base.possible_crtcs =
+			intel_encoder_possible_crtcs(encoder);
 		encoder->base.possible_clones =
 			intel_encoder_possible_clones(encoder);
 	}
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH v2 9/14 drm/i915: Fix DP-MST crtc_mask

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Each fake MST encoder is tied to a specific pipe. Fix the encoder's crtc_mask to reflect that fact.

---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -1
index 60652ebbdf61..d08e4a47816a 100644
@@ -602,7 +602,7 @@ intel_dp_create_fake_mst_encoder(struct intel_digital_port *intel_dig_port, enum
 	intel_encoder->type = INTEL_OUTPUT_DP_MST;
 	intel_encoder->power_domain = intel_dig_port->base.power_domain;
 	intel_encoder->port = intel_dig_port->base.port;
-	intel_encoder->crtc_mask = 0x7;
+	intel_encoder->crtc_mask = BIT(pipe);
 	intel_encoder->cloneable = 0;
 
 	intel_encoder->compute_config = intel_dp_mst_compute_config;
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

PATCH v2 10/14 drm/i915: Clean up encoder->crtc_mask setup

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Use BIT(pipe) for better legibility when populating the crtc_mask for encoders.

Also remove the redundant possible_crtcs setup for the TV encoder.

---
 drivers/gpu/drm/i915/display/intel_crt.c  | 4 ++--
 drivers/gpu/drm/i915/display/intel_dp.c   | 6 +++---
 drivers/gpu/drm/i915/display/intel_dvo.c  | 2 +-
 drivers/gpu/drm/i915/display/intel_hdmi.c | 6 +++---
 drivers/gpu/drm/i915/display/intel_lvds.c | 6 +++---
 drivers/gpu/drm/i915/display/intel_sdvo.c | 2 +-
 drivers/gpu/drm/i915/display/intel_tv.c   | 3 +--
 7 files changed, 14 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/display/intel_crt.c +2 -2
index 3fcf2f84bcce..68457e8e07aa 100644
@@ -997,9 +997,9 @@ void intel_crt_init(struct drm_i915_private *dev_priv)
 	crt->base.type = INTEL_OUTPUT_ANALOG;
 	crt->base.cloneable = (1 << INTEL_OUTPUT_DVO) | (1 << INTEL_OUTPUT_HDMI);
 	if (IS_I830(dev_priv))
-		crt->base.crtc_mask = (1 << 0);
+		crt->base.crtc_mask = BIT(PIPE_A);
 	else
-		crt->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+		crt->base.crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 
 	if (IS_GEN(dev_priv, 2))
 		connector->interlace_allowed = 0;
drivers/gpu/drm/i915/display/intel_dp.c +3 -3
index 0bdb7ecc5a81..6baa537e9849 100644
@@ -7283,11 +7283,11 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
 	intel_encoder->power_domain = intel_port_to_power_domain(port);
 	if (IS_CHERRYVIEW(dev_priv)) {
 		if (port == PORT_D)
-			intel_encoder->crtc_mask = 1 << 2;
+			intel_encoder->crtc_mask = BIT(PIPE_C);
 		else
-			intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+			intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	} else {
-		intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	}
 	intel_encoder->cloneable = 0;
 	intel_encoder->port = port;
drivers/gpu/drm/i915/display/intel_dvo.c +1 -1
index 22666d28f4aa..df491f59401b 100644
@@ -505,7 +505,7 @@ void intel_dvo_init(struct drm_i915_private *dev_priv)
 		intel_encoder->type = INTEL_OUTPUT_DVO;
 		intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
 		intel_encoder->port = port;
-		intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 
 		switch (dvo->type) {
 		case INTEL_DVO_CHIP_TMDS:
drivers/gpu/drm/i915/display/intel_hdmi.c +3 -3
index 0ebec69bbbfc..3a73577ef259 100644
@@ -3202,11 +3202,11 @@ void intel_hdmi_init(struct drm_i915_private *dev_priv,
 	intel_encoder->port = port;
 	if (IS_CHERRYVIEW(dev_priv)) {
 		if (port == PORT_D)
-			intel_encoder->crtc_mask = 1 << 2;
+			intel_encoder->crtc_mask = BIT(PIPE_C);
 		else
-			intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+			intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	} else {
-		intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	}
 	intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG;
 	/*
drivers/gpu/drm/i915/display/intel_lvds.c +3 -3
index efefed62a7f8..765091a9835c 100644
@@ -902,11 +902,11 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
 	intel_encoder->port = PORT_NONE;
 	intel_encoder->cloneable = 0;
 	if (HAS_PCH_SPLIT(dev_priv))
-		intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	else if (IS_GEN(dev_priv, 4))
-		intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	else
-		intel_encoder->crtc_mask = (1 << 1);
+		intel_encoder->crtc_mask = BIT(PIPE_B);
 
 	drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
 	connector->display_info.subpixel_order = SubPixelHorizontalRGB;
drivers/gpu/drm/i915/display/intel_sdvo.c +1 -1
index ceda03e5a3d4..81d9f43e0bf4 100644
@@ -2891,7 +2891,7 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, u16 flags)
 			      bytes[0], bytes[1]);
 		return false;
 	}
-	intel_sdvo->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+	intel_sdvo->base.crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 
 	return true;
 }
drivers/gpu/drm/i915/display/intel_tv.c +1 -2
index 0a95df6c6a57..f10741737876 100644
@@ -1948,9 +1948,8 @@ intel_tv_init(struct drm_i915_private *dev_priv)
 	intel_encoder->type = INTEL_OUTPUT_TVOUT;
 	intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
 	intel_encoder->port = PORT_NONE;
-	intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+	intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	intel_encoder->cloneable = 0;
-	intel_encoder->base.possible_crtcs = ((1 << 0) | (1 << 1));
 	intel_tv->type = DRM_MODE_CONNECTOR_Unknown;
 
 	/* BIOS margin values */
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

PATCH v2 11/14 drm/i915: Simplfy LVDS crtc_mask setup

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

We don't need to special case PCH vs. gen4 when setting up the LVDS crtc_mask. Just claim pipes A|B|C work and intel_encoder_crtcs() drop out any crtc that doesn't exist.

---
 drivers/gpu/drm/i915/display/intel_lvds.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_lvds.c +1 -3
index 765091a9835c..e79dcc891b80 100644
@@ -901,10 +901,8 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
 	intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
 	intel_encoder->port = PORT_NONE;
 	intel_encoder->cloneable = 0;
-	if (HAS_PCH_SPLIT(dev_priv))
+	if (INTEL_GEN(dev_priv) >= 4)
 		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
-	else if (IS_GEN(dev_priv, 4))
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	else
 		intel_encoder->crtc_mask = BIT(PIPE_B);
 
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH v2 12/14 drm/i915: s/crtc_mask/pipe_mask/

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Rename the encoder->crtc_mask to encoder->pipe_mask to better reflect what it actually contains.

---
 drivers/gpu/drm/i915/display/icl_dsi.c       | 2 +-
 drivers/gpu/drm/i915/display/intel_crt.c     | 4 ++--
 drivers/gpu/drm/i915/display/intel_ddi.c     | 2 +-
 drivers/gpu/drm/i915/display/intel_display.c | 2 +-
 drivers/gpu/drm/i915/display/intel_dp.c      | 6 +++---
 drivers/gpu/drm/i915/display/intel_dp_mst.c  | 2 +-
 drivers/gpu/drm/i915/display/intel_dvo.c     | 2 +-
 drivers/gpu/drm/i915/display/intel_hdmi.c    | 6 +++---
 drivers/gpu/drm/i915/display/intel_lvds.c    | 4 ++--
 drivers/gpu/drm/i915/display/intel_sdvo.c    | 2 +-
 drivers/gpu/drm/i915/display/intel_tv.c      | 2 +-
 drivers/gpu/drm/i915/display/vlv_dsi.c       | 6 +++---
 drivers/gpu/drm/i915/intel_drv.h             | 5 +++--
 13 files changed, 23 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/display/icl_dsi.c +1 -1
index b8673debf932..0641bc1a36fb 100644
@@ -1549,7 +1549,7 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
 	encoder->get_hw_state = gen11_dsi_get_hw_state;
 	encoder->type = INTEL_OUTPUT_DSI;
 	encoder->cloneable = 0;
-	encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+	encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	encoder->power_domain = POWER_DOMAIN_PORT_DSI;
 	encoder->get_power_domains = gen11_dsi_get_power_domains;
 
drivers/gpu/drm/i915/display/intel_crt.c +2 -2
index 68457e8e07aa..c9055e1ea988 100644
@@ -997,9 +997,9 @@ void intel_crt_init(struct drm_i915_private *dev_priv)
 	crt->base.type = INTEL_OUTPUT_ANALOG;
 	crt->base.cloneable = (1 << INTEL_OUTPUT_DVO) | (1 << INTEL_OUTPUT_HDMI);
 	if (IS_I830(dev_priv))
-		crt->base.crtc_mask = BIT(PIPE_A);
+		crt->base.pipe_mask = BIT(PIPE_A);
 	else
-		crt->base.crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+		crt->base.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 
 	if (IS_GEN(dev_priv, 2))
 		connector->interlace_allowed = 0;
drivers/gpu/drm/i915/display/intel_ddi.c +1 -1
index 30e48609db1d..9ab6b40e4b61 100644
@@ -4250,7 +4250,7 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
 	intel_encoder->port = port;
 	intel_encoder->cloneable = 0;
 	for_each_pipe(dev_priv, pipe)
-		intel_encoder->crtc_mask |= BIT(pipe);
+		intel_encoder->pipe_mask |= BIT(pipe);
 
 	if (INTEL_GEN(dev_priv) >= 11)
 		intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
drivers/gpu/drm/i915/display/intel_display.c +1 -1
index 93fdd1cbd343..70ec20444255 100644
@@ -15218,7 +15218,7 @@ static u32 intel_encoder_possible_crtcs(struct intel_encoder *encoder)
 	u32 possible_crtcs = 0;
 
 	for_each_intel_crtc(dev, crtc) {
-		if (encoder->crtc_mask & BIT(crtc->pipe))
+		if (encoder->pipe_mask & BIT(crtc->pipe))
 			possible_crtcs |= drm_crtc_mask(&crtc->base);
 	}
 
drivers/gpu/drm/i915/display/intel_dp.c +3 -3
index 6baa537e9849..ef183a90e929 100644
@@ -7283,11 +7283,11 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
 	intel_encoder->power_domain = intel_port_to_power_domain(port);
 	if (IS_CHERRYVIEW(dev_priv)) {
 		if (port == PORT_D)
-			intel_encoder->crtc_mask = BIT(PIPE_C);
+			intel_encoder->pipe_mask = BIT(PIPE_C);
 		else
-			intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
+			intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	} else {
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+		intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	}
 	intel_encoder->cloneable = 0;
 	intel_encoder->port = port;
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -1
index d08e4a47816a..f79842c7be67 100644
@@ -602,7 +602,7 @@ intel_dp_create_fake_mst_encoder(struct intel_digital_port *intel_dig_port, enum
 	intel_encoder->type = INTEL_OUTPUT_DP_MST;
 	intel_encoder->power_domain = intel_dig_port->base.power_domain;
 	intel_encoder->port = intel_dig_port->base.port;
-	intel_encoder->crtc_mask = BIT(pipe);
+	intel_encoder->pipe_mask = BIT(pipe);
 	intel_encoder->cloneable = 0;
 
 	intel_encoder->compute_config = intel_dp_mst_compute_config;
drivers/gpu/drm/i915/display/intel_dvo.c +1 -1
index df491f59401b..1563d42397aa 100644
@@ -505,7 +505,7 @@ void intel_dvo_init(struct drm_i915_private *dev_priv)
 		intel_encoder->type = INTEL_OUTPUT_DVO;
 		intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
 		intel_encoder->port = port;
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
+		intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B);
 
 		switch (dvo->type) {
 		case INTEL_DVO_CHIP_TMDS:
drivers/gpu/drm/i915/display/intel_hdmi.c +3 -3
index 3a73577ef259..4cb8f4f14055 100644
@@ -3202,11 +3202,11 @@ void intel_hdmi_init(struct drm_i915_private *dev_priv,
 	intel_encoder->port = port;
 	if (IS_CHERRYVIEW(dev_priv)) {
 		if (port == PORT_D)
-			intel_encoder->crtc_mask = BIT(PIPE_C);
+			intel_encoder->pipe_mask = BIT(PIPE_C);
 		else
-			intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
+			intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	} else {
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+		intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	}
 	intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG;
 	/*
drivers/gpu/drm/i915/display/intel_lvds.c +2 -2
index e79dcc891b80..d6bb2e9111d8 100644
@@ -902,9 +902,9 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
 	intel_encoder->port = PORT_NONE;
 	intel_encoder->cloneable = 0;
 	if (INTEL_GEN(dev_priv) >= 4)
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+		intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	else
-		intel_encoder->crtc_mask = BIT(PIPE_B);
+		intel_encoder->pipe_mask = BIT(PIPE_B);
 
 	drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
 	connector->display_info.subpixel_order = SubPixelHorizontalRGB;
drivers/gpu/drm/i915/display/intel_sdvo.c +1 -1
index 81d9f43e0bf4..38931d425d66 100644
@@ -2891,7 +2891,7 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, u16 flags)
 			      bytes[0], bytes[1]);
 		return false;
 	}
-	intel_sdvo->base.crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+	intel_sdvo->base.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 
 	return true;
 }
drivers/gpu/drm/i915/display/intel_tv.c +1 -1
index f10741737876..1fd52e8d81a4 100644
@@ -1948,7 +1948,7 @@ intel_tv_init(struct drm_i915_private *dev_priv)
 	intel_encoder->type = INTEL_OUTPUT_TVOUT;
 	intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
 	intel_encoder->port = PORT_NONE;
-	intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B);
+	intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B);
 	intel_encoder->cloneable = 0;
 	intel_tv->type = DRM_MODE_CONNECTOR_Unknown;
 
drivers/gpu/drm/i915/display/vlv_dsi.c +3 -3
index e272d826210a..7c1f27744189 100644
@@ -1898,11 +1898,11 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
 	 * port C. BXT isn't limited like this.
 	 */
 	if (IS_GEN9_LP(dev_priv))
-		intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
+		intel_encoder->pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
 	else if (port == PORT_A)
-		intel_encoder->crtc_mask = BIT(PIPE_A);
+		intel_encoder->pipe_mask = BIT(PIPE_A);
 	else
-		intel_encoder->crtc_mask = BIT(PIPE_B);
+		intel_encoder->pipe_mask = BIT(PIPE_B);
 
 	if (dev_priv->vbt.dsi.config->dual_link)
 		intel_dsi->ports = BIT(PORT_A) | BIT(PORT_C);
drivers/gpu/drm/i915/intel_drv.h +3 -2
index 24c63ed45c6f..d89ecc6bf64b 100644
@@ -106,7 +106,9 @@ struct intel_encoder {
 
 	enum intel_output_type type;
 	enum port port;
-	unsigned int cloneable;
+	u16 cloneable;
+	u8 pipe_mask;
+
 	bool (*hotplug)(struct intel_encoder *encoder,
 			struct intel_connector *connector);
 	enum intel_output_type (*compute_output_type)(struct intel_encoder *,
@@ -164,7 +166,6 @@ struct intel_encoder {
 	 * device interrupts are disabled.
 	 */
 	void (*suspend)(struct intel_encoder *);
-	int crtc_mask;
 	enum hpd_pin hpd_pin;
 	enum intel_display_power_domain power_domain;
 	/* for communication with audio component; protected by av_mutex */
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

PATCH v2 13/14 drm: Validate encoder->possible_clones

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Many drivers are populating encoder->possible_clones wrong. Let's persuade them to get it right by adding some loud WARNs.

We'll cross check the bits between any two encoders. So either both encoders can clone with the other, or neither can.

We'll also complain about effectively empty possible_clones, and possible_clones containing bits for encoders that don't exist.

TODO: Or should we just silently filter out any bits for non-existing encoders?

v2: encoder->possible_clones now includes the encoder itelf

---
 drivers/gpu/drm/drm_encoder.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/drm_encoder.c +30 -0
index e87e6fecc1fb..3ece97a9d029 100644
@@ -78,6 +78,34 @@ static void fixup_possible_clones(struct drm_device *dev)
 		encoder->possible_clones |= drm_encoder_mask(encoder);
 }
 
+static void validate_possible_clones(struct drm_encoder *encoder)
+{
+	struct drm_device *dev = encoder->dev;
+	struct drm_encoder *other;
+	u32 encoder_mask = 0;
+
+	drm_for_each_encoder(other, dev) {
+		encoder_mask |= drm_encoder_mask(other);
+
+		WARN(!(encoder->possible_clones & drm_encoder_mask(other)) !=
+		     !(other->possible_clones & drm_encoder_mask(encoder)),
+		     "possible_clones mismatch: "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x vs. "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x\n",
+		     encoder->base.id, encoder->name,
+		     drm_encoder_mask(encoder), encoder->possible_clones,
+		     other->base.id, other->name,
+		     drm_encoder_mask(other), other->possible_clones);
+	}
+
+	WARN((encoder->possible_clones & drm_encoder_mask(encoder)) == 0 ||
+	     (encoder->possible_clones & ~encoder_mask) != 0,
+	     "Bogus possible_clones: "
+	     "[ENCODER:%d:%s] possible_clones=0x%x (full encoder mask=0x%x)\n",
+	     encoder->base.id, encoder->name,
+	     encoder->possible_clones, encoder_mask);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -86,6 +114,8 @@ int drm_encoder_register_all(struct drm_device *dev)
 	fixup_possible_clones(dev);
 
 	drm_for_each_encoder(encoder, dev) {
+		validate_possible_clones(encoder);
+
 		if (encoder->funcs->late_register)
 			ret = encoder->funcs->late_register(encoder);
 		if (ret)
Signature · 6 lines
2.21.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH v2 14/14 drm: Validate encoder->possible_crtcs

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

WARN if the encoder possible_crtcs is effectively empty or contains bits for non-existing crtcs.

TODO: Or should we perhapst just filter out any bit for a non-exisiting crtc?

---
 drivers/gpu/drm/drm_encoder.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/drm_encoder.c +18 -0
index 3ece97a9d029..07191e2db64c 100644
@@ -106,6 +106,23 @@ static void validate_possible_clones(struct drm_encoder *encoder)
 	     encoder->possible_clones, encoder_mask);
 }
 
+static void validate_possible_crtcs(struct drm_encoder *encoder)
+{
+	struct drm_device *dev = encoder->dev;
+	struct drm_crtc *crtc;
+	u32 crtc_mask = 0;
+
+	drm_for_each_crtc(crtc, dev)
+		crtc_mask |= drm_crtc_mask(crtc);
+
+	WARN((encoder->possible_crtcs & crtc_mask) == 0 ||
+	     (encoder->possible_crtcs & ~crtc_mask) != 0,
+	     "Bogus possible_crtcs: "
+	     "[ENCODER:%d:%s] possible_crtcs=0x%x (full crtc mask=0x%x)\n",
+	     encoder->base.id, encoder->name,
+	     encoder->possible_crtcs, crtc_mask);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -114,6 +131,7 @@ int drm_encoder_register_all(struct drm_device *dev)
 	fixup_possible_clones(dev);
 
 	drm_for_each_encoder(encoder, dev) {
+		validate_possible_crtcs(encoder);
 		validate_possible_clones(encoder);
 
 		if (encoder->funcs->late_register)
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

✓ Fi.CI.BAT: success for drm: Try to fix encoder possible_clones/crtc

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: drm: Try to fix encoder possible_clones/crtc
URL : https://patchwork.freedesktop.org/series/63399/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6431 -> Patchwork_13568
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/

Known issues
------------

Here are the changes found in Patchwork_13568 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_reloc@basic-cpu-noreloc:
- fi-icl-dsi: [PASS][1] -> [INCOMPLETE][2] ([fdo#107713])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/fi-icl-dsi/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/fi-icl-dsi/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][3] -> [DMESG-WARN][4] ([fdo#102614])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/fi-hsw-peppy/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/fi-hsw-peppy/igt@[email protected]

#### Possible fixes ####

* igt@gem_close_race@basic-process:
- fi-icl-u3: [DMESG-WARN][5] ([fdo#107724]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/fi-icl-u3/igt@[email protected]

* igt@i915_selftest@live_hangcheck:
- fi-icl-u3: [INCOMPLETE][7] ([fdo#107713] / [fdo#108569]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/fi-icl-u3/igt@i915_selftest@live_hangcheck.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/fi-icl-u3/igt@i915_selftest@live_hangcheck.html

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][9] ([fdo#109485]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/fi-kbl-7500u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/fi-kbl-7500u/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485

Participating hosts (53 -> 47)
------------------------------

Additional (1): fi-pnv-d510
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_6431 -> Patchwork_13568

CI_DRM_6431: 9a40fb28e45261f2fc44a9b271c19faf1f071138 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5090: c6c75e11175baeb6b984e0cc13c6fbe2863a0794 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13568: 80085b69f7244160427fc81d76fb6f140c9df15a @ git://anongit.freedesktop.org/gfx-ci/linux

== Kernel 32bit build ==

Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/build_32bit.log

  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h

Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 112 modules
ERROR: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! scripts/Makefile.modpost:91: recipe for target '__modpost' failed make[1]: *** [__modpost] Error 1
Makefile:1287: recipe for target 'modules' failed
make: *** [modules] Error 2

== Linux commits ==

80085b69f724 drm: Validate encoder->possible_crtcs 619bd5c1b429 drm: Validate encoder->possible_clones a825a82859a4 drm/i915: s/crtc_mask/pipe_mask/ 98e95fb67f51 drm/i915: Simplfy LVDS crtc_mask setup dc94a4c35ced drm/i915: Clean up encoder->crtc_mask setup eb3d8b1499b8 drm/i915: Fix DP-MST crtc_mask 4631a1ef7404 drm/i915: Populate possible_crtcs correctly 2289c1b60665 drm/i915: Polish possible_clones setup 7d83c6354420 drm/imx: Remove the bogus possible_clones setup 1b76c2b9729c drm/exynos: Use drm_encoder_mask() 88c7757629da drm/sti: Try to fix up the tvout possible clones 76460d1aa2b5 drm/sti: Remove pointless casts 42670e947cca drm/gma500: Sanitize possible_clones ef3e94dd4ab1 drm: Include the encoder itself in possible_clones

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

✓ Fi.CI.IGT: success for drm: Try to fix encoder possible_clones/crtc

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: drm: Try to fix encoder possible_clones/crtc
URL : https://patchwork.freedesktop.org/series/63399/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6431_full -> Patchwork_13568_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Known issues
------------

Here are the changes found in Patchwork_13568_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@rcs0-s3:
- shard-kbl: [PASS][1] -> [DMESG-WARN][2] ([fdo#108566]) +6 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-kbl2/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-kbl2/igt@[email protected]

* igt@i915_suspend@sysfs-reader:
- shard-apl: [PASS][3] -> [DMESG-WARN][4] ([fdo#108566]) +4 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-apl1/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-apl3/igt@[email protected]

* igt@kms_big_fb@yf-tiled-32bpp-rotate-0:
- shard-apl: [PASS][5] -> [INCOMPLETE][6] ([fdo#103927]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-apl5/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-apl8/igt@[email protected]

* igt@kms_cursor_legacy@cursorb-vs-flipb-varying-size:
- shard-hsw: [PASS][7] -> [INCOMPLETE][8] ([fdo#103540])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-hsw6/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-hsw7/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-rgb565-draw-pwrite:
- shard-iclb: [PASS][9] -> [FAIL][10] ([fdo#103167]) +4 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb2/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb1/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
- shard-skl: [PASS][11] -> [FAIL][12] ([fdo#108145])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-skl2/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-skl7/igt@[email protected]

* igt@kms_psr@psr2_sprite_render:
- shard-iclb: [PASS][13] -> [SKIP][14] ([fdo#109441]) +1 similar issue
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb2/igt@kms_psr@psr2_sprite_render.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb4/igt@kms_psr@psr2_sprite_render.html

* igt@sw_sync@sync_expired_merge:
- shard-iclb: [PASS][15] -> [INCOMPLETE][16] ([fdo#107713])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb8/igt@sw_sync@sync_expired_merge.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb7/igt@sw_sync@sync_expired_merge.html

* igt@tools_test@tools_test:
- shard-hsw: [PASS][17] -> [SKIP][18] ([fdo#109271])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-hsw2/igt@tools_test@tools_test.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-hsw8/igt@tools_test@tools_test.html

#### Possible fixes ####

* igt@gem_eio@unwedge-stress:
- shard-snb: [FAIL][19] ([fdo#109661]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-snb5/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-snb1/igt@[email protected]

* igt@i915_pm_rpm@i2c:
- shard-hsw: [FAIL][21] ([fdo#104097]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-hsw2/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-hsw8/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-skl: [FAIL][23] ([fdo#105363]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-skl10/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-skl1/igt@[email protected]

* igt@kms_flip@flip-vs-suspend:
- shard-apl: [DMESG-WARN][25] ([fdo#108566]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-apl1/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-apl3/igt@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-skl: [INCOMPLETE][27] ([fdo#109507]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-skl3/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-skl4/igt@[email protected]

* igt@kms_flip@plain-flip-fb-recreate-interruptible:
- shard-skl: [FAIL][29] ([fdo#100368]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-skl3/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-skl5/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render:
- shard-iclb: [FAIL][31] ([fdo#103167]) -> [PASS][32] +5 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb4/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html

* igt@kms_plane@pixel-format-pipe-a-planes-source-clamping:
- shard-iclb: [INCOMPLETE][33] ([fdo#107713] / [fdo#110036 ]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb8/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb7/igt@[email protected]

* igt@kms_plane_lowres@pipe-a-tiling-x:
- shard-iclb: [FAIL][35] ([fdo#103166]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb6/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb1/igt@[email protected]

* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: [SKIP][37] ([fdo#109441]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

* igt@kms_rotation_crc@multiplane-rotation-cropping-bottom:
- shard-iclb: [INCOMPLETE][39] ([fdo#107713] / [fdo#110026]) -> [PASS][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-iclb7/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-iclb3/igt@[email protected]

#### Warnings ####

* igt@kms_content_protection@atomic:
- shard-kbl: [DMESG-FAIL][41] -> [FAIL][42] ([fdo#110321] / [fdo#110336])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-kbl2/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-kbl2/igt@[email protected]

* igt@kms_flip@flip-vs-suspend:
- shard-kbl: [DMESG-WARN][43] ([fdo#108566]) -> [INCOMPLETE][44] ([fdo#103665])
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6431/shard-kbl6/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/shard-kbl4/igt@[email protected]

[fdo#100368]: https://bugs.freedesktop.org/show_bug.cgi?id=100368
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104097]: https://bugs.freedesktop.org/show_bug.cgi?id=104097
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109507]: https://bugs.freedesktop.org/show_bug.cgi?id=109507
[fdo#109661]: https://bugs.freedesktop.org/show_bug.cgi?id=109661
[fdo#110026]: https://bugs.freedesktop.org/show_bug.cgi?id=110026
[fdo#110036 ]: https://bugs.freedesktop.org/show_bug.cgi?id=110036
[fdo#110321]: https://bugs.freedesktop.org/show_bug.cgi?id=110321
[fdo#110336]: https://bugs.freedesktop.org/show_bug.cgi?id=110336

Participating hosts (10 -> 10)
------------------------------

No changes in participating hosts

Build changes
-------------

* Linux: CI_DRM_6431 -> Patchwork_13568

CI_DRM_6431: 9a40fb28e45261f2fc44a9b271c19faf1f071138 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5090: c6c75e11175baeb6b984e0cc13c6fbe2863a0794 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13568: 80085b69f7244160427fc81d76fb6f140c9df15a @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13568/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx