All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Deepak M <m.deepak@intel.com>, jani.nikula@intel.com
Subject: [PATCH 03/11] drm/i915/bios: have functions return vbt, not bdb, header pointer
Date: Mon, 14 Dec 2015 12:50:47 +0200	[thread overview]
Message-ID: <d2c5210402fdd8c277e1d50892b0620d10c50ae8.1450089383.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1450089383.git.jani.nikula@intel.com>
In-Reply-To: <cover.1450089383.git.jani.nikula@intel.com>

This will simplify further work.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c | 41 +++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 401e1141f55f..2fc2a994f395 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -1214,7 +1214,14 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
 	}
 }
 
-static const struct bdb_header *validate_vbt(const void *base,
+static const struct bdb_header *get_bdb_header(const struct vbt_header *vbt)
+{
+	const void *_vbt = vbt;
+
+	return _vbt + vbt->bdb_offset;
+}
+
+static const struct vbt_header *validate_vbt(const void *base,
 					     size_t size,
 					     const void *_vbt,
 					     const char *source)
@@ -1223,6 +1230,9 @@ static const struct bdb_header *validate_vbt(const void *base,
 	const struct vbt_header *vbt = _vbt;
 	const struct bdb_header *bdb;
 
+	if (!vbt)
+		return NULL;
+
 	if (offset + sizeof(struct vbt_header) > size) {
 		DRM_DEBUG_DRIVER("VBT header incomplete\n");
 		return NULL;
@@ -1239,7 +1249,7 @@ static const struct bdb_header *validate_vbt(const void *base,
 		return NULL;
 	}
 
-	bdb = base + offset;
+	bdb = get_bdb_header(vbt);
 	if (offset + bdb->bdb_size > size) {
 		DRM_DEBUG_DRIVER("BDB incomplete\n");
 		return NULL;
@@ -1247,12 +1257,12 @@ static const struct bdb_header *validate_vbt(const void *base,
 
 	DRM_DEBUG_KMS("Using VBT from %s: %20s\n",
 		      source, vbt->signature);
-	return bdb;
+	return vbt;
 }
 
-static const struct bdb_header *find_vbt(void __iomem *bios, size_t size)
+static const struct vbt_header *find_vbt(void __iomem *bios, size_t size)
 {
-	const struct bdb_header *bdb = NULL;
+	const struct vbt_header *vbt = NULL;
 	size_t i;
 
 	/* Scour memory looking for the VBT signature. */
@@ -1266,12 +1276,12 @@ static const struct bdb_header *find_vbt(void __iomem *bios, size_t size)
 			 */
 			void *_bios = (void __force *) bios;
 
-			bdb = validate_vbt(_bios, size, _bios + i, "PCI ROM");
+			vbt = validate_vbt(_bios, size, _bios + i, "PCI ROM");
 			break;
 		}
 	}
 
-	return bdb;
+	return vbt;
 }
 
 /**
@@ -1288,7 +1298,8 @@ intel_parse_bios(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct pci_dev *pdev = dev->pdev;
-	const struct bdb_header *bdb = NULL;
+	const struct vbt_header *vbt;
+	const struct bdb_header *bdb;
 	u8 __iomem *bios = NULL;
 
 	if (HAS_PCH_NOP(dev))
@@ -1297,24 +1308,24 @@ intel_parse_bios(struct drm_device *dev)
 	init_vbt_defaults(dev_priv);
 
 	/* XXX Should this validation be moved to intel_opregion.c? */
-	if (dev_priv->opregion.vbt)
-		bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
-				   dev_priv->opregion.vbt, "OpRegion");
-
-	if (bdb == NULL) {
+	vbt = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
+			   dev_priv->opregion.vbt, "OpRegion");
+	if (!vbt) {
 		size_t size;
 
 		bios = pci_map_rom(pdev, &size);
 		if (!bios)
 			return -1;
 
-		bdb = find_vbt(bios, size);
-		if (!bdb) {
+		vbt = find_vbt(bios, size);
+		if (!vbt) {
 			pci_unmap_rom(pdev, bios);
 			return -1;
 		}
 	}
 
+	bdb = get_bdb_header(vbt);
+
 	/* Grab useful general definitions */
 	parse_general_features(dev_priv, bdb);
 	parse_general_definitions(dev_priv, bdb);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-12-14 10:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14 10:50 [PATCH 00/11] drm/i915: VBT/opregion refactor to support >6 KB VBT Jani Nikula
2015-12-14 10:50 ` [PATCH 01/11] drm/i915: Add Intel opregion mailbox 5 structure Jani Nikula
2015-12-14 10:50 ` [PATCH 02/11] drm/i915: move "no VBT in opregion" quirk to intel_opregion_setup() Jani Nikula
2015-12-14 10:50 ` Jani Nikula [this message]
2015-12-14 10:50 ` [PATCH 04/11] drm/i915/bios: move debug logging about VBT source to intel_parse_bios() Jani Nikula
2015-12-15 11:14   ` [PATCH v2 " Jani Nikula
2015-12-14 10:50 ` [PATCH 05/11] drm/i915/bios: rename intel_parse_bios to intel_bios_init Jani Nikula
2015-12-14 10:50 ` [PATCH 06/11] drm/i915: refactor VBT validation Jani Nikula
2015-12-14 13:41   ` Ville Syrjälä
2015-12-14 14:34     ` Jani Nikula
2015-12-14 14:42       ` Ville Syrjälä
2015-12-15 11:16   ` [PATCH v2 " Jani Nikula
2015-12-14 10:50 ` [PATCH 07/11] drm/i915/opregion: make VBT size limit more strict Jani Nikula
2015-12-14 10:50 ` [PATCH 08/11] drm/i915/opregion: make VBT pointer a const Jani Nikula
2015-12-14 10:50 ` [PATCH 09/11] drm/i915: don't use a temp buffer for opregion debugfs file Jani Nikula
2015-12-14 13:45   ` Ville Syrjälä
2015-12-14 14:38     ` Jani Nikula
2015-12-14 14:45       ` Ville Syrjälä
2015-12-14 10:50 ` [PATCH 10/11] drm/i915/debugfs: add a separate debugfs file for VBT Jani Nikula
2015-12-14 10:57   ` Chris Wilson
2015-12-14 11:06     ` Jani Nikula
2015-12-14 11:29       ` Chris Wilson
2015-12-14 13:20   ` [PATCH v2 " Jani Nikula
2015-12-15 11:17     ` [PATCH v3 " Jani Nikula
2015-12-14 10:50 ` [PATCH 11/11] drm/i915/opregion: handle VBT sizes bigger than 6 KB Jani Nikula
2015-12-14 14:19   ` Ville Syrjälä
2015-12-14 14:34     ` Ville Syrjälä
2015-12-15 14:02       ` Ville Syrjälä
2015-12-16  9:37         ` Jani Nikula
2015-12-14 14:40     ` Jani Nikula
2015-12-15 11:18   ` [PATCH v2 " Jani Nikula
2015-12-17  7:30   ` [PATCH " Mika Kahola
2015-12-17  9:46     ` Jani Nikula

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=d2c5210402fdd8c277e1d50892b0620d10c50ae8.1450089383.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=m.deepak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.