Merge tag 'selinux-pr-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / hid / intel-ish-hid / ishtp / client.c
index 1cc157126fce762952ecca81b0e6224c9b8b352a..405e0d5212cc8d35f1a0c9ba098e408fe9a54a13 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/wait.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <asm/cacheflush.h>
 #include "hbm.h"
 #include "client.h"
 
@@ -111,7 +112,7 @@ static void ishtp_cl_init(struct ishtp_cl *cl, struct ishtp_device *dev)
 
 /**
  * ishtp_cl_allocate() - allocates client structure and sets it up.
- * @dev: ishtp device
+ * @cl_device: ishtp client device
  *
  * Allocate memory for new client device and call to initialize each field.
  *
@@ -263,7 +264,6 @@ EXPORT_SYMBOL(ishtp_cl_unlink);
 int ishtp_cl_disconnect(struct ishtp_cl *cl)
 {
        struct ishtp_device *dev;
-       int err;
 
        if (WARN_ON(!cl || !cl->dev))
                return -ENODEV;
@@ -283,7 +283,7 @@ int ishtp_cl_disconnect(struct ishtp_cl *cl)
                return -ENODEV;
        }
 
-       err = wait_event_interruptible_timeout(cl->wait_ctrl_res,
+       wait_event_interruptible_timeout(cl->wait_ctrl_res,
                        (dev->dev_state != ISHTP_DEV_ENABLED ||
                        cl->state == ISHTP_CL_DISCONNECTED),
                        ishtp_secs_to_jiffies(ISHTP_CL_CONNECT_TIMEOUT));
@@ -773,6 +773,14 @@ static void ishtp_cl_send_msg_dma(struct ishtp_device *dev,
        /* write msg to dma buf */
        memcpy(msg_addr, cl_msg->send_buf.data, cl_msg->send_buf.size);
 
+       /*
+        * if current fw don't support cache snooping, driver have to
+        * flush the cache manually.
+        */
+       if (dev->ops->dma_no_cache_snooping &&
+               dev->ops->dma_no_cache_snooping(dev))
+               clflush_cache_range(msg_addr, cl_msg->send_buf.size);
+
        /* send dma_xfer hbm msg */
        off = msg_addr - (unsigned char *)dev->ishtp_host_dma_tx_buf;
        ishtp_hbm_hdr(&hdr, sizeof(struct dma_xfer_hbm));
@@ -997,6 +1005,15 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg,
                }
 
                buffer = rb->buffer.data;
+
+               /*
+                * if current fw don't support cache snooping, driver have to
+                * flush the cache manually.
+                */
+               if (dev->ops->dma_no_cache_snooping &&
+                       dev->ops->dma_no_cache_snooping(dev))
+                       clflush_cache_range(msg, hbm->msg_length);
+
                memcpy(buffer, msg, hbm->msg_length);
                rb->buf_idx = hbm->msg_length;