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/amdgpu: Add supported NPS modes node

Add sysfs node to show supported NPS mode for the
partition configuration selected using xcp_config

v2: Hide node if dynamic nps switch not supported

v3: Fix removal of files in case of error

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Asad Kamal and committed by
Alex Deucher
04e91017 35a6e15a

+47 -1
+47 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
··· 471 471 [AMDGPU_CPX_PARTITION_MODE] = "CPX", 472 472 }; 473 473 474 + static const char *nps_desc[] = { 475 + [UNKNOWN_MEMORY_PARTITION_MODE] = "UNKNOWN", 476 + [AMDGPU_NPS1_PARTITION_MODE] = "NPS1", 477 + [AMDGPU_NPS2_PARTITION_MODE] = "NPS2", 478 + [AMDGPU_NPS3_PARTITION_MODE] = "NPS3", 479 + [AMDGPU_NPS4_PARTITION_MODE] = "NPS4", 480 + [AMDGPU_NPS6_PARTITION_MODE] = "NPS6", 481 + [AMDGPU_NPS8_PARTITION_MODE] = "NPS8", 482 + }; 483 + 474 484 ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs); 475 485 476 486 #define to_xcp_attr(x) \ ··· 550 540 return size; 551 541 } 552 542 543 + static ssize_t supported_nps_configs_show(struct kobject *kobj, 544 + struct kobj_attribute *attr, char *buf) 545 + { 546 + struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj); 547 + int size = 0, mode; 548 + char *sep = ""; 549 + 550 + if (!xcp_cfg || !xcp_cfg->compatible_nps_modes) 551 + return sysfs_emit(buf, "Not supported\n"); 552 + 553 + for_each_inst(mode, xcp_cfg->compatible_nps_modes) { 554 + size += sysfs_emit_at(buf, size, "%s%s", sep, nps_desc[mode]); 555 + sep = ", "; 556 + } 557 + 558 + size += sysfs_emit_at(buf, size, "\n"); 559 + 560 + return size; 561 + } 562 + 553 563 static ssize_t xcp_config_show(struct kobject *kobj, 554 564 struct kobj_attribute *attr, char *buf) 555 565 { ··· 626 596 static struct kobj_attribute supp_part_sysfs_mode = 627 597 __ATTR_RO(supported_xcp_configs); 628 598 599 + static struct kobj_attribute supp_nps_sysfs_mode = 600 + __ATTR_RO(supported_nps_configs); 601 + 629 602 static const struct attribute *xcp_attrs[] = { 630 603 &supp_part_sysfs_mode.attr, 631 604 &xcp_cfg_sysfs_mode.attr, ··· 658 625 if (r) 659 626 goto err1; 660 627 628 + if (adev->gmc.supported_nps_modes != 0) { 629 + r = sysfs_create_file(&xcp_cfg->kobj, &supp_nps_sysfs_mode.attr); 630 + if (r) { 631 + sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs); 632 + goto err1; 633 + } 634 + } 635 + 661 636 mode = (xcp_cfg->xcp_mgr->mode == 662 637 AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE) ? 663 638 AMDGPU_SPX_PARTITION_MODE : 664 639 xcp_cfg->xcp_mgr->mode; 665 640 r = amdgpu_xcp_get_res_info(xcp_cfg->xcp_mgr, mode, xcp_cfg); 666 - if (r) 641 + if (r) { 642 + sysfs_remove_file(&xcp_cfg->kobj, &supp_nps_sysfs_mode.attr); 643 + sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs); 667 644 goto err1; 645 + } 668 646 669 647 xcp_cfg->mode = mode; 670 648 for (i = 0; i < xcp_cfg->num_res; i++) { ··· 697 653 kobject_put(&xcp_res->kobj); 698 654 } 699 655 656 + sysfs_remove_file(&xcp_cfg->kobj, &supp_nps_sysfs_mode.attr); 700 657 sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs); 701 658 err1: 702 659 kobject_put(&xcp_cfg->kobj); ··· 718 673 kobject_put(&xcp_res->kobj); 719 674 } 720 675 676 + sysfs_remove_file(&xcp_cfg->kobj, &supp_nps_sysfs_mode.attr); 721 677 sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs); 722 678 kobject_put(&xcp_cfg->kobj); 723 679 }