Commit 4de4a0f1 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm-xe-fixes-2024-09-05' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes

- GSC loading fix (Daniele)
- PCODE mutex fix (Matt)
- Suspend/Resume fixes (Maarten, Imre)
- RPM fixes (Rodrigo)
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ZtmyFvDfFLPbuf6A@intel.com
parents f2064ae3 4bfc9c55
...@@ -13,7 +13,7 @@ static inline int ...@@ -13,7 +13,7 @@ static inline int
snb_pcode_write_timeout(struct intel_uncore *uncore, u32 mbox, u32 val, snb_pcode_write_timeout(struct intel_uncore *uncore, u32 mbox, u32 val,
int fast_timeout_us, int slow_timeout_ms) int fast_timeout_us, int slow_timeout_ms)
{ {
return xe_pcode_write_timeout(__compat_uncore_to_gt(uncore), mbox, val, return xe_pcode_write_timeout(__compat_uncore_to_tile(uncore), mbox, val,
slow_timeout_ms ?: 1); slow_timeout_ms ?: 1);
} }
...@@ -21,13 +21,13 @@ static inline int ...@@ -21,13 +21,13 @@ static inline int
snb_pcode_write(struct intel_uncore *uncore, u32 mbox, u32 val) snb_pcode_write(struct intel_uncore *uncore, u32 mbox, u32 val)
{ {
return xe_pcode_write(__compat_uncore_to_gt(uncore), mbox, val); return xe_pcode_write(__compat_uncore_to_tile(uncore), mbox, val);
} }
static inline int static inline int
snb_pcode_read(struct intel_uncore *uncore, u32 mbox, u32 *val, u32 *val1) snb_pcode_read(struct intel_uncore *uncore, u32 mbox, u32 *val, u32 *val1)
{ {
return xe_pcode_read(__compat_uncore_to_gt(uncore), mbox, val, val1); return xe_pcode_read(__compat_uncore_to_tile(uncore), mbox, val, val1);
} }
static inline int static inline int
...@@ -35,7 +35,7 @@ skl_pcode_request(struct intel_uncore *uncore, u32 mbox, ...@@ -35,7 +35,7 @@ skl_pcode_request(struct intel_uncore *uncore, u32 mbox,
u32 request, u32 reply_mask, u32 reply, u32 request, u32 reply_mask, u32 reply,
int timeout_base_ms) int timeout_base_ms)
{ {
return xe_pcode_request(__compat_uncore_to_gt(uncore), mbox, request, reply_mask, reply, return xe_pcode_request(__compat_uncore_to_tile(uncore), mbox, request, reply_mask, reply,
timeout_base_ms); timeout_base_ms);
} }
......
...@@ -17,6 +17,13 @@ static inline struct xe_gt *__compat_uncore_to_gt(struct intel_uncore *uncore) ...@@ -17,6 +17,13 @@ static inline struct xe_gt *__compat_uncore_to_gt(struct intel_uncore *uncore)
return xe_root_mmio_gt(xe); return xe_root_mmio_gt(xe);
} }
static inline struct xe_tile *__compat_uncore_to_tile(struct intel_uncore *uncore)
{
struct xe_device *xe = container_of(uncore, struct xe_device, uncore);
return xe_device_get_root_tile(xe);
}
static inline u32 intel_uncore_read(struct intel_uncore *uncore, static inline u32 intel_uncore_read(struct intel_uncore *uncore,
i915_reg_t i915_reg) i915_reg_t i915_reg)
{ {
......
...@@ -315,8 +315,12 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime) ...@@ -315,8 +315,12 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
* properly. * properly.
*/ */
intel_power_domains_disable(xe); intel_power_domains_disable(xe);
if (has_display(xe)) intel_fbdev_set_suspend(&xe->drm, FBINFO_STATE_SUSPENDED, true);
if (has_display(xe)) {
drm_kms_helper_poll_disable(&xe->drm); drm_kms_helper_poll_disable(&xe->drm);
if (!runtime)
intel_display_driver_disable_user_access(xe);
}
if (!runtime) if (!runtime)
intel_display_driver_suspend(xe); intel_display_driver_suspend(xe);
...@@ -327,12 +331,13 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime) ...@@ -327,12 +331,13 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
intel_hpd_cancel_work(xe); intel_hpd_cancel_work(xe);
intel_encoder_suspend_all(&xe->display); if (!runtime && has_display(xe)) {
intel_display_driver_suspend_access(xe);
intel_encoder_suspend_all(&xe->display);
}
intel_opregion_suspend(xe, s2idle ? PCI_D1 : PCI_D3cold); intel_opregion_suspend(xe, s2idle ? PCI_D1 : PCI_D3cold);
intel_fbdev_set_suspend(&xe->drm, FBINFO_STATE_SUSPENDED, true);
intel_dmc_suspend(xe); intel_dmc_suspend(xe);
} }
...@@ -370,14 +375,20 @@ void xe_display_pm_resume(struct xe_device *xe, bool runtime) ...@@ -370,14 +375,20 @@ void xe_display_pm_resume(struct xe_device *xe, bool runtime)
intel_display_driver_init_hw(xe); intel_display_driver_init_hw(xe);
intel_hpd_init(xe); intel_hpd_init(xe);
if (!runtime && has_display(xe))
intel_display_driver_resume_access(xe);
/* MST sideband requires HPD interrupts enabled */ /* MST sideband requires HPD interrupts enabled */
intel_dp_mst_resume(xe); intel_dp_mst_resume(xe);
if (!runtime) if (!runtime)
intel_display_driver_resume(xe); intel_display_driver_resume(xe);
intel_hpd_poll_disable(xe); if (has_display(xe)) {
if (has_display(xe))
drm_kms_helper_poll_enable(&xe->drm); drm_kms_helper_poll_enable(&xe->drm);
if (!runtime)
intel_display_driver_enable_user_access(xe);
}
intel_hpd_poll_disable(xe);
intel_opregion_resume(xe); intel_opregion_resume(xe);
......
...@@ -203,6 +203,12 @@ struct xe_tile { ...@@ -203,6 +203,12 @@ struct xe_tile {
} vf; } vf;
} sriov; } sriov;
/** @pcode: tile's PCODE */
struct {
/** @pcode.lock: protecting tile's PCODE mailbox data */
struct mutex lock;
} pcode;
/** @migrate: Migration helper for vram blits and clearing */ /** @migrate: Migration helper for vram blits and clearing */
struct xe_migrate *migrate; struct xe_migrate *migrate;
......
...@@ -519,10 +519,22 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc) ...@@ -519,10 +519,22 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
void xe_gsc_load_start(struct xe_gsc *gsc) void xe_gsc_load_start(struct xe_gsc *gsc)
{ {
struct xe_gt *gt = gsc_to_gt(gsc); struct xe_gt *gt = gsc_to_gt(gsc);
struct xe_device *xe = gt_to_xe(gt);
if (!xe_uc_fw_is_loadable(&gsc->fw) || !gsc->q) if (!xe_uc_fw_is_loadable(&gsc->fw) || !gsc->q)
return; return;
/*
* The GSC HW is only reset by driver FLR or D3cold entry. We don't
* support the former at runtime, while the latter is only supported on
* DGFX, for which we don't support GSC. Therefore, if GSC failed to
* load previously there is no need to try again because the HW is
* stuck in the error state.
*/
xe_assert(xe, !IS_DGFX(xe));
if (xe_uc_fw_is_in_error_state(&gsc->fw))
return;
/* GSC FW survives GT reset and D3Hot */ /* GSC FW survives GT reset and D3Hot */
if (gsc_fw_is_loaded(gt)) { if (gsc_fw_is_loaded(gt)) {
xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED); xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED);
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "xe_migrate.h" #include "xe_migrate.h"
#include "xe_mmio.h" #include "xe_mmio.h"
#include "xe_pat.h" #include "xe_pat.h"
#include "xe_pcode.h"
#include "xe_pm.h" #include "xe_pm.h"
#include "xe_mocs.h" #include "xe_mocs.h"
#include "xe_reg_sr.h" #include "xe_reg_sr.h"
...@@ -387,7 +386,6 @@ int xe_gt_init_early(struct xe_gt *gt) ...@@ -387,7 +386,6 @@ int xe_gt_init_early(struct xe_gt *gt)
xe_tuning_process_gt(gt); xe_tuning_process_gt(gt);
xe_force_wake_init_gt(gt, gt_to_fw(gt)); xe_force_wake_init_gt(gt, gt_to_fw(gt));
xe_pcode_init(gt);
spin_lock_init(&gt->global_invl_lock); spin_lock_init(&gt->global_invl_lock);
return 0; return 0;
...@@ -755,12 +753,13 @@ static int gt_reset(struct xe_gt *gt) ...@@ -755,12 +753,13 @@ static int gt_reset(struct xe_gt *gt)
xe_gt_info(gt, "reset started\n"); xe_gt_info(gt, "reset started\n");
xe_pm_runtime_get(gt_to_xe(gt));
if (xe_fault_inject_gt_reset()) { if (xe_fault_inject_gt_reset()) {
err = -ECANCELED; err = -ECANCELED;
goto err_fail; goto err_fail;
} }
xe_pm_runtime_get(gt_to_xe(gt));
xe_gt_sanitize(gt); xe_gt_sanitize(gt);
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
...@@ -795,11 +794,11 @@ static int gt_reset(struct xe_gt *gt) ...@@ -795,11 +794,11 @@ static int gt_reset(struct xe_gt *gt)
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
err_msg: err_msg:
XE_WARN_ON(xe_uc_start(&gt->uc)); XE_WARN_ON(xe_uc_start(&gt->uc));
xe_pm_runtime_put(gt_to_xe(gt));
err_fail: err_fail:
xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err)); xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err));
xe_device_declare_wedged(gt_to_xe(gt)); xe_device_declare_wedged(gt_to_xe(gt));
xe_pm_runtime_put(gt_to_xe(gt));
return err; return err;
} }
......
...@@ -310,12 +310,6 @@ struct xe_gt { ...@@ -310,12 +310,6 @@ struct xe_gt {
/** @eclass: per hardware engine class interface on the GT */ /** @eclass: per hardware engine class interface on the GT */
struct xe_hw_engine_class_intf eclass[XE_ENGINE_CLASS_MAX]; struct xe_hw_engine_class_intf eclass[XE_ENGINE_CLASS_MAX];
/** @pcode: GT's PCODE */
struct {
/** @pcode.lock: protecting GT's PCODE mailbox data */
struct mutex lock;
} pcode;
/** @sysfs: sysfs' kobj used by xe_gt_sysfs */ /** @sysfs: sysfs' kobj used by xe_gt_sysfs */
struct kobject *sysfs; struct kobject *sysfs;
......
...@@ -915,7 +915,7 @@ static void pc_init_pcode_freq(struct xe_guc_pc *pc) ...@@ -915,7 +915,7 @@ static void pc_init_pcode_freq(struct xe_guc_pc *pc)
u32 min = DIV_ROUND_CLOSEST(pc->rpn_freq, GT_FREQUENCY_MULTIPLIER); u32 min = DIV_ROUND_CLOSEST(pc->rpn_freq, GT_FREQUENCY_MULTIPLIER);
u32 max = DIV_ROUND_CLOSEST(pc->rp0_freq, GT_FREQUENCY_MULTIPLIER); u32 max = DIV_ROUND_CLOSEST(pc->rp0_freq, GT_FREQUENCY_MULTIPLIER);
XE_WARN_ON(xe_pcode_init_min_freq_table(pc_to_gt(pc), min, max)); XE_WARN_ON(xe_pcode_init_min_freq_table(gt_to_tile(pc_to_gt(pc)), min, max));
} }
static int pc_init_freqs(struct xe_guc_pc *pc) static int pc_init_freqs(struct xe_guc_pc *pc)
......
...@@ -441,14 +441,14 @@ static int xe_hwmon_pcode_read_i1(struct xe_gt *gt, u32 *uval) ...@@ -441,14 +441,14 @@ static int xe_hwmon_pcode_read_i1(struct xe_gt *gt, u32 *uval)
if (gt_to_xe(gt)->info.platform == XE_DG2) if (gt_to_xe(gt)->info.platform == XE_DG2)
return -ENXIO; return -ENXIO;
return xe_pcode_read(gt, PCODE_MBOX(PCODE_POWER_SETUP, return xe_pcode_read(gt_to_tile(gt), PCODE_MBOX(PCODE_POWER_SETUP,
POWER_SETUP_SUBCOMMAND_READ_I1, 0), POWER_SETUP_SUBCOMMAND_READ_I1, 0),
uval, NULL); uval, NULL);
} }
static int xe_hwmon_pcode_write_i1(struct xe_gt *gt, u32 uval) static int xe_hwmon_pcode_write_i1(struct xe_gt *gt, u32 uval)
{ {
return xe_pcode_write(gt, PCODE_MBOX(PCODE_POWER_SETUP, return xe_pcode_write(gt_to_tile(gt), PCODE_MBOX(PCODE_POWER_SETUP,
POWER_SETUP_SUBCOMMAND_WRITE_I1, 0), POWER_SETUP_SUBCOMMAND_WRITE_I1, 0),
(uval & POWER_SETUP_I1_DATA_MASK)); (uval & POWER_SETUP_I1_DATA_MASK));
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "xe_assert.h" #include "xe_assert.h"
#include "xe_device.h" #include "xe_device.h"
#include "xe_gt.h"
#include "xe_mmio.h" #include "xe_mmio.h"
#include "xe_pcode_api.h" #include "xe_pcode_api.h"
...@@ -30,7 +29,7 @@ ...@@ -30,7 +29,7 @@
* - PCODE for display operations * - PCODE for display operations
*/ */
static int pcode_mailbox_status(struct xe_gt *gt) static int pcode_mailbox_status(struct xe_tile *tile)
{ {
u32 err; u32 err;
static const struct pcode_err_decode err_decode[] = { static const struct pcode_err_decode err_decode[] = {
...@@ -45,9 +44,9 @@ static int pcode_mailbox_status(struct xe_gt *gt) ...@@ -45,9 +44,9 @@ static int pcode_mailbox_status(struct xe_gt *gt)
[PCODE_ERROR_MASK] = {-EPROTO, "Unknown"}, [PCODE_ERROR_MASK] = {-EPROTO, "Unknown"},
}; };
err = xe_mmio_read32(gt, PCODE_MAILBOX) & PCODE_ERROR_MASK; err = xe_mmio_read32(tile->primary_gt, PCODE_MAILBOX) & PCODE_ERROR_MASK;
if (err) { if (err) {
drm_err(&gt_to_xe(gt)->drm, "PCODE Mailbox failed: %d %s", err, drm_err(&tile_to_xe(tile)->drm, "PCODE Mailbox failed: %d %s", err,
err_decode[err].str ?: "Unknown"); err_decode[err].str ?: "Unknown");
return err_decode[err].errno ?: -EPROTO; return err_decode[err].errno ?: -EPROTO;
} }
...@@ -55,84 +54,85 @@ static int pcode_mailbox_status(struct xe_gt *gt) ...@@ -55,84 +54,85 @@ static int pcode_mailbox_status(struct xe_gt *gt)
return 0; return 0;
} }
static int __pcode_mailbox_rw(struct xe_gt *gt, u32 mbox, u32 *data0, u32 *data1, static int __pcode_mailbox_rw(struct xe_tile *tile, u32 mbox, u32 *data0, u32 *data1,
unsigned int timeout_ms, bool return_data, unsigned int timeout_ms, bool return_data,
bool atomic) bool atomic)
{ {
struct xe_gt *mmio = tile->primary_gt;
int err; int err;
if (gt_to_xe(gt)->info.skip_pcode) if (tile_to_xe(tile)->info.skip_pcode)
return 0; return 0;
if ((xe_mmio_read32(gt, PCODE_MAILBOX) & PCODE_READY) != 0) if ((xe_mmio_read32(mmio, PCODE_MAILBOX) & PCODE_READY) != 0)
return -EAGAIN; return -EAGAIN;
xe_mmio_write32(gt, PCODE_DATA0, *data0); xe_mmio_write32(mmio, PCODE_DATA0, *data0);
xe_mmio_write32(gt, PCODE_DATA1, data1 ? *data1 : 0); xe_mmio_write32(mmio, PCODE_DATA1, data1 ? *data1 : 0);
xe_mmio_write32(gt, PCODE_MAILBOX, PCODE_READY | mbox); xe_mmio_write32(mmio, PCODE_MAILBOX, PCODE_READY | mbox);
err = xe_mmio_wait32(gt, PCODE_MAILBOX, PCODE_READY, 0, err = xe_mmio_wait32(mmio, PCODE_MAILBOX, PCODE_READY, 0,
timeout_ms * USEC_PER_MSEC, NULL, atomic); timeout_ms * USEC_PER_MSEC, NULL, atomic);
if (err) if (err)
return err; return err;
if (return_data) { if (return_data) {
*data0 = xe_mmio_read32(gt, PCODE_DATA0); *data0 = xe_mmio_read32(mmio, PCODE_DATA0);
if (data1) if (data1)
*data1 = xe_mmio_read32(gt, PCODE_DATA1); *data1 = xe_mmio_read32(mmio, PCODE_DATA1);
} }
return pcode_mailbox_status(gt); return pcode_mailbox_status(tile);
} }
static int pcode_mailbox_rw(struct xe_gt *gt, u32 mbox, u32 *data0, u32 *data1, static int pcode_mailbox_rw(struct xe_tile *tile, u32 mbox, u32 *data0, u32 *data1,
unsigned int timeout_ms, bool return_data, unsigned int timeout_ms, bool return_data,
bool atomic) bool atomic)
{ {
if (gt_to_xe(gt)->info.skip_pcode) if (tile_to_xe(tile)->info.skip_pcode)
return 0; return 0;
lockdep_assert_held(&gt->pcode.lock); lockdep_assert_held(&tile->pcode.lock);
return __pcode_mailbox_rw(gt, mbox, data0, data1, timeout_ms, return_data, atomic); return __pcode_mailbox_rw(tile, mbox, data0, data1, timeout_ms, return_data, atomic);
} }
int xe_pcode_write_timeout(struct xe_gt *gt, u32 mbox, u32 data, int timeout) int xe_pcode_write_timeout(struct xe_tile *tile, u32 mbox, u32 data, int timeout)
{ {
int err; int err;
mutex_lock(&gt->pcode.lock); mutex_lock(&tile->pcode.lock);
err = pcode_mailbox_rw(gt, mbox, &data, NULL, timeout, false, false); err = pcode_mailbox_rw(tile, mbox, &data, NULL, timeout, false, false);
mutex_unlock(&gt->pcode.lock); mutex_unlock(&tile->pcode.lock);
return err; return err;
} }
int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) int xe_pcode_read(struct xe_tile *tile, u32 mbox, u32 *val, u32 *val1)
{ {
int err; int err;
mutex_lock(&gt->pcode.lock); mutex_lock(&tile->pcode.lock);
err = pcode_mailbox_rw(gt, mbox, val, val1, 1, true, false); err = pcode_mailbox_rw(tile, mbox, val, val1, 1, true, false);
mutex_unlock(&gt->pcode.lock); mutex_unlock(&tile->pcode.lock);
return err; return err;
} }
static int pcode_try_request(struct xe_gt *gt, u32 mbox, static int pcode_try_request(struct xe_tile *tile, u32 mbox,
u32 request, u32 reply_mask, u32 reply, u32 request, u32 reply_mask, u32 reply,
u32 *status, bool atomic, int timeout_us, bool locked) u32 *status, bool atomic, int timeout_us, bool locked)
{ {
int slept, wait = 10; int slept, wait = 10;
xe_gt_assert(gt, timeout_us > 0); xe_tile_assert(tile, timeout_us > 0);
for (slept = 0; slept < timeout_us; slept += wait) { for (slept = 0; slept < timeout_us; slept += wait) {
if (locked) if (locked)
*status = pcode_mailbox_rw(gt, mbox, &request, NULL, 1, true, *status = pcode_mailbox_rw(tile, mbox, &request, NULL, 1, true,
atomic); atomic);
else else
*status = __pcode_mailbox_rw(gt, mbox, &request, NULL, 1, true, *status = __pcode_mailbox_rw(tile, mbox, &request, NULL, 1, true,
atomic); atomic);
if ((*status == 0) && ((request & reply_mask) == reply)) if ((*status == 0) && ((request & reply_mask) == reply))
return 0; return 0;
...@@ -149,7 +149,7 @@ static int pcode_try_request(struct xe_gt *gt, u32 mbox, ...@@ -149,7 +149,7 @@ static int pcode_try_request(struct xe_gt *gt, u32 mbox,
/** /**
* xe_pcode_request - send PCODE request until acknowledgment * xe_pcode_request - send PCODE request until acknowledgment
* @gt: gt * @tile: tile
* @mbox: PCODE mailbox ID the request is targeted for * @mbox: PCODE mailbox ID the request is targeted for
* @request: request ID * @request: request ID
* @reply_mask: mask used to check for request acknowledgment * @reply_mask: mask used to check for request acknowledgment
...@@ -166,17 +166,17 @@ static int pcode_try_request(struct xe_gt *gt, u32 mbox, ...@@ -166,17 +166,17 @@ static int pcode_try_request(struct xe_gt *gt, u32 mbox,
* Returns 0 on success, %-ETIMEDOUT in case of a timeout, <0 in case of some * Returns 0 on success, %-ETIMEDOUT in case of a timeout, <0 in case of some
* other error as reported by PCODE. * other error as reported by PCODE.
*/ */
int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
u32 reply_mask, u32 reply, int timeout_base_ms) u32 reply_mask, u32 reply, int timeout_base_ms)
{ {
u32 status; u32 status;
int ret; int ret;
xe_gt_assert(gt, timeout_base_ms <= 3); xe_tile_assert(tile, timeout_base_ms <= 3);
mutex_lock(&gt->pcode.lock); mutex_lock(&tile->pcode.lock);
ret = pcode_try_request(gt, mbox, request, reply_mask, reply, &status, ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
false, timeout_base_ms * 1000, true); false, timeout_base_ms * 1000, true);
if (!ret) if (!ret)
goto out; goto out;
...@@ -191,20 +191,20 @@ int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, ...@@ -191,20 +191,20 @@ int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
* requests, and for any quirks of the PCODE firmware that delays * requests, and for any quirks of the PCODE firmware that delays
* the request completion. * the request completion.
*/ */
drm_err(&gt_to_xe(gt)->drm, drm_err(&tile_to_xe(tile)->drm,
"PCODE timeout, retrying with preemption disabled\n"); "PCODE timeout, retrying with preemption disabled\n");
preempt_disable(); preempt_disable();
ret = pcode_try_request(gt, mbox, request, reply_mask, reply, &status, ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
true, 50 * 1000, true); true, 50 * 1000, true);
preempt_enable(); preempt_enable();
out: out:
mutex_unlock(&gt->pcode.lock); mutex_unlock(&tile->pcode.lock);
return status ? status : ret; return status ? status : ret;
} }
/** /**
* xe_pcode_init_min_freq_table - Initialize PCODE's QOS frequency table * xe_pcode_init_min_freq_table - Initialize PCODE's QOS frequency table
* @gt: gt instance * @tile: tile instance
* @min_gt_freq: Minimal (RPn) GT frequency in units of 50MHz. * @min_gt_freq: Minimal (RPn) GT frequency in units of 50MHz.
* @max_gt_freq: Maximal (RP0) GT frequency in units of 50MHz. * @max_gt_freq: Maximal (RP0) GT frequency in units of 50MHz.
* *
...@@ -227,30 +227,30 @@ int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, ...@@ -227,30 +227,30 @@ int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
* - -EACCES, "PCODE Rejected" * - -EACCES, "PCODE Rejected"
* - -EPROTO, "Unknown" * - -EPROTO, "Unknown"
*/ */
int xe_pcode_init_min_freq_table(struct xe_gt *gt, u32 min_gt_freq, int xe_pcode_init_min_freq_table(struct xe_tile *tile, u32 min_gt_freq,
u32 max_gt_freq) u32 max_gt_freq)
{ {
int ret; int ret;
u32 freq; u32 freq;
if (!gt_to_xe(gt)->info.has_llc) if (!tile_to_xe(tile)->info.has_llc)
return 0; return 0;
if (max_gt_freq <= min_gt_freq) if (max_gt_freq <= min_gt_freq)
return -EINVAL; return -EINVAL;
mutex_lock(&gt->pcode.lock); mutex_lock(&tile->pcode.lock);
for (freq = min_gt_freq; freq <= max_gt_freq; freq++) { for (freq = min_gt_freq; freq <= max_gt_freq; freq++) {
u32 data = freq << PCODE_FREQ_RING_RATIO_SHIFT | freq; u32 data = freq << PCODE_FREQ_RING_RATIO_SHIFT | freq;
ret = pcode_mailbox_rw(gt, PCODE_WRITE_MIN_FREQ_TABLE, ret = pcode_mailbox_rw(tile, PCODE_WRITE_MIN_FREQ_TABLE,
&data, NULL, 1, false, false); &data, NULL, 1, false, false);
if (ret) if (ret)
goto unlock; goto unlock;
} }
unlock: unlock:
mutex_unlock(&gt->pcode.lock); mutex_unlock(&tile->pcode.lock);
return ret; return ret;
} }
...@@ -270,7 +270,7 @@ int xe_pcode_init_min_freq_table(struct xe_gt *gt, u32 min_gt_freq, ...@@ -270,7 +270,7 @@ int xe_pcode_init_min_freq_table(struct xe_gt *gt, u32 min_gt_freq,
int xe_pcode_ready(struct xe_device *xe, bool locked) int xe_pcode_ready(struct xe_device *xe, bool locked)
{ {
u32 status, request = DGFX_GET_INIT_STATUS; u32 status, request = DGFX_GET_INIT_STATUS;
struct xe_gt *gt = xe_root_mmio_gt(xe); struct xe_tile *tile = xe_device_get_root_tile(xe);
int timeout_us = 180000000; /* 3 min */ int timeout_us = 180000000; /* 3 min */
int ret; int ret;
...@@ -281,15 +281,15 @@ int xe_pcode_ready(struct xe_device *xe, bool locked) ...@@ -281,15 +281,15 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
return 0; return 0;
if (locked) if (locked)
mutex_lock(&gt->pcode.lock); mutex_lock(&tile->pcode.lock);
ret = pcode_try_request(gt, DGFX_PCODE_STATUS, request, ret = pcode_try_request(tile, DGFX_PCODE_STATUS, request,
DGFX_INIT_STATUS_COMPLETE, DGFX_INIT_STATUS_COMPLETE,
DGFX_INIT_STATUS_COMPLETE, DGFX_INIT_STATUS_COMPLETE,
&status, false, timeout_us, locked); &status, false, timeout_us, locked);
if (locked) if (locked)
mutex_unlock(&gt->pcode.lock); mutex_unlock(&tile->pcode.lock);
if (ret) if (ret)
drm_err(&xe->drm, drm_err(&xe->drm,
...@@ -300,14 +300,14 @@ int xe_pcode_ready(struct xe_device *xe, bool locked) ...@@ -300,14 +300,14 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
/** /**
* xe_pcode_init: initialize components of PCODE * xe_pcode_init: initialize components of PCODE
* @gt: gt instance * @tile: tile instance
* *
* This function initializes the xe_pcode component. * This function initializes the xe_pcode component.
* To be called once only during probe. * To be called once only during probe.
*/ */
void xe_pcode_init(struct xe_gt *gt) void xe_pcode_init(struct xe_tile *tile)
{ {
drmm_mutex_init(&gt_to_xe(gt)->drm, &gt->pcode.lock); drmm_mutex_init(&tile_to_xe(tile)->drm, &tile->pcode.lock);
} }
/** /**
......
...@@ -7,21 +7,21 @@ ...@@ -7,21 +7,21 @@
#define _XE_PCODE_H_ #define _XE_PCODE_H_
#include <linux/types.h> #include <linux/types.h>
struct xe_gt; struct xe_tile;
struct xe_device; struct xe_device;
void xe_pcode_init(struct xe_gt *gt); void xe_pcode_init(struct xe_tile *tile);
int xe_pcode_probe_early(struct xe_device *xe); int xe_pcode_probe_early(struct xe_device *xe);
int xe_pcode_ready(struct xe_device *xe, bool locked); int xe_pcode_ready(struct xe_device *xe, bool locked);
int xe_pcode_init_min_freq_table(struct xe_gt *gt, u32 min_gt_freq, int xe_pcode_init_min_freq_table(struct xe_tile *tile, u32 min_gt_freq,
u32 max_gt_freq); u32 max_gt_freq);
int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1); int xe_pcode_read(struct xe_tile *tile, u32 mbox, u32 *val, u32 *val1);
int xe_pcode_write_timeout(struct xe_gt *gt, u32 mbox, u32 val, int xe_pcode_write_timeout(struct xe_tile *tile, u32 mbox, u32 val,
int timeout_ms); int timeout_ms);
#define xe_pcode_write(gt, mbox, val) \ #define xe_pcode_write(tile, mbox, val) \
xe_pcode_write_timeout(gt, mbox, val, 1) xe_pcode_write_timeout(tile, mbox, val, 1)
int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
u32 reply_mask, u32 reply, int timeout_ms); u32 reply_mask, u32 reply, int timeout_ms);
#define PCODE_MBOX(mbcmd, param1, param2)\ #define PCODE_MBOX(mbcmd, param1, param2)\
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "xe_ggtt.h" #include "xe_ggtt.h"
#include "xe_gt.h" #include "xe_gt.h"
#include "xe_migrate.h" #include "xe_migrate.h"
#include "xe_pcode.h"
#include "xe_sa.h" #include "xe_sa.h"
#include "xe_tile.h" #include "xe_tile.h"
#include "xe_tile_sysfs.h" #include "xe_tile_sysfs.h"
...@@ -124,6 +125,8 @@ int xe_tile_init_early(struct xe_tile *tile, struct xe_device *xe, u8 id) ...@@ -124,6 +125,8 @@ int xe_tile_init_early(struct xe_tile *tile, struct xe_device *xe, u8 id)
if (IS_ERR(tile->primary_gt)) if (IS_ERR(tile->primary_gt))
return PTR_ERR(tile->primary_gt); return PTR_ERR(tile->primary_gt);
xe_pcode_init(tile);
return 0; return 0;
} }
......
...@@ -65,7 +65,7 @@ const char *xe_uc_fw_status_repr(enum xe_uc_fw_status status) ...@@ -65,7 +65,7 @@ const char *xe_uc_fw_status_repr(enum xe_uc_fw_status status)
return "<invalid>"; return "<invalid>";
} }
static inline int xe_uc_fw_status_to_error(enum xe_uc_fw_status status) static inline int xe_uc_fw_status_to_error(const enum xe_uc_fw_status status)
{ {
switch (status) { switch (status) {
case XE_UC_FIRMWARE_NOT_SUPPORTED: case XE_UC_FIRMWARE_NOT_SUPPORTED:
...@@ -108,7 +108,7 @@ static inline const char *xe_uc_fw_type_repr(enum xe_uc_fw_type type) ...@@ -108,7 +108,7 @@ static inline const char *xe_uc_fw_type_repr(enum xe_uc_fw_type type)
} }
static inline enum xe_uc_fw_status static inline enum xe_uc_fw_status
__xe_uc_fw_status(struct xe_uc_fw *uc_fw) __xe_uc_fw_status(const struct xe_uc_fw *uc_fw)
{ {
/* shouldn't call this before checking hw/blob availability */ /* shouldn't call this before checking hw/blob availability */
XE_WARN_ON(uc_fw->status == XE_UC_FIRMWARE_UNINITIALIZED); XE_WARN_ON(uc_fw->status == XE_UC_FIRMWARE_UNINITIALIZED);
...@@ -156,6 +156,11 @@ static inline bool xe_uc_fw_is_overridden(const struct xe_uc_fw *uc_fw) ...@@ -156,6 +156,11 @@ static inline bool xe_uc_fw_is_overridden(const struct xe_uc_fw *uc_fw)
return uc_fw->user_overridden; return uc_fw->user_overridden;
} }
static inline bool xe_uc_fw_is_in_error_state(const struct xe_uc_fw *uc_fw)
{
return xe_uc_fw_status_to_error(__xe_uc_fw_status(uc_fw)) < 0;
}
static inline void xe_uc_fw_sanitize(struct xe_uc_fw *uc_fw) static inline void xe_uc_fw_sanitize(struct xe_uc_fw *uc_fw)
{ {
if (xe_uc_fw_is_loadable(uc_fw)) if (xe_uc_fw_is_loadable(uc_fw))
......
...@@ -34,7 +34,6 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, ...@@ -34,7 +34,6 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct xe_tile *tile = dev_to_tile(dev); struct xe_tile *tile = dev_to_tile(dev);
struct xe_gt *gt = tile->primary_gt;
u32 val, mbox; u32 val, mbox;
int err; int err;
...@@ -42,7 +41,7 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, ...@@ -42,7 +41,7 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
| REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_P0) | REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_P0)
| REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_HBM); | REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_HBM);
err = xe_pcode_read(gt, mbox, &val, NULL); err = xe_pcode_read(tile, mbox, &val, NULL);
if (err) if (err)
return err; return err;
...@@ -57,7 +56,6 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, ...@@ -57,7 +56,6 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct xe_tile *tile = dev_to_tile(dev); struct xe_tile *tile = dev_to_tile(dev);
struct xe_gt *gt = tile->primary_gt;
u32 val, mbox; u32 val, mbox;
int err; int err;
...@@ -65,7 +63,7 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, ...@@ -65,7 +63,7 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
| REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_PN) | REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_PN)
| REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_HBM); | REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_HBM);
err = xe_pcode_read(gt, mbox, &val, NULL); err = xe_pcode_read(tile, mbox, &val, NULL);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment