Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

remoteproc: qcom_q6v5_pas: Add hwspinlock bust on stop

When remoteproc goes down unexpectedly this results in a state where any
acquired hwspinlocks will remain locked possibly resulting in deadlock.
In order to ensure all locks are freed we include a call to
qcom_smem_bust_hwspin_lock_by_host() during remoteproc shutdown.

For qcom_q6v5_pas remoteprocs, each remoteproc has an assigned smem
host_id. Remoteproc can pass this id to smem to try and bust the lock on
remoteproc stop.

This edge case only occurs with q6v5_pas watchdog crashes. The error
fatal case has handling to clear the hwspinlock before the error fatal
interrupt is triggered.

Signed-off-by: Richard Maina <quic_rmaina@quicinc.com>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
Link: https://lore.kernel.org/r/20240529-hwspinlock-bust-v3-4-c8b924ffa5a2@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Richard Maina and committed by
Bjorn Andersson
568b13b6 2e3f0d69

+11
+11
drivers/remoteproc/qcom_q6v5_pas.c
··· 52 52 const char *ssr_name; 53 53 const char *sysmon_name; 54 54 int ssctl_id; 55 + unsigned int smem_host_id; 55 56 56 57 int region_assign_idx; 57 58 int region_assign_count; ··· 82 81 int lite_pas_id; 83 82 unsigned int minidump_id; 84 83 int crash_reason_smem; 84 + unsigned int smem_host_id; 85 85 bool decrypt_shutdown; 86 86 const char *info_name; 87 87 ··· 400 398 handover = qcom_q6v5_unprepare(&adsp->q6v5); 401 399 if (handover) 402 400 qcom_pas_handover(&adsp->q6v5); 401 + 402 + if (adsp->smem_host_id) 403 + ret = qcom_smem_bust_hwspin_lock_by_host(adsp->smem_host_id); 403 404 404 405 return ret; 405 406 } ··· 732 727 adsp->pas_id = desc->pas_id; 733 728 adsp->lite_pas_id = desc->lite_pas_id; 734 729 adsp->info_name = desc->sysmon_name; 730 + adsp->smem_host_id = desc->smem_host_id; 735 731 adsp->decrypt_shutdown = desc->decrypt_shutdown; 736 732 adsp->region_assign_idx = desc->region_assign_idx; 737 733 adsp->region_assign_count = min_t(int, MAX_ASSIGN_COUNT, desc->region_assign_count); ··· 1202 1196 .ssr_name = "lpass", 1203 1197 .sysmon_name = "adsp", 1204 1198 .ssctl_id = 0x14, 1199 + .smem_host_id = 2, 1205 1200 }; 1206 1201 1207 1202 static const struct adsp_data sm8550_cdsp_resource = { ··· 1223 1216 .ssr_name = "cdsp", 1224 1217 .sysmon_name = "cdsp", 1225 1218 .ssctl_id = 0x17, 1219 + .smem_host_id = 5, 1226 1220 }; 1227 1221 1228 1222 static const struct adsp_data sm8550_mpss_resource = { ··· 1244 1236 .ssr_name = "mpss", 1245 1237 .sysmon_name = "modem", 1246 1238 .ssctl_id = 0x12, 1239 + .smem_host_id = 1, 1247 1240 .region_assign_idx = 2, 1248 1241 .region_assign_count = 1, 1249 1242 .region_assign_vmid = QCOM_SCM_VMID_MSS_MSA, ··· 1284 1275 .ssr_name = "cdsp", 1285 1276 .sysmon_name = "cdsp", 1286 1277 .ssctl_id = 0x17, 1278 + .smem_host_id = 5, 1287 1279 .region_assign_idx = 2, 1288 1280 .region_assign_count = 1, 1289 1281 .region_assign_shared = true, ··· 1309 1299 .ssr_name = "mpss", 1310 1300 .sysmon_name = "modem", 1311 1301 .ssctl_id = 0x12, 1302 + .smem_host_id = 1, 1312 1303 .region_assign_idx = 2, 1313 1304 .region_assign_count = 3, 1314 1305 .region_assign_vmid = QCOM_SCM_VMID_MSS_MSA,