From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Subject: [PATCH] drm/i915: Check encoder type in enc_to_dig_port()
Date: Fri, 24 Feb 2017 16:18:45 +0200 [thread overview]
Message-ID: <20170224141845.5836-1-ander.conselvan.de.oliveira@intel.com> (raw)
In-Reply-To: <20170224141127.1155-1-ander.conselvan.de.oliveira@intel.com>
Don't allow conversion from arbitraty encoder types to a digital port.
Calling enc_to_dig_port() with the wrong encoder may seem far fetched,
but certain paths of the ddi code may be called with hasell's analog
encoder and the conversion is wrong for DP mst encoders too, so safe
guard against it.
v2: Warn if encoder type is unknown and device is not DDI. (Imre)
v3: Remove stray hunk from rebase error. (Ander)
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
---
drivers/gpu/drm/i915/intel_drv.h | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c916338..97621a1 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1121,7 +1121,19 @@ intel_attached_encoder(struct drm_connector *connector)
static inline struct intel_digital_port *
enc_to_dig_port(struct drm_encoder *encoder)
{
- return container_of(encoder, struct intel_digital_port, base.base);
+ struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+
+ switch (intel_encoder->type) {
+ case INTEL_OUTPUT_UNKNOWN:
+ WARN_ON(!HAS_DDI(to_i915(encoder->dev)));
+ case INTEL_OUTPUT_DP:
+ case INTEL_OUTPUT_EDP:
+ case INTEL_OUTPUT_HDMI:
+ return container_of(encoder, struct intel_digital_port,
+ base.base);
+ default:
+ return NULL;
+ }
}
static inline struct intel_dp_mst_encoder *
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-24 14:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 6:34 [PATCH v3 0/6] Fix Geminilake DDI power well enable timeouts Ander Conselvan de Oliveira
2017-02-22 6:34 ` [PATCH v3 1/6] drm/i915: Store aux power domain in intel_dp Ander Conselvan de Oliveira
2017-02-22 6:34 ` [PATCH v3 2/6] drm/i915: Store encoder power domain in struct intel_encoder Ander Conselvan de Oliveira
2017-02-22 6:34 ` [PATCH v3 3/6] drm/i915: Check encoder type in enc_to_dig_port() Ander Conselvan de Oliveira
2017-02-24 13:38 ` Imre Deak
2017-02-24 14:11 ` [PATCH] " Ander Conselvan de Oliveira
2017-02-24 14:18 ` Ander Conselvan de Oliveira [this message]
2017-02-24 15:34 ` Imre Deak
2017-02-22 6:34 ` [PATCH v3 4/6] drm/i915/glk: Implement WaDDIIOTimeout Ander Conselvan de Oliveira
2017-02-22 6:34 ` [PATCH v3 5/6] drm/i915/glk: Don't enable DDI IO power domains during init Ander Conselvan de Oliveira
2017-02-22 6:34 ` [PATCH v3 6/6] drm/i915: Only enable DDI IO power domains after enabling DPLL Ander Conselvan de Oliveira
2017-02-24 13:50 ` Imre Deak
2017-02-24 14:19 ` [PATCH] " Ander Conselvan de Oliveira
2017-02-27 20:38 ` Ville Syrjälä
2017-02-28 7:28 ` Ander Conselvan De Oliveira
2017-02-22 7:22 ` ✓ Fi.CI.BAT: success for Fix Geminilake DDI power well enable timeouts (rev3) Patchwork
2017-02-24 15:22 ` ✓ Fi.CI.BAT: success for Fix Geminilake DDI power well enable timeouts (rev6) Patchwork
2017-02-27 7:15 ` Ander Conselvan De Oliveira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170224141845.5836-1-ander.conselvan.de.oliveira@intel.com \
--to=ander.conselvan.de.oliveira@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox