Граф коммитов

539 Коммитов

Автор SHA1 Сообщение Дата
Felix Kuehling 9ac2c75171 libhsakmt: Map VRAM only on supported peer GPUs
hsaKmtMapMemoryToGPU should not try to map VRAM on peer GPUs that don't
have an IO-Link to the memory. The new P2P mapping code in KFD will
fail otherwise.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: I6d59b55651b98756865a0f69eafef3e386372cf3
2022-07-19 21:21:59 -04:00
Felix Kuehling 87aca673e8 libhsakmt: Init apertures in AcquireSystemProperties
This allows init_process_apertures to use the whole consistent topoology
instead of taking its own partial snapshot.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: Ia13e7aa7fcd090ea8d6cacd4babb29a27c20207f
2022-07-19 21:21:59 -04:00
Jonathan Kim a31206e98b libhsakmt: fix runtime disable check
Kernel debug IOCTL got version bumped to v11.
Updated runtime enable but missed runtime disable check update.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Change-Id: I71a8970ccfe7dc517abe7b4ad962369aea6a0496
2022-07-12 20:59:08 -04:00
Eric Huang 37be876cad libhsakmt: allocate unified memory for ctx save restore area
To improve performance on queue preemption, allocate ctx s/r
 area in VRAM instead of system memory, and migrate it back
 to system memory when VRAM is full.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Change-Id: If775782027188dbe84b6868260e429373675434c
2022-07-11 18:06:55 -04:00
Jonathan Kim 79cd63fab6 libhsakmt: permit runtime enable version for new hw mode set restrictions
The KFD no longer allow debug ops that modify HW state prior to
trap activation so permit bump in major version.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Change-Id: I072d3998b7b043df9a67f0f6762b0afdfa9382c6
2022-06-24 10:21:57 -04:00
Graham Sider e17b159230 libhsakmt: Make queue memory allocation non-paged
Non-paged allocation for queue memory necessary for binding wptr to
GART. Required to support usermode queue oversubscription with MES on
GFX11.

Change ensures queue memory does not specify ATS.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: I10b23b0205c90dad902c711a88cfb5e9b4979617
2022-06-22 18:37:26 -04:00
Philip Yang 405fbd6f93 libhsakmt: add open SMI event handle
System Management Interface event is read from anonymous file handle,
this helper wrap the ioctl interface to get anonymous file handle for
GPU nodeid.

Define SMI event IDs, event triggers, copy the same value from
kfd_ioctl.h to avoid translation.

Change-Id: I5c8ba5301473bb3b80bb4e2aa33a9f675bedb001
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2022-06-20 08:49:13 -04:00
Philip Yang 88778e13dc libhsakmt: hsaKmtGetNodeProperties add gpu_id
Add KFDGpuID to HsaNodeProperties to return gpu_id to upper layer,
gpu_id is hash ID generated by KFD to distinguish GPUs on the system.
ROCr and ROCProfiler will use gpu_id to analyze SMI event message.

Change-Id: I6eabe6849230e04120674f5bc55e6ea254a532d6
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2022-06-20 08:48:44 -04:00
Alex Sierra 0e908f05bb libhsakmt: add env var to set max VA alignment order
This env variable sets the max VA alignment order size as
"PAGE_SIZE * 2^alignment order" during mapping. By default the order
size is set to 9(2MB).

Signed-off-by: Alex Sierra <alex.sierra@amd.com>
Change-Id: I01ae4e0963f4d21c7c367464e60f865bc58d7fac
2022-06-13 15:46:54 -04:00
Daniel Phillips 6da6058d4a libhsakmt: Add support for hsaKmtAvailableMemory
New API function to report available memory per GPU

Signed-off-by: Daniel Phillips <Daniel.Phillips@amd.com>
Change-Id: I63c1e4ca0020c657977ab3635947ab0ed0a81440
2022-06-13 09:37:32 -04:00
Timothy Pearson 5fd3c868b2 Initial support for POWER platforms
Tested on Talos II with Vega 64

POWER systems allocate NUMA nodes on multiples of 8 to allow CPU
onlining / offlining
Set the correct NUMA mask bits when requesting node-bound memory
allocations

