hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/misc/mei/mei_dev.h
....@@ -1,17 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
2
- *
3
+ * Copyright (c) 2003-2019, Intel Corporation. All rights reserved.
34 * Intel Management Engine Interface (Intel MEI) Linux driver
4
- * Copyright (c) 2003-2018, Intel Corporation.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
155 */
166
177 #ifndef _MEI_DEV_H_
....@@ -122,6 +112,19 @@
122112 unsigned char *data;
123113 };
124114
115
+/**
116
+ * struct mei_dma_dscr - dma address descriptor
117
+ *
118
+ * @vaddr: dma buffer virtual address
119
+ * @daddr: dma buffer physical address
120
+ * @size : dma buffer size
121
+ */
122
+struct mei_dma_dscr {
123
+ void *vaddr;
124
+ dma_addr_t daddr;
125
+ size_t size;
126
+};
127
+
125128 /* Maximum number of processed FW status registers */
126129 #define MEI_FW_STATUS_MAX 6
127130 /* Minimal buffer for FW status string (8 bytes in dw + space or '\0') */
....@@ -171,6 +174,7 @@
171174 * @fop_type: file operation type
172175 * @buf: buffer for data associated with the callback
173176 * @buf_idx: last read index
177
+ * @vtag: virtual tag
174178 * @fp: pointer to file structure
175179 * @status: io status of the cb
176180 * @internal: communication between driver and FW flag
....@@ -182,10 +186,26 @@
182186 enum mei_cb_file_ops fop_type;
183187 struct mei_msg_data buf;
184188 size_t buf_idx;
189
+ u8 vtag;
185190 const struct file *fp;
186191 int status;
187192 u32 internal:1;
188193 u32 blocking:1;
194
+};
195
+
196
+/**
197
+ * struct mei_cl_vtag - file pointer to vtag mapping structure
198
+ *
199
+ * @list: link in map queue
200
+ * @fp: file pointer
201
+ * @vtag: corresponding vtag
202
+ * @pending_read: the read is pending on this file
203
+ */
204
+struct mei_cl_vtag {
205
+ struct list_head list;
206
+ const struct file *fp;
207
+ u8 vtag;
208
+ u8 pending_read:1;
189209 };
190210
191211 /**
....@@ -204,6 +224,7 @@
204224 * @me_cl: fw client connected
205225 * @fp: file associated with client
206226 * @host_client_id: host id
227
+ * @vtag_map: vtag map
207228 * @tx_flow_ctrl_creds: transmit flow credentials
208229 * @rx_flow_ctrl_creds: receive flow credentials
209230 * @timer_count: watchdog timer for operation completion
....@@ -212,6 +233,7 @@
212233 * @tx_cb_queued: number of tx callbacks in queue
213234 * @writing_state: state of the tx
214235 * @rd_pending: pending read credits
236
+ * @rd_completed_lock: protects rd_completed queue
215237 * @rd_completed: completed read
216238 *
217239 * @cldev: device on the mei client bus
....@@ -229,6 +251,7 @@
229251 struct mei_me_client *me_cl;
230252 const struct file *fp;
231253 u8 host_client_id;
254
+ struct list_head vtag_map;
232255 u8 tx_flow_ctrl_creds;
233256 u8 rx_flow_ctrl_creds;
234257 u8 timer_count;
....@@ -237,6 +260,7 @@
237260 u8 tx_cb_queued;
238261 enum mei_file_transaction_states writing_state;
239262 struct list_head rd_pending;
263
+ spinlock_t rd_completed_lock; /* protects rd_completed queue */
240264 struct list_head rd_completed;
241265
242266 struct mei_cl_device *cldev;
....@@ -257,6 +281,7 @@
257281 * @hw_config : configure hw
258282 *
259283 * @fw_status : get fw status registers
284
+ * @trc_status : get trc status register
260285 * @pg_state : power gating state of the device
261286 * @pg_in_transition : is device now in pg transition
262287 * @pg_is_enabled : is power gating enabled
....@@ -284,9 +309,11 @@
284309 bool (*hw_is_ready)(struct mei_device *dev);
285310 int (*hw_reset)(struct mei_device *dev, bool enable);
286311 int (*hw_start)(struct mei_device *dev);
287
- void (*hw_config)(struct mei_device *dev);
312
+ int (*hw_config)(struct mei_device *dev);
288313
289314 int (*fw_status)(struct mei_device *dev, struct mei_fw_status *fw_sts);
315
+ int (*trc_status)(struct mei_device *dev, u32 *trc);
316
+
290317 enum mei_pg_state (*pg_state)(struct mei_device *dev);
291318 bool (*pg_in_transition)(struct mei_device *dev);
292319 bool (*pg_is_enabled)(struct mei_device *dev);
....@@ -407,8 +434,10 @@
407434 *
408435 * @rd_msg_buf : control messages buffer
409436 * @rd_msg_hdr : read message header storage
437
+ * @rd_msg_hdr_count : how many dwords were already read from header
410438 *
411439 * @hbuf_is_ready : query if the host host/write buffer is ready
440
+ * @dr_dscr: DMA ring descriptors: TX, RX, and CTRL
412441 *
413442 * @version : HBM protocol version in use
414443 * @hbm_f_pg_supported : hbm feature pgi protocol
....@@ -419,6 +448,8 @@
419448 * @hbm_f_ie_supported : hbm feature immediate reply to enum request
420449 * @hbm_f_os_supported : hbm feature support OS ver message
421450 * @hbm_f_dr_supported : hbm feature dma ring supported
451
+ * @hbm_f_vt_supported : hbm feature vtag supported
452
+ * @hbm_f_cap_supported : hbm feature capabilities message supported
422453 *
423454 * @fw_ver : FW versions
424455 *
....@@ -437,6 +468,8 @@
437468 *
438469 * @device_list : mei client bus list
439470 * @cl_bus_lock : client bus list lock
471
+ *
472
+ * @kind : kind of mei device
440473 *
441474 * @dbgfs_dir : debugfs mei root directory
442475 *
....@@ -485,10 +518,13 @@
485518 #endif /* CONFIG_PM */
486519
487520 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE];
488
- u32 rd_msg_hdr;
521
+ u32 rd_msg_hdr[MEI_RD_MSG_BUF_SIZE];
522
+ int rd_msg_hdr_count;
489523
490524 /* write buffer */
491525 bool hbuf_is_ready;
526
+
527
+ struct mei_dma_dscr dr_dscr[DMA_DSCR_NUM];
492528
493529 struct hbm_version version;
494530 unsigned int hbm_f_pg_supported:1;
....@@ -499,6 +535,8 @@
499535 unsigned int hbm_f_ie_supported:1;
500536 unsigned int hbm_f_os_supported:1;
501537 unsigned int hbm_f_dr_supported:1;
538
+ unsigned int hbm_f_vt_supported:1;
539
+ unsigned int hbm_f_cap_supported:1;
502540
503541 struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS];
504542
....@@ -519,13 +557,14 @@
519557 struct list_head device_list;
520558 struct mutex cl_bus_lock;
521559
560
+ const char *kind;
561
+
522562 #if IS_ENABLED(CONFIG_DEBUG_FS)
523563 struct dentry *dbgfs_dir;
524564 #endif /* CONFIG_DEBUG_FS */
525565
526
-
527566 const struct mei_hw_ops *ops;
528
- char hw[0] __aligned(sizeof(void *));
567
+ char hw[] __aligned(sizeof(void *));
529568 };
530569
531570 static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
....@@ -582,6 +621,16 @@
582621 void mei_stop(struct mei_device *dev);
583622 void mei_cancel_work(struct mei_device *dev);
584623
624
+void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state);
625
+
626
+int mei_dmam_ring_alloc(struct mei_device *dev);
627
+void mei_dmam_ring_free(struct mei_device *dev);
628
+bool mei_dma_ring_is_allocated(struct mei_device *dev);
629
+void mei_dma_ring_reset(struct mei_device *dev);
630
+void mei_dma_ring_read(struct mei_device *dev, unsigned char *buf, u32 len);
631
+void mei_dma_ring_write(struct mei_device *dev, unsigned char *buf, u32 len);
632
+u32 mei_dma_ring_empty_slots(struct mei_device *dev);
633
+
585634 /*
586635 * MEI interrupt functions prototype
587636 */
....@@ -599,9 +648,9 @@
599648 */
600649
601650
602
-static inline void mei_hw_config(struct mei_device *dev)
651
+static inline int mei_hw_config(struct mei_device *dev)
603652 {
604
- dev->ops->hw_config(dev);
653
+ return dev->ops->hw_config(dev);
605654 }
606655
607656 static inline enum mei_pg_state mei_pg_state(struct mei_device *dev)
....@@ -696,6 +745,13 @@
696745 return dev->ops->rdbuf_full_slots(dev);
697746 }
698747
748
+static inline int mei_trc_status(struct mei_device *dev, u32 *trc)
749
+{
750
+ if (dev->ops->trc_status)
751
+ return dev->ops->trc_status(dev, trc);
752
+ return -EOPNOTSUPP;
753
+}
754
+
699755 static inline int mei_fw_status(struct mei_device *dev,
700756 struct mei_fw_status *fw_status)
701757 {
....@@ -707,23 +763,21 @@
707763 bool mei_write_is_idle(struct mei_device *dev);
708764
709765 #if IS_ENABLED(CONFIG_DEBUG_FS)
710
-int mei_dbgfs_register(struct mei_device *dev, const char *name);
766
+void mei_dbgfs_register(struct mei_device *dev, const char *name);
711767 void mei_dbgfs_deregister(struct mei_device *dev);
712768 #else
713
-static inline int mei_dbgfs_register(struct mei_device *dev, const char *name)
714
-{
715
- return 0;
716
-}
769
+static inline void mei_dbgfs_register(struct mei_device *dev, const char *name) {}
717770 static inline void mei_dbgfs_deregister(struct mei_device *dev) {}
718771 #endif /* CONFIG_DEBUG_FS */
719772
720773 int mei_register(struct mei_device *dev, struct device *parent);
721774 void mei_deregister(struct mei_device *dev);
722775
723
-#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d internal=%1d comp=%1d"
776
+#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d ext=%1d internal=%1d comp=%1d"
724777 #define MEI_HDR_PRM(hdr) \
725778 (hdr)->host_addr, (hdr)->me_addr, \
726
- (hdr)->length, (hdr)->dma_ring, (hdr)->internal, (hdr)->msg_complete
779
+ (hdr)->length, (hdr)->dma_ring, (hdr)->extended, \
780
+ (hdr)->internal, (hdr)->msg_complete
727781
728782 ssize_t mei_fw_status2str(struct mei_fw_status *fw_sts, char *buf, size_t len);
729783 /**