[Intel-gfx] [PATCH 9/9] drm/i915: [sparse] __iomem fixes for intel_bios

Ben Widawsky ben at bwidawsk.net
Mon Apr 16 23:07:48 CEST 2012


This is only the first part of the patch which does the correct types.
The fix for dereferencing stuff was taking too long, so I've stopped.

Signed-off-by: Ben Widawsky <benjamin.widawsky at intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 3534593..7233e72 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -697,24 +697,27 @@ intel_parse_bios(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct pci_dev *pdev = dev->pdev;
-	struct bdb_header *bdb = NULL;
+	struct bdb_header __iomem *bdb = NULL;
 	u8 __iomem *bios = NULL;
 
 	init_vbt_defaults(dev_priv);
 
 	/* XXX Should this validation be moved to intel_opregion.c? */
 	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt) {
-		struct vbt_header *vbt = dev_priv->opregion.vbt;
-		if (memcmp(vbt->signature, "$VBT", 4) == 0) {
+		char sig[20];
+		struct vbt_header __iomem *vbt = dev_priv->opregion.vbt;
+		memcpy_fromio(sig, &vbt->signature, sizeof(sig));
+		if (memcmp(sig, "$VBT", 4) == 0) {
 			DRM_DEBUG_KMS("Using VBT from OpRegion: %20s\n",
 					 vbt->signature);
-			bdb = (struct bdb_header *)((char *)vbt + vbt->bdb_offset);
+			bdb = (struct bdb_header __iomem *)((char __iomem *)vbt +
+				ioread32(&vbt->bdb_offset));
 		} else
 			dev_priv->opregion.vbt = NULL;
 	}
 
 	if (bdb == NULL) {
-		struct vbt_header *vbt = NULL;
+		struct vbt_header __iomem *vbt = NULL;
 		size_t size;
 		int i;
 
@@ -724,8 +727,9 @@ intel_parse_bios(struct drm_device *dev)
 
 		/* Scour memory looking for the VBT signature */
 		for (i = 0; i + 4 < size; i++) {
-			if (!memcmp(bios + i, "$VBT", 4)) {
-				vbt = (struct vbt_header *)(bios + i);
+			u32 temp = ioread32(bios + i);
+			if (!memcmp(&temp, "$VBT", 4)) {
+				vbt = (struct vbt_header __iomem *)(bios + i);
 				break;
 			}
 		}
@@ -736,7 +740,7 @@ intel_parse_bios(struct drm_device *dev)
 			return -1;
 		}
 
-		bdb = (struct bdb_header *)(bios + i + vbt->bdb_offset);
+		bdb = (struct bdb_header __iomem *)(bios + i + vbt->bdb_offset);
 	}
 
 	/* Grab useful general definitions */
-- 
1.7.10




More information about the Intel-gfx mailing list