This is a cleanup/squash/rebase of:
https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/pull/47

Change-Id: Id4af6dff7e66e9d464d6b17a1e99087eb3ac8e51
Signed-off-by: Jeremy Newton <Jeremy.Newton@amd.com>
2022-04-19 12:19:15 -04:00
Felix Kuehling f88aaa933b libhsakmt: Update kfd_ioctl.h
Import the latest version from the kernel tree.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: If5f998ad55085ebd5020adaa382181204d834e3e
2022-03-21 14:41:18 -04:00
Mukul Joshi b8dc875b3c libhsakmt: Update context save area size calculations
Currently, context save area size passed to KFD includes the
size of the debug area. Change this to report the actual size
of the context save area to KFD.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Change-Id: I5d440ae802255a97ade046775f6a000bae79d5d5
2022-03-02 15:28:38 -05:00
Lang Yu 052b7957ea libhsakmt: Add another pci device id for cyan skillfish
Add PCI DID for cyan skillfish.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
Change-Id: I1d06936cccdf99af76fe5ca3ff323538fac76c9c
2022-01-27 01:41:00 -05:00
Aaron Liu 7cdf38f6c0 libhsakmt: correct the gfx version for gfx90c
The gfx version of gfx90c is 90C instead of 902.

Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Change-Id: Id009c9357f816b8ccab605090df47626f1a579ef
2022-01-26 01:25:58 -05:00
David Yat Sin 4986f4a5c2 libhsakmt:Add MADV_DONTFORK to device mappings
Mapped memory areas become invalid after fork, and the child process is
required to remap the memory areas after a fork. So we mark these device
memory mappings with MADV_DONTFORK so that they are removed from the
child process after fork.

This was causing some issues when doing CRIU checkpoint/restore because
CRIU and amdgpu_plugin were not able to handle these mappings.

Change-Id: I50eb334aecea6dab7522d94da0273adcf4fb1ce0
Signed-off-by: David Yat Sin <david.yatsin@amd.com>
2022-01-10 16:25:16 -05:00
Joseph Greathouse a06d1a3884 Correct gfx90c gfx arch number in HSA topology
The AMD compiler team has confirmed that they expect gfx90c
to be gfx90c, with a major/minor/stepping of 9, 0, and 12
respectively. It appears that there is a typo in the libhsakmt
topology information that lists this part as gfx902. This patch
fixes the issue.

Signed-off-by: Joseph Greathouse <Joseph.Greathouse@amd.com>
Change-Id: I6f907a7aa6f190b12aba8bb4210c7b341b3c720b
2021-12-03 13:11:26 -05:00
Sean Keely 5e3983cb93 Check errno for error type in hsaKmtAllocQueueGWS.
Check errno rather than err and drop negation.

Change-Id: I1804d67292c3b054eab8fc077c8e9b22a8cdcc9f
2021-10-06 15:08:28 -04:00
Sean Keely b67bc6fcc9 Check errno rather than return from kmtIoctl in hsaKmtRuntimeEnable.
The return code is just -1 if any error occurs.  To detect debugger
unavailable we need to check the actual ioctl error code.

Change-Id: I8a294c754196aec916809497ec8e810da2f072b8
Signed-off-by: Sean Keely <Sean.Keely@amd.com>
2021-10-06 15:07:22 -04:00
Philip Yang f82927ad65 libhsakmt: register and deregister userptr in parallel
For userptr, after taking aperture lock, decrease registration_count and
ensure object registration_count equal to 0 to release KFD and thunk
object.

Move decrementing of registration count from fmm_deregister_memory into
__fmm_release to avoid a race condition when dropping the aperture lock
in fmm_deregister_memory.

Change-Id: I5381fa6b8a77a1516af2554e5174e91969c338c4
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-10-01 15:56:38 -04:00
Yifan Zhang db1d6d92ab libhsakmt: dump errno the queue destroy fails.
to faciliate debugging, print errno when queue destroy fail
current log give very little information when fail:

