From 6d7125f025c7d6a0c97fe3cf8fdea4bf5c7d3a2b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 20 Jun 2010 12:26:53 +0200 Subject: [PATCH 2/2] fix stolen memory detection for i830 and 845G the register is the same as in newer chipsets, but the values mean something else. the agp driver got it right already. --- drivers/gpu/drm/i915/i915_dma.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_reg.h | 7 +++++++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index c3cfafc..241753f 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1098,6 +1098,8 @@ static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size, */ if (IS_G4X(dev) || IS_PINEVIEW(dev) || IS_IRONLAKE(dev) || IS_GEN6(dev)) overhead = 4096; + else if (IS_GEN2(dev)) + overhead = (128 * 1024) + 4096; /* Even for smaller aperture. */ else overhead = (*aperture_size / 1024) + 4096; @@ -1162,6 +1164,29 @@ static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size, tmp & SNB_GMCH_GMS_STOLEN_MASK); return -1; } + } else if (IS_I830(dev) || IS_845G(dev)) { + switch (tmp & I830_GMCH_GMS_MASK) { + case I830_GMCH_GMS_DISABLED: + DRM_ERROR("video memory is disabled\n"); + return -1; + case I830_GMCH_GMS_LOCAL: + /* FIXME: intel-agp has the code to handle that */ + DRM_ERROR("local video memory found, but won't be used\n"); + return -1; + case I830_GMCH_GMS_STOLEN_512: + stolen = 512 * 1024; + break; + case I830_GMCH_GMS_STOLEN_1024: + stolen = 1024 * 1024; + break; + case I830_GMCH_GMS_STOLEN_8192: + stolen = 8192 * 1024; + break; + default: + DRM_ERROR("unexpected GMCH_GMS value: 0x%02x\n", + tmp & I830_GMCH_GMS_MASK); + return -1; + } } else { switch (tmp & INTEL_GMCH_GMS_MASK) { case INTEL_855_GMCH_GMS_DISABLED: diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 4cbc521..9168b4c 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -36,6 +36,13 @@ #define INTEL_GMCH_MEM_64M 0x1 #define INTEL_GMCH_MEM_128M 0 +#define I830_GMCH_GMS_MASK 0x70 +#define I830_GMCH_GMS_DISABLED 0x00 +#define I830_GMCH_GMS_LOCAL 0x10 +#define I830_GMCH_GMS_STOLEN_512 0x20 +#define I830_GMCH_GMS_STOLEN_1024 0x30 +#define I830_GMCH_GMS_STOLEN_8192 0x40 + #define INTEL_GMCH_GMS_MASK (0xf << 4) #define INTEL_855_GMCH_GMS_DISABLED (0x0 << 4) #define INTEL_855_GMCH_GMS_STOLEN_1M (0x1 << 4) -- 1.7.1.15.g43acf