History

Merge tag 'amd-drm-next-5.14-2021-05-19' of https://gitlab.freedesktop.org/agd5f/linux into drm-next

amd-drm-next-5.14-2021-05-19: amdgpu: - Aldebaran updates - More LTTPR display work - Vangogh updates - SDMA 5.x GCR fixes - RAS fixes - PCIe ASPM support - Modifier fixes - Enable TMZ on Renoir - Buffer object code cleanup - Display overlay fixes - Initial support for multiple eDP panels - Initial SR-IOV support for Aldebaran - DP link training refactor - Misc code cleanups and bug fixes - SMU regression fixes for variable sized arrays - MAINTAINERS fixes for amdgpu amdkfd: - Initial SR-IOV support for Aldebaran - Topology fixes - Initial HMM SVM support - Misc code cleanups and bug fixes radeon: - Misc code cleanups and bug fixes - SMU regression fixes for variable sized arrays - Flickering fix for Oland with multiple 4K displays UAPI: - amdgpu: Drop AMDGPU_GEM_CREATE_SHADOW flag. This was always a kernel internal flag and userspace use of it has always been blocked. It's no longer needed so remove it. - amdkgd: HMM SVM support Overview: https://patchwork.freedesktop.org/series/85562/ Porposed userspace: https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/tree/fxkamd/hmm-wip Signed-off-by: Dave Airlie <airlied@redhat.com>

Dave Airlie committed 5 years ago

Commit c99c4d02 parents 2ba0478 2bb5b5f159 files · +8897 −1576Browse files

Showing the changes to include/uapi (2 of 159 files). Show all

Unified · Split

2 files
  1. include/uapi/drm/amdgpu_drm.h +0 −2
  2. include/uapi/linux/kfd_ioctl.h +169 −2