[ RUN      ] KFDQMTest.AllSdmaQueues
 [          ] Regular SDMA engines number: 1 SDMA queues per engine: 2
 [       OK ] KFDQMTest.AllSdmaQueues (11 ms)
 [ RUN      ] KFDQMTest.AllXgmiSdmaQueues
 [          ] XGMI SDMA engines number: 0 SDMA queues per engine: 2
 [       OK ] KFDQMTest.AllXgmiSdmaQueues (6 ms)
 [ RUN      ] KFDQMTest.AllQueues
 /home/foreman/build/hsakmt-roct-amdgpu-1.0.9.40500/sources/libhsakmt/tests/kfdtest/src/KFDQMTest.cpp:381: Failure
 Value of: (cpQueues[i].Destroy())
   Actual: 1
 Expected: HSAKMT_STATUS_SUCCESS
 Which is: 0

Signed-off-by: Yifan Zhang <yifan1.zhang@amd.com>
Change-Id: I5b1b5b616a5fd7ff198360c893a7aeed685022bd
2021-09-15 04:34:58 -04:00
Philip Yang 8f7443494a libhsakmt: fix multiple threads register userptr race v2
After calling ioctl to create userptr obj, take aperture lock, check if
there is same userptr obj created after finding object, to catch the
race that multiple threads register same userptr to multiple GPUs.

If same userptr obj exist, then increase userptr registeration_count,
and free the newly create obj.

Change-Id: I63ae3a4f54da8aedd11c124d8d53ebe727b8203a
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-09-14 12:36:36 -04:00
Philip Yang a809a5bf32 Revert "libhsakmt: fix multiple threads register userptr race"
This reverts commit c4d5ee28f0.

Change-Id: I954326d9a291280de7c9b7ef49a8cce0cd9dd9ad
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-09-14 12:36:36 -04:00
Philip Yang 91b0fce535 Revert "libhsakmt: Fix deadlock in map_mmio"
This reverts commit 19536080a8.

Change-Id: Ibd32ac36bcb9ee418957d25b240ef9dd9172fbd3
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-09-14 12:36:36 -04:00
Philip Yang 445fcd803b Revert "libhsakmt: Fix deadlocks in __fmm_release"
This reverts commit 5fac7dcc3b.

Change-Id: Idf636655ac01f569d8e92e9c0e100e5db7d1cb61
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-09-14 12:36:36 -04:00
Kent Russell 268bb1ae84 Revert "Revert "Get Marketing name from libdrm-amdgpu""
This reverts commit 89c9d6a3b9.

Reason for revert: aqlprofile has merged

Change-Id: Iee0fbe8ac1e475123273b328949f68f10490d3ca
2021-09-01 07:44:23 -04:00
changzhu 978028d3f6 libhsakmt: fix KFDOpenCloseKFDTest.OpenAlreadyOpenedKFD Segmentation fault on gfx902
g_props is intialized in topology_take_snapshot which needs to call
hsaKmtAcquireSystemProperties. In hsaKmtOpenKFD, it doesn't call hsaKmtAcquireSystemProperties.
So it needs to change parameter of topology_is_svm_needed from node_id
to EngineId to avoid Segmentation fault on gfx902.

Signed-off-by: changzhu <Changfeng.Zhu@amd.com>
Change-Id: Iba8d20a9142510c70927454d26bdcaf579ad5574
2021-08-31 22:57:24 -04:00
Kent Russell 89c9d6a3b9 Revert "Get Marketing name from libdrm-amdgpu"
This reverts commit cb1c84d99b.

Reason for revert: aqlprofiler hasn't promoted yet

Change-Id: I9e6a4169f014a6181f43ee8ef4810be2667d98bd
2021-08-31 09:11:51 -04:00
Chengming Gui bcd49af8bb libhsakmt: Add new DIDs for gfx1030/gfx1031/gfx1032
Signed-off-by: Chengming Gui <Jack.Gui@amd.com>
Change-Id: Iddb27ce2bedda9a57944eca1e2bb93001e61f733
2021-08-30 23:17:45 -04:00
Jinzhou Su 294086096a libhsakmt: Add another gfx90c DID
Add pci device ID.

Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Change-Id: Idcf8e99583fc9991a0d71d1e0d7e741a132ed730
2021-08-30 22:49:02 -04:00
Mike Li cb1c84d99b Get Marketing name from libdrm-amdgpu
Use the database provided by libdrm-amdgpu,as this is maintained by AMD

