hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/qcom/venus/hfi_venus.c
....@@ -1,16 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
34 * Copyright (C) 2017 Linaro Ltd.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 and
7
- * only version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
145 */
156
167 #include <linux/delay.h>
....@@ -19,7 +10,6 @@
1910 #include <linux/interrupt.h>
2011 #include <linux/iopoll.h>
2112 #include <linux/kernel.h>
22
-#include <linux/qcom_scm.h>
2313 #include <linux/slab.h>
2414
2515 #include "core.h"
....@@ -27,6 +17,7 @@
2717 #include "hfi_msgs.h"
2818 #include "hfi_venus.h"
2919 #include "hfi_venus_io.h"
20
+#include "firmware.h"
3021
3122 #define HFI_MASK_QHDR_TX_TYPE 0xff000000
3223 #define HFI_MASK_QHDR_RX_TYPE 0x00ff0000
....@@ -54,11 +45,6 @@
5445 #define IFACEQ_VAR_SMALL_PKT_SIZE 100
5546 #define IFACEQ_VAR_LARGE_PKT_SIZE 512
5647 #define IFACEQ_VAR_HUGE_PKT_SIZE (1024 * 12)
57
-
58
-enum tzbsp_video_state {
59
- TZBSP_VIDEO_STATE_SUSPEND = 0,
60
- TZBSP_VIDEO_STATE_RESUME
61
-};
6248
6349 struct hfi_queue_table_header {
6450 u32 version;
....@@ -144,7 +130,7 @@
144130 };
145131
146132 static bool venus_pkt_debug;
147
-static int venus_fw_debug = HFI_DEBUG_MSG_ERROR | HFI_DEBUG_MSG_FATAL;
133
+int venus_fw_debug = HFI_DEBUG_MSG_ERROR | HFI_DEBUG_MSG_FATAL;
148134 static bool venus_sys_idle_indicator;
149135 static bool venus_fw_low_power_mode = true;
150136 static int venus_hw_rsp_timeout = 1000;
....@@ -491,7 +477,7 @@
491477 minor = minor >> WRAPPER_HW_VERSION_MINOR_VERSION_SHIFT;
492478 step = ver & WRAPPER_HW_VERSION_STEP_VERSION_MASK;
493479
494
- dev_dbg(dev, "venus hw version %x.%x.%x\n", major, minor, step);
480
+ dev_dbg(dev, VDBGL "venus hw version %x.%x.%x\n", major, minor, step);
495481
496482 return major;
497483 }
....@@ -575,7 +561,7 @@
575561 if (!hdev->power_enabled)
576562 return 0;
577563
578
- ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
564
+ ret = venus_set_hw_state_suspend(hdev->core);
579565 if (ret)
580566 return ret;
581567
....@@ -595,7 +581,7 @@
595581 if (hdev->power_enabled)
596582 return 0;
597583
598
- ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0);
584
+ ret = venus_set_hw_state_resume(hdev->core);
599585 if (ret)
600586 goto err;
601587
....@@ -608,7 +594,7 @@
608594 return 0;
609595
610596 err_suspend:
611
- qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
597
+ venus_set_hw_state_suspend(hdev->core);
612598 err:
613599 hdev->power_enabled = false;
614600 return ret;
....@@ -920,7 +906,7 @@
920906 if (pkt->hdr.pkt_type != HFI_MSG_SYS_COV) {
921907 struct hfi_msg_sys_debug_pkt *pkt = packet;
922908
923
- dev_dbg(dev, "%s", pkt->msg_data);
909
+ dev_dbg(dev, VDBGFW "%s", pkt->msg_data);
924910 }
925911 }
926912 }
....@@ -1000,13 +986,6 @@
1000986
1001987 venus_set_state(hdev, VENUS_STATE_DEINIT);
1002988
1003
- /*
1004
- * Once SYS_ERROR received from HW, it is safe to halt the AXI.
1005
- * With SYS_ERROR, Venus FW may have crashed and HW might be
1006
- * active and causing unnecessary transactions. Hence it is
1007
- * safe to stop all AXI transactions from venus subsystem.
1008
- */
1009
- venus_halt_axi(hdev);
1010989 venus_sfr_print(hdev);
1011990 }
1012991
....@@ -1023,10 +1002,6 @@
10231002 res = hdev->core->res;
10241003 pkt = hdev->pkt_buf;
10251004
1026
- if (hdev->irq_status & WRAPPER_INTR_STATUS_A2HWD_MASK) {
1027
- venus_sfr_print(hdev);
1028
- hfi_process_watchdog_timeout(core);
1029
- }
10301005
10311006 while (!venus_iface_msgq_read(hdev, pkt)) {
10321007 msg_ret = hfi_process_msg_packet(core, pkt);
....@@ -1146,6 +1121,10 @@
11461121 struct venus_hfi_device *hdev = to_hfi_priv(inst->core);
11471122 struct hfi_session_init_pkt pkt;
11481123 int ret;
1124
+
1125
+ ret = venus_sys_set_debug(hdev, venus_fw_debug);
1126
+ if (ret)
1127
+ goto err;
11491128
11501129 ret = pkt_session_init(&pkt, inst, session_type, codec);
11511130 if (ret)
....@@ -1355,6 +1334,8 @@
13551334 pkt = (struct hfi_session_set_property_pkt *)packet;
13561335
13571336 ret = pkt_session_set_property(pkt, inst, ptype, pdata);
1337
+ if (ret == -ENOTSUPP)
1338
+ return 0;
13581339 if (ret)
13591340 return ret;
13601341
....@@ -1626,3 +1607,54 @@
16261607 core->ops = NULL;
16271608 return ret;
16281609 }
1610
+
1611
+void venus_hfi_queues_reinit(struct venus_core *core)
1612
+{
1613
+ struct venus_hfi_device *hdev = to_hfi_priv(core);
1614
+ struct hfi_queue_table_header *tbl_hdr;
1615
+ struct iface_queue *queue;
1616
+ struct hfi_sfr *sfr;
1617
+ unsigned int i;
1618
+
1619
+ mutex_lock(&hdev->lock);
1620
+
1621
+ for (i = 0; i < IFACEQ_NUM; i++) {
1622
+ queue = &hdev->queues[i];
1623
+ queue->qhdr =
1624
+ IFACEQ_GET_QHDR_START_ADDR(hdev->ifaceq_table.kva, i);
1625
+
1626
+ venus_set_qhdr_defaults(queue->qhdr);
1627
+
1628
+ queue->qhdr->start_addr = queue->qmem.da;
1629
+
1630
+ if (i == IFACEQ_CMD_IDX)
1631
+ queue->qhdr->type |= HFI_HOST_TO_CTRL_CMD_Q;
1632
+ else if (i == IFACEQ_MSG_IDX)
1633
+ queue->qhdr->type |= HFI_CTRL_TO_HOST_MSG_Q;
1634
+ else if (i == IFACEQ_DBG_IDX)
1635
+ queue->qhdr->type |= HFI_CTRL_TO_HOST_DBG_Q;
1636
+ }
1637
+
1638
+ tbl_hdr = hdev->ifaceq_table.kva;
1639
+ tbl_hdr->version = 0;
1640
+ tbl_hdr->size = IFACEQ_TABLE_SIZE;
1641
+ tbl_hdr->qhdr0_offset = sizeof(struct hfi_queue_table_header);
1642
+ tbl_hdr->qhdr_size = sizeof(struct hfi_queue_header);
1643
+ tbl_hdr->num_q = IFACEQ_NUM;
1644
+ tbl_hdr->num_active_q = IFACEQ_NUM;
1645
+
1646
+ /*
1647
+ * Set receive request to zero on debug queue as there is no
1648
+ * need of interrupt from video hardware for debug messages
1649
+ */
1650
+ queue = &hdev->queues[IFACEQ_DBG_IDX];
1651
+ queue->qhdr->rx_req = 0;
1652
+
1653
+ sfr = hdev->sfr.kva;
1654
+ sfr->buf_size = ALIGNED_SFR_SIZE;
1655
+
1656
+ /* ensure table and queue header structs are settled in memory */
1657
+ wmb();
1658
+
1659
+ mutex_unlock(&hdev->lock);
1660
+}