Machines with Intel integrated graphics have this concept of stolen
memory; system memory set aside by the BIOS for use by the graphics
chip.  On OpenBSD we don't touch that memory since we don't want to
step on the BIOS' toes.  We also assume that this memory is mapped in
the graphics translation table (GTT).  So we reserve a block of the
size of the stolen memory at the start of the aperture and never use
it.

On modern machines this strategy doesn't make a lot of sense.  The
size of the stolen memory can be larger than the graphics aperture,
leaving inteldrm(4) no space to map framebuffers and other graphics
objects.

The diff below gets rid of this policy on Sandy Bridge and Ivy Bridge
CPUs, making the full aperture available for use by inteldrm(4).  This
works fine on my x220, but before I commit this, I'd like to see a
little bit more testing.  If you have a machine with Intel HD Graphics
2000/3000/2500/4000, please give this diff a try.  If possible, test
the following:

 * Check that X still works properly.

 * Check that suspend/resume still works.  (Don't bother if
   suspend/resume doesn't work without this diff).

 * Disable the inteldrm driver (boot with the -c option, disable
   inteldrm at the UKC> prompt) and check if the VGA text console
   still works properly.

Thanks,

Mark

Index: agp_i810.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/agp_i810.c,v
retrieving revision 1.74
diff -u -p -r1.74 agp_i810.c
--- agp_i810.c  18 Mar 2013 12:02:56 -0000      1.74
+++ agp_i810.c  4 Apr 2013 20:38:14 -0000
@@ -506,79 +506,11 @@ agp_i810_attach(struct device *parent, s
 
        case CHIP_SANDYBRIDGE:
        case CHIP_IVYBRIDGE:
-
-               /* Stolen memory is set up at the beginning of the aperture by
-                * the BIOS, consisting of the GATT followed by 4kb for the
-                * BIOS display.
+               /*
+                * Even though stolen memory exists on these machines,
+                * it isn't necessarily mapped into the aperture.
                 */
-
-               gcc1 = (u_int16_t)pci_conf_read(bpa.pa_pc, bpa.pa_tag,
-                   AGP_INTEL_SNB_GMCH_CTRL);
-
-               stolen = 4;
-
-               switch (gcc1 & AGP_INTEL_SNB_GMCH_GMS_STOLEN_MASK) {
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_32M:
-                       isc->stolen = (32768 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_64M:
-                       isc->stolen = (65536 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_96M:
-                       isc->stolen = (98304 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_128M:
-                       isc->stolen = (131072 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_160M:
-                       isc->stolen = (163840 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_192M:
-                       isc->stolen = (196608 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_224M:
-                       isc->stolen = (229376 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_256M:
-                       isc->stolen = (262144 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_288M:
-                       isc->stolen = (294912 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_320M:
-                       isc->stolen = (327680 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_352M:
-                       isc->stolen = (360448 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_384M:
-                       isc->stolen = (393216 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_416M:
-                       isc->stolen = (425984 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_448M:
-                       isc->stolen = (458752 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_480M:
-                       isc->stolen = (491520 - stolen) * 1024 / 4096;
-                       break;
-               case AGP_INTEL_SNB_GMCH_GMS_STOLEN_512M:
-                       isc->stolen = (524288 - stolen) * 1024 / 4096;
-                       break;
-               default:
-                       isc->stolen = 0;
-                       printf("unknown memory configuration, disabling\n");
-                       goto out;
-               }
-
-#ifdef DEBUG
-               if (isc->stolen > 0) {
-                       printf(": detected %dk stolen memory",
-                           isc->stolen * 4);
-               } else
-                       printf(": no preallocated video memory\n");
-#endif
+               isc->stolen = 0;
 
                /* GATT address is already in there, make sure it's enabled */
                gatt->ag_physical = READ4(AGP_I810_PGTBL_CTL) & ~1;



Reply via email to