···55config INTEL_ISH_HID66 tristate "Intel Integrated Sensor Hub"77 default n88+ depends on X8689 select HID910 help1011 The Integrated Sensor Hub (ISH) enables the ability to offload
+26-2
drivers/hid/intel-ish-hid/ipc/ipc.c
···544544#define TIMEOUT_FOR_HW_RDY_MS 300545545546546/**547547- * ish_fw_reset_work_fn() - FW reset worker function547547+ * fw_reset_work_fn() - FW reset worker function548548 * @unused: not used549549 *550550 * Call ish_fw_reset_handler to complete FW reset···889889 return drbl_val;890890}891891892892+/**893893+ * _dma_no_cache_snooping()894894+ *895895+ * Check on current platform, DMA supports cache snooping or not.896896+ * This callback is used to notify uplayer driver if manully cache897897+ * flush is needed when do DMA operation.898898+ *899899+ * Please pay attention to this callback implementation, if declare900900+ * having cache snooping on a cache snooping not supported platform901901+ * will cause uplayer driver receiving mismatched data; and if902902+ * declare no cache snooping on a cache snooping supported platform903903+ * will cause cache be flushed twice and performance hit.904904+ *905905+ * @dev: ishtp device pointer906906+ *907907+ * Return: false - has cache snooping capability908908+ * true - no cache snooping, need manually cache flush909909+ */910910+static bool _dma_no_cache_snooping(struct ishtp_device *dev)911911+{912912+ return dev->pdev->device == EHL_Ax_DEVICE_ID;913913+}914914+892915static const struct ishtp_hw_ops ish_hw_ops = {893916 .hw_reset = _ish_hw_reset,894917 .ipc_reset = _ish_ipc_reset,···920897 .write = write_ipc_to_queue,921898 .get_fw_status = _ish_read_fw_sts_reg,922899 .sync_fw_clock = _ish_sync_fw_clock,923923- .ishtp_read_hdr = _ishtp_read_hdr900900+ .ishtp_read_hdr = _ishtp_read_hdr,901901+ .dma_no_cache_snooping = _dma_no_cache_snooping924902};925903926904/**
+1-2
drivers/hid/intel-ish-hid/ipc/pci-ish.c
···263263 struct pci_dev *pdev = to_pci_dev(ish_resume_device);264264 struct ishtp_device *dev = pci_get_drvdata(pdev);265265 uint32_t fwsts = dev->ops->get_fw_status(dev);266266- int ret;267266268267 if (ish_should_leave_d0i3(pdev) && !dev->suspend_flag269268 && IPC_IS_ISH_ILUP(fwsts)) {···274275275276 /* Waiting to get resume response */276277 if (dev->resume_flag)277277- ret = wait_event_interruptible_timeout(dev->resume_wait,278278+ wait_event_interruptible_timeout(dev->resume_wait,278279 !dev->resume_flag,279280 msecs_to_jiffies(WAIT_FOR_RESUME_ACK_MS));280281
+24-25
drivers/hid/intel-ish-hid/ishtp-fw-loader.c
···31313232/**3333 * enum ish_loader_commands - ISH loader host commands.3434- * LOADER_CMD_XFER_QUERY Query the Shim firmware loader for3434+ * @LOADER_CMD_XFER_QUERY: Query the Shim firmware loader for3535 * capabilities3636- * LOADER_CMD_XFER_FRAGMENT Transfer one firmware image fragment at a3636+ * @LOADER_CMD_XFER_FRAGMENT: Transfer one firmware image fragment at a3737 * time. The command may be executed3838 * multiple times until the entire firmware3939 * image is downloaded to SRAM.4040- * LOADER_CMD_START Start executing the main firmware.4040+ * @LOADER_CMD_START: Start executing the main firmware.4141 */4242enum ish_loader_commands {4343 LOADER_CMD_XFER_QUERY = 0,···9595/**9696 * struct loader_msg_hdr - Header for ISH Loader commands.9797 * @command: LOADER_CMD* commands. Bit 7 is the response.9898+ * @reserved: Reserved space9899 * @status: Command response status. Non 0, is error99100 * condition.100101 *···174173 * struct response_info - Encapsulate firmware response related175174 * information for passing between function176175 * loader_cl_send() and process_recv() callback.177177- * @data Copy the data received from firmware here.178178- * @max_size Max size allocated for the @data buffer. If the176176+ * @data: Copy the data received from firmware here.177177+ * @max_size: Max size allocated for the @data buffer. If the179178 * received data exceeds this value, we log an180179 * error.181181- * @size Actual size of data received from firmware.182182- * @error Returns 0 for success, negative error code for a180180+ * @size: Actual size of data received from firmware.181181+ * @error: Returns 0 for success, negative error code for a183182 * failure in function process_recv().184184- * @received Set to true on receiving a valid firmware183183+ * @received: Set to true on receiving a valid firmware185184 * response to host command186186- * @wait_queue Wait queue for Host firmware loading where the185185+ * @wait_queue: Wait queue for Host firmware loading where the187186 * client sends message to ISH firmware and waits188187 * for response189188 */···196195 wait_queue_head_t wait_queue;197196};198197199199-/**198198+/*200199 * struct ishtp_cl_data - Encapsulate per ISH-TP Client Data.201200 * @work_ishtp_reset: Work queue for reset handling.202201 * @work_fw_load: Work queue for host firmware loading.203203- * @flag_retry Flag for indicating host firmware loading should202202+ * @flag_retry: Flag for indicating host firmware loading should204203 * be retried.205205- * @retry_count Count the number of retries.204204+ * @retry_count: Count the number of retries.206205 *207206 * This structure is used to store data per client.208207 */···241240/**242241 * get_firmware_variant() - Gets the filename of firmware image to be243242 * loaded based on platform variant.244244- * @client_data Client data instance.245245- * @filename Returns firmware filename.243243+ * @client_data: Client data instance.244244+ * @filename: Returns firmware filename.246245 *247246 * Queries the firmware-name device property string.248247 *···267266/**268267 * loader_cl_send() Send message from host to firmware269268 * @client_data: Client data instance270270- * @out_msg Message buffer to be sent to firmware271271- * @out_size Size of out going message272272- * @in_msg Message buffer where the incoming data copied.269269+ * @out_msg: Message buffer to be sent to firmware270270+ * @out_size: Size of out going message271271+ * @in_msg: Message buffer where the incoming data copied.273272 * This buffer is allocated by calling274274- * @in_size Max size of incoming message273273+ * @in_size: Max size of incoming message275274 *276275 * Return: Number of bytes copied in the in_msg on success, negative277276 * error code on failure.···436435437436/**438437 * loader_cl_event_cb() - bus driver callback for incoming message439439- * @device: Pointer to the ishtp client device for which this438438+ * @cl_device: Pointer to the ishtp client device for which this440439 * message is targeted441440 *442441 * Remove the packet from the list and process the message by calling···537536}538537539538/**540540- * ish_fw_xfer_ishtp() Loads ISH firmware using ishtp interface539539+ * ish_fw_xfer_ishtp() - Loads ISH firmware using ishtp interface541540 * @client_data: Client data instance542541 * @fw: Pointer to firmware data struct in host memory543542 *···734733}735734736735/**737737- * ish_fw_start() Start executing ISH main firmware736736+ * ish_fw_start() - Start executing ISH main firmware738737 * @client_data: client data instance739738 *740739 * This function sends message to Shim firmware loader to start···757756}758757759758/**760760- * load_fw_from_host() Loads ISH firmware from host759759+ * load_fw_from_host() - Loads ISH firmware from host761760 * @client_data: Client data instance762761 *763762 * This function loads the ISH firmware to ISH SRAM and starts execution···10161015 *10171016 * Return: 010181017 */10191019-static int loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device)10181018+static void loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device)10201019{10211020 struct ishtp_cl_data *client_data;10221021 struct ishtp_cl *loader_ishtp_cl = ishtp_get_drvdata(cl_device);···10331032 cancel_work_sync(&client_data->work_ishtp_reset);10341033 loader_deinit(loader_ishtp_cl);10351034 ishtp_put_device(cl_device);10361036-10371037- return 0;10381035}1039103610401037/**
+9-6
drivers/hid/intel-ish-hid/ishtp-hid-client.c
···1111#include <linux/sched.h>1212#include "ishtp-hid.h"13131414+/* ISH Transport protocol (ISHTP in short) GUID */1515+static const guid_t hid_ishtp_guid =1616+ GUID_INIT(0x33AECD58, 0xB679, 0x4E54,1717+ 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26);1818+1419/* Rx ring buffer pool size */1520#define HID_CL_RX_RING_SIZE 321621#define HID_CL_TX_RING_SIZE 16···2318#define cl_data_to_dev(client_data) ishtp_device(client_data->cl_device)24192520/**2626- * report_bad_packets() - Report bad packets2121+ * report_bad_packet() - Report bad packets2722 * @hid_ishtp_cl: Client instance to get stats2823 * @recv_buf: Raw received host interface message2924 * @cur_pos: Current position index in payload···784779 }785780}786781787787-void (*hid_print_trace)(void *unused, const char *format, ...);782782+ishtp_print_log ishtp_hid_print_trace;788783789784/**790785 * hid_ishtp_cl_probe() - ISHTP client driver probe···823818824819 INIT_WORK(&client_data->work, hid_ishtp_cl_reset_handler);825820826826- hid_print_trace = ishtp_trace_callback(cl_device);821821+ ishtp_hid_print_trace = ishtp_trace_callback(cl_device);827822828823 rv = hid_ishtp_cl_init(hid_ishtp_cl, 0);829824 if (rv) {···843838 *844839 * Return: 0845840 */846846-static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)841841+static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)847842{848843 struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device);849844 struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl);···861856 hid_ishtp_cl = NULL;862857863858 client_data->num_hid_devices = 0;864864-865865- return 0;866859}867860868861/**
+1-1
drivers/hid/intel-ish-hid/ishtp-hid.c
···254254}255255256256/**257257- * ishtp_hid_probe() - Remove registered hid device257257+ * ishtp_hid_remove() - Remove registered hid device258258 * @client_data: client data pointer259259 *260260 * This function is used to destroy allocatd HID device.
+2-7
drivers/hid/intel-ish-hid/ishtp-hid.h
···1616#define IS_RESPONSE 0x8017171818/* Used to dump to Linux trace buffer, if enabled */1919-extern void (*hid_print_trace)(void *unused, const char *format, ...);1919+extern ishtp_print_log ishtp_hid_print_trace;2020#define hid_ishtp_trace(client, ...) \2121- (hid_print_trace)(NULL, __VA_ARGS__)2222-2323-/* ISH Transport protocol (ISHTP in short) GUID */2424-static const guid_t hid_ishtp_guid =2525- GUID_INIT(0x33AECD58, 0xB679, 0x4E54,2626- 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26);2121+ (ishtp_hid_print_trace)(NULL, __VA_ARGS__)27222823/* ISH HID message structure */2924struct hostif_msg_hdr {
+11-13
drivers/hid/intel-ish-hid/ishtp/bus.c
···164164165165/**166166 * ishtp_get_fw_client_id() - Get fw client id167167+ * @fw_client: firmware client used to fetch the ID167168 *168169 * This interface is used to reset HW get FW client id.169170 *···258257static int ishtp_cl_device_remove(struct device *dev)259258{260259 struct ishtp_cl_device *device = to_ishtp_cl_device(dev);261261- struct ishtp_cl_driver *driver;262262-263263- if (!device || !dev->driver)264264- return 0;260260+ struct ishtp_cl_driver *driver = to_ishtp_cl_driver(dev->driver);265261266262 if (device->event_cb) {267263 device->event_cb = NULL;268264 cancel_work_sync(&device->event_work);269265 }270266271271- driver = to_ishtp_cl_driver(dev->driver);272272- if (!driver->remove) {273273- dev->driver = NULL;267267+ if (driver->remove)268268+ driver->remove(device);274269275275- return 0;276276- }277277-278278- return driver->remove(device);270270+ return 0;279271}280272281273/**···836842837843/**838844 * ishtp_device() - Return device pointer845845+ * @device: ISH-TP client device instance839846 *840847 * This interface is used to return device pointer from ishtp_cl_device841848 * instance.···853858 * ishtp_get_pci_device() - Return PCI device dev pointer854859 * This interface is used to return PCI device pointer855860 * from ishtp_cl_device instance.861861+ * @device: ISH-TP client device instance856862 *857863 * Return: device *.858864 */···865869866870/**867871 * ishtp_trace_callback() - Return trace callback872872+ * @cl_device: ISH-TP client device instance868873 *869874 * This interface is used to return trace callback function pointer.870875 *871871- * Return: void *.876876+ * Return: *ishtp_print_log()872877 */873873-void *ishtp_trace_callback(struct ishtp_cl_device *cl_device)878878+ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device)874879{875880 return cl_device->ishtp_dev->print_log;876881}···879882880883/**881884 * ish_hw_reset() - Call HW reset IPC callback885885+ * @dev: ISHTP device instance882886 *883887 * This interface is used to reset HW in case of error.884888 *
+20-3
drivers/hid/intel-ish-hid/ishtp/client.c
···1010#include <linux/wait.h>1111#include <linux/delay.h>1212#include <linux/dma-mapping.h>1313+#include <asm/cacheflush.h>1314#include "hbm.h"1415#include "client.h"1516···112111113112/**114113 * ishtp_cl_allocate() - allocates client structure and sets it up.115115- * @dev: ishtp device114114+ * @cl_device: ishtp client device116115 *117116 * Allocate memory for new client device and call to initialize each field.118117 *···264263int ishtp_cl_disconnect(struct ishtp_cl *cl)265264{266265 struct ishtp_device *dev;267267- int err;268266269267 if (WARN_ON(!cl || !cl->dev))270268 return -ENODEV;···283283 return -ENODEV;284284 }285285286286- err = wait_event_interruptible_timeout(cl->wait_ctrl_res,286286+ wait_event_interruptible_timeout(cl->wait_ctrl_res,287287 (dev->dev_state != ISHTP_DEV_ENABLED ||288288 cl->state == ISHTP_CL_DISCONNECTED),289289 ishtp_secs_to_jiffies(ISHTP_CL_CONNECT_TIMEOUT));···773773 /* write msg to dma buf */774774 memcpy(msg_addr, cl_msg->send_buf.data, cl_msg->send_buf.size);775775776776+ /*777777+ * if current fw don't support cache snooping, driver have to778778+ * flush the cache manually.779779+ */780780+ if (dev->ops->dma_no_cache_snooping &&781781+ dev->ops->dma_no_cache_snooping(dev))782782+ clflush_cache_range(msg_addr, cl_msg->send_buf.size);783783+776784 /* send dma_xfer hbm msg */777785 off = msg_addr - (unsigned char *)dev->ishtp_host_dma_tx_buf;778786 ishtp_hbm_hdr(&hdr, sizeof(struct dma_xfer_hbm));···1005997 }10069981007999 buffer = rb->buffer.data;10001000+10011001+ /*10021002+ * if current fw don't support cache snooping, driver have to10031003+ * flush the cache manually.10041004+ */10051005+ if (dev->ops->dma_no_cache_snooping &&10061006+ dev->ops->dma_no_cache_snooping(dev))10071007+ clflush_cache_range(msg, hbm->msg_length);10081008+10081009 memcpy(buffer, msg, hbm->msg_length);10091010 rb->buf_idx = hbm->msg_length;10101011