Merge "dsp-kernel: Move the ssrcount access within a critical section"

This commit is contained in:
qctecmdr
2024-05-28 20:37:25 -07:00
committed by Gerrit - the friendly Code Review server

View File

@@ -3500,9 +3500,11 @@ int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
trace_fastrpc_msg("context_free: end"); trace_fastrpc_msg("context_free: end");
} }
if (!kernel) { if (!kernel) {
mutex_lock(&fl->apps->channel[cid].smd_mutex);
if (VALID_FASTRPC_CID(cid) if (VALID_FASTRPC_CID(cid)
&& (fl->ssrcount != fl->apps->channel[cid].ssrcount)) && (fl->ssrcount != fl->apps->channel[cid].ssrcount))
err = -ECONNRESET; err = -ECONNRESET;
mutex_unlock(&fl->apps->channel[cid].smd_mutex);
} }
invoke_end: invoke_end:
@@ -6699,8 +6701,8 @@ int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
} }
} }
fl->cid = cid; fl->cid = cid;
fl->ssrcount = fl->apps->channel[cid].ssrcount;
mutex_lock(&fl->apps->channel[cid].smd_mutex); mutex_lock(&fl->apps->channel[cid].smd_mutex);
fl->ssrcount = fl->apps->channel[cid].ssrcount;
err = fastrpc_session_alloc_locked(&fl->apps->channel[cid], err = fastrpc_session_alloc_locked(&fl->apps->channel[cid],
0, fl->sharedcb, fl->pd_type, &fl->sctx); 0, fl->sharedcb, fl->pd_type, &fl->sctx);
mutex_unlock(&fl->apps->channel[cid].smd_mutex); mutex_unlock(&fl->apps->channel[cid].smd_mutex);
@@ -7894,7 +7896,9 @@ void fastrpc_restart_drivers(int cid)
struct fastrpc_apps *me = &gfa; struct fastrpc_apps *me = &gfa;
fastrpc_notify_drivers(me, cid); fastrpc_notify_drivers(me, cid);
mutex_lock(&me->channel[cid].smd_mutex);
me->channel[cid].ssrcount++; me->channel[cid].ssrcount++;
mutex_unlock(&me->channel[cid].smd_mutex);
} }
static int fastrpc_restart_notifier_cb(struct notifier_block *nb, static int fastrpc_restart_notifier_cb(struct notifier_block *nb,
@@ -7908,9 +7912,14 @@ static int fastrpc_restart_notifier_cb(struct notifier_block *nb,
int cid = -1; int cid = -1;
struct timespec64 startT = {0}; struct timespec64 startT = {0};
unsigned long irq_flags = 0; unsigned long irq_flags = 0;
uint64_t ssrcount = 0;
ctx = container_of(nb, struct fastrpc_channel_ctx, nb); ctx = container_of(nb, struct fastrpc_channel_ctx, nb);
cid = ctx - &me->channel[0]; cid = ctx - &me->channel[0];
/* ssrcount should be read within a critical section */
mutex_lock(&me->channel[cid].smd_mutex);
ssrcount = ctx->ssrcount;
mutex_unlock(&me->channel[cid].smd_mutex);
switch (code) { switch (code) {
case QCOM_SSR_BEFORE_SHUTDOWN: case QCOM_SSR_BEFORE_SHUTDOWN:
fastrpc_rproc_trace_events(gcinfo[cid].subsys, fastrpc_rproc_trace_events(gcinfo[cid].subsys,
@@ -7943,13 +7952,11 @@ static int fastrpc_restart_notifier_cb(struct notifier_block *nb,
"QCOM_SSR_BEFORE_POWERUP", "fastrpc_restart_notifier-enter"); "QCOM_SSR_BEFORE_POWERUP", "fastrpc_restart_notifier-enter");
pr_info("adsprpc: %s: subsystem %s is about to start\n", pr_info("adsprpc: %s: subsystem %s is about to start\n",
__func__, gcinfo[cid].subsys); __func__, gcinfo[cid].subsys);
if (cid == CDSP_DOMAIN_ID && dump_enabled() && if (cid == CDSP_DOMAIN_ID && dump_enabled() && ssrcount)
ctx->ssrcount)
fastrpc_update_ramdump_status(cid); fastrpc_update_ramdump_status(cid);
fastrpc_notify_drivers(me, cid); fastrpc_notify_drivers(me, cid);
/* Skip ram dump collection in first boot */ /* Skip ram dump collection in first boot */
if (cid == CDSP_DOMAIN_ID && dump_enabled() && if (cid == CDSP_DOMAIN_ID && dump_enabled() && ssrcount) {
ctx->ssrcount) {
mutex_lock(&me->channel[cid].smd_mutex); mutex_lock(&me->channel[cid].smd_mutex);
fastrpc_print_debug_data(cid); fastrpc_print_debug_data(cid);
mutex_unlock(&me->channel[cid].smd_mutex); mutex_unlock(&me->channel[cid].smd_mutex);