Skip to content

Commit

Permalink
Merge tag 'drm-xe-fixes-2024-02-01' of https://gitlab.freedesktop.org…
Browse files Browse the repository at this point in the history
…/drm/xe/kernel into drm-fixes

UAPI Changes:
- Only allow a single user-fence per exec / bind.
  The reason for this clarification fix is a limitation in the implementation
  which can be lifted moving forward, if needed.

Driver Changes:
- A crash fix
- A fix for an assert due to missing mem_acces ref
- Only allow a single user-fence per exec / bind.
- Some sparse warning fixes
- Two fixes for compilation failures on various odd
  combinations of gcc / arch pointed out on LKML.
- Fix a fragile partial allocation pointed out on LKML.

Cross-driver Change:
- A sysfs ABI documentation warning fix
  This also touches i915 and is acked by i915 maintainers.

Signed-off-by: Dave Airlie <[email protected]>

From: Thomas Hellstrom <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/ZbuCYdMDVK-kAWC5@fedora
  • Loading branch information
airlied committed Feb 2, 2024
2 parents 419d8a9 + 5f16ee2 commit 111a3f0
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 167 deletions.
14 changes: 7 additions & 7 deletions Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
What: /sys/devices/.../hwmon/hwmon<i>/in0_input
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/in0_input
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Description: RO. Current Voltage in millivolt.

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_max
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/power1_max
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Expand All @@ -20,15 +20,15 @@ Description: RW. Card reactive sustained (PL1/Tau) power limit in microwatts.

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_rated_max
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/power1_rated_max
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Description: RO. Card default power limit (default TDP setting).

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_max_interval
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/power1_max_interval
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Expand All @@ -37,7 +37,7 @@ Description: RW. Sustained power limit interval (Tau in PL1/Tau) in

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_crit
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/power1_crit
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Expand All @@ -50,7 +50,7 @@ Description: RW. Card reactive critical (I1) power limit in microwatts.

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/curr1_crit
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/curr1_crit
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Expand All @@ -63,7 +63,7 @@ Description: RW. Card reactive critical (I1) power limit in milliamperes.

Only supported for particular Intel i915 graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/energy1_input
What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/energy1_input
Date: February 2023
KernelVersion: 6.2
Contact: [email protected]
Expand Down
14 changes: 7 additions & 7 deletions Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
What: /sys/devices/.../hwmon/hwmon<i>/power1_max
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/power1_max
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Expand All @@ -12,15 +12,15 @@ Description: RW. Card reactive sustained (PL1) power limit in microwatts.

Only supported for particular Intel xe graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_rated_max
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/power1_rated_max
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Description: RO. Card default power limit (default TDP setting).

Only supported for particular Intel xe graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_crit
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/power1_crit
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Expand All @@ -33,7 +33,7 @@ Description: RW. Card reactive critical (I1) power limit in microwatts.

Only supported for particular Intel xe graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/curr1_crit
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/curr1_crit
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Expand All @@ -44,23 +44,23 @@ Description: RW. Card reactive critical (I1) power limit in milliamperes.
the operating frequency if the power averaged over a window
exceeds this limit.

What: /sys/devices/.../hwmon/hwmon<i>/in0_input
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/in0_input
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Description: RO. Current Voltage in millivolt.

Only supported for particular Intel xe graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/energy1_input
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/energy1_input
Date: September 2023
KernelVersion: 6.5
Contact: [email protected]
Description: RO. Energy input of device in microjoules.

Only supported for particular Intel xe graphics platforms.

What: /sys/devices/.../hwmon/hwmon<i>/power1_max_interval
What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/power1_max_interval
Date: October 2023
KernelVersion: 6.6
Contact: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/xe/abi/guc_actions_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

