forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/misc/mei/bus-fixup.c
....@@ -1,23 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
2
- *
3
+ * Copyright (c) 2013-2020, 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 #include <linux/kernel.h>
188 #include <linux/sched.h>
199 #include <linux/module.h>
20
-#include <linux/moduleparam.h>
2110 #include <linux/device.h>
2211 #include <linux/slab.h>
2312 #include <linux/uuid.h>
....@@ -41,6 +30,9 @@
4130 #define MEI_UUID_MKHIF_FIX UUID_LE(0x55213584, 0x9a29, 0x4916, \
4231 0xba, 0xdf, 0xf, 0xb7, 0xed, 0x68, 0x2a, 0xeb)
4332
33
+#define MEI_UUID_HDCP UUID_LE(0xB638AB7E, 0x94E2, 0x4EA2, \
34
+ 0xA5, 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04)
35
+
4436 #define MEI_UUID_ANY NULL_UUID_LE
4537
4638 /**
....@@ -54,8 +46,6 @@
5446 */
5547 static void number_of_connections(struct mei_cl_device *cldev)
5648 {
57
- dev_dbg(&cldev->dev, "running hook %s\n", __func__);
58
-
5949 if (cldev->me_cl->props.max_number_of_connections > 1)
6050 cldev->do_match = 0;
6151 }
....@@ -67,9 +57,17 @@
6757 */
6858 static void blacklist(struct mei_cl_device *cldev)
6959 {
70
- dev_dbg(&cldev->dev, "running hook %s\n", __func__);
71
-
7260 cldev->do_match = 0;
61
+}
62
+
63
+/**
64
+ * whitelist - forcefully whitelist client
65
+ *
66
+ * @cldev: me clients device
67
+ */
68
+static void whitelist(struct mei_cl_device *cldev)
69
+{
70
+ cldev->do_match = 1;
7371 }
7472
7573 #define OSTYPE_LINUX 2
....@@ -93,7 +91,7 @@
9391 struct mkhi_fwcaps {
9492 struct mkhi_rule_id id;
9593 u8 len;
96
- u8 data[0];
94
+ u8 data[];
9795 } __packed;
9896
9997 struct mkhi_fw_ver_block {
....@@ -121,7 +119,7 @@
121119
122120 struct mkhi_msg {
123121 struct mkhi_msg_hdr hdr;
124
- u8 data[0];
122
+ u8 data[];
125123 } __packed;
126124
127125 #define MKHI_OSVER_BUF_LEN (sizeof(struct mkhi_msg_hdr) + \
....@@ -161,20 +159,20 @@
161159 static int mei_fwver(struct mei_cl_device *cldev)
162160 {
163161 char buf[MKHI_FWVER_BUF_LEN];
164
- struct mkhi_msg *req;
162
+ struct mkhi_msg req;
163
+ struct mkhi_msg *rsp;
165164 struct mkhi_fw_ver *fwver;
166165 int bytes_recv, ret, i;
167166
168167 memset(buf, 0, sizeof(buf));
169168
170
- req = (struct mkhi_msg *)buf;
171
- req->hdr.group_id = MKHI_GEN_GROUP_ID;
172
- req->hdr.command = MKHI_GEN_GET_FW_VERSION_CMD;
169
+ req.hdr.group_id = MKHI_GEN_GROUP_ID;
170
+ req.hdr.command = MKHI_GEN_GET_FW_VERSION_CMD;
173171
174
- ret = __mei_cl_send(cldev->cl, buf, sizeof(struct mkhi_msg_hdr),
172
+ ret = __mei_cl_send(cldev->cl, (u8 *)&req, sizeof(req),
175173 MEI_CL_IO_TX_BLOCKING);
176174 if (ret < 0) {
177
- dev_err(&cldev->dev, "Could not send ReqFWVersion cmd\n");
175
+ dev_err(&cldev->dev, "Could not send ReqFWVersion cmd ret = %d\n", ret);
178176 return ret;
179177 }
180178
....@@ -186,11 +184,12 @@
186184 * Should be at least one version block,
187185 * error out if nothing found
188186 */
189
- dev_err(&cldev->dev, "Could not read FW version\n");
187
+ dev_err(&cldev->dev, "Could not read FW version ret = %d\n", bytes_recv);
190188 return -EIO;
191189 }
192190
193
- fwver = (struct mkhi_fw_ver *)req->data;
191
+ rsp = (struct mkhi_msg *)buf;
192
+ fwver = (struct mkhi_fw_ver *)rsp->data;
194193 memset(cldev->bus->fw_ver, 0, sizeof(cldev->bus->fw_ver));
195194 for (i = 0; i < MEI_MAX_FW_VER_BLOCKS; i++) {
196195 if ((size_t)bytes_recv < MKHI_FWVER_LEN(i + 1))
....@@ -252,7 +251,6 @@
252251 {
253252 struct pci_dev *pdev = to_pci_dev(cldev->dev.parent);
254253
255
- dev_dbg(&cldev->dev, "running hook %s\n", __func__);
256254 if (pdev->device == MEI_DEV_ID_WPT_LP ||
257255 pdev->device == MEI_DEV_ID_SPT ||
258256 pdev->device == MEI_DEV_ID_SPT_H)
....@@ -332,16 +330,14 @@
332330
333331 WARN_ON(mutex_is_locked(&bus->device_lock));
334332
335
- ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd),
336
- MEI_CL_IO_TX_BLOCKING);
333
+ ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(cmd), MEI_CL_IO_TX_BLOCKING);
337334 if (ret < 0) {
338
- dev_err(bus->dev, "Could not send IF version cmd\n");
335
+ dev_err(bus->dev, "Could not send IF version cmd ret = %d\n", ret);
339336 return ret;
340337 }
341338
342339 /* to be sure on the stack we alloc memory */
343
- if_version_length = sizeof(struct mei_nfc_reply) +
344
- sizeof(struct mei_nfc_if_version);
340
+ if_version_length = sizeof(*reply) + sizeof(*ver);
345341
346342 reply = kzalloc(if_version_length, GFP_KERNEL);
347343 if (!reply)
....@@ -350,12 +346,12 @@
350346 ret = 0;
351347 bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length, 0, 0);
352348 if (bytes_recv < 0 || (size_t)bytes_recv < if_version_length) {
353
- dev_err(bus->dev, "Could not read IF version\n");
349
+ dev_err(bus->dev, "Could not read IF version ret = %d\n", bytes_recv);
354350 ret = -EIO;
355351 goto err;
356352 }
357353
358
- memcpy(ver, reply->data, sizeof(struct mei_nfc_if_version));
354
+ memcpy(ver, reply->data, sizeof(*ver));
359355
360356 dev_info(bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n",
361357 ver->fw_ivn, ver->vendor_id, ver->radio_type);
....@@ -405,8 +401,6 @@
405401 int ret;
406402
407403 bus = cldev->bus;
408
-
409
- dev_dbg(&cldev->dev, "running hook %s\n", __func__);
410404
411405 mutex_lock(&bus->device_lock);
412406 /* we need to connect to INFO GUID */
....@@ -469,6 +463,17 @@
469463 dev_dbg(bus->dev, "end of fixup match = %d\n", cldev->do_match);
470464 }
471465
466
+/**
467
+ * vt_support - enable on bus clients with vtag support
468
+ *
469
+ * @cldev: me clients device
470
+ */
471
+static void vt_support(struct mei_cl_device *cldev)
472
+{
473
+ if (cldev->me_cl->props.vt_supported == 1)
474
+ cldev->do_match = 1;
475
+}
476
+
472477 #define MEI_FIXUP(_uuid, _hook) { _uuid, _hook }
473478
474479 static struct mei_fixup {
....@@ -481,6 +486,8 @@
481486 MEI_FIXUP(MEI_UUID_NFC_HCI, mei_nfc),
482487 MEI_FIXUP(MEI_UUID_WD, mei_wd),
483488 MEI_FIXUP(MEI_UUID_MKHIF_FIX, mei_mkhi_fix),
489
+ MEI_FIXUP(MEI_UUID_HDCP, whitelist),
490
+ MEI_FIXUP(MEI_UUID_ANY, vt_support),
484491 };
485492
486493 /**