Signed-off-by: Mike Li <Tianxinmike.Li@amd.com>
Change-Id: I319a46d833cb23173a77fdff1deae69ea58588b8
2021-08-26 16:43:31 -04:00
Tony Tye d0ae4b1f3f Update HSA_RUNTIME_ENABLE_MIN_MAJOR to 10
The major version of the debug ioctl functions has been updated to 10.

Change-Id: Iddc8656ad07c92aa30c6a7a99add28ab3a3f5a80
2021-08-21 21:47:09 +00:00
Graham Sider 9745c58d40 libhsakmt: Hotfix for incorrect hex gfx versions
Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Ic67b7a3e1649288c8fdef85fef875327ffc50948
2021-08-11 16:59:44 -04:00
Chengming Gui cff8e4992c libhsakmt: Add DIDs for Beige_Goby
Signed-off-by: Chengming Gui <Jack.Gui@amd.com>
Change-Id: Iff82aa0ab70df49ffc6d8004e40b5cccd637da44
2021-08-09 11:32:11 +08:00
Graham Sider bb8deeae11 libhsakmt: Retrieve gfx version from sysfs
If lookup is successful, device info from find_hsa_gfxip_device() is
used to populate props->EngineId.ui32 gfx version fields and node CAL
name (props->AMDName).

If unsuccessful, uses gfx_target_version sysfs field if present
(otherwise results in error), and sets the node CAL name to
"GFX<GFX_VERSION>" (e.g. 9.0.8 -> GFX090008).

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Id39c521b769aebbe40c934f19e03150a66884cce
2021-08-05 15:19:57 -04:00
Graham Sider 29369753f5 libhsakmt: Remove redundant checks, small bug fixes
Some g_system and Node ID checks already performed by validate_nodeid().
Fixes bug where hsaKmtGetNodeProperties() would return on
validate_nodeid() error without releasing lock. Switches some
conditionals to return INVALID_NODE_UNIT instead of INVALID_PARAMETER if
NodeId >= NumNodes. Removes some g_system assertions to return error
code rather than trigger a hard fault.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Id1604b20c2cef8808b98cdad61bd47aa7ea3d229
2021-08-05 15:00:58 -04:00
Graham Sider 1ad1a2a817 libhsakmt: Remove asic_family vars/helpers
Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: I1bd054d8f9ffc56e2c48a5df4899966918f26e1b
2021-08-05 15:00:58 -04:00
Graham Sider 8f883d0830 libhsakmt: Replace asic_family with gfx version
All conditional logic previously dependent on asic_family now dependent
on gfx version. As such, HSA_FORCE_ASIC_TYPE is now deprecated and
HSA_OVERRIDE_GFX_VERSION should be used instead.

device_info structs containing asic_family, eop_buffer_size, and
doorbell_size removed (alongside dev_lookup_table[]). eop_buffer_size
and doorbell_size now determined via macro, with eop_buffer_size and
full gfx version field being added to queue struct.

Certain funcs previously dependent on DID or GPU ID now dependent on
Node ID (due to use of get_gfxv_by_node_id()).

Fixes sleeper bug where ctl_stack_size and debug_memory_size were being
incorrectly programmed on gfx90a.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Iaabdc5c73920ad83b4b379cd6086992357b8ff10
2021-08-05 15:00:26 -04:00
Graham Sider 0b46d418c3 libhsakmt: Use gfx version conditions in pmc_table.c
get_block_properties() switch statement now based on major GFX version
instead of asic_family. Addition for NPI bringup only needed on major
GFX revisions unless differing perf_counter_block assignment necessary.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Ia02676d2a3a8f968b67feeafbab534ef4c01c0dd
2021-08-05 14:54:58 -04:00
Graham Sider bc4aca039c libhsakmt: Use node_id in topology_is_svm_needed()
Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: I7773ccb959e60e43b816477c5659f1fe835ecbbd
2021-08-05 14:52:09 -04:00
Graham Sider 2f261a8dab libhsakmt: Deprecate is_gfx700()
Condition generalized by
(get_gfxv_by_node_id(NodeId) == GFX_VERSION_KAVERI)

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: Iff4f77043e3ce8e48a9e84fbf257ebf59abf5bbb
2021-08-05 14:50:07 -04:00
Graham Sider 8880610265 libhsakmt: Add gfx version defines, helpers
Add defines for converting between full gfx version (in decimal) to
major/minor/stepping values, and major/minor/stepping values to full gfx
version (in hex). The first is to be used when grabbing the gfx version
from sysfs, the second when returning the gfx version in
get_gfxv_by_node_id() for comparisions in Thunk.

