Skip to content

Commit 33197bd

Browse files
author
Jiri Kosina
committed
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
2 parents 7f1f380 + aa59d6b commit 33197bd

File tree

14 files changed

+113
-71
lines changed

14 files changed

+113
-71
lines changed

drivers/hid/intel-ish-hid/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ menu "Intel ISH HID support"
55
config INTEL_ISH_HID
66
tristate "Intel Integrated Sensor Hub"
77
default n
8+
depends on X86
89
select HID
910
help
1011
The Integrated Sensor Hub (ISH) enables the ability to offload

drivers/hid/intel-ish-hid/ipc/ipc.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
544544
#define TIMEOUT_FOR_HW_RDY_MS 300
545545

546546
/**
547-
* ish_fw_reset_work_fn() - FW reset worker function
547+
* fw_reset_work_fn() - FW reset worker function
548548
* @unused: not used
549549
*
550550
* Call ish_fw_reset_handler to complete FW reset
@@ -889,6 +889,29 @@ static uint32_t ish_ipc_get_header(struct ishtp_device *dev, int length,
889889
return drbl_val;
890890
}
891891

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+
892915
static const struct ishtp_hw_ops ish_hw_ops = {
893916
.hw_reset = _ish_hw_reset,
894917
.ipc_reset = _ish_ipc_reset,
@@ -897,7 +920,8 @@ static const struct ishtp_hw_ops ish_hw_ops = {
897920
.write = write_ipc_to_queue,
898921
.get_fw_status = _ish_read_fw_sts_reg,
899922
.sync_fw_clock = _ish_sync_fw_clock,
900-
.ishtp_read_hdr = _ishtp_read_hdr
923+
.ishtp_read_hdr = _ishtp_read_hdr,
924+
.dma_no_cache_snooping = _dma_no_cache_snooping
901925
};
902926

903927
/**

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ static void __maybe_unused ish_resume_handler(struct work_struct *work)
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);
266-
int ret;
267266

268267
if (ish_should_leave_d0i3(pdev) && !dev->suspend_flag
269268
&& IPC_IS_ISH_ILUP(fwsts)) {
@@ -275,7 +274,7 @@ static void __maybe_unused ish_resume_handler(struct work_struct *work)
275274

276275
/* Waiting to get resume response */
277276
if (dev->resume_flag)
278-
ret = wait_event_interruptible_timeout(dev->resume_wait,
277+
wait_event_interruptible_timeout(dev->resume_wait,
279278
!dev->resume_flag,
280279
msecs_to_jiffies(WAIT_FOR_RESUME_ACK_MS));
281280

drivers/hid/intel-ish-hid/ishtp-fw-loader.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
/**
3333
* 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
3535
* 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
3737
* time. The command may be executed
3838
* multiple times until the entire firmware
3939
* image is downloaded to SRAM.
40-
* LOADER_CMD_START Start executing the main firmware.
40+
* @LOADER_CMD_START: Start executing the main firmware.
4141
*/
4242
enum ish_loader_commands {
4343
LOADER_CMD_XFER_QUERY = 0,
@@ -95,6 +95,7 @@ static int dma_buf_size_limit = 4 * PAGE_SIZE;
9595
/**
9696
* struct loader_msg_hdr - Header for ISH Loader commands.
9797
* @command: LOADER_CMD* commands. Bit 7 is the response.
98+
* @reserved: Reserved space
9899
* @status: Command response status. Non 0, is error
99100
* condition.
100101
*
@@ -173,16 +174,16 @@ struct loader_start {
173174
* struct response_info - Encapsulate firmware response related
174175
* information for passing between function
175176
* loader_cl_send() and process_recv() callback.
176-
* @data Copy the data received from firmware here.
177-
* @max_size Max size allocated for the @data buffer. If the
177+
* @data: Copy the data received from firmware here.
178+
* @max_size: Max size allocated for the @data buffer. If the
178179
* received data exceeds this value, we log an
179180
* error.
180-
* @size Actual size of data received from firmware.
181-
* @error Returns 0 for success, negative error code for a
181+
* @size: Actual size of data received from firmware.
182+
* @error: Returns 0 for success, negative error code for a
182183
* failure in function process_recv().
183-
* @received Set to true on receiving a valid firmware
184+
* @received: Set to true on receiving a valid firmware
184185
* response to host command
185-
* @wait_queue Wait queue for Host firmware loading where the
186+
* @wait_queue: Wait queue for Host firmware loading where the
186187
* client sends message to ISH firmware and waits
187188
* for response
188189
*/
@@ -195,13 +196,13 @@ struct response_info {
195196
wait_queue_head_t wait_queue;
196197
};
197198

198-
/**
199+
/*
199200
* struct ishtp_cl_data - Encapsulate per ISH-TP Client Data.
200201
* @work_ishtp_reset: Work queue for reset handling.
201202
* @work_fw_load: Work queue for host firmware loading.
202-
* @flag_retry Flag for indicating host firmware loading should
203+
* @flag_retry: Flag for indicating host firmware loading should
203204
* be retried.
204-
* @retry_count Count the number of retries.
205+
* @retry_count: Count the number of retries.
205206
*
206207
* This structure is used to store data per client.
207208
*/
@@ -240,8 +241,8 @@ struct ishtp_cl_data {
240241
/**
241242
* get_firmware_variant() - Gets the filename of firmware image to be
242243
* loaded based on platform variant.
243-
* @client_data Client data instance.
244-
* @filename Returns firmware filename.
244+
* @client_data: Client data instance.
245+
* @filename: Returns firmware filename.
245246
*
246247
* Queries the firmware-name device property string.
247248
*
@@ -266,11 +267,11 @@ static int get_firmware_variant(struct ishtp_cl_data *client_data,
266267
/**
267268
* loader_cl_send() Send message from host to firmware
268269
* @client_data: Client data instance
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.
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.
272273
* This buffer is allocated by calling
273-
* @in_size Max size of incoming message
274+
* @in_size: Max size of incoming message
274275
*
275276
* Return: Number of bytes copied in the in_msg on success, negative
276277
* error code on failure.
@@ -435,7 +436,7 @@ static void process_recv(struct ishtp_cl *loader_ishtp_cl,
435436

436437
/**
437438
* loader_cl_event_cb() - bus driver callback for incoming message
438-
* @device: Pointer to the ishtp client device for which this
439+
* @cl_device: Pointer to the ishtp client device for which this
439440
* message is targeted
440441
*
441442
* Remove the packet from the list and process the message by calling
@@ -536,7 +537,7 @@ static int ish_query_loader_prop(struct ishtp_cl_data *client_data,
536537
}
537538

538539
/**
539-
* ish_fw_xfer_ishtp() Loads ISH firmware using ishtp interface
540+
* ish_fw_xfer_ishtp() - Loads ISH firmware using ishtp interface
540541
* @client_data: Client data instance
541542
* @fw: Pointer to firmware data struct in host memory
542543
*
@@ -733,7 +734,7 @@ static int ish_fw_xfer_direct_dma(struct ishtp_cl_data *client_data,
733734
}
734735

735736
/**
736-
* ish_fw_start() Start executing ISH main firmware
737+
* ish_fw_start() - Start executing ISH main firmware
737738
* @client_data: client data instance
738739
*
739740
* This function sends message to Shim firmware loader to start
@@ -756,7 +757,7 @@ static int ish_fw_start(struct ishtp_cl_data *client_data)
756757
}
757758

758759
/**
759-
* load_fw_from_host() Loads ISH firmware from host
760+
* load_fw_from_host() - Loads ISH firmware from host
760761
* @client_data: Client data instance
761762
*
762763
* This function loads the ISH firmware to ISH SRAM and starts execution
@@ -1015,7 +1016,7 @@ static int loader_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
10151016
*
10161017
* Return: 0
10171018
*/
1018-
static int loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
1019+
static void loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
10191020
{
10201021
struct ishtp_cl_data *client_data;
10211022
struct ishtp_cl *loader_ishtp_cl = ishtp_get_drvdata(cl_device);
@@ -1032,8 +1033,6 @@ static int loader_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
10321033
cancel_work_sync(&client_data->work_ishtp_reset);
10331034
loader_deinit(loader_ishtp_cl);
10341035
ishtp_put_device(cl_device);
1035-
1036-
return 0;
10371036
}
10381037

10391038
/**

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
#include <linux/sched.h>
1212
#include "ishtp-hid.h"
1313

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+
1419
/* Rx ring buffer pool size */
1520
#define HID_CL_RX_RING_SIZE 32
1621
#define HID_CL_TX_RING_SIZE 16
1722

1823
#define cl_data_to_dev(client_data) ishtp_device(client_data->cl_device)
1924

2025
/**
21-
* report_bad_packets() - Report bad packets
26+
* report_bad_packet() - Report bad packets
2227
* @hid_ishtp_cl: Client instance to get stats
2328
* @recv_buf: Raw received host interface message
2429
* @cur_pos: Current position index in payload
@@ -779,7 +784,7 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work)
779784
}
780785
}
781786

782-
void (*hid_print_trace)(void *unused, const char *format, ...);
787+
ishtp_print_log ishtp_hid_print_trace;
783788

784789
/**
785790
* hid_ishtp_cl_probe() - ISHTP client driver probe
@@ -818,7 +823,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
818823

819824
INIT_WORK(&client_data->work, hid_ishtp_cl_reset_handler);
820825

821-
hid_print_trace = ishtp_trace_callback(cl_device);
826+
ishtp_hid_print_trace = ishtp_trace_callback(cl_device);
822827

823828
rv = hid_ishtp_cl_init(hid_ishtp_cl, 0);
824829
if (rv) {
@@ -838,7 +843,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
838843
*
839844
* Return: 0
840845
*/
841-
static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
846+
static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
842847
{
843848
struct ishtp_cl *hid_ishtp_cl = ishtp_get_drvdata(cl_device);
844849
struct ishtp_cl_data *client_data = ishtp_get_client_data(hid_ishtp_cl);
@@ -856,8 +861,6 @@ static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
856861
hid_ishtp_cl = NULL;
857862

858863
client_data->num_hid_devices = 0;
859-
860-
return 0;
861864
}
862865

863866
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int ishtp_hid_probe(unsigned int cur_hid_dev,
254254
}
255255

256256
/**
257-
* ishtp_hid_probe() - Remove registered hid device
257+
* ishtp_hid_remove() - Remove registered hid device
258258
* @client_data: client data pointer
259259
*
260260
* This function is used to destroy allocatd HID device.

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@
1616
#define IS_RESPONSE 0x80
1717

1818
/* 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;
2020
#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__)
2722

2823
/* ISH HID message structure */
2924
struct hostif_msg_hdr {

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ EXPORT_SYMBOL(ishtp_fw_cl_get_client);
164164

165165
/**
166166
* ishtp_get_fw_client_id() - Get fw client id
167+
* @fw_client: firmware client used to fetch the ID
167168
*
168169
* This interface is used to reset HW get FW client id.
169170
*
@@ -257,24 +258,17 @@ static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv)
257258
static int ishtp_cl_device_remove(struct device *dev)
258259
{
259260
struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
260-
struct ishtp_cl_driver *driver;
261-
262-
if (!device || !dev->driver)
263-
return 0;
261+
struct ishtp_cl_driver *driver = to_ishtp_cl_driver(dev->driver);
264262

265263
if (device->event_cb) {
266264
device->event_cb = NULL;
267265
cancel_work_sync(&device->event_work);
268266
}
269267

270-
driver = to_ishtp_cl_driver(dev->driver);
271-
if (!driver->remove) {
272-
dev->driver = NULL;
268+
if (driver->remove)
269+
driver->remove(device);
273270

274-
return 0;
275-
}
276-
277-
return driver->remove(device);
271+
return 0;
278272
}
279273

280274
/**
@@ -842,6 +836,7 @@ int ishtp_use_dma_transfer(void)
842836

843837
/**
844838
* ishtp_device() - Return device pointer
839+
* @device: ISH-TP client device instance
845840
*
846841
* This interface is used to return device pointer from ishtp_cl_device
847842
* instance.
@@ -858,6 +853,7 @@ EXPORT_SYMBOL(ishtp_device);
858853
* ishtp_get_pci_device() - Return PCI device dev pointer
859854
* This interface is used to return PCI device pointer
860855
* from ishtp_cl_device instance.
856+
* @device: ISH-TP client device instance
861857
*
862858
* Return: device *.
863859
*/
@@ -869,19 +865,21 @@ EXPORT_SYMBOL(ishtp_get_pci_device);
869865

870866
/**
871867
* ishtp_trace_callback() - Return trace callback
868+
* @cl_device: ISH-TP client device instance
872869
*
873870
* This interface is used to return trace callback function pointer.
874871
*
875-
* Return: void *.
872+
* Return: *ishtp_print_log()
876873
*/
877-
void *ishtp_trace_callback(struct ishtp_cl_device *cl_device)
874+
ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device)
878875
{
879876
return cl_device->ishtp_dev->print_log;
880877
}
881878
EXPORT_SYMBOL(ishtp_trace_callback);
882879

883880
/**
884881
* ish_hw_reset() - Call HW reset IPC callback
882+
* @dev: ISHTP device instance
885883
*
886884
* This interface is used to reset HW in case of error.
887885
*

0 commit comments

Comments
 (0)