From a8a3681b1f046400cb71afe0b17b7d6bb2f2d991 Mon Sep 17 00:00:00 2001 From: "Sun, Jing" Date: Fri, 20 Dec 2024 02:49:44 +0000 Subject: [PATCH] Update i915 PXP and MEI Driver to DII client. Signed-off-by: Sun, Jing --- drivers/gpu/drm/i915/gt/iov/intel_iov_ggtt.c | 2 +- drivers/gpu/drm/i915/i915_driver.c | 4 +- drivers/gpu/drm/i915/pxp/intel_pxp.c | 174 ++++++++++++++----- drivers/gpu/drm/i915/pxp/intel_pxp_irq.c | 5 +- drivers/gpu/drm/i915/pxp/intel_pxp_session.c | 3 + drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 85 +++++---- drivers/gpu/drm/i915/pxp/intel_pxp_types.h | 1 + drivers/misc/mei/bus-fixup.c | 12 +- drivers/misc/mei/hw-me-regs.h | 2 + drivers/misc/mei/main.c | 4 +- drivers/misc/mei/pci-me.c | 2 + drivers/misc/mei/pxp/mei_pxp.c | 10 +- include/drm/i915_pxp_tee_interface.h | 4 +- 13 files changed, 213 insertions(+), 95 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/iov/intel_iov_ggtt.c b/drivers/gpu/drm/i915/gt/iov/intel_iov_ggtt.c index 5d5efa33bbf6..7f561a09e0bb 100644 --- a/drivers/gpu/drm/i915/gt/iov/intel_iov_ggtt.c +++ b/drivers/gpu/drm/i915/gt/iov/intel_iov_ggtt.c @@ -173,7 +173,7 @@ static bool is_pte_replicable(struct intel_iov *iov, gen8_pte_t pte) void intel_iov_ggtt_vf_update_pte(struct intel_iov *iov, u32 offset, gen8_pte_t pte) { struct intel_iov_vf_ggtt_ptes *buffer = &iov->vf.ptes_buffer; - u16 max_copies = FIELD_MAX(VF2PF_MMIO_UPDATE_GGTT_REQUEST_MSG_1_NUM_COPIES); + u16 max_copies = (u8)FIELD_MAX(VF2PF_MMIO_UPDATE_GGTT_REQUEST_MSG_1_NUM_COPIES); u16 max_ptes = MMIO_UPDATE_GGTT_MAX_PTES; u32 pte_offset = (offset >> PAGE_SHIFT) - (iov->vf.config.ggtt_base >> PAGE_SHIFT); diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index 3bc35c6ef8a4..29d20b253f94 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -853,7 +853,9 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto out_cleanup_modeset2; - intel_pxp_init(i915); + ret = intel_pxp_init(i915); + if (ret != -ENODEV) + drm_dbg(&i915->drm, "pxp init failed with %d\n", ret); ret = intel_display_driver_probe(i915); if (ret) diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.c b/drivers/gpu/drm/i915/pxp/intel_pxp.c index 64ab58540b6e..ab8fdbef0a10 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp.c @@ -101,7 +101,7 @@ static int create_vcs_context(struct intel_pxp *pxp) I915_GEM_HWS_PXP_ADDR, &pxp_lock, "pxp_context"); if (IS_ERR(ce)) { - drm_err(>->i915->drm, "failed to create VCS ctx for PXP\n"); + drm_err(>->i915->drm, "Failed to create VCS ctx for PXP\n"); return PTR_ERR(ce); } @@ -201,6 +201,10 @@ int intel_pxp_init(struct drm_i915_private *i915) struct intel_gt *gt; bool is_full_feature = false; + if (intel_gt_is_wedged(to_gt(i915))) { + drm_err(&i915->drm, "Failed to init pxp due to not connected\n"); + return -ENOTCONN; + } /* * NOTE: Get the ctrl_gt before checking intel_pxp_is_supported since * we still need it if PXP's backend tee transport is needed. @@ -211,17 +215,20 @@ int intel_pxp_init(struct drm_i915_private *i915) else gt = find_gt_for_required_teelink(i915); - if (!gt) + if (!gt) { + drm_err(&i915->drm, "Failed to find gt to init pxp\n"); return -ENODEV; - + } /* * At this point, we will either enable full featured PXP capabilities * including session and object management, or we will init the backend tee * channel for internal users such as HuC loading by GSC */ i915->pxp = kzalloc(sizeof(*i915->pxp), GFP_KERNEL); - if (!i915->pxp) + if (!i915->pxp) { + drm_err(&i915->drm, "Failed to allocate pxp\n"); return -ENOMEM; + } /* init common info used by all feature-mode usages*/ i915->pxp->ctrl_gt = gt; @@ -309,6 +316,8 @@ static int __pxp_global_teardown_final(struct intel_pxp *pxp) if (!pxp->arb_session.is_valid) return 0; + + drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: teardown for suspend/fini"); /* * To ensure synchronous and coherent session teardown completion * in response to suspend or shutdown triggers, don't use a worker. @@ -318,8 +327,10 @@ static int __pxp_global_teardown_final(struct intel_pxp *pxp) timeout = intel_pxp_get_backend_timeout_ms(pxp); - if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) + if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) { + drm_err(&pxp->ctrl_gt->i915->drm, "PXP: teardown timed out"); return -ETIMEDOUT; + } return 0; } @@ -330,6 +341,8 @@ static int __pxp_global_teardown_restart(struct intel_pxp *pxp) if (pxp->arb_session.is_valid) return 0; + + drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: teardown for restart"); /* * The arb-session is currently inactive and we are doing a reset and restart * due to a runtime event. Use the worker that was designed for this. @@ -338,8 +351,11 @@ static int __pxp_global_teardown_restart(struct intel_pxp *pxp) timeout = intel_pxp_get_backend_timeout_ms(pxp); - if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) + if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) { + drm_err(&pxp->ctrl_gt->i915->drm, "PXP: restart backend timed out (%d ms)", + timeout); return -ETIMEDOUT; + } return 0; } @@ -357,7 +373,7 @@ void intel_pxp_end(struct intel_pxp *pxp) mutex_lock(&pxp->arb_mutex); if (__pxp_global_teardown_final(pxp)) - drm_dbg(&i915->drm, "PXP end timed out\n"); + drm_err(&i915->drm, "PXP end timed out\n"); mutex_unlock(&pxp->arb_mutex); @@ -391,14 +407,23 @@ static bool pxp_fw_dependencies_completed(struct intel_pxp *pxp) */ int intel_pxp_get_readiness_status(struct intel_pxp *pxp, int timeout_ms) { - if (!intel_pxp_is_enabled(pxp)) + if (!intel_pxp_is_enabled(pxp)) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to get readiness due to PXP not enabled\n"); return -ENODEV; + } - if (pxp_required_fw_failed(pxp)) + if (pxp_required_fw_failed(pxp)) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to get readiness due to failed fw\n"); return -ENODEV; + } - if (pxp->platform_cfg_is_bad) + if (pxp->platform_cfg_is_bad) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to get readiness due to bad cfg\n"); return -ENODEV; + } if (timeout_ms) { if (wait_for(pxp_fw_dependencies_completed(pxp), timeout_ms)) @@ -420,23 +445,33 @@ int intel_pxp_start(struct intel_pxp *pxp) int ret = 0; ret = intel_pxp_get_readiness_status(pxp, PXP_READINESS_TIMEOUT); - if (ret < 0) + if (ret < 0) { + drm_err(&pxp->ctrl_gt->i915->drm, + "PXP: tried but not-avail (%d)\n", ret); return ret; - else if (ret > 1) + } else if (ret > 1) { + drm_err(&pxp->ctrl_gt->i915->drm, + "PXP: per UAPI spec user may retry later (%d)\n", ret); return -EIO; /* per UAPI spec, user may retry later */ + } mutex_lock(&pxp->arb_mutex); ret = __pxp_global_teardown_restart(pxp); - if (ret) + if (ret) { + drm_err(&pxp->ctrl_gt->i915->drm, + "PXP: failed to restart (%d)\n", ret); goto unlock; + } /* make sure the compiler doesn't optimize the double access */ barrier(); - if (!pxp->arb_session.is_valid) + if (!pxp->arb_session.is_valid) { + drm_err(&pxp->ctrl_gt->i915->drm, + "PXP: invalid arb session\n"); ret = -EIO; - + } unlock: mutex_unlock(&pxp->arb_mutex); return ret; @@ -458,11 +493,13 @@ int intel_pxp_key_check(struct intel_pxp *pxp, struct drm_i915_gem_object *obj, bool assign) { - if (!intel_pxp_is_active(pxp)) + if (!intel_pxp_is_active(pxp)) { return -ENODEV; + } - if (!i915_gem_object_is_protected(obj)) + if (!i915_gem_object_is_protected(obj)) { return -EINVAL; + } GEM_BUG_ON(!pxp->key_instance); @@ -475,9 +512,10 @@ int intel_pxp_key_check(struct intel_pxp *pxp, if (!obj->pxp_key_instance && assign) obj->pxp_key_instance = pxp->key_instance; - if (obj->pxp_key_instance != pxp->key_instance) + if (obj->pxp_key_instance != pxp->key_instance) { + drm_err(&pxp->ctrl_gt->i915->drm, "PXP: unmatched key"); return -ENOEXEC; - + } return 0; } @@ -544,8 +582,11 @@ static int pxp_set_session_status(struct intel_pxp *pxp, u32 session_id; int ret = 0; - if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) + if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to get set_session_status params\n"); return -EFAULT; + } session_id = params.pxp_tag & PRELIM_DRM_I915_PXP_TAG_SESSION_ID_MASK; @@ -567,13 +608,22 @@ static int pxp_set_session_status(struct intel_pxp *pxp, ret = -EINVAL; } + drm_dbg(&pxp->ctrl_gt->i915->drm, + "Set pxp session status (req %d ret %d)\n", + params.req_session_state, ret); + if (ret >= 0) { pxp_ops->status = ret; - - if (copy_to_user(uparams, ¶ms, sizeof(params))) + if (copy_to_user(uparams, ¶ms, sizeof(params))) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to set set_session_status params\n"); ret = -EFAULT; - else + } else { ret = 0; + } + } else { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to set session status (%d)\n", ret); } return ret; @@ -595,21 +645,26 @@ intel_pxp_ioctl_io_message(struct intel_pxp *pxp, struct drm_file *drmfile, if (!params->msg_in || !params->msg_out || !ioctl_buffer_size_valid(params->msg_out_buf_size) || - !ioctl_buffer_size_valid(params->msg_in_size)) + !ioctl_buffer_size_valid(params->msg_in_size)) { + drm_err(&i915->drm, "Invalid io message\n"); return -EINVAL; + } msg_in = kzalloc(params->msg_in_size, GFP_KERNEL); - if (!msg_in) + if (!msg_in) { + drm_err(&i915->drm, "Failed to allocate msg_in\n"); return -ENOMEM; + } msg_out = kzalloc(params->msg_out_buf_size, GFP_KERNEL); if (!msg_out) { + drm_err(&i915->drm, "Failed to allocate msg_out\n"); ret = -ENOMEM; goto end; } if (copy_from_user(msg_in, u64_to_user_ptr(params->msg_in), params->msg_in_size)) { - drm_dbg(&i915->drm, "Failed to copy_from_user for TEE message\n"); + drm_err(&i915->drm, "Failed to get io message\n"); ret = -EFAULT; goto end; } @@ -625,12 +680,15 @@ intel_pxp_ioctl_io_message(struct intel_pxp *pxp, struct drm_file *drmfile, msg_out, params->msg_out_buf_size, ¶ms->msg_out_ret_size); if (ret) { - drm_dbg(&i915->drm, "Failed to send/receive user TEE message\n"); + drm_err(&i915->drm, + "Failed to send/receive io message (%d)\n", ret); goto end; } + drm_dbg(&i915->drm, "Handled io message (%d)\n", ret); + if (copy_to_user(u64_to_user_ptr(params->msg_out), msg_out, params->msg_out_ret_size)) { - drm_dbg(&i915->drm, "Failed copy_to_user for TEE message\n"); + drm_err(&i915->drm, "Failed to set io message\n"); ret = -EFAULT; goto end; } @@ -651,19 +709,23 @@ static int pxp_send_tee_msg(struct intel_pxp *pxp, u64_to_user_ptr(pxp_ops->params); int ret = 0; - if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) + if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) { + drm_err(&i915->drm, "Failed to get tee message\n"); return -EFAULT; + } ret = intel_pxp_ioctl_io_message(pxp, drmfile, ¶ms); if (ret >= 0) { pxp_ops->status = ret; - if (copy_to_user(uparams, ¶ms, sizeof(params))) + if (copy_to_user(uparams, ¶ms, sizeof(params))) { + drm_err(&i915->drm, "Failed to set tee message\n"); ret = -EFAULT; - else + } else { ret = 0; + } } else { - drm_dbg(&i915->drm, "Failed to send user TEE IO message\n"); + drm_err(&i915->drm, "Failed to send tee message\n"); } return ret; @@ -676,18 +738,27 @@ static int pxp_query_tag(struct intel_pxp *pxp, struct prelim_drm_i915_pxp_ops * u64_to_user_ptr(pxp_ops->params); int ret = 0; - if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) + if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) { + drm_err(&pxp->ctrl_gt->i915->drm, "Failed to get query tag\n"); return -EFAULT; + } ret = intel_pxp_sm_ioctl_query_pxp_tag(pxp, ¶ms.session_is_alive, ¶ms.pxp_tag); + + drm_dbg(&pxp->ctrl_gt->i915->drm, + "Queried tag (is_alive %d pxp_tag %d ret %d)\n", + params.session_is_alive, params.pxp_tag, ret); + if (ret >= 0) { pxp_ops->status = ret; - - if (copy_to_user(uparams, ¶ms, sizeof(params))) + if (copy_to_user(uparams, ¶ms, sizeof(params))) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to set query tag\n"); ret = -EFAULT; - else + } else { ret = 0; + } } return ret; @@ -703,17 +774,24 @@ pxp_process_host_session_handle_request(struct intel_pxp *pxp, u64_to_user_ptr(pxp_ops->params); int ret = 0; - if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) + if (copy_from_user(¶ms, uparams, sizeof(params)) != 0) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to get host handle request\n"); return -EFAULT; + } if (params.request_type != PRELIM_DRM_I915_PXP_GET_HOST_SESSION_HANDLE) { ret = PRELIM_DRM_I915_PXP_OP_STATUS_ERROR_INVALID; + drm_err(&pxp->ctrl_gt->i915->drm, + "Invalid host request type (%d)\n", params.request_type); goto error_out; } /* legacy hw doesn't use this - user space shouldn't be requesting this */ if (!HAS_ENGINE(pxp->ctrl_gt, GSC0)) { ret = PRELIM_DRM_I915_PXP_OP_STATUS_ERROR_INVALID; + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to handle host request due to no engine\n"); goto error_out; } @@ -721,17 +799,22 @@ pxp_process_host_session_handle_request(struct intel_pxp *pxp, ¶ms.host_session_handle); if (!params.host_session_handle) { ret = PRELIM_DRM_I915_PXP_OP_STATUS_ERROR_UNKNOWN; - drm_warn(&pxp->ctrl_gt->i915->drm, "Host Session Handle allocated 0x0\n"); + drm_err(&pxp->ctrl_gt->i915->drm, "Host Session Handle allocated 0x0\n"); } + drm_dbg(&pxp->ctrl_gt->i915->drm, "Handled host request (%d)\n", ret); + error_out: if (ret >= 0) { pxp_ops->status = ret; - if (copy_to_user(uparams, ¶ms, sizeof(params))) + if (copy_to_user(uparams, ¶ms, sizeof(params))) { + drm_err(&pxp->ctrl_gt->i915->drm, + "Failed to set host handle request\n"); ret = -EFAULT; - else + } else { ret = 0; + } } return ret; @@ -760,22 +843,25 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm); if (!wakeref) { - drm_dbg(&i915->drm, "pxp ioctl blocked due to state in suspend\n"); + drm_err(&i915->drm, "pxp ioctl blocked due to state in suspend\n"); pxp_ops->status = PRELIM_DRM_I915_PXP_OP_STATUS_SESSION_NOT_AVAILABLE; return 0; } if (pxp_action_needs_arb_session(pxp_ops->action)) { if (pxp->hw_state_invalidated) { - drm_dbg(&i915->drm, "pxp ioctl retry required due to state attacked\n"); + drm_err(&i915->drm, + "pxp ioctl retry required due to state attacked\n"); pxp_ops->status = PRELIM_DRM_I915_PXP_OP_STATUS_RETRY_REQUIRED; goto out_pm; } if (!intel_pxp_is_active(pxp)) { ret = intel_pxp_start(pxp); - if (ret) + if (ret) { + drm_err(&i915->drm, "Failed to start PXP\n"); goto out_pm; + } } } @@ -784,7 +870,7 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) { ret = intel_gsccs_alloc_client_resources(pxp, drmfile); if (ret) { - drm_warn(&i915->drm, "GSCCS drm-client allocation failure\n"); + drm_err(&i915->drm, "GSCCS drm-client allocation failure\n"); goto out_unlock; } } diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c index 91e9622c07d0..d81750b9bdda 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c @@ -40,11 +40,12 @@ void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir) GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT)) { /* immediately mark PXP as inactive on termination */ intel_pxp_mark_termination_in_progress(pxp); - pxp->session_events |= PXP_TERMINATION_REQUEST | PXP_INVAL_REQUIRED; + pxp->session_events |= PXP_TERMINATION_REQUEST | PXP_INVAL_REQUIRED | + PXP_EVENT_TYPE_IRQ; } if (iir & GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT) - pxp->session_events |= PXP_TERMINATION_COMPLETE; + pxp->session_events |= PXP_TERMINATION_COMPLETE | PXP_EVENT_TYPE_IRQ; if (pxp->session_events) queue_work(system_unbound_wq, &pxp->session_work); diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_session.c b/drivers/gpu/drm/i915/pxp/intel_pxp_session.c index bcdabc93b036..90149c6c665f 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_session.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_session.c @@ -487,6 +487,7 @@ static void pxp_terminate_complete(struct intel_pxp *pxp) { /* Re-create the arb session after teardown handle complete */ if (pxp->hw_state_invalidated) { + drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: creating arb_session after invalidation"); pxp_create_arb_session(pxp); pxp->hw_state_invalidated = false; } @@ -508,6 +509,8 @@ static void pxp_session_work(struct work_struct *work) if (!events) return; + drm_dbg(>->i915->drm, "PXP: processing event-flags 0x%08x", events); + if (events & PXP_INVAL_REQUIRED) intel_pxp_invalidate(pxp); diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c index 93d9d571ec63..ec8dc2de20da 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c @@ -71,39 +71,41 @@ int intel_pxp_tee_io_message(struct intel_pxp *pxp, */ if (!pxp_component) { ret = -ENODEV; + drm_err(&i915->drm, "PXP component not found\n"); goto unlock; } if (pxp->mei_pxp_last_msg_interrupted) { /* read and drop data from the previous iteration */ - ret = pxp_component->ops->recv(pxp_component->tee_dev, &tmp_drop_buf, 64); - if (ret == -EINTR) + ret = pxp_component->ops->recv(pxp_component->tee_dev, &tmp_drop_buf, 64, 1); + if (ret == -EINTR) { + drm_err(&i915->drm, "Failed to receive last tee message\n"); goto unlock; - + } pxp->mei_pxp_last_msg_interrupted = false; } - ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size); + ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size, 1); + if (ret) { /* flag on next msg to drop interrupted msg */ if (ret == -EINTR) pxp->mei_pxp_last_msg_interrupted = true; - drm_err(&i915->drm, "Failed to send PXP TEE message\n"); + drm_err(&i915->drm, "Failed to send tee message (%d)\n", ret); goto unlock; } - ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size); + ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size, 1); if (ret < 0) { /* flag on next msg to drop interrupted msg */ if (ret == -EINTR) pxp->mei_pxp_last_msg_interrupted = true; - drm_err(&i915->drm, "Failed to receive PXP TEE message\n"); + drm_err(&i915->drm, "Failed to receive tee message (%d)\n", ret); goto unlock; } if (ret > msg_out_max_size) { - drm_err(&i915->drm, - "Failed to receive PXP TEE message due to unexpected output size\n"); + drm_err(&i915->drm, "Unexpected tee message output size (%d)\n", ret); ret = -ENOSPC; goto unlock; } @@ -130,12 +132,14 @@ int intel_pxp_tee_stream_message(struct intel_pxp *pxp, struct scatterlist *sg; int ret; - if (msg_in_len > max_msg_size || msg_out_len > max_msg_size) + if (msg_in_len > max_msg_size || msg_out_len > max_msg_size) { + drm_err(&i915->drm, "Failed to stream TEE message due to invalid params\n"); return -ENOSPC; - + } mutex_lock(&pxp->tee_mutex); if (unlikely(!pxp_component || !pxp_component->ops->gsc_command)) { + drm_err(&i915->drm, "Invalid pxp component or gsc command\n"); ret = -ENODEV; goto unlock; } @@ -149,7 +153,7 @@ int intel_pxp_tee_stream_message(struct intel_pxp *pxp, ret = pxp_component->ops->gsc_command(pxp_component->tee_dev, client_id, fence_id, sg, msg_in_len, sg); if (ret < 0) - drm_err(&i915->drm, "Failed to send PXP TEE gsc command\n"); + drm_err(&i915->drm, "Failed to send PXP TEE gsc command (%d)\n", ret); else memcpy(msg_out, pxp->stream_cmd.vaddr, msg_out_len); @@ -180,8 +184,11 @@ static int i915_pxp_tee_component_bind(struct device *i915_kdev, if (!HAS_HECI_PXP(i915)) { pxp->dev_link = device_link_add(i915_kdev, tee_kdev, DL_FLAG_STATELESS); - if (drm_WARN_ON(&i915->drm, !pxp->dev_link)) + if (drm_WARN_ON(&i915->drm, !pxp->dev_link)) { + drm_err(&i915->drm, + "Failed to add device link for pxp component\n"); return -ENODEV; + } } mutex_lock(&pxp->tee_mutex); @@ -194,7 +201,8 @@ static int i915_pxp_tee_component_bind(struct device *i915_kdev, /* load huc via pxp */ ret = intel_huc_fw_load_and_auth_via_gsc(&uc->huc); if (ret < 0) - gt_probe_error(gt, "failed to load huc via gsc %d\n", ret); + gt_probe_error(gt, + "Failed to load huc via gsc (%d)\n", ret); } } @@ -254,22 +262,23 @@ static int alloc_streaming_command(struct intel_pxp *pxp) /* allocate lmem object of one page for PXP command memory and store it */ obj = i915_gem_object_create_lmem(i915, PAGE_SIZE, I915_BO_ALLOC_CONTIGUOUS); if (IS_ERR(obj)) { - drm_err(&i915->drm, "Failed to allocate pxp streaming command!\n"); + drm_err(&i915->drm, + "Failed to allocate pxp streaming command\n"); return PTR_ERR(obj); } err = i915_gem_object_pin_pages_unlocked(obj); if (err) { - drm_err(&i915->drm, "Failed to pin gsc message page!\n"); + drm_err(&i915->drm, "Failed to pin gsc message page\n"); goto out_put; } /* map the lmem into the virtual memory pointer */ cmd = i915_gem_object_pin_map_unlocked(obj, - intel_gt_coherent_map_type(pxp->ctrl_gt, - obj, true)); + intel_gt_coherent_map_type(pxp->ctrl_gt, + obj, true)); if (IS_ERR(cmd)) { - drm_err(&i915->drm, "Failed to map gsc message page!\n"); + drm_err(&i915->drm, "Failed to map gsc message page\n"); err = PTR_ERR(cmd); goto out_unpin; } @@ -359,18 +368,21 @@ int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp, NULL); if (ret) { - drm_err(&i915->drm, "Failed to send tee msg init arb session, ret=[%d]\n", ret); + drm_err(&i915->drm, + "Failed to send tee msg init arb session (%d)\n", ret); } else if (msg_out.header.status != 0) { if (is_fw_err_platform_config(pxp, msg_out.header.status)) { - drm_info_once(&i915->drm, - "PXP init-arb-session-%d failed due to BIOS/SOC:0x%08x:%s\n", - arb_session_id, msg_out.header.status, - fw_err_to_string(msg_out.header.status)); + drm_err(&i915->drm, + "PXP init-arb-session-%d failed due to BIOS/SOC:0x%08x:%s\n", + arb_session_id, msg_out.header.status, + fw_err_to_string(msg_out.header.status)); } else { - drm_dbg(&i915->drm, "PXP init-arb-session--%d failed 0x%08x:%st:\n", + drm_err(&i915->drm, + "PXP init-arb-session--%d failed 0x%08x:%st:\n", arb_session_id, msg_out.header.status, fw_err_to_string(msg_out.header.status)); - drm_dbg(&i915->drm, " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", + drm_err(&i915->drm, + " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", msg_in.header.command_id, msg_in.header.api_version); } } @@ -402,23 +414,28 @@ static void intel_pxp_tee_end_one_fw_session(struct intel_pxp *pxp, u32 session_ NULL); /* Cleanup coherency between GT and Firmware is critical, so try again if it fails */ - if ((ret || msg_out.header.status != 0x0) && ++trials < 3) + if ((ret || msg_out.header.status != 0x0) && ++trials < 3) { + drm_err(&i915->drm, "Retried sending tee message\n"); goto try_again; + } if (ret) { - drm_err(&i915->drm, "Failed to send tee msg for inv-stream-key-%u, ret=[%d]\n", + drm_err(&i915->drm, + "Failed to send tee msg for inv-stream-key-%u (%d)\n", session_id, ret); } else if (msg_out.header.status != 0) { if (is_fw_err_platform_config(pxp, msg_out.header.status)) { - drm_info_once(&i915->drm, - "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n", - session_id, msg_out.header.status, - fw_err_to_string(msg_out.header.status)); + drm_err(&i915->drm, + "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n", + session_id, msg_out.header.status, + fw_err_to_string(msg_out.header.status)); } else { - drm_dbg(&i915->drm, "PXP inv-stream-key-%u failed 0x%08x:%s:\n", + drm_err(&i915->drm, + "PXP inv-stream-key-%u failed 0x%08x:%s:\n", session_id, msg_out.header.status, fw_err_to_string(msg_out.header.status)); - drm_dbg(&i915->drm, " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", + drm_err(&i915->drm, + " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", msg_in.header.command_id, msg_in.header.api_version); } } diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_types.h b/drivers/gpu/drm/i915/pxp/intel_pxp_types.h index cfb665c067cf..c4e70c46cbfd 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_types.h +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_types.h @@ -164,6 +164,7 @@ struct intel_pxp { #define PXP_TERMINATION_REQUEST BIT(0) #define PXP_TERMINATION_COMPLETE BIT(1) #define PXP_INVAL_REQUIRED BIT(2) +#define PXP_EVENT_TYPE_IRQ BIT(3) }; #endif /* __INTEL_PXP_TYPES_H__ */ diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 2733070acf39..04b77943274d 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -151,7 +151,7 @@ static int mei_fwver(struct mei_cl_device *cldev) ret = __mei_cl_send(cldev->cl, (u8 *)&req, sizeof(req), 0, MEI_CL_IO_TX_BLOCKING); if (ret < 0) { - dev_info(&cldev->dev, "Could not send ReqFWVersion cmd ret = %d\n", ret); + dev_err(&cldev->dev, "Could not send ReqFWVersion cmd ret = %d\n", ret); return ret; } @@ -163,7 +163,7 @@ static int mei_fwver(struct mei_cl_device *cldev) * Should be at least one version block, * error out if nothing found */ - dev_info(&cldev->dev, "Could not read FW version ret = %d\n", bytes_recv); + dev_err(&cldev->dev, "Could not read FW version ret = %d\n", bytes_recv); return -EIO; } @@ -221,14 +221,14 @@ static void mei_mkhi_fix(struct mei_cl_device *cldev) if (cldev->bus->fw_f_fw_ver_supported) { ret = mei_fwver(cldev); if (ret < 0) - dev_info(&cldev->dev, "FW version command failed %d\n", + dev_err(&cldev->dev, "FW version command failed %d\n", ret); } if (cldev->bus->hbm_f_os_supported) { ret = mei_osver(cldev); if (ret < 0) - dev_info(&cldev->dev, "OS version command failed %d\n", + dev_err(&cldev->dev, "OS version command failed %d\n", ret); } mei_cldev_disable(cldev); @@ -251,7 +251,7 @@ static void mei_gsc_mkhi_ver(struct mei_cl_device *cldev) ret = mei_fwver(cldev); if (ret < 0) - dev_info(&cldev->dev, "FW version command failed %d\n", ret); + dev_err(&cldev->dev, "FW version command failed %d\n", ret); mei_cldev_disable(cldev); } @@ -282,7 +282,7 @@ static void mei_gsc_mkhi_fix_ver(struct mei_cl_device *cldev) ret = mei_fwver(cldev); if (ret < 0) - dev_info(&cldev->dev, "FW version command failed %d\n", + dev_err(&cldev->dev, "FW version command failed %d\n", ret); out: mei_cldev_disable(cldev); diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h index d3c03d4edbef..e167ac7f4dea 100644 --- a/drivers/misc/mei/hw-me-regs.h +++ b/drivers/misc/mei/hw-me-regs.h @@ -112,6 +112,8 @@ #define MEI_DEV_ID_RPL_S 0x7A68 /* Raptor Lake Point S */ #define MEI_DEV_ID_MTL_M 0x7E70 /* Meteor Lake Point M */ +#define MEI_DEV_ID_MTL_S 0x7F68 /* Meteor Lake Point S */ + #define MEI_DEV_ID_ARL_S 0x7F68 /* Arrow Lake Point S */ #define MEI_DEV_ID_ARL_H 0x7770 /* Arrow Lake Point H */ diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index c018534c780f..5a099fd9aa3f 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -1278,8 +1278,10 @@ static int __init mei_init(void) int ret; ret = class_register(&mei_class); - if (ret) + if (ret) { + pr_err("unable to register mei class\n"); return ret; + } ret = alloc_chrdev_region(&mei_devt, 0, MEI_MAX_DEVS, "mei"); if (ret < 0) { diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 6c4f5e9fe834..c93cc1ca23f2 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c @@ -119,6 +119,8 @@ static const struct pci_device_id mei_me_pci_tbl[] = { {MEI_PCI_DEVICE(MEI_DEV_ID_RPL_S, MEI_ME_PCH15_SPS_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_M, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_S, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_S, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_H, MEI_ME_PCH15_CFG)}, diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c index 6e9dae08efb0..833981b4e882 100644 --- a/drivers/misc/mei/pxp/mei_pxp.c +++ b/drivers/misc/mei/pxp/mei_pxp.c @@ -27,10 +27,11 @@ * @dev: device corresponding to the mei_cl_device * @message: a message buffer to send * @size: size of the message + * @vtag: the vtag of the connection (use 0 for default) * Return: 0 on Success, <0 on Failure */ static int -mei_pxp_send_message(struct device *dev, const void *message, size_t size) +mei_pxp_send_message(struct device *dev, const void *message, size_t size, u8 vtag) { struct mei_cl_device *cldev; ssize_t byte; @@ -40,7 +41,7 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) cldev = to_mei_cl_device(dev); - byte = mei_cldev_send(cldev, message, size); + byte = mei_cldev_send_vtag(cldev, (u8 *)message, size, vtag); if (byte < 0) { dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte); return byte; @@ -54,10 +55,11 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) * @dev: device corresponding to the mei_cl_device * @buffer: a message buffer to contain the received message * @size: size of the buffer + * @vtag: the vtag of the connection (use 0 for default) * Return: bytes sent on Success, <0 on Failure */ static int -mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) +mei_pxp_receive_message(struct device *dev, void *buffer, size_t size, u8 vtag) { struct mei_cl_device *cldev; ssize_t byte; @@ -67,7 +69,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) cldev = to_mei_cl_device(dev); - byte = mei_cldev_recv(cldev, buffer, size); + byte = mei_cldev_recv_vtag(cldev, buffer, size, &vtag); if (byte < 0) { dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); return byte; diff --git a/include/drm/i915_pxp_tee_interface.h b/include/drm/i915_pxp_tee_interface.h index a702b6ec17f7..0c38f4290ed2 100644 --- a/include/drm/i915_pxp_tee_interface.h +++ b/include/drm/i915_pxp_tee_interface.h @@ -22,8 +22,8 @@ struct i915_pxp_component_ops { */ struct module *owner; - int (*send)(struct device *dev, const void *message, size_t size); - int (*recv)(struct device *dev, void *buffer, size_t size); + int (*send)(struct device *dev, const void *message, size_t size, u8 vtag); + int (*recv)(struct device *dev, void *buffer, size_t size, u8 vtag); ssize_t (*gsc_command)(struct device *dev, u8 client_id, u32 fence_id, struct scatterlist *sg_in, size_t total_in_len, struct scatterlist *sg_out);