dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
To: rodrigo.vivi@intel.com, irlied@linux.ie, daniel@ffwll.ch,
	sudeep.dutt@intel.com, jani.nikula@intel.com,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: pankaj.laxminarayan.bharadiya@intel.com
Subject: [Intel-gfx] [RFC 3/7] drm/i915: add helper functions to get device ptr
Date: Mon,  6 Jan 2020 22:53:22 +0530	[thread overview]
Message-ID: <20200106172326.32592-4-pankaj.laxminarayan.bharadiya@intel.com> (raw)
In-Reply-To: <20200106172326.32592-1-pankaj.laxminarayan.bharadiya@intel.com>

We will need struct device pointer to pass it to dev_WARN* calls.

Add helper functions to exract device pointer from various structs.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display_types.h | 14 ++++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.h                     |  5 +++++
 drivers/gpu/drm/i915/i915_drv.h                    | 11 +++++++++++
 3 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 630a94892b7b..6cca8921f3c6 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1523,6 +1523,20 @@ dp_to_i915(struct intel_dp *intel_dp)
 	return to_i915(dp_to_dig_port(intel_dp)->base.base.dev);
 }
 
+static inline struct device *enc_to_dev(const struct intel_encoder *encoder)
+{
+	return encoder->base.dev->dev;
+}
+
+static inline struct device *
+crtc_state_to_dev(const struct intel_crtc_state *state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(state->uapi.crtc);
+	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
+
+	return i915_to_dev(i915);
+}
+
 static inline struct intel_digital_port *
 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
 {
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index b47c6acaf9c0..2900ef848e84 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -348,6 +348,11 @@ static inline struct intel_gvt *to_gvt(struct drm_i915_private *i915)
 	return i915->gvt;
 }
 
+static inline struct device *vgpu_to_dev(const struct intel_vgpu *vgpu)
+{
+	return i915_to_dev(vgpu->gvt->dev_priv);
+}
+
 enum {
 	INTEL_GVT_REQUEST_EMULATE_VBLANK = 0,
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b7f122dccdca..bd4557d6f35b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1314,6 +1314,17 @@ static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
 	return pci_get_drvdata(pdev);
 }
 
+static inline struct device *i915_to_dev(const struct drm_i915_private *i915)
+{
+	return i915->drm.dev;
+}
+
+static inline struct device *
+perf_stream_to_dev(const struct i915_perf_stream *stream)
+{
+	return i915_to_dev(stream->perf->i915);
+}
+
 /* Simple iterator over all initialised engines */
 #define for_each_engine(engine__, dev_priv__, id__) \
 	for ((id__) = 0; \
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-01-06 17:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 17:23 [Intel-gfx] [RFC 0/7] drm/i915: Convert WARN* to use device-specific variants Pankaj Bharadiya
2020-01-06 17:23 ` [Intel-gfx] [RFC 1/7] treewide: device: add condition support to dev_WARN Pankaj Bharadiya
2020-01-08 11:13   ` Jani Nikula
2020-01-06 17:23 ` [Intel-gfx] [RFC 2/7] drm/i915/i915_utils: add dev_WARN_ON and dev_WARN_ON_ONCE macros Pankaj Bharadiya
2020-01-06 17:23 ` Pankaj Bharadiya [this message]
2020-01-08 11:17   ` [Intel-gfx] [RFC 3/7] drm/i915: add helper functions to get device ptr Jani Nikula
2020-01-06 17:23 ` [Intel-gfx] [RFC 4/7] drm/i915: Make WARN* device specific where drm_device ptr available Pankaj Bharadiya
2020-01-06 17:23 ` [Intel-gfx] [RFC 5/7] drm/i915: Make WARN* device specific where drm_priv ptr is available Pankaj Bharadiya
2020-01-08 12:52   ` Jani Nikula
2020-01-09 11:25     ` Bharadiya,Pankaj
2020-01-06 17:23 ` [Intel-gfx] [RFC 6/7] drm/i915: Make WARN* device specific where dev_priv can be extracted Pankaj Bharadiya
2020-01-06 17:23 ` [Intel-gfx] [RFC 7/7] drm/i915: Make WARN* device specific for various cases Pankaj Bharadiya

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=20200106172326.32592-4-pankaj.laxminarayan.bharadiya@intel.com \
    --to=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=irlied@linux.ie \
    --cc=jani.nikula@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sudeep.dutt@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).