Commit ba816d3c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'arm-soc-fixes-5.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC fixes from Arnd Bergmann:
 "Only a small number of fixes so far, including some that I had applied
  during the merge window, so this is based on the original merge of the
  other branches.

   - The largest change is a fix for a reference counting bug in the AMD
     TEE driver.

   - Neil Armstrong now co-maintains Amlogic SoC support

   - Two build warning fixes for renesas device tree files

   - A sign expansion bug for optee

   - A DT binding fix for a mismerge"

* tag 'arm-soc-fixes-5.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
  ARM: npcm: wpcm450: select interrupt controller driver
  MAINTAINERS: ARM/Amlogic SoCs: add Neil as primary maintainer
  tee: amdtee: unload TA only when its refcount becomes 0
  dt-bindings: nvmem: mediatek: remove duplicate mt8192 line
  firmware: arm_scmi: Remove duplicate declaration of struct scmi_protocol_handle
  firmware: arm_scpi: Prevent the ternary sign expansion bug
  arm64: dts: renesas: Add port@0 node for all CSI-2 nodes to dtsi
  arm64: dts: renesas: aistarvision-mipi-adapter-2.1: Fix CSI40 ports
parents 921dd235 d37316b7
...@@ -9,7 +9,6 @@ Required properties: ...@@ -9,7 +9,6 @@ Required properties:
"mediatek,mt8173-efuse" or "mediatek,efuse": for MT8173 "mediatek,mt8173-efuse" or "mediatek,efuse": for MT8173
"mediatek,mt8192-efuse", "mediatek,efuse": for MT8192 "mediatek,mt8192-efuse", "mediatek,efuse": for MT8192
"mediatek,mt8516-efuse", "mediatek,efuse": for MT8516 "mediatek,mt8516-efuse", "mediatek,efuse": for MT8516
"mediatek,mt8192-efuse", "mediatek,efuse": for MT8192
- reg: Should contain registers location and length - reg: Should contain registers location and length
= Data cells = = Data cells =
......
...@@ -1618,8 +1618,8 @@ F: Documentation/devicetree/bindings/sound/amlogic* ...@@ -1618,8 +1618,8 @@ F: Documentation/devicetree/bindings/sound/amlogic*
F: sound/soc/meson/ F: sound/soc/meson/
ARM/Amlogic Meson SoC support ARM/Amlogic Meson SoC support
M: Neil Armstrong <narmstrong@baylibre.com>
M: Kevin Hilman <khilman@baylibre.com> M: Kevin Hilman <khilman@baylibre.com>
R: Neil Armstrong <narmstrong@baylibre.com>
R: Jerome Brunet <jbrunet@baylibre.com> R: Jerome Brunet <jbrunet@baylibre.com>
R: Martin Blumenstingl <martin.blumenstingl@googlemail.com> R: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
......
...@@ -10,6 +10,7 @@ config ARCH_WPCM450 ...@@ -10,6 +10,7 @@ config ARCH_WPCM450
bool "Support for WPCM450 BMC (Hermon)" bool "Support for WPCM450 BMC (Hermon)"
depends on ARCH_MULTI_V5 depends on ARCH_MULTI_V5
select CPU_ARM926T select CPU_ARM926T
select WPCM450_AIC
select NPCM7XX_TIMER select NPCM7XX_TIMER
help help
General support for WPCM450 BMC (Hermon). General support for WPCM450 BMC (Hermon).
......
...@@ -14,7 +14,6 @@ &csi20 { ...@@ -14,7 +14,6 @@ &csi20 {
ports { ports {
port@0 { port@0 {
reg = <0>;
csi20_in: endpoint { csi20_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1 2>; data-lanes = <1 2>;
...@@ -29,7 +28,6 @@ &csi40 { ...@@ -29,7 +28,6 @@ &csi40 {
ports { ports {
port@0 { port@0 {
reg = <0>;
csi40_in: endpoint { csi40_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1 2>; data-lanes = <1 2>;
......
...@@ -2573,6 +2573,10 @@ ports { ...@@ -2573,6 +2573,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2628,6 +2632,10 @@ ports { ...@@ -2628,6 +2632,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -2419,6 +2419,10 @@ ports { ...@@ -2419,6 +2419,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2474,6 +2478,10 @@ ports { ...@@ -2474,6 +2478,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -33,7 +33,7 @@ &csi40 { ...@@ -33,7 +33,7 @@ &csi40 {
status = "okay"; status = "okay";
ports { ports {
port { port@0 {
csi40_in: endpoint { csi40_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1 2>; data-lanes = <1 2>;
......
...@@ -1823,6 +1823,10 @@ ports { ...@@ -1823,6 +1823,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -2709,6 +2709,10 @@ ports { ...@@ -2709,6 +2709,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2764,6 +2768,10 @@ ports { ...@@ -2764,6 +2768,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -192,6 +192,10 @@ ports { ...@@ -192,6 +192,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -3097,6 +3097,10 @@ ports { ...@@ -3097,6 +3097,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -3152,6 +3156,10 @@ ports { ...@@ -3152,6 +3156,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -3191,6 +3199,10 @@ ports { ...@@ -3191,6 +3199,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -2761,6 +2761,10 @@ ports { ...@@ -2761,6 +2761,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2816,6 +2820,10 @@ ports { ...@@ -2816,6 +2820,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -2499,6 +2499,10 @@ ports { ...@@ -2499,6 +2499,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2554,6 +2558,10 @@ ports { ...@@ -2554,6 +2558,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -2575,6 +2575,10 @@ ports { ...@@ -2575,6 +2575,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -2630,6 +2634,10 @@ ports { ...@@ -2630,6 +2634,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -1106,6 +1106,10 @@ ports { ...@@ -1106,6 +1106,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -1439,6 +1439,10 @@ ports { ...@@ -1439,6 +1439,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
...@@ -1478,6 +1482,10 @@ ports { ...@@ -1478,6 +1482,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -298,8 +298,6 @@ &csi40 { ...@@ -298,8 +298,6 @@ &csi40 {
ports { ports {
port@0 { port@0 {
reg = <0>;
csi40_in: endpoint { csi40_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1 2>; data-lanes = <1 2>;
......
...@@ -1970,6 +1970,10 @@ ports { ...@@ -1970,6 +1970,10 @@ ports {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
port@0 {
reg = <0>;
};
port@1 { port@1 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
...@@ -349,7 +349,6 @@ &csi20 { ...@@ -349,7 +349,6 @@ &csi20 {
ports { ports {
port@0 { port@0 {
reg = <0>;
csi20_in: endpoint { csi20_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1>; data-lanes = <1>;
...@@ -364,8 +363,6 @@ &csi40 { ...@@ -364,8 +363,6 @@ &csi40 {
ports { ports {
port@0 { port@0 {
reg = <0>;
csi40_in: endpoint { csi40_in: endpoint {
clock-lanes = <0>; clock-lanes = <0>;
data-lanes = <1 2 3 4>; data-lanes = <1 2 3 4>;
......
...@@ -79,8 +79,6 @@ struct scmi_protocol_events { ...@@ -79,8 +79,6 @@ struct scmi_protocol_events {
int scmi_notification_init(struct scmi_handle *handle); int scmi_notification_init(struct scmi_handle *handle);
void scmi_notification_exit(struct scmi_handle *handle); void scmi_notification_exit(struct scmi_handle *handle);
struct scmi_protocol_handle;
int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id, int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id,
const struct scmi_protocol_handle *ph, const struct scmi_protocol_handle *ph,
const struct scmi_protocol_events *ee); const struct scmi_protocol_events *ee);
......
...@@ -552,8 +552,10 @@ static unsigned long scpi_clk_get_val(u16 clk_id) ...@@ -552,8 +552,10 @@ static unsigned long scpi_clk_get_val(u16 clk_id)
ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id, ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id,
sizeof(le_clk_id), &rate, sizeof(rate)); sizeof(le_clk_id), &rate, sizeof(rate));
if (ret)
return 0;
return ret ? ret : le32_to_cpu(rate); return le32_to_cpu(rate);
} }
static int scpi_clk_set_val(u16 clk_id, unsigned long rate) static int scpi_clk_set_val(u16 clk_id, unsigned long rate)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define TEEC_SUCCESS 0x00000000 #define TEEC_SUCCESS 0x00000000
#define TEEC_ERROR_GENERIC 0xFFFF0000 #define TEEC_ERROR_GENERIC 0xFFFF0000
#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 #define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006
#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C
#define TEEC_ERROR_COMMUNICATION 0xFFFF000E #define TEEC_ERROR_COMMUNICATION 0xFFFF000E
#define TEEC_ORIGIN_COMMS 0x00000002 #define TEEC_ORIGIN_COMMS 0x00000002
...@@ -93,6 +94,18 @@ struct amdtee_shm_data { ...@@ -93,6 +94,18 @@ struct amdtee_shm_data {
u32 buf_id; u32 buf_id;
}; };
/**
* struct amdtee_ta_data - Keeps track of all TAs loaded in AMD Secure
* Processor
* @ta_handle: Handle to TA loaded in TEE
* @refcount: Reference count for the loaded TA
*/
struct amdtee_ta_data {
struct list_head list_node;
u32 ta_handle;
u32 refcount;
};
#define LOWER_TWO_BYTE_MASK 0x0000FFFF #define LOWER_TWO_BYTE_MASK 0x0000FFFF
/** /**
......
...@@ -121,15 +121,69 @@ static int amd_params_to_tee_params(struct tee_param *tee, u32 count, ...@@ -121,15 +121,69 @@ static int amd_params_to_tee_params(struct tee_param *tee, u32 count,
return ret; return ret;
} }
static DEFINE_MUTEX(ta_refcount_mutex);
static struct list_head ta_list = LIST_HEAD_INIT(ta_list);
static u32 get_ta_refcount(u32 ta_handle)
{
struct amdtee_ta_data *ta_data;
u32 count = 0;
/* Caller must hold a mutex */
list_for_each_entry(ta_data, &ta_list, list_node)
if (ta_data->ta_handle == ta_handle)
return ++ta_data->refcount;
ta_data = kzalloc(sizeof(*ta_data), GFP_KERNEL);
if (ta_data) {
ta_data->ta_handle = ta_handle;
ta_data->refcount = 1;
count = ta_data->refcount;
list_add(&ta_data->list_node, &ta_list);
}
return count;
}
static u32 put_ta_refcount(u32 ta_handle)
{
struct amdtee_ta_data *ta_data;
u32 count = 0;
/* Caller must hold a mutex */
list_for_each_entry(ta_data, &ta_list, list_node)
if (ta_data->ta_handle == ta_handle) {
count = --ta_data->refcount;
if (count == 0) {
list_del(&ta_data->list_node);
kfree(ta_data);
break;
}
}
return count;
}
int handle_unload_ta(u32 ta_handle) int handle_unload_ta(u32 ta_handle)
{ {
struct tee_cmd_unload_ta cmd = {0}; struct tee_cmd_unload_ta cmd = {0};
u32 status; u32 status, count;
int ret; int ret;
if (!ta_handle) if (!ta_handle)
return -EINVAL; return -EINVAL;
mutex_lock(&ta_refcount_mutex);
count = put_ta_refcount(ta_handle);
if (count) {
pr_debug("unload ta: not unloading %u count %u\n",
ta_handle, count);
ret = -EBUSY;
goto unlock;
}
cmd.ta_handle = ta_handle; cmd.ta_handle = ta_handle;
ret = psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA, (void *)&cmd, ret = psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA, (void *)&cmd,
...@@ -137,8 +191,12 @@ int handle_unload_ta(u32 ta_handle) ...@@ -137,8 +191,12 @@ int handle_unload_ta(u32 ta_handle)
if (!ret && status != 0) { if (!ret && status != 0) {
pr_err("unload ta: status = 0x%x\n", status); pr_err("unload ta: status = 0x%x\n", status);
ret = -EBUSY; ret = -EBUSY;
} else {
pr_debug("unloaded ta handle %u\n", ta_handle);
} }
unlock:
mutex_unlock(&ta_refcount_mutex);
return ret; return ret;
} }
...@@ -340,7 +398,8 @@ int handle_open_session(struct tee_ioctl_open_session_arg *arg, u32 *info, ...@@ -340,7 +398,8 @@ int handle_open_session(struct tee_ioctl_open_session_arg *arg, u32 *info,
int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg) int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg)
{ {
struct tee_cmd_load_ta cmd = {0}; struct tee_cmd_unload_ta unload_cmd = {};
struct tee_cmd_load_ta load_cmd = {};
phys_addr_t blob; phys_addr_t blob;
int ret; int ret;
...@@ -353,21 +412,36 @@ int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg) ...@@ -353,21 +412,36 @@ int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg)
return -EINVAL; return -EINVAL;
} }
cmd.hi_addr = upper_32_bits(blob); load_cmd.hi_addr = upper_32_bits(blob);
cmd.low_addr = lower_32_bits(blob); load_cmd.low_addr = lower_32_bits(blob);
cmd.size = size; load_cmd.size = size;
ret = psp_tee_process_cmd(TEE_CMD_ID_LOAD_TA, (void *)&cmd, mutex_lock(&ta_refcount_mutex);
sizeof(cmd), &arg->ret);
ret = psp_tee_process_cmd(TEE_CMD_ID_LOAD_TA, (void *)&load_cmd,
sizeof(load_cmd), &arg->ret);
if (ret) { if (ret) {
arg->ret_origin = TEEC_ORIGIN_COMMS; arg->ret_origin = TEEC_ORIGIN_COMMS;
arg->ret = TEEC_ERROR_COMMUNICATION; arg->ret = TEEC_ERROR_COMMUNICATION;
} else { } else if (arg->ret == TEEC_SUCCESS) {
set_session_id(cmd.ta_handle, 0, &arg->session); ret = get_ta_refcount(load_cmd.ta_handle);
if (!ret) {
arg->ret_origin = TEEC_ORIGIN_COMMS;
arg->ret = TEEC_ERROR_OUT_OF_MEMORY;
/* Unload the TA on error */
unload_cmd.ta_handle = load_cmd.ta_handle;
psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA,
(void *)&unload_cmd,
sizeof(unload_cmd), &ret);
} else {
set_session_id(load_cmd.ta_handle, 0, &arg->session);
}
} }
mutex_unlock(&ta_refcount_mutex);
pr_debug("load TA: TA handle = 0x%x, RO = 0x%x, ret = 0x%x\n", pr_debug("load TA: TA handle = 0x%x, RO = 0x%x, ret = 0x%x\n",
cmd.ta_handle, arg->ret_origin, arg->ret); load_cmd.ta_handle, arg->ret_origin, arg->ret);
return 0; return 0;
} }
...@@ -59,10 +59,9 @@ static void release_session(struct amdtee_session *sess) ...@@ -59,10 +59,9 @@ static void release_session(struct amdtee_session *sess)
continue; continue;
handle_close_session(sess->ta_handle, sess->session_info[i]); handle_close_session(sess->ta_handle, sess->session_info[i]);
handle_unload_ta(sess->ta_handle);
} }
/* Unload Trusted Application once all sessions are closed */
handle_unload_ta(sess->ta_handle);
kfree(sess); kfree(sess);
} }
...@@ -224,8 +223,6 @@ static void destroy_session(struct kref *ref) ...@@ -224,8 +223,6 @@ static void destroy_session(struct kref *ref)
struct amdtee_session *sess = container_of(ref, struct amdtee_session, struct amdtee_session *sess = container_of(ref, struct amdtee_session,
refcount); refcount);
/* Unload the TA from TEE */
handle_unload_ta(sess->ta_handle);
mutex_lock(&session_list_mutex); mutex_lock(&session_list_mutex);
list_del(&sess->list_node); list_del(&sess->list_node);
mutex_unlock(&session_list_mutex); mutex_unlock(&session_list_mutex);
...@@ -238,7 +235,7 @@ int amdtee_open_session(struct tee_context *ctx, ...@@ -238,7 +235,7 @@ int amdtee_open_session(struct tee_context *ctx,
{ {
struct amdtee_context_data *ctxdata = ctx->data; struct amdtee_context_data *ctxdata = ctx->data;
struct amdtee_session *sess = NULL; struct amdtee_session *sess = NULL;
u32 session_info; u32 session_info, ta_handle;
size_t ta_size; size_t ta_size;
int rc, i; int rc, i;
void *ta; void *ta;
...@@ -259,11 +256,14 @@ int amdtee_open_session(struct tee_context *ctx, ...@@ -259,11 +256,14 @@ int amdtee_open_session(struct tee_context *ctx,
if (arg->ret != TEEC_SUCCESS) if (arg->ret != TEEC_SUCCESS)
goto out; goto out;
ta_handle = get_ta_handle(arg->session);
mutex_lock(&session_list_mutex); mutex_lock(&session_list_mutex);
sess = alloc_session(ctxdata, arg->session); sess = alloc_session(ctxdata, arg->session);
mutex_unlock(&session_list_mutex); mutex_unlock(&session_list_mutex);
if (!sess) { if (!sess) {
handle_unload_ta(ta_handle);
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -277,6 +277,7 @@ int amdtee_open_session(struct tee_context *ctx, ...@@ -277,6 +277,7 @@ int amdtee_open_session(struct tee_context *ctx,
if (i >= TEE_NUM_SESSIONS) { if (i >= TEE_NUM_SESSIONS) {
pr_err("reached maximum session count %d\n", TEE_NUM_SESSIONS); pr_err("reached maximum session count %d\n", TEE_NUM_SESSIONS);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session); kref_put(&sess->refcount, destroy_session);
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -289,12 +290,13 @@ int amdtee_open_session(struct tee_context *ctx, ...@@ -289,12 +290,13 @@ int amdtee_open_session(struct tee_context *ctx,
spin_lock(&sess->lock); spin_lock(&sess->lock);
clear_bit(i, sess->sess_mask); clear_bit(i, sess->sess_mask);
spin_unlock(&sess->lock); spin_unlock(&sess->lock);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session); kref_put(&sess->refcount, destroy_session);
goto out; goto out;
} }
sess->session_info[i] = session_info; sess->session_info[i] = session_info;
set_session_id(sess->ta_handle, i, &arg->session); set_session_id(ta_handle, i, &arg->session);
out: out:
free_pages((u64)ta, get_order(ta_size)); free_pages((u64)ta, get_order(ta_size));
return rc; return rc;
...@@ -329,6 +331,7 @@ int amdtee_close_session(struct tee_context *ctx, u32 session) ...@@ -329,6 +331,7 @@ int amdtee_close_session(struct tee_context *ctx, u32 session)
/* Close the session */ /* Close the session */
handle_close_session(ta_handle, session_info); handle_close_session(ta_handle, session_info);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session); kref_put(&sess->refcount, destroy_session);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment