Commit fb99e79e authored by Alan Previn's avatar Alan Previn Committed by Greg Kroah-Hartman
Browse files

mei: update mei-pxp's component interface with timeouts



In debugging platform or firmware related MEI-PXP connection
issues, having a timeout when clients (such as i915) calling
into mei-pxp's send/receive functions have proven useful as opposed to
blocking forever until the kernel triggers a watchdog panic (when
platform issues are experienced).

Update the mei-pxp component interface send and receive functions
to take in timeouts.

Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20231011110157.247552-5-tomas.winkler@intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dab79a22
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include "intel_pxp_tee.h"
#include "intel_pxp_types.h"

#define PXP_TRANSPORT_TIMEOUT_MS 5000 /* 5 sec */

static bool
is_fw_err_platform_config(u32 type)
{
@@ -71,13 +73,15 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
		goto unlock;
	}

	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,
				       PXP_TRANSPORT_TIMEOUT_MS);
	if (ret) {
		drm_err(&i915->drm, "Failed to send PXP TEE message\n");
		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,
				       PXP_TRANSPORT_TIMEOUT_MS);
	if (ret < 0) {
		drm_err(&i915->drm, "Failed to receive PXP TEE message\n");
		goto unlock;
+27 −6
Original line number Diff line number Diff line
@@ -46,10 +46,20 @@ static inline int mei_pxp_reenable(const struct device *dev, struct mei_cl_devic
 * @dev: device corresponding to the mei_cl_device
 * @message: a message buffer to send
 * @size: size of the message
 * Return: 0 on Success, <0 on Failure
 * @timeout_ms: timeout in milliseconds, zero means wait indefinitely.
 *
 * Returns: 0 on Success, <0 on Failure with the following defined failures.
 *         -ENODEV: Client was not connected.
 *                  Caller may attempt to try again immediately.
 *         -ENOMEM: Internal memory allocation failure experienced.
 *                  Caller may sleep to allow kernel reclaim before retrying.
 *         -EINTR : Calling thread received a signal. Caller may choose
 *                  to abandon with the same thread id.
 *         -ETIME : Request is timed out.
 *                  Caller may attempt to try again immediately.
 */
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, unsigned long timeout_ms)
{
	struct mei_cl_device *cldev;
	ssize_t byte;
@@ -60,7 +70,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_timeout(cldev, message, size, timeout_ms);
	if (byte < 0) {
		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
		switch (byte) {
@@ -84,10 +94,21 @@ 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
 * Return: bytes sent on Success, <0 on Failure
 * @timeout_ms: timeout in milliseconds, zero means wait indefinitely.
 *
 * Returns: number of bytes send on Success, <0 on Failure with the following defined failures.
 *         -ENODEV: Client was not connected.
 *                  Caller may attempt to try again from send immediately.
 *         -ENOMEM: Internal memory allocation failure experienced.
 *                  Caller may sleep to allow kernel reclaim before retrying.
 *         -EINTR : Calling thread received a signal. Caller will need to repeat calling
 *                  (with a different owning thread) to retrieve existing unclaimed response
 *                  (and may discard it).
 *         -ETIME : Request is timed out.
 *                  Caller may attempt to try again from send immediately.
 */
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, unsigned long timeout_ms)
{
	struct mei_cl_device *cldev;
	ssize_t byte;
@@ -100,7 +121,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size)
	cldev = to_mei_cl_device(dev);

retry:
	byte = mei_cldev_recv(cldev, buffer, size);
	byte = mei_cldev_recv_timeout(cldev, buffer, size, timeout_ms);
	if (byte < 0) {
		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
		switch (byte) {
+4 −2
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ 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,
		    unsigned long timeout_ms);
	int (*recv)(struct device *dev, void *buffer, size_t size,
		    unsigned long timeout_ms);
	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);