blob: a609905a9ea39d91d70a4052a21bb3a3d71f9611 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 350201cc09a58dcf5c49f636238b01637f5ee06d Mon Sep 17 00:00:00 2001
2From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
3Date: Fri, 13 Apr 2018 11:35:10 +0300
4Subject: [PATCH] bus: fsl-mc: Add dprc-reset-container support
5
6DPRC-reset is required for VFIO and is missing from
7mc-bus support.
8This patch added reset-container support.
9
10Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
11Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
12---
13 drivers/bus/fsl-mc/dprc.c | 41 +++++++++++++++++++++++++++++++++++++
14 drivers/bus/fsl-mc/fsl-mc-private.h | 10 +++++++++
15 2 files changed, 51 insertions(+)
16
17--- a/drivers/bus/fsl-mc/dprc.c
18+++ b/drivers/bus/fsl-mc/dprc.c
19@@ -73,6 +73,47 @@ int dprc_close(struct fsl_mc_io *mc_io,
20 EXPORT_SYMBOL_GPL(dprc_close);
21
22 /**
23+ * dprc_reset_container - Reset child container.
24+ * @mc_io: Pointer to MC portal's I/O object
25+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26+ * @token: Token of DPRC object
27+ * @child_container_id: ID of the container to reset
28+ *
29+ * In case a software context crashes or becomes non-responsive, the parent
30+ * may wish to reset its resources container before the software context is
31+ * restarted.
32+ *
33+ * This routine informs all objects assigned to the child container that the
34+ * container is being reset, so they may perform any cleanup operations that are
35+ * needed. All objects handles that were owned by the child container shall be
36+ * closed.
37+ *
38+ * Note that such request may be submitted even if the child software context
39+ * has not crashed, but the resulting object cleanup operations will not be
40+ * aware of that.
41+ *
42+ * Return: '0' on Success; Error code otherwise.
43+ */
44+int dprc_reset_container(struct fsl_mc_io *mc_io,
45+ u32 cmd_flags,
46+ u16 token,
47+ int child_container_id)
48+{
49+ struct fsl_mc_command cmd = { 0 };
50+ struct dprc_cmd_reset_container *cmd_params;
51+
52+ /* prepare command */
53+ cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT,
54+ cmd_flags, token);
55+ cmd_params = (struct dprc_cmd_reset_container *)cmd.params;
56+ cmd_params->child_container_id = cpu_to_le32(child_container_id);
57+
58+ /* send command to mc*/
59+ return mc_send_command(mc_io, &cmd);
60+}
61+EXPORT_SYMBOL_GPL(dprc_reset_container);
62+
63+/**
64 * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt.
65 * @mc_io: Pointer to MC portal's I/O object
66 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
67--- a/drivers/bus/fsl-mc/fsl-mc-private.h
68+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
69@@ -93,6 +93,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
70 #define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
71
72 #define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
73+#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005)
74
75 #define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
76 #define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
77@@ -111,6 +112,10 @@ struct dprc_cmd_open {
78 __le32 container_id;
79 };
80
81+struct dprc_cmd_reset_container {
82+ __le32 child_container_id;
83+};
84+
85 struct dprc_cmd_set_irq {
86 /* cmd word 0 */
87 __le32 irq_val;
88@@ -394,6 +399,11 @@ int dprc_get_container_id(struct fsl_mc_
89 u32 cmd_flags,
90 int *container_id);
91
92+int dprc_reset_container(struct fsl_mc_io *mc_io,
93+ u32 cmd_flags,
94+ u16 token,
95+ int child_container_id);
96+
97 /*
98 * Data Path Buffer Pool (DPBP) API
99 */