int msm_smp2p_deinit_rmt_lpb_proc(int remote_pid) { int ret = 0; int tmp; struct smp2p_loopback_ctx *ctx; if (remote_pid >= SMP2P_NUM_PROCS) return -EINVAL; ctx = &remote_loopback[remote_pid]; remote_loopback[remote_pid].out_is_active = false; remote_loopback[remote_pid].in_is_active = false; flush_work(&ctx->rmt_lpb_work); tmp = msm_smp2p_out_close(&remote_loopback[remote_pid].out); remote_loopback[remote_pid].out = NULL; if (tmp) { SMP2P_ERR("%s: outbound 'smp2p':%d close failed %d\n", __func__, remote_pid, tmp); ret = tmp; } tmp = msm_smp2p_in_unregister(remote_pid, SMP2P_RLPB_ENTRY_NAME, &remote_loopback[remote_pid].in_nb); if (tmp) { SMP2P_ERR("%s: inbound 'smp2p':%d close failed %d\n", __func__, remote_pid, tmp); ret = tmp; } return ret; }
/** * smp2p_ut_remote_inout_core - Verify inbound/outbound functionality. * * @s: pointer to output file * @remote_pid: Remote processor to test * * This test verifies inbound/outbound functionality for the remote processor. */ static void smp2p_ut_remote_inout_core(struct seq_file *s, int remote_pid) { int failed = 0; struct msm_smp2p_out *handle; int ret; uint32_t test_request; uint32_t test_response = 0; static struct mock_cb_data cb_out; static struct mock_cb_data cb_in; seq_printf(s, "Running %s for '%s' remote pid %d\n", __func__, smp2p_pid_to_name(remote_pid), remote_pid); mock_cb_data_init(&cb_out); mock_cb_data_init(&cb_in); do { /* Open output entry */ ret = msm_smp2p_out_open(remote_pid, "smp2p", &cb_out.nb, &handle); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_out.cb_completion, HZ / 2), >, 0); UT_ASSERT_INT(cb_out.cb_count, ==, 1); UT_ASSERT_INT(cb_out.event_open, ==, 1); /* Open inbound entry */ ret = msm_smp2p_in_register(remote_pid, "smp2p", &cb_in.nb); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_in.cb_completion, HZ / 2), >, 0); UT_ASSERT_INT(cb_in.cb_count, ==, 1); UT_ASSERT_INT(cb_in.event_open, ==, 1); /* Write an echo request */ mock_cb_data_reset(&cb_out); mock_cb_data_reset(&cb_in); test_request = 0x0; SMP2P_SET_RMT_CMD_TYPE(test_request, 1); SMP2P_SET_RMT_CMD(test_request, SMP2P_LB_CMD_ECHO); SMP2P_SET_RMT_DATA(test_request, 0xAA55); ret = msm_smp2p_out_write(handle, test_request); UT_ASSERT_INT(ret, ==, 0); /* Verify inbound reply */ UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_in.cb_completion, HZ / 2), >, 0); UT_ASSERT_INT(cb_in.cb_count, ==, 1); UT_ASSERT_INT(cb_in.event_entry_update, ==, 1); UT_ASSERT_INT(SMP2P_GET_RMT_DATA( cb_in.entry_data.current_value), ==, 0xAA55); ret = msm_smp2p_in_read(remote_pid, "smp2p", &test_response); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT(0, ==, SMP2P_GET_RMT_CMD_TYPE(test_response)); UT_ASSERT_INT(SMP2P_LB_CMD_ECHO, ==, SMP2P_GET_RMT_CMD(test_response)); UT_ASSERT_INT(0xAA55, ==, SMP2P_GET_RMT_DATA(test_response)); /* Write a clear all request */ mock_cb_data_reset(&cb_in); test_request = 0x0; SMP2P_SET_RMT_CMD_TYPE(test_request, 1); SMP2P_SET_RMT_CMD(test_request, SMP2P_LB_CMD_CLEARALL); SMP2P_SET_RMT_DATA(test_request, 0xAA55); ret = msm_smp2p_out_write(handle, test_request); UT_ASSERT_INT(ret, ==, 0); /* Verify inbound reply */ UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_in.cb_completion, HZ / 2), >, 0); UT_ASSERT_INT(cb_in.cb_count, ==, 1); UT_ASSERT_INT(cb_in.event_entry_update, ==, 1); UT_ASSERT_INT(SMP2P_GET_RMT_DATA( cb_in.entry_data.current_value), ==, 0x0000); ret = msm_smp2p_in_read(remote_pid, "smp2p", &test_response); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT(0, ==, SMP2P_GET_RMT_CMD_TYPE(test_response)); UT_ASSERT_INT(0x0000, ==, SMP2P_GET_RMT_DATA(test_response)); /* Write a decrement request */ mock_cb_data_reset(&cb_in); test_request = 0x0; SMP2P_SET_RMT_CMD_TYPE(test_request, 1); SMP2P_SET_RMT_CMD(test_request, SMP2P_LB_CMD_PINGPONG); SMP2P_SET_RMT_DATA(test_request, 0xAA55); ret = msm_smp2p_out_write(handle, test_request); UT_ASSERT_INT(ret, ==, 0); /* Verify inbound reply */ UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_in.cb_completion, HZ / 2), >, 0); UT_ASSERT_INT(cb_in.cb_count, ==, 1); UT_ASSERT_INT(cb_in.event_entry_update, ==, 1); UT_ASSERT_INT(SMP2P_GET_RMT_DATA( cb_in.entry_data.current_value), ==, 0xAA54); ret = msm_smp2p_in_read(remote_pid, "smp2p", &test_response); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT(0, ==, SMP2P_GET_RMT_CMD_TYPE(test_response)); UT_ASSERT_INT(SMP2P_LB_CMD_PINGPONG, ==, SMP2P_GET_RMT_CMD(test_response)); UT_ASSERT_INT(0xAA54, ==, SMP2P_GET_RMT_DATA(test_response)); /* Test the ignore flag */ mock_cb_data_reset(&cb_in); test_request = 0x0; SMP2P_SET_RMT_CMD_TYPE(test_request, 1); SMP2P_SET_RMT_CMD(test_request, SMP2P_RLPB_IGNORE); SMP2P_SET_RMT_DATA(test_request, 0xAA55); ret = msm_smp2p_out_write(handle, test_request); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &cb_in.cb_completion, HZ / 2), ==, 0); UT_ASSERT_INT(cb_in.cb_count, ==, 0); UT_ASSERT_INT(cb_in.event_entry_update, ==, 0); ret = msm_smp2p_in_read(remote_pid, "smp2p", &test_response); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT(0xAA54, ==, SMP2P_GET_RMT_DATA(test_response)); /* Cleanup */ ret = msm_smp2p_out_close(&handle); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_PTR(handle, ==, 0); ret = msm_smp2p_in_unregister(remote_pid, "smp2p", &cb_in.nb); UT_ASSERT_INT(ret, ==, 0); seq_printf(s, "\tOK\n"); } while (0); if (failed) { if (handle) (void)msm_smp2p_out_close(&handle); (void)msm_smp2p_in_unregister(remote_pid, "smp2p", &cb_in.nb); pr_err("%s: Failed\n", __func__); seq_printf(s, "\tFailed\n"); } }
/** * smp2p_ut_local_in_multiple - Verify Multiple Inbound Registration. * * @s: pointer to output file * * This test verifies multiple clients registering for same inbound entries * using the remote mock processor. */ static void smp2p_ut_local_in_multiple(struct seq_file *s) { int failed = 0; struct msm_smp2p_remote_mock *rmp = NULL; int ret; static struct mock_cb_data cb_in_1; static struct mock_cb_data cb_in_2; static struct mock_cb_data cb_out; seq_printf(s, "Running %s\n", __func__); mock_cb_data_init(&cb_in_1); mock_cb_data_init(&cb_in_2); mock_cb_data_init(&cb_out); do { /* Initialize mock edge */ ret = smp2p_reset_mock_edge(); UT_ASSERT_INT(ret, ==, 0); rmp = msm_smp2p_get_remote_mock(); UT_ASSERT_PTR(rmp, !=, NULL); rmp->rx_interrupt_count = 0; memset(&rmp->remote_item, 0, sizeof(struct smp2p_smem_item)); rmp->remote_item.header.magic = SMP2P_MAGIC; SMP2P_SET_LOCAL_PID( rmp->remote_item.header.rem_loc_proc_id, SMP2P_REMOTE_MOCK_PROC); SMP2P_SET_REMOTE_PID( rmp->remote_item.header.rem_loc_proc_id, SMP2P_APPS_PROC); SMP2P_SET_VERSION( rmp->remote_item.header.feature_version, 1); SMP2P_SET_FEATURES( rmp->remote_item.header.feature_version, 0); SMP2P_SET_ENT_TOTAL( rmp->remote_item.header.valid_total_ent, 1); SMP2P_SET_ENT_VALID( rmp->remote_item.header.valid_total_ent, 0); rmp->remote_item.header.reserved = 0x0; msm_smp2p_set_remote_mock_exists(true); /* Create an Entry in the remote mock object */ scnprintf(rmp->remote_item.entries[0].name, SMP2P_MAX_ENTRY_NAME, "smp2p%d", 1); rmp->remote_item.entries[0].entry = 0; rmp->tx_interrupt(); /* Register multiple clients for the inbound entry */ ret = msm_smp2p_in_register(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &cb_in_1.nb); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &(cb_in_1.cb_completion), HZ / 2), >, 0); UT_ASSERT_INT(cb_in_1.cb_count, ==, 1); UT_ASSERT_INT(cb_in_1.event_entry_update, ==, 0); ret = msm_smp2p_in_register(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &cb_in_2.nb); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &(cb_in_2.cb_completion), HZ / 2), >, 0); UT_ASSERT_INT(cb_in_2.cb_count, ==, 1); UT_ASSERT_INT(cb_in_2.event_entry_update, ==, 0); /* Unregister the clients */ ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &(cb_in_1.nb)); UT_ASSERT_INT(ret, ==, 0); ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &(cb_in_2.nb)); UT_ASSERT_INT(ret, ==, 0); seq_printf(s, "\tOK\n"); } while (0); if (failed) { pr_err("%s: Failed\n", __func__); seq_printf(s, "\tFailed\n"); ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &(cb_in_1.nb)); ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[0].name, &(cb_in_2.nb)); } }
static void smp2p_ut_local_in_max_entries(struct seq_file *s) { int j = 0; int failed = 0; struct msm_smp2p_remote_mock *rmp = NULL; int ret; static struct mock_cb_data cb_in[SMP2P_MAX_ENTRY]; static struct mock_cb_data cb_out; seq_printf(s, "Running %s\n", __func__); for (j = 0; j < SMP2P_MAX_ENTRY; j++) mock_cb_data_init(&cb_in[j]); mock_cb_data_init(&cb_out); do { /* */ ret = smp2p_reset_mock_edge(); UT_ASSERT_INT(ret, ==, 0); rmp = msm_smp2p_get_remote_mock(); UT_ASSERT_PTR(rmp, !=, NULL); rmp->rx_interrupt_count = 0; memset(&rmp->remote_item, 0, sizeof(struct smp2p_smem_item)); rmp->remote_item.header.magic = SMP2P_MAGIC; SMP2P_SET_LOCAL_PID( rmp->remote_item.header.rem_loc_proc_id, SMP2P_REMOTE_MOCK_PROC); SMP2P_SET_REMOTE_PID( rmp->remote_item.header.rem_loc_proc_id, SMP2P_APPS_PROC); SMP2P_SET_VERSION( rmp->remote_item.header.feature_version, 1); SMP2P_SET_FEATURES( rmp->remote_item.header.feature_version, 0); SMP2P_SET_ENT_TOTAL( rmp->remote_item.header.valid_total_ent, SMP2P_MAX_ENTRY); SMP2P_SET_ENT_VALID( rmp->remote_item.header.valid_total_ent, 0); rmp->remote_item.header.flags = 0x0; msm_smp2p_set_remote_mock_exists(true); /* */ for (j = 0; j < SMP2P_MAX_ENTRY; j++) { scnprintf(rmp->remote_item.entries[j].name, SMP2P_MAX_ENTRY_NAME, "smp2p%d", j); rmp->remote_item.entries[j].entry = 0; rmp->tx_interrupt(); } /* */ for (j = 0; j < SMP2P_MAX_ENTRY; j++) { ret = msm_smp2p_in_register(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[j].name, &(cb_in[j].nb)); UT_ASSERT_INT(ret, ==, 0); UT_ASSERT_INT( (int)wait_for_completion_timeout( &(cb_in[j].cb_completion), HZ / 2), >, 0); UT_ASSERT_INT(cb_in[j].cb_count, ==, 1); UT_ASSERT_INT(cb_in[j].event_entry_update, ==, 0); } UT_ASSERT_INT(j, ==, SMP2P_MAX_ENTRY); /* */ for (j = 0; j < SMP2P_MAX_ENTRY; j++) { ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[j].name, &(cb_in[j].nb)); UT_ASSERT_INT(ret, ==, 0); } UT_ASSERT_INT(j, ==, SMP2P_MAX_ENTRY); seq_printf(s, "\tOK\n"); } while (0); if (failed) { pr_err("%s: Failed\n", __func__); seq_printf(s, "\tFailed\n"); for (j = 0; j < SMP2P_MAX_ENTRY; j++) ret = msm_smp2p_in_unregister(SMP2P_REMOTE_MOCK_PROC, rmp->remote_item.entries[j].name, &(cb_in[j].nb)); } }