#define HOST2GUC_SELF_CFG_REQUEST_MSG_LEN (GUC_HXG_REQUEST_MSG_MIN_LEN + 3u)
#define HOST2GUC_SELF_CFG_REQUEST_MSG_0_MBZ GUC_HXG_REQUEST_MSG_0_DATA0
#define HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_KEY (0xffff << 16)
#define HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_LEN (0xffff << 0)
#define HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_KEY (0xffffu << 16)
#define HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_LEN (0xffffu << 0)
#define HOST2GUC_SELF_CFG_REQUEST_MSG_2_VALUE32 GUC_HXG_REQUEST_MSG_n_DATAn
#define HOST2GUC_SELF_CFG_REQUEST_MSG_3_VALUE64 GUC_HXG_REQUEST_MSG_n_DATAn

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/xe/abi/guc_actions_slpc_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ struct slpc_shared_data {
(HOST2GUC_PC_SLPC_REQUEST_REQUEST_MSG_MIN_LEN + \
HOST2GUC_PC_SLPC_EVENT_MAX_INPUT_ARGS)
#define HOST2GUC_PC_SLPC_REQUEST_MSG_0_MBZ GUC_HXG_REQUEST_MSG_0_DATA0
#define HOST2GUC_PC_SLPC_REQUEST_MSG_1_EVENT_ID (0xff << 8)
#define HOST2GUC_PC_SLPC_REQUEST_MSG_1_EVENT_ARGC (0xff << 0)
#define HOST2GUC_PC_SLPC_REQUEST_MSG_1_EVENT_ID (0xffu << 8)
#define HOST2GUC_PC_SLPC_REQUEST_MSG_1_EVENT_ARGC (0xffu << 0)
#define HOST2GUC_PC_SLPC_REQUEST_MSG_N_EVENT_DATA_N GUC_HXG_REQUEST_MSG_n_DATAn

#endif
8 changes: 4 additions & 4 deletions drivers/gpu/drm/xe/abi/guc_communication_ctb_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ static_assert(sizeof(struct guc_ct_buffer_desc) == 64);
#define GUC_CTB_HDR_LEN 1u
#define GUC_CTB_MSG_MIN_LEN GUC_CTB_HDR_LEN
#define GUC_CTB_MSG_MAX_LEN 256u
#define GUC_CTB_MSG_0_FENCE (0xffff << 16)
#define GUC_CTB_MSG_0_FORMAT (0xf << 12)
#define GUC_CTB_MSG_0_FENCE (0xffffu << 16)
#define GUC_CTB_MSG_0_FORMAT (0xfu << 12)
#define GUC_CTB_FORMAT_HXG 0u
#define GUC_CTB_MSG_0_RESERVED (0xf << 8)
#define GUC_CTB_MSG_0_NUM_DWORDS (0xff << 0)
#define GUC_CTB_MSG_0_RESERVED (0xfu << 8)
#define GUC_CTB_MSG_0_NUM_DWORDS (0xffu << 0)

/**
* DOC: CTB HXG Message
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/xe/abi/guc_klvs_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*/

#define GUC_KLV_LEN_MIN 1u
#define GUC_KLV_0_KEY (0xffff << 16)
#define GUC_KLV_0_LEN (0xffff << 0)
#define GUC_KLV_n_VALUE (0xffffffff << 0)
#define GUC_KLV_0_KEY (0xffffu << 16)
#define GUC_KLV_0_LEN (0xffffu << 0)
#define GUC_KLV_n_VALUE (0xffffffffu << 0)

/**
* DOC: GuC Self Config KLVs
Expand Down
20 changes: 10 additions & 10 deletions drivers/gpu/drm/xe/abi/guc_messages_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@
*/

#define GUC_HXG_MSG_MIN_LEN 1u
#define GUC_HXG_MSG_0_ORIGIN (0x1 << 31)
#define GUC_HXG_MSG_0_ORIGIN (0x1u << 31)
#define GUC_HXG_ORIGIN_HOST 0u
#define GUC_HXG_ORIGIN_GUC 1u
#define GUC_HXG_MSG_0_TYPE (0x7 << 28)
#define GUC_HXG_MSG_0_TYPE (0x7u << 28)
#define GUC_HXG_TYPE_REQUEST 0u
#define GUC_HXG_TYPE_EVENT 1u
#define GUC_HXG_TYPE_NO_RESPONSE_BUSY 3u
#define GUC_HXG_TYPE_NO_RESPONSE_RETRY 5u
#define GUC_HXG_TYPE_RESPONSE_FAILURE 6u
#define GUC_HXG_TYPE_RESPONSE_SUCCESS 7u
#define GUC_HXG_MSG_0_AUX (0xfffffff << 0)
#define GUC_HXG_MSG_n_PAYLOAD (0xffffffff << 0)
#define GUC_HXG_MSG_0_AUX (0xfffffffu << 0)
#define GUC_HXG_MSG_n_PAYLOAD (0xffffffffu << 0)

/**
* DOC: HXG Request
Expand Down Expand Up @@ -85,8 +85,8 @@
*/

#define GUC_HXG_REQUEST_MSG_MIN_LEN GUC_HXG_MSG_MIN_LEN
#define GUC_HXG_REQUEST_MSG_0_DATA0 (0xfff << 16)
#define GUC_HXG_REQUEST_MSG_0_ACTION (0xffff << 0)
#define GUC_HXG_REQUEST_MSG_0_DATA0 (0xfffu << 16)
#define GUC_HXG_REQUEST_MSG_0_ACTION (0xffffu << 0)
#define GUC_HXG_REQUEST_MSG_n_DATAn GUC_HXG_MSG_n_PAYLOAD

/**
Expand Down Expand Up @@ -117,8 +117,8 @@
*/

#define GUC_HXG_EVENT_MSG_MIN_LEN GUC_HXG_MSG_MIN_LEN
#define GUC_HXG_EVENT_MSG_0_DATA0 (0xfff << 16)
#define GUC_HXG_EVENT_MSG_0_ACTION (0xffff << 0)
#define GUC_HXG_EVENT_MSG_0_DATA0 (0xfffu << 16)
#define GUC_HXG_EVENT_MSG_0_ACTION (0xffffu << 0)
#define GUC_HXG_EVENT_MSG_n_DATAn GUC_HXG_MSG_n_PAYLOAD

/**
Expand Down Expand Up @@ -188,8 +188,8 @@
*/

#define GUC_HXG_FAILURE_MSG_LEN GUC_HXG_MSG_MIN_LEN
#define GUC_HXG_FAILURE_MSG_0_HINT (0xfff << 16)
#define GUC_HXG_FAILURE_MSG_0_ERROR (0xffff << 0)
#define GUC_HXG_FAILURE_MSG_0_HINT (0xfffu << 16)
#define GUC_HXG_FAILURE_MSG_0_ERROR (0xffffu << 0)

/**
* DOC: HXG Response
Expand Down
10 changes: 9 additions & 1 deletion drivers/gpu/drm/xe/xe_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
u64 addresses[XE_HW_ENGINE_MAX_INSTANCE];
struct drm_gpuvm_exec vm_exec = {.extra.fn = xe_exec_fn};
struct drm_exec *exec = &vm_exec.exec;
u32 i, num_syncs = 0;
u32 i, num_syncs = 0, num_ufence = 0;
struct xe_sched_job *job;
struct dma_fence *rebind_fence;
struct xe_vm *vm;
Expand Down Expand Up @@ -157,6 +157,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
SYNC_PARSE_FLAG_LR_MODE : 0));
if (err)
goto err_syncs;

if (xe_sync_is_ufence(&syncs[i]))
num_ufence++;
}

if (XE_IOCTL_DBG(xe, num_ufence > 1)) {
err = -EINVAL;
goto err_syncs;
}

if (xe_exec_queue_is_parallel(q)) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/xe/xe_gt_mcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ static bool xe_gt_mcr_get_nonterminated_steering(struct xe_gt *gt,
* to synchronize with external clients (e.g., firmware), so a semaphore
* register will also need to be taken.
*/
static void mcr_lock(struct xe_gt *gt)
static void mcr_lock(struct xe_gt *gt) __acquires(&gt->mcr_lock)
{
struct xe_device *xe = gt_to_xe(gt);
int ret = 0;
Expand All @@ -500,7 +500,7 @@ static void mcr_lock(struct xe_gt *gt)
drm_WARN_ON_ONCE(&xe->drm, ret == -ETIMEDOUT);
}

static void mcr_unlock(struct xe_gt *gt)
static void mcr_unlock(struct xe_gt *gt) __releases(&gt->mcr_lock)
{
/* Release hardware semaphore - this is done by writing 1 to the register */
if (GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270)
Expand Down
11 changes: 7 additions & 4 deletions drivers/gpu/drm/xe/xe_gt_pagefault.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
goto unlock_vm;
}

if (!xe_vma_is_userptr(vma) || !xe_vma_userptr_check_repin(vma)) {
if (!xe_vma_is_userptr(vma) ||
!xe_vma_userptr_check_repin(to_userptr_vma(vma))) {
downgrade_write(&vm->lock);
write_locked = false;
}
Expand All @@ -181,11 +182,13 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
/* TODO: Validate fault */

if (xe_vma_is_userptr(vma) && write_locked) {
struct xe_userptr_vma *uvma = to_userptr_vma(vma);

spin_lock(&vm->userptr.invalidated_lock);
list_del_init(&vma->userptr.invalidate_link);
list_del_init(&uvma->userptr.invalidate_link);
spin_unlock(&vm->userptr.invalidated_lock);

ret = xe_vma_userptr_pin_pages(vma);
ret = xe_vma_userptr_pin_pages(uvma);
if (ret)
goto unlock_vm;

Expand Down Expand Up @@ -220,7 +223,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
dma_fence_put(fence);

if (xe_vma_is_userptr(vma))
ret = xe_vma_userptr_check_repin(vma);
ret = xe_vma_userptr_check_repin(to_userptr_vma(vma));
vma->usm.tile_invalidated &= ~BIT(tile->id);

unlock_dma_resv:
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/xe/xe_guc_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,9 @@ void xe_guc_pc_fini(struct xe_guc_pc *pc)
struct xe_device *xe = pc_to_xe(pc);

if (xe->info.skip_guc_pc) {
xe_device_mem_access_get(xe);
xe_gt_idle_disable_c6(pc_to_gt(pc));
xe_device_mem_access_put(xe);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/xe/xe_hw_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ struct xe_hw_fence *xe_hw_fence_create(struct xe_hw_fence_ctx *ctx,
if (!fence)
return ERR_PTR(-ENOMEM);

dma_fence_init(&fence->dma, &xe_hw_fence_ops, &ctx->irq->lock,
ctx->dma_fence_ctx, ctx->next_seqno++);

fence->ctx = ctx;
fence->seqno_map = seqno_map;
INIT_LIST_HEAD(&fence->irq_link);

dma_fence_init(&fence->dma, &xe_hw_fence_ops, &ctx->irq->lock,
ctx->dma_fence_ctx, ctx->next_seqno++);

trace_xe_hw_fence_create(fence);

return fence;
Expand Down
14 changes: 7 additions & 7 deletions drivers/gpu/drm/xe/xe_lrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "xe_map.h"
#include "xe_vm.h"

#define CTX_VALID (1 << 0)
#define CTX_PRIVILEGE (1 << 8)
#define CTX_ADDRESSING_MODE_SHIFT 3
#define LEGACY_64B_CONTEXT 3
#define LRC_VALID (1 << 0)
#define LRC_PRIVILEGE (1 << 8)
#define LRC_ADDRESSING_MODE_SHIFT 3
#define LRC_LEGACY_64B_CONTEXT 3

#define ENGINE_CLASS_SHIFT 61
#define ENGINE_INSTANCE_SHIFT 48
Expand Down Expand Up @@ -762,15 +762,15 @@ int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
(q->usm.acc_notify << ACC_NOTIFY_S) |
q->usm.acc_trigger);

lrc->desc = CTX_VALID;
lrc->desc |= LEGACY_64B_CONTEXT << CTX_ADDRESSING_MODE_SHIFT;
lrc->desc = LRC_VALID;
lrc->desc |= LRC_LEGACY_64B_CONTEXT << LRC_ADDRESSING_MODE_SHIFT;
/* TODO: Priority */

/* While this appears to have something about privileged batches or
* some such, it really just means PPGTT mode.
*/
if (vm)
lrc->desc |= CTX_PRIVILEGE;
lrc->desc |= LRC_PRIVILEGE;

if (GRAPHICS_VERx100(xe) < 1250) {
lrc->desc |= (u64)hwe->instance << ENGINE_INSTANCE_SHIFT;
Expand Down
Loading

0 comments on commit 111a3f0

Please sign in to comment.