Add enum for defines of full gfx versions for various cards. These are
to be used in conditionals to replace CHIP_*/asic_family comparisons. On
NPI bringup, addition to this enum will not be required for
functionality unless explicitly needed for a conditional. Most ASICs in
this enum simply for completeness.

Add get_gfxv_by_node_id(): returns full gfx version in hex.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: I9d1dba7fdd4a587a000eea2f4141a1d301bf4776
2021-08-05 14:48:07 -04:00
Aaron Liu fc216a3668 libhsakmt: expand control stack size limit for all gfx103x
Expand check control stack size for Beige Goby, Van Gogh and Yellow Carp.

Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Change-Id: I6c8345bbb751eb9179fc740fe1674504b4295a5f
2021-07-30 10:24:25 -04:00
Aaron Liu 80e4cb6261 libhsakmt: reorder the list of GPUs in enum asic_family_type
Put CHIP_gfx90a next to CHIP_gfx908 to keep all the GFXv9
chips together.

Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Change-Id: I32b4b7f7746ae4bdaff7e178f13307c1bcfa93e1
2021-07-30 10:23:56 -04:00
chen gong 860931557c libhsakmt: add cyan skillfish support
Signed-off-by: chen gong <curry.gong@amd.com>
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Change-Id: Ie26c2e156c9c4e68a6b36fe699adccf3f808b5e7
2021-07-29 16:44:16 -04:00
Philip Yang fa7b4a6268 libhsakmt: Qyery pointer info flags for registered memory
hsaKmtQueryPointerInfo return vm_obj flags for all below registered
memory types other than hsaKmtAllocMemory, and set the CoarseGrain flag
correctly for:

Graphics: always coarse grain.

Shared: hsaKmtShareMemory pass mflags with export handle to KFD to store
in KFD objs, hsaKmtRegisterSharedHandle get mflags from KFD with import
handle.

Userptr: it is already coarse-grain by default, or based on mflags
provided in hsaKmtRegisterMemoryWithFlags call.



Change-Id: Idc23e8b0cf599b02580737639da2f9ef4ccd0c0d
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-07-22 21:14:46 -04:00
Philip Yang 2c796e62be libhsakmt: Query pointer info returns HsaMemFlags
Query pointer info returns KFD_IOC_ALLOC_MEM_FLAGS_* flags, it should
return HsaMemFlags, fix it by renaming vm_obj->flags to mflags and
always saving HsaMemFlags.

Use consistent function parameter and variable name to avoid confusion:
mflags for HsaMemFlags and ioc_flags for KFD_IOC_ALLOC_MEM_FLAGS_*
flags.

AMDKFD_IOC_GET_DMABUF_INFO return ioc_flags, translate it to mflags
using new helper fmm_translate_ioc_to_hsa_flags.



Change-Id: If9e117c507139c0166abb1ab0df8c233ef7e48a1
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
2021-07-22 21:14:46 -04:00
Aaron Liu 3d12437f1b libhsakmt: add yellow carp DID
Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Change-Id: If798dc733bc8d65c67922fb5d2e32aa1dada8381
2021-07-22 21:18:42 +08:00
Kent Russell ed62c7aa1c libhsakmt: Add gfx1032 DID
0x73E3 DID was missing, add it.

Signed-off-by: Kent Russell <kent.russell@amd.com>
Change-Id: Id1ae2f268e0e8b5cfec5ae2065153fe73854b93a
2021-07-22 07:37:19 -04:00
Jonathan Kim 1ce548829b libhsakmt: add runtime enable and disable calls
Add hsaKmtRuntimeEnable and disable.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Change-Id: I083f9293948e975546a1b3c1334cb41499b9ab1f
2021-07-16 18:37:41 -04:00