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

Configure Feed

Select the types of activity you want to include in your feed.

drm/imagination: Warn or error on unsupported hardware

Gate the use of unsupported hardware behind a new module parameter
(exp_hw_support).

Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>
Link: https://patch.msgid.link/20260113-device-support-info-v1-6-91e5db7f7294@imgtec.com
Signed-off-by: Matt Coster <matt.coster@imgtec.com>

+72 -1
+72 -1
drivers/gpu/drm/imagination/pvr_device.c
··· 525 525 } 526 526 EXPORT_SYMBOL_IF_KUNIT(pvr_gpuid_decode_string); 527 527 528 + static bool pvr_exp_hw_support; 529 + module_param_named(exp_hw_support, pvr_exp_hw_support, bool, 0600); 530 + MODULE_PARM_DESC(exp_hw_support, "Bypass runtime checks for fully supported GPU cores. WARNING: enabling this option may result in a buggy, insecure, or otherwise unusable driver."); 531 + 532 + /** 533 + * enum pvr_gpu_support_level - The level of support for a gpu_id in the current 534 + * version of the driver. 535 + * 536 + * @PVR_GPU_UNKNOWN: Cores that are unknown to the driver. These may not even exist. 537 + * @PVR_GPU_EXPERIMENTAL: Cores that have experimental support. 538 + * @PVR_GPU_SUPPORTED: Cores that are supported and maintained. 539 + */ 540 + enum pvr_gpu_support_level { 541 + PVR_GPU_UNKNOWN, 542 + PVR_GPU_EXPERIMENTAL, 543 + PVR_GPU_SUPPORTED, 544 + }; 545 + 546 + static enum pvr_gpu_support_level 547 + pvr_gpu_support_level(const struct pvr_gpu_id *gpu_id) 548 + { 549 + switch (pvr_gpu_id_to_packed_bvnc(gpu_id)) { 550 + case PVR_PACKED_BVNC(33, 15, 11, 3): 551 + case PVR_PACKED_BVNC(36, 53, 104, 796): 552 + return PVR_GPU_SUPPORTED; 553 + 554 + case PVR_PACKED_BVNC(36, 52, 104, 182): 555 + return PVR_GPU_EXPERIMENTAL; 556 + 557 + default: 558 + return PVR_GPU_UNKNOWN; 559 + } 560 + } 561 + 562 + static int 563 + pvr_check_gpu_supported(struct pvr_device *pvr_dev, 564 + const struct pvr_gpu_id *gpu_id) 565 + { 566 + struct drm_device *drm_dev = from_pvr_device(pvr_dev); 567 + 568 + switch (pvr_gpu_support_level(gpu_id)) { 569 + case PVR_GPU_SUPPORTED: 570 + if (pvr_exp_hw_support) 571 + drm_info(drm_dev, "Module parameter 'exp_hw_support' was set, but this hardware is fully supported by the current driver."); 572 + 573 + break; 574 + 575 + case PVR_GPU_EXPERIMENTAL: 576 + if (!pvr_exp_hw_support) { 577 + drm_err(drm_dev, "Unsupported GPU! Set 'exp_hw_support' to bypass this check."); 578 + return -ENODEV; 579 + } 580 + 581 + drm_warn(drm_dev, "Running on unsupported hardware; you may encounter bugs!"); 582 + break; 583 + 584 + /* NOTE: This code path may indicate misbehaving hardware. */ 585 + case PVR_GPU_UNKNOWN: 586 + default: 587 + if (!pvr_exp_hw_support) { 588 + drm_err(drm_dev, "Unknown GPU! Set 'exp_hw_support' to bypass this check."); 589 + return -ENODEV; 590 + } 591 + 592 + drm_warn(drm_dev, "Running on unknown hardware; expect issues."); 593 + break; 594 + } 595 + 596 + return 0; 597 + } 598 + 528 599 static char *pvr_gpuid_override; 529 600 module_param_named(gpuid, pvr_gpuid_override, charp, 0400); 530 601 MODULE_PARM_DESC(gpuid, "GPU ID (BVNC) to be used instead of the value read from hardware."); ··· 626 555 return err; 627 556 } 628 557 629 - return 0; 558 + return pvr_check_gpu_supported(pvr_dev, gpu_id); 630 559 } 631 560 632 561 /**