Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-5.14/intel-ish' into for-linus

- support for ISH DMA on EHL platform from Even Xu
- various code style fixes and cleanups from Lee Jones and Uwe Kleine-König

+113 -71
+1
drivers/hid/intel-ish-hid/Kconfig
··· 5 5 config INTEL_ISH_HID 6 6 tristate "Intel Integrated Sensor Hub" 7 7 default n 8 + depends on X86 8 9 select HID 9 10 help 10 11 The Integrated Sensor Hub (ISH) enables the ability to offload
+26 -2
drivers/hid/intel-ish-hid/ipc/ipc.c
··· 544 544 #define TIMEOUT_FOR_HW_RDY_MS 300 545 545 546 546 /** 547 - * ish_fw_reset_work_fn() - FW reset worker function 547 + * fw_reset_work_fn() - FW reset worker function 548 548 * @unused: not used 549 549 * 550 550 * Call ish_fw_reset_handler to complete FW reset ··· 889 889 return drbl_val; 890 890 } 891 891 892 + /** 893 + * _dma_no_cache_snooping() 894 + * 895 + * Check on current platform, DMA supports cache snooping or not. 896 + * This callback is used to notify uplayer driver if manully cache 897 + * flush is needed when do DMA operation. 898 + * 899 + * Please pay attention to this callback implementation, if declare 900 + * having cache snooping on a cache snooping not supported platform 901 + * will cause uplayer driver receiving mismatched data; and if 902 + * declare no cache snooping on a cache snooping supported platform 903 + * will cause cache be flushed twice and performance hit. 904 + * 905 + * @dev: ishtp device pointer 906 + * 907 + * Return: false - has cache snooping capability 908 + * true - no cache snooping, need manually cache flush 909 + */ 910 + static bool _dma_no_cache_snooping(struct ishtp_device *dev) 911 + { 912 + return dev->pdev->device == EHL_Ax_DEVICE_ID; 913 + } 914 + 892 915 static const struct ishtp_hw_ops ish_hw_ops = { 893 916 .hw_reset = _ish_hw_reset, 894 917 .ipc_reset = _ish_ipc_reset, ··· 920 897 .write = write_ipc_to_queue, 921 898 .get_fw_status = _ish_read_fw_sts_reg, 922 899 .sync_fw_clock = _ish_sync_fw_clock, 923 - .ishtp_read_hdr = _ishtp_read_hdr 900 + .ishtp_read_hdr = _ishtp_read_hdr, 901 + .dma_no_cache_snooping = _dma_no_cache_snooping 924 902 }; 925 903 926 904 /**
+1 -2
drivers/hid/intel-ish-hid/ipc/pci-ish.c
··· 263 263 struct pci_dev *pdev = to_pci_dev(ish_resume_device); 264 264 struct ishtp_device *dev = pci_get_drvdata(pdev); 265 265 uint32_t fwsts = dev->ops->get_fw_status(dev); 266 - int ret; 267 266 268 267 if (ish_should_leave_d0i3(pdev) && !dev->suspend_flag 269 268 && IPC_IS_ISH_ILUP(fwsts)) { ··· 274 275 275 276 /* Waiting to get resume response */ 276 277 if (dev->resume_flag) 277 - ret = wait_event_interruptible_timeout(dev->resume_wait, 278 + wait_event_interruptible_timeout(dev->resume_wait, 278 279 !dev->resume_flag, 279 280 msecs_to_jiffies(WAIT_FOR_RESUME_ACK_MS)); 280 281
+24 -25
drivers/hid/intel-ish-hid/ishtp-fw-loader.c
··· 31 31 32 32 /** 33 33 * enum ish_loader_commands - ISH loader host commands. 34 - * LOADER_CMD_XFER_QUERY Query the Shim firmware loader for 34 + * @LOADER_CMD_XFER_QUERY: Query the Shim firmware loader for 35 35 * capabilities 36 - * LOADER_CMD_XFER_FRAGMENT Transfer one firmware image fragment at a 36 + * @LOADER_CMD_XFER_FRAGMENT: Transfer one firmware image fragment at a 37 37 * time. The command may be executed 38 38 * multiple times until the entire firmware 39 39 * image is downloaded to SRAM. 40 - * LOADER_CMD_START Start executing the main firmware. 40 + * @LOADER_CMD_START: Start executing the main firmware. 41 41 */ 42 42 enum ish_loader_commands { 43 43 LOADER_CMD_XFER_QUERY = 0, ··· 95 95 /** 96 96 * struct loader_msg_hdr - Header for ISH Loader commands. 97 97 * @command: LOADER_CMD* commands. Bit 7 is the response. 98 + * @reserved: Reserved space 98 99 * @status: Command response status. Non 0, is error 99 100 * condition. 100 101 * ··· 174 173 * struct response_info - Encapsulate firmware response related 175 174 * information for passing between function 176 175 * loader_cl_send() and process_recv() callback. 177 - * @data Copy the data received from firmware here. 178 - * @max_size Max size allocated for the @data buffer. If the 176 + * @data: Copy the data received from firmware here. 177 + * @max_size: Max size allocated for the @data buffer. If the 179 178 * received data exceeds this value, we log an 180 179 * error. 181 - * @size Actual size of data received from firmware. 182 - * @error Returns 0 for success, negative error code for a 180 + * @size: Actual size of data received from firmware. 181 + * @error: Returns 0 for success, negative error code for a 183 182 * failure in function process_recv(). 184 - * @received Set to true on receiving a valid firmware 183 + * @received: Set to true on receiving a valid firmware 185 184 * response to host command 186 - * @wait_queue Wait queue for Host firmware loading where the 185 + * @wait_queue: Wait queue for Host firmware loading where the 187 186 * client sends message to ISH firmware and waits 188 187 * for response 189 188 */ ··· 196 195 wait_queue_head_t wait_queue; 197 196 }; 198 197 199 - /** 198 + /* 200 199 * struct ishtp_cl_data - Encapsulate per ISH-TP Client Data. 201 200 * @work_ishtp_reset: Work queue for reset handling. 202 201 * @work_fw_load: Work queue for host firmware loading. 203 - * @flag_retry Flag for indicating host firmware loading should 202 + * @flag_retry: Flag for indicating host firmware loading should 204 203 * be retried. 205 - * @retry_count Count the number of retries. 204 + * @retry_count: Count the number of retries. 206 205 * 207 206 * This structure is used to store data per client. 208 207 */ ··· 241 240 /** 242 241 * get_firmware_variant() - Gets the filename of firmware image to be 243 242 * loaded based on platform variant. 244 - * @client_data Client data instance. 245 - * @filename Returns firmware filename. 243 + * @client_data: Client data instance. 244 + * @filename: Returns firmware filename. 246 245 * 247 246 * Queries the firmware-name device property string. 248 247 * ··· 267 266 /** 268 267 * loader_cl_send() Send message from host to firmware 269 268 * @client_data: Client data instance 270 - * @out_msg Message buffer to be sent to firmware 271 - * @out_size Size of out going message 272 - * @in_msg Message buffer where the incoming data copied. 269 + * @out_msg: Message buffer to be sent to firmware 270 + * @out_size: Size of out going message 271 + * @in_msg: Message buffer where the incoming data copied. 273 272 * This buffer is allocated by calling 274 - * @in_size Max size of incoming message 273 + * @in_size: Max size of incoming message 275 274 * 276 275 * Return: Number of bytes copied in the in_msg on success, negative 277 276 * error code on failure. ··· 436 435 437 436 /** 438 437 * loader_cl_event_cb() - bus driver callback for incoming message 439 - * @device: Pointer to the ishtp client device for which this 438 + * @cl_device: Pointer to the ishtp client device for which this 440 439 * message is targeted 441 440 * 442 441 * Remove the packet from the list and process the message by calling ··· 537 536 } 538 537 539 538 /** 540 - * ish_fw_xfer_ishtp() Loads ISH firmware using ishtp interface 539 + * ish_fw_xfer_ishtp() - Loads ISH firmware using ishtp interface 541 540 * @client_data: Client data instance 542 541 * @fw: Pointer to firmware data struct in host memory 543 542 * ··· 734 733 } 735 734 736 735 /** 737 - * ish_fw_start() Start executing ISH main firmware 736 + * ish_fw_start() - Start executing ISH main firmware 738 737 * @client_data: client data instance 739 738 * 740 739 * This function sends message to Shim firmware loader to start ··· 757 756 } 758 757 759 758 /** 760 - * load_fw_from_host() Loads ISH firmware from host 759 + * load_fw_from_host() - Loads ISH firmware from host 761 760 * @client_data: Client data instance 762 761 * 763 762 * This function loads the ISH firmware to ISH SRAM and starts execution ··· 1016 1015 * 1017 1016 * Return: 0 1018 1017 */ 1019 - static int loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device) 1018 + static void loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device) 1020 1019 { 1021 1020 struct ishtp_cl_data *client_data; 1022 1021 struct ishtp_cl *loader_ishtp_cl = ishtp_get_drvdata(cl_device); ··· 1033 1032 cancel_work_sync(&client_data->work_ishtp_reset); 1034 1033 loader_deinit(loader_ishtp_cl); 1035 1034 ishtp_put_device(cl_device); 1036 - 1037 - return 0; 1038 1035 } 1039 1036 1040 1037 /**
+9 -6
drivers/hid/intel-ish-hid/ishtp-hid-client.c
··· 11 11 #include <linux/sched.h> 12 12 #include "ishtp-hid.h" 13 13 14 + /* ISH Transport protocol (ISHTP in short) GUID */ 15 + static const guid_t hid_ishtp_guid = 16 + GUID_INIT(0x33AECD58, 0xB679, 0x4E54, 17 + 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26); 18 + 14 19 /* Rx ring buffer pool size */ 15 20 #define HID_CL_RX_RING_SIZE 32 16 21 #define HID_CL_TX_RING_SIZE 16 ··· 23 18 #define cl_data_to_dev(client_data) ishtp_device(client_data->cl_device) 24 19 25 20 /** 26 - * report_bad_packets() - Report bad packets 21 + * report_bad_packet() - Report bad packets 27 22 * @hid_ishtp_cl: Client instance to get stats 28 23 * @recv_buf: Raw received host interface message 29 24 * @cur_pos: Current position index in payload ··· 784 779 } 785 780 } 786 781 787 - void (*hid_print_trace)(void *unused, const char *format, ...); 782 + ishtp_print_log ishtp_hid_print_trace; 788 783 789 784 /** 790 785 * hid_ishtp_cl_probe() - ISHTP client driver probe ··· 823 818 824 819 INIT_WORK(&client_data->work, hid_ishtp_cl_reset_handler); 825 820 826 - hid_print_trace = ishtp_trace_callback(cl_device); 821 + ishtp_hid_print_trace = ishtp_trace_callback(cl_device); 827 822 828 823 rv = hid_ishtp_cl_init(hid_ishtp_cl, 0); 829 824 if (rv) { ··· 843 838 * 844 839 * Return: 0 845 840 */ 846 - static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) 841 + static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) 847 842 { 848 843 struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device); 849 844 struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl); ··· 861 856 hid_ishtp_cl = NULL; 862 857 863 858 client_data->num_hid_devices = 0; 864 - 865 - return 0; 866 859 } 867 860 868 861 /**
+1 -1
drivers/hid/intel-ish-hid/ishtp-hid.c
··· 254 254 } 255 255 256 256 /** 257 - * ishtp_hid_probe() - Remove registered hid device 257 + * ishtp_hid_remove() - Remove registered hid device 258 258 * @client_data: client data pointer 259 259 * 260 260 * This function is used to destroy allocatd HID device.
+2 -7
drivers/hid/intel-ish-hid/ishtp-hid.h
··· 16 16 #define IS_RESPONSE 0x80 17 17 18 18 /* Used to dump to Linux trace buffer, if enabled */ 19 - extern void (*hid_print_trace)(void *unused, const char *format, ...); 19 + extern ishtp_print_log ishtp_hid_print_trace; 20 20 #define hid_ishtp_trace(client, ...) \ 21 - (hid_print_trace)(NULL, __VA_ARGS__) 22 - 23 - /* ISH Transport protocol (ISHTP in short) GUID */ 24 - static const guid_t hid_ishtp_guid = 25 - GUID_INIT(0x33AECD58, 0xB679, 0x4E54, 26 - 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26); 21 + (ishtp_hid_print_trace)(NULL, __VA_ARGS__) 27 22 28 23 /* ISH HID message structure */ 29 24 struct hostif_msg_hdr {
+11 -13
drivers/hid/intel-ish-hid/ishtp/bus.c
··· 164 164 165 165 /** 166 166 * ishtp_get_fw_client_id() - Get fw client id 167 + * @fw_client: firmware client used to fetch the ID 167 168 * 168 169 * This interface is used to reset HW get FW client id. 169 170 * ··· 258 257 static int ishtp_cl_device_remove(struct device *dev) 259 258 { 260 259 struct ishtp_cl_device *device = to_ishtp_cl_device(dev); 261 - struct ishtp_cl_driver *driver; 262 - 263 - if (!device || !dev->driver) 264 - return 0; 260 + struct ishtp_cl_driver *driver = to_ishtp_cl_driver(dev->driver); 265 261 266 262 if (device->event_cb) { 267 263 device->event_cb = NULL; 268 264 cancel_work_sync(&device->event_work); 269 265 } 270 266 271 - driver = to_ishtp_cl_driver(dev->driver); 272 - if (!driver->remove) { 273 - dev->driver = NULL; 267 + if (driver->remove) 268 + driver->remove(device); 274 269 275 - return 0; 276 - } 277 - 278 - return driver->remove(device); 270 + return 0; 279 271 } 280 272 281 273 /** ··· 836 842 837 843 /** 838 844 * ishtp_device() - Return device pointer 845 + * @device: ISH-TP client device instance 839 846 * 840 847 * This interface is used to return device pointer from ishtp_cl_device 841 848 * instance. ··· 853 858 * ishtp_get_pci_device() - Return PCI device dev pointer 854 859 * This interface is used to return PCI device pointer 855 860 * from ishtp_cl_device instance. 861 + * @device: ISH-TP client device instance 856 862 * 857 863 * Return: device *. 858 864 */ ··· 865 869 866 870 /** 867 871 * ishtp_trace_callback() - Return trace callback 872 + * @cl_device: ISH-TP client device instance 868 873 * 869 874 * This interface is used to return trace callback function pointer. 870 875 * 871 - * Return: void *. 876 + * Return: *ishtp_print_log() 872 877 */ 873 - void *ishtp_trace_callback(struct ishtp_cl_device *cl_device) 878 + ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device) 874 879 { 875 880 return cl_device->ishtp_dev->print_log; 876 881 } ··· 879 882 880 883 /** 881 884 * ish_hw_reset() - Call HW reset IPC callback 885 + * @dev: ISHTP device instance 882 886 * 883 887 * This interface is used to reset HW in case of error. 884 888 *
+20 -3
drivers/hid/intel-ish-hid/ishtp/client.c
··· 10 10 #include <linux/wait.h> 11 11 #include <linux/delay.h> 12 12 #include <linux/dma-mapping.h> 13 + #include <asm/cacheflush.h> 13 14 #include "hbm.h" 14 15 #include "client.h" 15 16 ··· 112 111 113 112 /** 114 113 * ishtp_cl_allocate() - allocates client structure and sets it up. 115 - * @dev: ishtp device 114 + * @cl_device: ishtp client device 116 115 * 117 116 * Allocate memory for new client device and call to initialize each field. 118 117 * ··· 264 263 int ishtp_cl_disconnect(struct ishtp_cl *cl) 265 264 { 266 265 struct ishtp_device *dev; 267 - int err; 268 266 269 267 if (WARN_ON(!cl || !cl->dev)) 270 268 return -ENODEV; ··· 283 283 return -ENODEV; 284 284 } 285 285 286 - err = wait_event_interruptible_timeout(cl->wait_ctrl_res, 286 + wait_event_interruptible_timeout(cl->wait_ctrl_res, 287 287 (dev->dev_state != ISHTP_DEV_ENABLED || 288 288 cl->state == ISHTP_CL_DISCONNECTED), 289 289 ishtp_secs_to_jiffies(ISHTP_CL_CONNECT_TIMEOUT)); ··· 773 773 /* write msg to dma buf */ 774 774 memcpy(msg_addr, cl_msg->send_buf.data, cl_msg->send_buf.size); 775 775 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 + 776 784 /* send dma_xfer hbm msg */ 777 785 off = msg_addr - (unsigned char *)dev->ishtp_host_dma_tx_buf; 778 786 ishtp_hbm_hdr(&hdr, sizeof(struct dma_xfer_hbm)); ··· 1005 997 } 1006 998 1007 999 buffer = rb->buffer.data; 1000 + 1001 + /* 1002 + * if current fw don't support cache snooping, driver have to 1003 + * flush the cache manually. 1004 + */ 1005 + if (dev->ops->dma_no_cache_snooping && 1006 + dev->ops->dma_no_cache_snooping(dev)) 1007 + clflush_cache_range(msg, hbm->msg_length); 1008 + 1008 1009 memcpy(buffer, msg, hbm->msg_length); 1009 1010 rb->buf_idx = hbm->msg_length; 1010 1011
+5 -5
drivers/hid/intel-ish-hid/ishtp/hbm.c
··· 398 398 } 399 399 400 400 /** 401 - * ishtp_client_disconnect_request() - Receive disconnect request 401 + * ishtp_hbm_fw_disconnect_req() - Receive disconnect request 402 402 * @dev: ISHTP device instance 403 403 * @disconnect_req: disconnect request structure 404 404 * ··· 430 430 } 431 431 432 432 /** 433 - * ishtp_hbm_dma_xfer_ack(() - Receive transfer ACK 433 + * ishtp_hbm_dma_xfer_ack() - Receive transfer ACK 434 434 * @dev: ISHTP device instance 435 435 * @dma_xfer: HBM transfer message 436 436 * ··· 914 914 /*** Suspend and resume notification ***/ 915 915 916 916 static uint32_t current_state; 917 - static uint32_t supported_states = 0 | SUSPEND_STATE_BIT; 917 + static uint32_t supported_states = SUSPEND_STATE_BIT | CONNECTED_STANDBY_STATE_BIT; 918 918 919 919 /** 920 920 * ishtp_send_suspend() - Send suspend message to FW ··· 933 933 memset(&state_status_msg, 0, len); 934 934 state_status_msg.hdr.cmd = SYSTEM_STATE_STATUS; 935 935 state_status_msg.supported_states = supported_states; 936 - current_state |= SUSPEND_STATE_BIT; 936 + current_state |= (SUSPEND_STATE_BIT | CONNECTED_STANDBY_STATE_BIT); 937 937 dev->print_log(dev, "%s() sends SUSPEND notification\n", __func__); 938 938 state_status_msg.states_status = current_state; 939 939 ··· 959 959 memset(&state_status_msg, 0, len); 960 960 state_status_msg.hdr.cmd = SYSTEM_STATE_STATUS; 961 961 state_status_msg.supported_states = supported_states; 962 - current_state &= ~SUSPEND_STATE_BIT; 962 + current_state &= ~(CONNECTED_STANDBY_STATE_BIT | SUSPEND_STATE_BIT); 963 963 dev->print_log(dev, "%s() sends RESUME notification\n", __func__); 964 964 state_status_msg.states_status = current_state; 965 965
+1
drivers/hid/intel-ish-hid/ishtp/hbm.h
··· 235 235 #define SYSTEM_STATE_QUERY_SUBSCRIBERS 0x3 236 236 #define SYSTEM_STATE_STATE_CHANGE_REQ 0x4 237 237 /*indicates suspend and resume states*/ 238 + #define CONNECTED_STANDBY_STATE_BIT (1<<0) 238 239 #define SUSPEND_STATE_BIT (1<<1) 239 240 240 241 struct ish_system_states_header {
+3 -2
drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
··· 10 10 11 11 #include <linux/types.h> 12 12 #include <linux/spinlock.h> 13 + #include <linux/intel-ish-client-if.h> 13 14 #include "bus.h" 14 15 #include "hbm.h" 15 16 ··· 119 118 unsigned long buffer_length); 120 119 uint32_t (*get_fw_status)(struct ishtp_device *dev); 121 120 void (*sync_fw_clock)(struct ishtp_device *dev); 121 + bool (*dma_no_cache_snooping)(struct ishtp_device *dev); 122 122 }; 123 123 124 124 /** ··· 204 202 uint64_t ishtp_host_dma_rx_buf_phys; 205 203 206 204 /* Dump to trace buffers if enabled*/ 207 - __printf(2, 3) void (*print_log)(struct ishtp_device *dev, 208 - const char *format, ...); 205 + ishtp_print_log print_log; 209 206 210 207 /* Debug stats */ 211 208 unsigned int ipc_rx_cnt;
+1 -3
drivers/platform/chrome/cros_ec_ishtp.c
··· 703 703 * 704 704 * Return: 0 705 705 */ 706 - static int cros_ec_ishtp_remove(struct ishtp_cl_device *cl_device) 706 + static void cros_ec_ishtp_remove(struct ishtp_cl_device *cl_device) 707 707 { 708 708 struct ishtp_cl *cros_ish_cl = ishtp_get_drvdata(cl_device); 709 709 struct ishtp_cl_data *client_data = ishtp_get_client_data(cros_ish_cl); ··· 712 712 cancel_work_sync(&client_data->work_ec_evt); 713 713 cros_ish_deinit(cros_ish_cl); 714 714 ishtp_put_device(cl_device); 715 - 716 - return 0; 717 715 } 718 716 719 717 /**
+8 -2
include/linux/intel-ish-client-if.h
··· 8 8 #ifndef _INTEL_ISH_CLIENT_IF_H_ 9 9 #define _INTEL_ISH_CLIENT_IF_H_ 10 10 11 + #include <linux/device.h> 12 + #include <linux/uuid.h> 13 + 11 14 struct ishtp_cl_device; 12 15 struct ishtp_device; 13 16 struct ishtp_cl; 14 17 struct ishtp_fw_client; 18 + 19 + typedef __printf(2, 3) void (*ishtp_print_log)(struct ishtp_device *dev, 20 + const char *format, ...); 15 21 16 22 /* Client state */ 17 23 enum cl_state { ··· 42 36 const char *name; 43 37 const guid_t *guid; 44 38 int (*probe)(struct ishtp_cl_device *dev); 45 - int (*remove)(struct ishtp_cl_device *dev); 39 + void (*remove)(struct ishtp_cl_device *dev); 46 40 int (*reset)(struct ishtp_cl_device *dev); 47 41 const struct dev_pm_ops *pm; 48 42 }; ··· 82 76 /* Get the device * from ishtp device instance */ 83 77 struct device *ishtp_device(struct ishtp_cl_device *cl_device); 84 78 /* Trace interface for clients */ 85 - void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); 79 + ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device); 86 80 /* Get device pointer of PCI device for DMA acces */ 87 81 struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device); 88 82