Commit dab79a22 authored by Alexander Usyskin's avatar Alexander Usyskin Committed by Greg Kroah-Hartman

mei: pxp: re-enable client on errors

Disable and enable mei-pxp client on errors to clean the internal state.
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-4-tomas.winkler@intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ee5cb393
...@@ -23,6 +23,24 @@ ...@@ -23,6 +23,24 @@
#include "mei_pxp.h" #include "mei_pxp.h"
static inline int mei_pxp_reenable(const struct device *dev, struct mei_cl_device *cldev)
{
int ret;
dev_warn(dev, "Trying to reset the channel...\n");
ret = mei_cldev_disable(cldev);
if (ret < 0)
dev_warn(dev, "mei_cldev_disable failed. %d\n", ret);
/*
* Explicitly ignoring disable failure,
* enable may fix the states and succeed
*/
ret = mei_cldev_enable(cldev);
if (ret < 0)
dev_err(dev, "mei_cldev_enable failed. %d\n", ret);
return ret;
}
/** /**
* mei_pxp_send_message() - Sends a PXP message to ME FW. * mei_pxp_send_message() - Sends a PXP message to ME FW.
* @dev: device corresponding to the mei_cl_device * @dev: device corresponding to the mei_cl_device
...@@ -35,6 +53,7 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) ...@@ -35,6 +53,7 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size)
{ {
struct mei_cl_device *cldev; struct mei_cl_device *cldev;
ssize_t byte; ssize_t byte;
int ret;
if (!dev || !message) if (!dev || !message)
return -EINVAL; return -EINVAL;
...@@ -44,10 +63,20 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) ...@@ -44,10 +63,20 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size)
byte = mei_cldev_send(cldev, message, size); byte = mei_cldev_send(cldev, message, size);
if (byte < 0) { if (byte < 0) {
dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte); dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
return byte; switch (byte) {
case -ENOMEM:
fallthrough;
case -ENODEV:
fallthrough;
case -ETIME:
ret = mei_pxp_reenable(dev, cldev);
if (ret)
byte = ret;
break;
}
} }
return 0; return byte;
} }
/** /**
...@@ -63,6 +92,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) ...@@ -63,6 +92,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size)
struct mei_cl_device *cldev; struct mei_cl_device *cldev;
ssize_t byte; ssize_t byte;
bool retry = false; bool retry = false;
int ret;
if (!dev || !buffer) if (!dev || !buffer)
return -EINVAL; return -EINVAL;
...@@ -73,26 +103,22 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) ...@@ -73,26 +103,22 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size)
byte = mei_cldev_recv(cldev, buffer, size); byte = mei_cldev_recv(cldev, buffer, size);
if (byte < 0) { if (byte < 0) {
dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
if (byte != -ENOMEM) switch (byte) {
return byte; case -ENOMEM:
/* Retry the read when pages are reclaimed */
/* Retry the read when pages are reclaimed */ msleep(20);
msleep(20); if (!retry) {
if (!retry) { retry = true;
retry = true; goto retry;
goto retry; }
} else { fallthrough;
dev_warn(dev, "No memory on data receive after retry, trying to reset the channel...\n"); case -ENODEV:
byte = mei_cldev_disable(cldev); fallthrough;
if (byte < 0) case -ETIME:
dev_warn(dev, "mei_cldev_disable failed. %zd\n", byte); ret = mei_pxp_reenable(dev, cldev);
/* if (ret)
* Explicitly ignoring disable failure, byte = ret;
* enable may fix the states and succeed break;
*/
byte = mei_cldev_enable(cldev);
if (byte < 0)
dev_err(dev, "mei_cldev_enable failed. %zd\n", byte);
} }
} }
......
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