Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pullx86 core platform updates from Peter Anvin:
"This is the x86/platform branch with the objectionable IOSF patches
removed.

What is left is proper memory handling for Intel GPUs, and a change to
the Calgary IOMMU code which will be required to make kexec work
sanely on those platforms after some upcoming kexec changes"

* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86, calgary: Use 8M TCE table size by default
x86/gpu: Print the Intel graphics stolen memory range
x86/gpu: Add Intel graphics stolen memory quirk for gen2 platforms
x86/gpu: Add vfunc for Intel graphics stolen memory base address

+221 -41
+182 -29
arch/x86/kernel/early-quirks.c
··· 225 225 * 226 226 * And yes, so far on current devices the base addr is always under 4G. 227 227 */ 228 - static u32 __init intel_stolen_base(int num, int slot, int func) 228 + static u32 __init intel_stolen_base(int num, int slot, int func, size_t stolen_size) 229 229 { 230 230 u32 base; 231 231 ··· 243 243 #define KB(x) ((x) * 1024) 244 244 #define MB(x) (KB (KB (x))) 245 245 #define GB(x) (MB (KB (x))) 246 + 247 + static size_t __init i830_tseg_size(void) 248 + { 249 + u8 tmp = read_pci_config_byte(0, 0, 0, I830_ESMRAMC); 250 + 251 + if (!(tmp & TSEG_ENABLE)) 252 + return 0; 253 + 254 + if (tmp & I830_TSEG_SIZE_1M) 255 + return MB(1); 256 + else 257 + return KB(512); 258 + } 259 + 260 + static size_t __init i845_tseg_size(void) 261 + { 262 + u8 tmp = read_pci_config_byte(0, 0, 0, I845_ESMRAMC); 263 + 264 + if (!(tmp & TSEG_ENABLE)) 265 + return 0; 266 + 267 + switch (tmp & I845_TSEG_SIZE_MASK) { 268 + case I845_TSEG_SIZE_512K: 269 + return KB(512); 270 + case I845_TSEG_SIZE_1M: 271 + return MB(1); 272 + default: 273 + WARN_ON(1); 274 + return 0; 275 + } 276 + } 277 + 278 + static size_t __init i85x_tseg_size(void) 279 + { 280 + u8 tmp = read_pci_config_byte(0, 0, 0, I85X_ESMRAMC); 281 + 282 + if (!(tmp & TSEG_ENABLE)) 283 + return 0; 284 + 285 + return MB(1); 286 + } 287 + 288 + static size_t __init i830_mem_size(void) 289 + { 290 + return read_pci_config_byte(0, 0, 0, I830_DRB3) * MB(32); 291 + } 292 + 293 + static size_t __init i85x_mem_size(void) 294 + { 295 + return read_pci_config_byte(0, 0, 1, I85X_DRB3) * MB(32); 296 + } 297 + 298 + /* 299 + * On 830/845/85x the stolen memory base isn't available in any 300 + * register. We need to calculate it as TOM-TSEG_SIZE-stolen_size. 301 + */ 302 + static u32 __init i830_stolen_base(int num, int slot, int func, size_t stolen_size) 303 + { 304 + return i830_mem_size() - i830_tseg_size() - stolen_size; 305 + } 306 + 307 + static u32 __init i845_stolen_base(int num, int slot, int func, size_t stolen_size) 308 + { 309 + return i830_mem_size() - i845_tseg_size() - stolen_size; 310 + } 311 + 312 + static u32 __init i85x_stolen_base(int num, int slot, int func, size_t stolen_size) 313 + { 314 + return i85x_mem_size() - i85x_tseg_size() - stolen_size; 315 + } 316 + 317 + static u32 __init i865_stolen_base(int num, int slot, int func, size_t stolen_size) 318 + { 319 + /* 320 + * FIXME is the graphics stolen memory region 321 + * always at TOUD? Ie. is it always the last 322 + * one to be allocated by the BIOS? 323 + */ 324 + return read_pci_config_16(0, 0, 0, I865_TOUD) << 16; 325 + } 326 + 327 + static size_t __init i830_stolen_size(int num, int slot, int func) 328 + { 329 + size_t stolen_size; 330 + u16 gmch_ctrl; 331 + 332 + gmch_ctrl = read_pci_config_16(0, 0, 0, I830_GMCH_CTRL); 333 + 334 + switch (gmch_ctrl & I830_GMCH_GMS_MASK) { 335 + case I830_GMCH_GMS_STOLEN_512: 336 + stolen_size = KB(512); 337 + break; 338 + case I830_GMCH_GMS_STOLEN_1024: 339 + stolen_size = MB(1); 340 + break; 341 + case I830_GMCH_GMS_STOLEN_8192: 342 + stolen_size = MB(8); 343 + break; 344 + case I830_GMCH_GMS_LOCAL: 345 + /* local memory isn't part of the normal address space */ 346 + stolen_size = 0; 347 + break; 348 + default: 349 + return 0; 350 + } 351 + 352 + return stolen_size; 353 + } 246 354 247 355 static size_t __init gen3_stolen_size(int num, int slot, int func) 248 356 { ··· 418 310 return gmch_ctrl << 25; /* 32 MB units */ 419 311 } 420 312 421 - static inline size_t gen8_stolen_size(int num, int slot, int func) 313 + static size_t gen8_stolen_size(int num, int slot, int func) 422 314 { 423 315 u16 gmch_ctrl; 424 316 ··· 428 320 return gmch_ctrl << 25; /* 32 MB units */ 429 321 } 430 322 431 - typedef size_t (*stolen_size_fn)(int num, int slot, int func); 323 + 324 + struct intel_stolen_funcs { 325 + size_t (*size)(int num, int slot, int func); 326 + u32 (*base)(int num, int slot, int func, size_t size); 327 + }; 328 + 329 + static const struct intel_stolen_funcs i830_stolen_funcs = { 330 + .base = i830_stolen_base, 331 + .size = i830_stolen_size, 332 + }; 333 + 334 + static const struct intel_stolen_funcs i845_stolen_funcs = { 335 + .base = i845_stolen_base, 336 + .size = i830_stolen_size, 337 + }; 338 + 339 + static const struct intel_stolen_funcs i85x_stolen_funcs = { 340 + .base = i85x_stolen_base, 341 + .size = gen3_stolen_size, 342 + }; 343 + 344 + static const struct intel_stolen_funcs i865_stolen_funcs = { 345 + .base = i865_stolen_base, 346 + .size = gen3_stolen_size, 347 + }; 348 + 349 + static const struct intel_stolen_funcs gen3_stolen_funcs = { 350 + .base = intel_stolen_base, 351 + .size = gen3_stolen_size, 352 + }; 353 + 354 + static const struct intel_stolen_funcs gen6_stolen_funcs = { 355 + .base = intel_stolen_base, 356 + .size = gen6_stolen_size, 357 + }; 358 + 359 + static const struct intel_stolen_funcs gen8_stolen_funcs = { 360 + .base = intel_stolen_base, 361 + .size = gen8_stolen_size, 362 + }; 432 363 433 364 static struct pci_device_id intel_stolen_ids[] __initdata = { 434 - INTEL_I915G_IDS(gen3_stolen_size), 435 - INTEL_I915GM_IDS(gen3_stolen_size), 436 - INTEL_I945G_IDS(gen3_stolen_size), 437 - INTEL_I945GM_IDS(gen3_stolen_size), 438 - INTEL_VLV_M_IDS(gen6_stolen_size), 439 - INTEL_VLV_D_IDS(gen6_stolen_size), 440 - INTEL_PINEVIEW_IDS(gen3_stolen_size), 441 - INTEL_I965G_IDS(gen3_stolen_size), 442 - INTEL_G33_IDS(gen3_stolen_size), 443 - INTEL_I965GM_IDS(gen3_stolen_size), 444 - INTEL_GM45_IDS(gen3_stolen_size), 445 - INTEL_G45_IDS(gen3_stolen_size), 446 - INTEL_IRONLAKE_D_IDS(gen3_stolen_size), 447 - INTEL_IRONLAKE_M_IDS(gen3_stolen_size), 448 - INTEL_SNB_D_IDS(gen6_stolen_size), 449 - INTEL_SNB_M_IDS(gen6_stolen_size), 450 - INTEL_IVB_M_IDS(gen6_stolen_size), 451 - INTEL_IVB_D_IDS(gen6_stolen_size), 452 - INTEL_HSW_D_IDS(gen6_stolen_size), 453 - INTEL_HSW_M_IDS(gen6_stolen_size), 454 - INTEL_BDW_M_IDS(gen8_stolen_size), 455 - INTEL_BDW_D_IDS(gen8_stolen_size) 365 + INTEL_I830_IDS(&i830_stolen_funcs), 366 + INTEL_I845G_IDS(&i845_stolen_funcs), 367 + INTEL_I85X_IDS(&i85x_stolen_funcs), 368 + INTEL_I865G_IDS(&i865_stolen_funcs), 369 + INTEL_I915G_IDS(&gen3_stolen_funcs), 370 + INTEL_I915GM_IDS(&gen3_stolen_funcs), 371 + INTEL_I945G_IDS(&gen3_stolen_funcs), 372 + INTEL_I945GM_IDS(&gen3_stolen_funcs), 373 + INTEL_VLV_M_IDS(&gen6_stolen_funcs), 374 + INTEL_VLV_D_IDS(&gen6_stolen_funcs), 375 + INTEL_PINEVIEW_IDS(&gen3_stolen_funcs), 376 + INTEL_I965G_IDS(&gen3_stolen_funcs), 377 + INTEL_G33_IDS(&gen3_stolen_funcs), 378 + INTEL_I965GM_IDS(&gen3_stolen_funcs), 379 + INTEL_GM45_IDS(&gen3_stolen_funcs), 380 + INTEL_G45_IDS(&gen3_stolen_funcs), 381 + INTEL_IRONLAKE_D_IDS(&gen3_stolen_funcs), 382 + INTEL_IRONLAKE_M_IDS(&gen3_stolen_funcs), 383 + INTEL_SNB_D_IDS(&gen6_stolen_funcs), 384 + INTEL_SNB_M_IDS(&gen6_stolen_funcs), 385 + INTEL_IVB_M_IDS(&gen6_stolen_funcs), 386 + INTEL_IVB_D_IDS(&gen6_stolen_funcs), 387 + INTEL_HSW_D_IDS(&gen6_stolen_funcs), 388 + INTEL_HSW_M_IDS(&gen6_stolen_funcs), 389 + INTEL_BDW_M_IDS(&gen8_stolen_funcs), 390 + INTEL_BDW_D_IDS(&gen8_stolen_funcs) 456 391 }; 457 392 458 393 static void __init intel_graphics_stolen(int num, int slot, int func) ··· 512 361 513 362 for (i = 0; i < ARRAY_SIZE(intel_stolen_ids); i++) { 514 363 if (intel_stolen_ids[i].device == device) { 515 - stolen_size_fn stolen_size = 516 - (stolen_size_fn)intel_stolen_ids[i].driver_data; 517 - size = stolen_size(num, slot, func); 518 - start = intel_stolen_base(num, slot, func); 364 + const struct intel_stolen_funcs *stolen_funcs = 365 + (const struct intel_stolen_funcs *)intel_stolen_ids[i].driver_data; 366 + size = stolen_funcs->size(num, slot, func); 367 + start = stolen_funcs->base(num, slot, func, size); 519 368 if (size && start) { 369 + printk(KERN_INFO "Reserving Intel graphics stolen memory at 0x%x-0x%x\n", 370 + start, start + (u32)size - 1); 520 371 /* Mark this space as reserved */ 521 372 e820_add_region(start, size, E820_RESERVED); 522 373 sanitize_e820_map(e820.map,
+19 -12
arch/x86/kernel/pci-calgary_64.c
··· 1207 1207 return ret; 1208 1208 } 1209 1209 1210 - static inline int __init determine_tce_table_size(u64 ram) 1210 + static inline int __init determine_tce_table_size(void) 1211 1211 { 1212 1212 int ret; 1213 1213 1214 1214 if (specified_table_size != TCE_TABLE_SIZE_UNSPECIFIED) 1215 1215 return specified_table_size; 1216 1216 1217 - /* 1218 - * Table sizes are from 0 to 7 (TCE_TABLE_SIZE_64K to 1219 - * TCE_TABLE_SIZE_8M). Table size 0 has 8K entries and each 1220 - * larger table size has twice as many entries, so shift the 1221 - * max ram address by 13 to divide by 8K and then look at the 1222 - * order of the result to choose between 0-7. 1223 - */ 1224 - ret = get_order(ram >> 13); 1225 - if (ret > TCE_TABLE_SIZE_8M) 1217 + if (is_kdump_kernel() && saved_max_pfn) { 1218 + /* 1219 + * Table sizes are from 0 to 7 (TCE_TABLE_SIZE_64K to 1220 + * TCE_TABLE_SIZE_8M). Table size 0 has 8K entries and each 1221 + * larger table size has twice as many entries, so shift the 1222 + * max ram address by 13 to divide by 8K and then look at the 1223 + * order of the result to choose between 0-7. 1224 + */ 1225 + ret = get_order((saved_max_pfn * PAGE_SIZE) >> 13); 1226 + if (ret > TCE_TABLE_SIZE_8M) 1227 + ret = TCE_TABLE_SIZE_8M; 1228 + } else { 1229 + /* 1230 + * Use 8M by default (suggested by Muli) if it's not 1231 + * kdump kernel and saved_max_pfn isn't set. 1232 + */ 1226 1233 ret = TCE_TABLE_SIZE_8M; 1234 + } 1227 1235 1228 1236 return ret; 1229 1237 } ··· 1426 1418 return -ENOMEM; 1427 1419 } 1428 1420 1429 - specified_table_size = determine_tce_table_size((is_kdump_kernel() ? 1430 - saved_max_pfn : max_pfn) * PAGE_SIZE); 1421 + specified_table_size = determine_tce_table_size(); 1431 1422 1432 1423 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) { 1433 1424 struct calgary_bus_info *info = &bus_info[bus];
+20
include/drm/i915_drm.h
··· 56 56 57 57 #define I830_GMCH_CTRL 0x52 58 58 59 + #define I830_GMCH_GMS_MASK 0x70 60 + #define I830_GMCH_GMS_LOCAL 0x10 61 + #define I830_GMCH_GMS_STOLEN_512 0x20 62 + #define I830_GMCH_GMS_STOLEN_1024 0x30 63 + #define I830_GMCH_GMS_STOLEN_8192 0x40 64 + 59 65 #define I855_GMCH_GMS_MASK 0xF0 60 66 #define I855_GMCH_GMS_STOLEN_0M 0x0 61 67 #define I855_GMCH_GMS_STOLEN_1M (0x1 << 4) ··· 77 71 #define INTEL_GMCH_GMS_STOLEN_160M (0xb << 4) 78 72 #define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4) 79 73 #define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4) 74 + 75 + #define I830_DRB3 0x63 76 + #define I85X_DRB3 0x43 77 + #define I865_TOUD 0xc4 78 + 79 + #define I830_ESMRAMC 0x91 80 + #define I845_ESMRAMC 0x9e 81 + #define I85X_ESMRAMC 0x61 82 + #define TSEG_ENABLE (1 << 0) 83 + #define I830_TSEG_SIZE_512K (0 << 1) 84 + #define I830_TSEG_SIZE_1M (1 << 1) 85 + #define I845_TSEG_SIZE_MASK (3 << 1) 86 + #define I845_TSEG_SIZE_512K (2 << 1) 87 + #define I845_TSEG_SIZE_1M (3 << 1) 80 88 81 89 #endif /* _I915_DRM_H_ */