Skip to content

Commit 4aae88b

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: intel-ish-hid: ishtp: Add dma_no_cache_snooping() callback
Different platforms have different DMA capability, on most of platforms, DMA support cache snooping. But few platforms, such as ElkhartLake (EHL), don't support cache snooping which requires cache flush from driver. So add a hardware level callback to let ishtp driver know if cache flush is needed. As most of platform support cache snooping, so driver will not do cache flush by default, until platform implements this callback and return true explicitly. Acked-by: Pandruvada, Srinivas <[email protected]> Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 65e4122 commit 4aae88b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/hid/intel-ish-hid/ishtp/client.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/wait.h>
1111
#include <linux/delay.h>
1212
#include <linux/dma-mapping.h>
13+
#include <asm/cacheflush.h>
1314
#include "hbm.h"
1415
#include "client.h"
1516

@@ -772,6 +773,14 @@ static void ishtp_cl_send_msg_dma(struct ishtp_device *dev,
772773
/* write msg to dma buf */
773774
memcpy(msg_addr, cl_msg->send_buf.data, cl_msg->send_buf.size);
774775

776+
/*
777+
* if current fw don't support cache snooping, driver have to
778+
* flush the cache manually.
779+
*/
780+
if (dev->ops->dma_no_cache_snooping &&
781+
dev->ops->dma_no_cache_snooping(dev))
782+
clflush_cache_range(msg_addr, cl_msg->send_buf.size);
783+
775784
/* send dma_xfer hbm msg */
776785
off = msg_addr - (unsigned char *)dev->ishtp_host_dma_tx_buf;
777786
ishtp_hbm_hdr(&hdr, sizeof(struct dma_xfer_hbm));
@@ -996,6 +1005,15 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg,
9961005
}
9971006

9981007
buffer = rb->buffer.data;
1008+
1009+
/*
1010+
* if current fw don't support cache snooping, driver have to
1011+
* flush the cache manually.
1012+
*/
1013+
if (dev->ops->dma_no_cache_snooping &&
1014+
dev->ops->dma_no_cache_snooping(dev))
1015+
clflush_cache_range(msg, hbm->msg_length);
1016+
9991017
memcpy(buffer, msg, hbm->msg_length);
10001018
rb->buf_idx = hbm->msg_length;
10011019

drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct ishtp_hw_ops {
119119
unsigned long buffer_length);
120120
uint32_t (*get_fw_status)(struct ishtp_device *dev);
121121
void (*sync_fw_clock)(struct ishtp_device *dev);
122+
bool (*dma_no_cache_snooping)(struct ishtp_device *dev);
122123
};
123124

124125
/**

0 commit comments

Comments
 (0)