summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2023-10-11 14:01:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-18 10:01:33 +0200
commitee5cb39348e69a61a865801970ba8fdc399335de (patch)
treee03ca131dcd86a408a826be90a1d8237c2743e25 /drivers/misc
parentcf439721f66719c6aa73b5ea23320c2f8cba100f (diff)
mei: pxp: recover from recv fail under memory pressure
Under memory pressure recv fails due to kmalloc failure, and if drivers(pxp) retry send/receive, send blocks indefinitely. Send without recv leaves the channel in a bad state. Retry send attempt after small timeout and reset the channel if the retry failed on kmalloc failure too. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Link: https://lore.kernel.org/r/20231011110157.247552-3-tomas.winkler@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/pxp/mei_pxp.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c
index 2dcb9169e404..c6cdd6a47308 100644
--- a/drivers/misc/mei/pxp/mei_pxp.c
+++ b/drivers/misc/mei/pxp/mei_pxp.c
@@ -11,6 +11,7 @@
* negotiation messages to ME FW command payloads and vice versa.
*/
+#include <linux/delay.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/mei.h>
@@ -61,16 +62,38 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size)
{
struct mei_cl_device *cldev;
ssize_t byte;
+ bool retry = false;
if (!dev || !buffer)
return -EINVAL;
cldev = to_mei_cl_device(dev);
+retry:
byte = mei_cldev_recv(cldev, buffer, size);
if (byte < 0) {
dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
- return byte;
+ if (byte != -ENOMEM)
+ return byte;
+
+ /* Retry the read when pages are reclaimed */
+ msleep(20);
+ if (!retry) {
+ retry = true;
+ goto retry;
+ } else {
+ dev_warn(dev, "No memory on data receive after retry, trying to reset the channel...\n");
+ byte = mei_cldev_disable(cldev);
+ if (byte < 0)
+ dev_warn(dev, "mei_cldev_disable failed. %zd\n", byte);
+ /*
+ * Explicitly ignoring disable failure,
+ * enable may fix the states and succeed
+ */
+ byte = mei_cldev_enable(cldev);
+ if (byte < 0)
+ dev_err(dev, "mei_cldev_enable failed. %zd\n", byte);
+ }
}
return byte;