include/uapi/drm/amdgpu_drm.h+0−2
@@ -116,8 +116,6 @@ extern "C" { · 115 unmodified lines
116116 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
117117 /* Flag that the memory should be in VRAM and cleared */
118118 #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
119−/* Flag that create shadow bo(GTT) while allocating vram bo */
120−#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)
121119 /* Flag that allocating the BO should use linear VRAM */
122120 #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
123121 /* Flag that BO is always valid in this VM */
include/uapi/linux/kfd_ioctl.h+169−2
@@ -30,9 +30,10 @@ · 29 unmodified lines
3030 * - 1.1 - initial version
3131 * - 1.3 - Add SMI events support
3232 * - 1.4 - Indicate new SRAM EDC bit in device properties
33+ * - 1.5 - Add SVM API
3334 */
3435 #define KFD_IOCTL_MAJOR_VERSION 1
35−#define KFD_IOCTL_MINOR_VERSION 4
36+#define KFD_IOCTL_MINOR_VERSION 5
3637
3738 struct kfd_ioctl_get_version_args {
3839 __u32 major_version; /* from KFD */
@@ -473,6 +474,167 @@ enum kfd_mmio_remap { · 434 unmodified lines
473474 KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,
474475 };
475476
477+/* Guarantee host access to memory */
478+#define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000001
479+/* Fine grained coherency between all devices with access */
480+#define KFD_IOCTL_SVM_FLAG_COHERENT 0x00000002
481+/* Use any GPU in same hive as preferred device */
482+#define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL 0x00000004
483+/* GPUs only read, allows replication */
484+#define KFD_IOCTL_SVM_FLAG_GPU_RO 0x00000008
485+/* Allow execution on GPU */
486+#define KFD_IOCTL_SVM_FLAG_GPU_EXEC 0x00000010
487+/* GPUs mostly read, may allow similar optimizations as RO, but writes fault */
488+#define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY 0x00000020
489+
490+/**
491+ * kfd_ioctl_svm_op - SVM ioctl operations
492+ *
493+ * @KFD_IOCTL_SVM_OP_SET_ATTR: Modify one or more attributes
494+ * @KFD_IOCTL_SVM_OP_GET_ATTR: Query one or more attributes
495+ */
496+enum kfd_ioctl_svm_op {
497+ KFD_IOCTL_SVM_OP_SET_ATTR,
498+ KFD_IOCTL_SVM_OP_GET_ATTR
499+};
500+
501+/** kfd_ioctl_svm_location - Enum for preferred and prefetch locations
502+ *
503+ * GPU IDs are used to specify GPUs as preferred and prefetch locations.
504+ * Below definitions are used for system memory or for leaving the preferred
505+ * location unspecified.
506+ */
507+enum kfd_ioctl_svm_location {
508+ KFD_IOCTL_SVM_LOCATION_SYSMEM = 0,
509+ KFD_IOCTL_SVM_LOCATION_UNDEFINED = 0xffffffff
510+};
511+
512+/**
513+ * kfd_ioctl_svm_attr_type - SVM attribute types
514+ *
515+ * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC: gpuid of the preferred location, 0 for
516+ * system memory
517+ * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC: gpuid of the prefetch location, 0 for
518+ * system memory. Setting this triggers an
519+ * immediate prefetch (migration).
520+ * @KFD_IOCTL_SVM_ATTR_ACCESS:
521+ * @KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE:
522+ * @KFD_IOCTL_SVM_ATTR_NO_ACCESS: specify memory access for the gpuid given
523+ * by the attribute value
524+ * @KFD_IOCTL_SVM_ATTR_SET_FLAGS: bitmask of flags to set (see
525+ * KFD_IOCTL_SVM_FLAG_...)
526+ * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS: bitmask of flags to clear
527+ * @KFD_IOCTL_SVM_ATTR_GRANULARITY: migration granularity
528+ * (log2 num pages)
529+ */
530+enum kfd_ioctl_svm_attr_type {
531+ KFD_IOCTL_SVM_ATTR_PREFERRED_LOC,
532+ KFD_IOCTL_SVM_ATTR_PREFETCH_LOC,
533+ KFD_IOCTL_SVM_ATTR_ACCESS,
534+ KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE,
535+ KFD_IOCTL_SVM_ATTR_NO_ACCESS,
536+ KFD_IOCTL_SVM_ATTR_SET_FLAGS,
537+ KFD_IOCTL_SVM_ATTR_CLR_FLAGS,
538+ KFD_IOCTL_SVM_ATTR_GRANULARITY
539+};
540+
541+/**
542+ * kfd_ioctl_svm_attribute - Attributes as pairs of type and value
543+ *
544+ * The meaning of the @value depends on the attribute type.
545+ *
546+ * @type: attribute type (see enum @kfd_ioctl_svm_attr_type)
547+ * @value: attribute value
548+ */
549+struct kfd_ioctl_svm_attribute {
550+ __u32 type;
551+ __u32 value;
552+};
553+
554+/**
555+ * kfd_ioctl_svm_args - Arguments for SVM ioctl
556+ *
557+ * @op specifies the operation to perform (see enum
558+ * @kfd_ioctl_svm_op). @start_addr and @size are common for all
559+ * operations.
560+ *
561+ * A variable number of attributes can be given in @attrs.
562+ * @nattr specifies the number of attributes. New attributes can be
563+ * added in the future without breaking the ABI. If unknown attributes
564+ * are given, the function returns -EINVAL.
565+ *
566+ * @KFD_IOCTL_SVM_OP_SET_ATTR sets attributes for a virtual address
567+ * range. It may overlap existing virtual address ranges. If it does,
568+ * the existing ranges will be split such that the attribute changes
569+ * only apply to the specified address range.
570+ *
571+ * @KFD_IOCTL_SVM_OP_GET_ATTR returns the intersection of attributes
572+ * over all memory in the given range and returns the result as the
573+ * attribute value. If different pages have different preferred or
574+ * prefetch locations, 0xffffffff will be returned for
575+ * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC or
576+ * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC resepctively. For
577+ * @KFD_IOCTL_SVM_ATTR_SET_FLAGS, flags of all pages will be
578+ * aggregated by bitwise AND. The minimum migration granularity
579+ * throughout the range will be returned for
580+ * @KFD_IOCTL_SVM_ATTR_GRANULARITY.
581+ *
582+ * Querying of accessibility attributes works by initializing the
583+ * attribute type to @KFD_IOCTL_SVM_ATTR_ACCESS and the value to the
584+ * GPUID being queried. Multiple attributes can be given to allow
585+ * querying multiple GPUIDs. The ioctl function overwrites the
586+ * attribute type to indicate the access for the specified GPU.
587+ *
588+ * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS is invalid for
589+ * @KFD_IOCTL_SVM_OP_GET_ATTR.
590+ */
591+struct kfd_ioctl_svm_args {
592+ __u64 start_addr;
593+ __u64 size;
594+ __u32 op;
595+ __u32 nattr;
596+ /* Variable length array of attributes */
597+ struct kfd_ioctl_svm_attribute attrs[0];
598+};
599+
600+/**
601+ * kfd_ioctl_set_xnack_mode_args - Arguments for set_xnack_mode
602+ *
603+ * @xnack_enabled: [in/out] Whether to enable XNACK mode for this process
604+ *
605+ * @xnack_enabled indicates whether recoverable page faults should be
606+ * enabled for the current process. 0 means disabled, positive means
607+ * enabled, negative means leave unchanged. If enabled, virtual address
608+ * translations on GFXv9 and later AMD GPUs can return XNACK and retry
609+ * the access until a valid PTE is available. This is used to implement
610+ * device page faults.
611+ *
612+ * On output, @xnack_enabled returns the (new) current mode (0 or
613+ * positive). Therefore, a negative input value can be used to query
614+ * the current mode without changing it.
615+ *
616+ * The XNACK mode fundamentally changes the way SVM managed memory works
617+ * in the driver, with subtle effects on application performance and
618+ * functionality.
619+ *
620+ * Enabling XNACK mode requires shader programs to be compiled
621+ * differently. Furthermore, not all GPUs support changing the mode
622+ * per-process. Therefore changing the mode is only allowed while no
623+ * user mode queues exist in the process. This ensure that no shader
624+ * code is running that may be compiled for the wrong mode. And GPUs
625+ * that cannot change to the requested mode will prevent the XNACK
626+ * mode from occurring. All GPUs used by the process must be in the
627+ * same XNACK mode.
628+ *
629+ * GFXv8 or older GPUs do not support 48 bit virtual addresses or SVM.
630+ * Therefore those GPUs are not considered for the XNACK mode switch.
631+ *
632+ * Return: 0 on success, -errno on failure
633+ */
634+struct kfd_ioctl_set_xnack_mode_args {
635+ __s32 xnack_enabled;
636+};
637+
476638 #define AMDKFD_IOCTL_BASE 'K'
477639 #define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
478640 #define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
@@ -573,7 +735,12 @@ enum kfd_mmio_remap { · 94 unmodified lines
573735 #define AMDKFD_IOC_SMI_EVENTS \
574736 AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
575737
738+#define AMDKFD_IOC_SVM AMDKFD_IOWR(0x20, struct kfd_ioctl_svm_args)
739+
740+#define AMDKFD_IOC_SET_XNACK_MODE \
741+ AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)
742+
576743 #define AMDKFD_COMMAND_START 0x01
577−#define AMDKFD_COMMAND_END 0x20
744+#define AMDKFD_COMMAND_END 0x22
578745
579746 #endif