From 2af4676ab27e0c0707f5b4d577848308f15d8a3e Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 11:18:53 +0100 Subject: [PATCH 1/9] framework: support single thread without notification Allow building single thread support without BUILD_HAS_NOTIFICATION. Signed-off-by: Etienne Carriere --- framework/src/fwk_thread.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/framework/src/fwk_thread.c b/framework/src/fwk_thread.c index e3bed4528..a5a879cc6 100644 --- a/framework/src/fwk_thread.c +++ b/framework/src/fwk_thread.c @@ -95,6 +95,7 @@ static int put_event( int status; if (event->is_delayed_response) { +#ifdef BUILD_HAS_NOTIFICATION allocated_event = __fwk_thread_search_delayed_response( event->source_id, event->cookie); if (allocated_event == NULL) { @@ -115,6 +116,9 @@ static int put_event( if (ctx.waiting_event_processing_completion && (ctx.cookie == event->cookie)) is_wakeup_event = true; +#else + return FWK_E_PANIC; +#endif } else { allocated_event = duplicate_event(event); if (allocated_event == NULL) @@ -197,6 +201,7 @@ static void process_next_event(void) if (!async_response_event.is_delayed_response) put_event(&async_response_event, UNKNOWN_THREAD); else { +#ifdef BUILD_HAS_NOTIFICATION allocated_event = duplicate_event(&async_response_event); if (allocated_event != NULL) { fwk_list_push_tail( @@ -204,6 +209,10 @@ static void process_next_event(void) async_response_event.source_id), &allocated_event->slist_node); } +#else + FWK_LOG_CRIT(err_msg_line, status, __func__, __LINE__); + fwk_unexpected(); +#endif } } else { status = process_event(event, &async_response_event); @@ -490,6 +499,7 @@ int fwk_thread_put_event_and_wait(struct fwk_event *event, goto exit; ctx.cookie = response_event.cookie; } else { +#ifdef BUILD_HAS_NOTIFICATION allocated_event = duplicate_event(&response_event); if (allocated_event != NULL) { fwk_list_push_head( @@ -501,6 +511,9 @@ int fwk_thread_put_event_and_wait(struct fwk_event *event, goto exit; } ctx.cookie = allocated_event->cookie; +#else + return FWK_E_PANIC; +#endif } wait_state = WAITING_FOR_RESPONSE; -- GitLab From 40dce9228a1d532ee28e302b924aa48afc4af66d Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 11:18:18 +0100 Subject: [PATCH 2/9] framework: support multithread without notification Allow building multithread support without BUILD_HAS_NOTIFICATION. Signed-off-by: Etienne Carriere --- framework/src/fwk_multi_thread.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/framework/src/fwk_multi_thread.c b/framework/src/fwk_multi_thread.c index a1a8e51a4..5d03b7721 100644 --- a/framework/src/fwk_multi_thread.c +++ b/framework/src/fwk_multi_thread.c @@ -222,6 +222,7 @@ static int put_event(struct __fwk_thread_ctx *target_thread_ctx, target_thread_ctx, event); if (event->is_delayed_response) { +#ifdef BUILD_HAS_NOTIFICATION allocated_event = __fwk_thread_search_delayed_response( event->source_id, event->cookie); if (allocated_event == NULL) @@ -234,6 +235,9 @@ static int put_event(struct __fwk_thread_ctx *target_thread_ctx, memcpy(allocated_event->params, event->params, sizeof(allocated_event->params)); allocated_event->is_thread_wakeup_event = event->is_thread_wakeup_event; +#else + return FWK_E_PANIC; +#endif } else { allocated_event = duplicate_event(event); if (allocated_event == NULL) @@ -309,12 +313,16 @@ static void process_event_requiring_response(struct fwk_event *event) if (!resp_event.is_delayed_response) put_event(source_thread_ctx, &resp_event); else { +#ifdef BUILD_HAS_NOTIFICATION allocated_event = duplicate_event(&resp_event); if (allocated_event != NULL) { fwk_list_push_tail( __fwk_thread_get_delayed_response_list(resp_event.source_id), &allocated_event->slist_node); } +#else + FWK_LOG_CRIT(err_msg_line, status, __LINE__); +#endif } } -- GitLab From 93e62d0d6461a680d6ac019e33ad3977a3f018ec Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 09:57:11 +0100 Subject: [PATCH 3/9] mod_reset_domain: allow build without notification support Allow module reset_domain to built without BUILD_HAS_NOTIFICATION. Signed-off-by: Etienne Carriere --- module/reset_domain/src/mod_reset_domain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/reset_domain/src/mod_reset_domain.c b/module/reset_domain/src/mod_reset_domain.c index 5c60d0781..a6c96ea4e 100644 --- a/module/reset_domain/src/mod_reset_domain.c +++ b/module/reset_domain/src/mod_reset_domain.c @@ -58,6 +58,7 @@ static const struct mod_reset_domain_drv_api reset_api = { .set_reset_state = set_reset_state, }; +#ifdef BUILD_HAS_NOTIFICATION static int reset_issued_notify(fwk_id_t dev_id, uint32_t reset_state, uintptr_t cookie) @@ -108,6 +109,7 @@ static int rd_process_event( return reset_issued_notify(params->dev_id, params->reset_state, params->cookie); } +#endif /* BUILD_HAS_NOTIFICATION */ /* * Framework handlers @@ -177,11 +179,15 @@ const struct fwk_module module_reset_domain = { .name = "Reset domain", .type = FWK_MODULE_TYPE_HAL, .api_count = MOD_RESET_DOMAIN_API_COUNT, +#ifdef BUILD_HAS_NOTIFICATION .notification_count = MOD_RESET_DOMAIN_NOTIFICATION_IDX_COUNT, +#endif .event_count = MOD_RESET_DOMAIN_EVENT_IDX_COUNT, .init = rd_init, .element_init = rd_element_init, .bind = rd_bind, .process_bind_request = rd_process_bind_request, +#ifdef BUILD_HAS_NOTIFICATION .process_event = rd_process_event, +#endif }; -- GitLab From 69b61cbcd6e42d5def6d65c327c037ee6860b90f Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 09:58:37 +0100 Subject: [PATCH 4/9] mod_power_domain: allow build without notification support Allow module power_domain to built without BUILD_HAS_NOTIFICATION. Signed-off-by: Etienne Carriere --- .../power_domain/include/mod_power_domain.h | 2 ++ module/power_domain/src/mod_power_domain.c | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index 71395d4b3..3e9c5b688 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -780,6 +780,7 @@ static const fwk_id_t mod_pd_api_id_driver_input = FWK_ID_API_INIT(FWK_MODULE_IDX_POWER_DOMAIN, MOD_PD_API_IDX_DRIVER_INPUT); #endif +#ifdef BUILD_HAS_NOTIFICATION /*! * \brief Notification indices. */ @@ -885,6 +886,7 @@ static const fwk_id_t mod_pd_public_event_id_get_state = FWK_ID_EVENT_INIT(FWK_MODULE_IDX_POWER_DOMAIN, MOD_PD_PUBLIC_EVENT_IDX_GET_STATE); #endif +#endif /* BUILD_HAS_NOTIFICATION */ /*! * \} diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index 35f6d613b..fb2b4bf26 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -582,6 +582,7 @@ static bool is_allowed_by_parent_and_children(struct pd_ctx *pd, return true; } +#ifdef BUILD_HAS_NOTIFICATION /* * Check whether a power state pre-transition notification must be sent. * @@ -603,6 +604,7 @@ static bool check_power_state_pre_transition_notification(struct pd_ctx *pd, return true; } +#endif /* BUILD_HAS_NOTIFICATION */ /* * Initiate a power state pre-transition notification if necessary. @@ -615,6 +617,7 @@ static bool check_power_state_pre_transition_notification(struct pd_ctx *pd, */ static bool initiate_power_state_pre_transition_notification(struct pd_ctx *pd) { +#ifdef BUILD_HAS_NOTIFICATION unsigned int state; struct fwk_event notification_event = { .id = mod_pd_notification_id_power_state_pre_transition, @@ -653,6 +656,9 @@ static bool initiate_power_state_pre_transition_notification(struct pd_ctx *pd) return (pd->power_state_pre_transition_notification_ctx.pending_responses != 0); +#else + return false; +#endif } /* @@ -892,10 +898,15 @@ static void process_set_state_request( return; if (pd_in_charge_of_response != NULL) { +#ifdef BUILD_HAS_NOTIFICATION resp_event->is_delayed_response = true; resp_event->source_id = pd_in_charge_of_response->id; pd_in_charge_of_response->response.pending = true; pd_in_charge_of_response->response.cookie = resp_event->cookie; +#else + FWK_LOG_ERR("[PD] Notification not supported"); + fwk_unexpected(); +#endif } else { resp_params->status = status; resp_params->composite_state = composite_state; @@ -1115,12 +1126,14 @@ static void process_power_state_transition_report(struct pd_ctx *pd, { unsigned int new_state = report_params->state; unsigned int previous_state; +#ifdef BUILD_HAS_NOTIFICATION struct fwk_event notification_event = { .id = mod_pd_notification_id_power_state_transition, .response_requested = true, .source_id = FWK_ID_NONE }; struct mod_pd_power_state_transition_notification_params *params; +#endif if (new_state == pd->requested_state) respond(pd, FWK_SUCCESS); @@ -1128,6 +1141,7 @@ static void process_power_state_transition_report(struct pd_ctx *pd, previous_state = pd->current_state; pd->current_state = new_state; +#ifdef BUILD_HAS_NOTIFICATION if (pd->power_state_transition_notification_ctx.pending_responses == 0 && pd->config->disable_state_transition_notifications == false) { params = (struct mod_pd_power_state_transition_notification_params *) @@ -1137,6 +1151,7 @@ static void process_power_state_transition_report(struct pd_ctx *pd, fwk_notification_notify(¬ification_event, &pd->power_state_transition_notification_ctx.pending_responses); } +#endif if ((mod_pd_ctx.system_suspend.last_core_off_ongoing) && (pd == mod_pd_ctx.system_suspend.last_core_pd)) { @@ -1154,6 +1169,7 @@ static void process_power_state_transition_report(struct pd_ctx *pd, } } +#ifdef BUILD_HAS_NOTIFICATION /* * If notifications are pending, the transition report is delayed until all * the state change notifications responses have arrived. @@ -1169,6 +1185,7 @@ static void process_power_state_transition_report(struct pd_ctx *pd, return; } +#endif if (is_deeper_state(new_state, previous_state)) process_power_state_transition_report_deeper_state(pd); @@ -1945,6 +1962,7 @@ static int pd_process_event(const struct fwk_event *event, } } +#ifdef BUILD_HAS_NOTIFICATION static int process_pre_shutdown_notification_response(void) { if (mod_pd_ctx.system_shutdown.ongoing) { @@ -2005,6 +2023,7 @@ static int process_power_state_pre_transition_notification_response( return FWK_SUCCESS; } + static int process_power_state_transition_notification_response( struct pd_ctx *pd) { @@ -2088,6 +2107,7 @@ static int pd_process_notification(const struct fwk_event *event, (struct mod_pd_power_state_pre_transition_notification_resp_params *) event->params); } +#endif /* BUILD_HAS_NOTIFICATION */ /* Module definition */ const struct fwk_module module_power_domain = { @@ -2105,5 +2125,7 @@ const struct fwk_module module_power_domain = { .start = pd_start, .process_bind_request = pd_process_bind_request, .process_event = pd_process_event, +#ifdef BUILD_HAS_NOTIFICATION .process_notification = pd_process_notification +#endif }; -- GitLab From 896af899dda9cd9ae7e9899326ce8b7725231432 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 10:08:42 +0100 Subject: [PATCH 5/9] mod_clock: allow build without notification support Allow module clock to built without BUILD_HAS_NOTIFICATION. Note that when notification is disabled, module clock does not expect any configuration data. Signed-off-by: Etienne Carriere --- module/clock/src/mod_clock.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/module/clock/src/mod_clock.c b/module/clock/src/mod_clock.c index cecafc118..eb76e75b0 100644 --- a/module/clock/src/mod_clock.c +++ b/module/clock/src/mod_clock.c @@ -31,6 +31,7 @@ struct clock_dev_ctx { /* Driver API */ struct mod_clock_drv_api *api; +#ifdef BUILD_HAS_NOTIFICATION /* Cookie for the pre-transition notification response */ unsigned int pd_pre_power_transition_notification_cookie; @@ -39,6 +40,7 @@ struct clock_dev_ctx { /* Status of the pending transition */ unsigned int transition_pending_response_status; +#endif /* A request is on-going */ bool is_request_ongoing; @@ -61,7 +63,7 @@ static struct clock_ctx module_ctx; /* * Utility functions */ - +#ifdef BUILD_HAS_NOTIFICATION static int process_response_event(const struct fwk_event *event) { int status; @@ -86,6 +88,7 @@ static int process_response_event(const struct fwk_event *event) return fwk_thread_put_event(&resp_event); } +#endif /* BUILD_HAS_NOTIFICATION */ static int process_request_event(const struct fwk_event *event, struct fwk_event *resp_event) @@ -320,8 +323,10 @@ static int clock_init(fwk_id_t module_id, unsigned int element_count, if (element_count == 0) return FWK_SUCCESS; +#ifdef BUILD_HAS_NOTIFICATION if (config == NULL) return FWK_E_PARAM; +#endif module_ctx.config = config; module_ctx.dev_ctx_table = fwk_mm_calloc(element_count, @@ -362,7 +367,9 @@ static int clock_bind(fwk_id_t id, unsigned int round) static int clock_start(fwk_id_t id) { +#ifdef BUILD_HAS_NOTIFICATION int status; +#endif struct clock_dev_ctx *ctx; /* Nothing to be done at the module level */ @@ -374,6 +381,7 @@ static int clock_start(fwk_id_t id) if (fwk_id_is_type(ctx->config->pd_source_id, FWK_ID_TYPE_NONE)) return FWK_SUCCESS; +#ifdef BUILD_HAS_NOTIFICATION if ((ctx->api->process_power_transition != NULL) && (fwk_id_is_type( module_ctx.config->pd_transition_notification_id, @@ -397,6 +405,7 @@ static int clock_start(fwk_id_t id) if (status != FWK_SUCCESS) return status; } +#endif return FWK_SUCCESS; } @@ -405,7 +414,9 @@ static int clock_process_bind_request(fwk_id_t source_id, fwk_id_t target_id, fwk_id_t api_id, const void **api) { enum mod_clock_api_type api_type = fwk_id_get_api_idx(api_id); +#ifdef BUILD_HAS_NOTIFICATION struct clock_dev_ctx *ctx; +#endif switch (api_type) { case MOD_CLOCK_API_TYPE_HAL: @@ -413,6 +424,7 @@ static int clock_process_bind_request(fwk_id_t source_id, fwk_id_t target_id, return FWK_SUCCESS; +#ifdef BUILD_HAS_NOTIFICATION case MOD_CLOCK_API_TYPE_DRIVER_RESPONSE: if (!fwk_id_is_type(target_id, FWK_ID_TYPE_ELEMENT)) return FWK_E_PARAM; @@ -425,12 +437,14 @@ static int clock_process_bind_request(fwk_id_t source_id, fwk_id_t target_id, return FWK_E_ACCESS; return FWK_SUCCESS; +#endif default: return FWK_E_ACCESS; } } +#ifdef BUILD_HAS_NOTIFICATION static int clock_process_pd_pre_transition_notification( struct clock_dev_ctx *ctx, const struct fwk_event *event, @@ -617,6 +631,7 @@ static int clock_process_notification( else return FWK_E_HANDLER; } +#endif /* BUILD_HAS_NOTIFICATION */ static int clock_process_event(const struct fwk_event *event, struct fwk_event *resp_event) @@ -630,10 +645,10 @@ static int clock_process_event(const struct fwk_event *event, case MOD_CLOCK_EVENT_IDX_SET_STATE_REQUEST: case MOD_CLOCK_EVENT_IDX_GET_STATE_REQUEST: return process_request_event(event, resp_event); - +#ifdef BUILD_HAS_NOTIFICATION case CLOCK_EVENT_IDX_RESPONSE: return process_response_event(event); - +#endif default: return FWK_E_PANIC; } @@ -644,12 +659,16 @@ const struct fwk_module module_clock = { .type = FWK_MODULE_TYPE_HAL, .api_count = MOD_CLOCK_API_COUNT, .event_count = CLOCK_EVENT_IDX_COUNT, +#ifdef BUILD_HAS_NOTIFICATION .notification_count = MOD_CLOCK_NOTIFICATION_IDX_COUNT, +#endif .init = clock_init, .element_init = clock_dev_init, .bind = clock_bind, .start = clock_start, .process_bind_request = clock_process_bind_request, +#ifdef BUILD_HAS_NOTIFICATION .process_notification = clock_process_notification, +#endif .process_event = clock_process_event, }; -- GitLab From 29fcc8d8ffb14b5d8a18c4a07d8b8516f048b4a3 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 10:16:59 +0100 Subject: [PATCH 6/9] mod_dvfs: allow build without timer support Allow module dvfs to build without BUILD_HAS_MOD_TIMER. In such case, dvfs configuration data retry_ms must be zero, since we can program an delay before another state change attempt. Signed-off-by: Etienne Carriere --- module/dvfs/src/mod_dvfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/module/dvfs/src/mod_dvfs.c b/module/dvfs/src/mod_dvfs.c index 605c2d1d9..725668f61 100644 --- a/module/dvfs/src/mod_dvfs.c +++ b/module/dvfs/src/mod_dvfs.c @@ -103,8 +103,10 @@ struct mod_dvfs_domain_ctx { /* Clock API */ const struct mod_clock_api *clock; +#if BUILD_HAS_MOD_TIMER /* Alarm API for pending requests */ const struct mod_timer_alarm_api *alarm_api; +#endif /* DVFS perf updates notification API */ struct mod_dvfs_perf_updated_api *perf_updated_api; @@ -309,6 +311,7 @@ static void dvfs_flush_pending_request(struct mod_dvfs_domain_ctx *ctx) ctx->pending_request = (struct mod_dvfs_request){ 0 }; } +#if BUILD_HAS_MOD_TIMER static void alarm_callback(uintptr_t param) { struct fwk_event req; @@ -324,6 +327,7 @@ static void alarm_callback(uintptr_t param) fwk_thread_put_event(&req); } +#endif static int dvfs_handle_pending_request(struct mod_dvfs_domain_ctx *ctx) { @@ -333,11 +337,15 @@ static int dvfs_handle_pending_request(struct mod_dvfs_domain_ctx *ctx) return FWK_SUCCESS; if (ctx->config->retry_ms > 0) { +#if BUILD_HAS_MOD_TIMER status = ctx->apis.alarm_api->start(ctx->config->alarm_id, ctx->config->retry_ms, MOD_TIMER_ALARM_TYPE_ONCE, alarm_callback, (uintptr_t)ctx); if (status == FWK_SUCCESS) ctx->state = DVFS_DOMAIN_STATE_RETRY; +#else + fwk_unexpected(); +#endif } else { /* * If this domain does not have a timeout configured we start @@ -1173,10 +1181,15 @@ dvfs_bind_element(fwk_id_t domain_id, unsigned int round) /* Bind to the alarm HAL if required */ if (ctx->config->retry_ms > 0) { +#if BUILD_HAS_MOD_TIMER status = fwk_module_bind(ctx->config->alarm_id, MOD_TIMER_API_ID_ALARM, &ctx->apis.alarm_api); if (status != FWK_SUCCESS) return FWK_E_PANIC; +#else + FWK_LOG_CRIT("[DVFS] Non-zero retry_ms without BUILD_HAS_MOD_TIMER"); + return FWK_E_PANIC; +#endif } return FWK_SUCCESS; -- GitLab From a934e9c41cdc43f0c55fdfbf457898004c5553ca Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 10:20:21 +0100 Subject: [PATCH 7/9] mod_dvfs: allow build without multithreading Allow module dvfs to build without BUILD_HAS_MULTITHREADING. Signed-off-by: Etienne Carriere --- module/dvfs/src/mod_dvfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/dvfs/src/mod_dvfs.c b/module/dvfs/src/mod_dvfs.c index 725668f61..2fab9e238 100644 --- a/module/dvfs/src/mod_dvfs.c +++ b/module/dvfs/src/mod_dvfs.c @@ -664,6 +664,7 @@ static void dvfs_complete_respond(struct mod_dvfs_domain_ctx *ctx, return_opp = true; if (ctx->cookie != 0) { +#ifdef BUILD_HAS_MULTITHREADING /* * The request was handled asynchronously, retrieve * the delayed_response and return it to the caller @@ -682,6 +683,9 @@ static void dvfs_complete_respond(struct mod_dvfs_domain_ctx *ctx, fwk_thread_put_event(&read_req_event); } ctx->cookie = 0; +#else + fwk_unexpected(); +#endif } else if (resp_event != NULL) { /* * The request is being handled synchronously, return -- GitLab From 9b17e4871aceccb33977950736c81f56432b976a Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 11:21:55 +0100 Subject: [PATCH 8/9] mod_power_domain: support single thread configuration Allow module power_domain to build without BUILD_HAS_MULTITHREADING. Signed-off-by: Etienne Carriere --- module/power_domain/src/mod_power_domain.c | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index fb2b4bf26..01e771160 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -18,7 +18,11 @@ #include #include #include +#ifdef BUILD_HAS_MULTITHREADING #include +#else +#include +#endif #include #include #include @@ -733,8 +737,12 @@ static void respond(struct pd_ctx *pd, int resp_status) if (!pd->response.pending) return; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_get_delayed_response( pd->id, pd->response.cookie, &resp_event); +#else + status = FWK_E_PARAM; +#endif pd->response.pending = false; if (status != FWK_SUCCESS) @@ -1461,7 +1469,11 @@ static int pd_set_state(fwk_id_t pd_id, uint32_t state) req_params->composite_state = state; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_put_event_and_wait(&req, &resp); +#else + status = pd_process_event(&req, &resp); +#endif if (status != FWK_SUCCESS) return status; @@ -1522,7 +1534,11 @@ static int pd_get_state(fwk_id_t pd_id, unsigned int *state) req_params->composite = false; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_put_event_and_wait(&req, &resp); +#else + status = pd_process_event(&req, &resp); +#endif if (status != FWK_SUCCESS) return status; @@ -1546,7 +1562,11 @@ static int pd_reset(fwk_id_t pd_id) .target_id = pd_id, }; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_put_event_and_wait(&req, &resp); +#else + status = pd_process_event(&req, &resp); +#endif if (status != FWK_SUCCESS) return status; @@ -1570,7 +1590,11 @@ static int pd_system_suspend(unsigned int state) req_params->state = state; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_put_event_and_wait(&req, &resp); +#else + status = pd_process_event(&req, &resp); +#endif if (status != FWK_SUCCESS) return status; @@ -1583,6 +1607,9 @@ static int pd_system_shutdown(enum mod_pd_system_shutdown system_shutdown) struct fwk_event req; struct pd_system_shutdown_request *req_params = (struct pd_system_shutdown_request *)(&req.params); +#ifdef BUILD_HAS_MULTITHREADING + struct pd_response *resp_params = (struct pd_response *)resp.params; +#endif req = (struct fwk_event) { .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, @@ -1592,11 +1619,19 @@ static int pd_system_shutdown(enum mod_pd_system_shutdown system_shutdown) req_params->system_shutdown = system_shutdown; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_put_event(&req); if (status == FWK_SUCCESS) return FWK_PENDING; return status; +#else + status = pd_process_event(&req, &resp); + if (status != FWK_SUCCESS) + return status; + + return resp_params->status; +#endif } /* Functions specific to the driver input API */ @@ -1704,7 +1739,11 @@ static int pd_init(fwk_id_t module_id, unsigned int dev_count, mod_pd_ctx.pd_count = dev_count; mod_pd_ctx.system_pd_ctx = &mod_pd_ctx.pd_ctx_table[dev_count - 1]; +#ifdef BUILD_HAS_MULTITHREADING + return fwk_thread_create(module_id); +#else return FWK_SUCCESS; +#endif } static int pd_power_domain_init(fwk_id_t pd_id, unsigned int unused, -- GitLab From cc9c7aacd9d1f54a2f91aa6ed3f91b24769576ee Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 2 Dec 2020 11:22:10 +0100 Subject: [PATCH 9/9] mod_psu: support single thread configuration Allow module psu to build without BUILD_HAS_MULTITHREADING. Signed-off-by: Etienne Carriere --- module/psu/src/mod_psu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/psu/src/mod_psu.c b/module/psu/src/mod_psu.c index b89296eef..928b902a2 100644 --- a/module/psu/src/mod_psu.c +++ b/module/psu/src/mod_psu.c @@ -400,10 +400,15 @@ static int mod_psu_process_event( case MOD_PSU_IMPL_EVENT_IDX_RESPONSE: ctx->op.state = MOD_PSU_STATE_IDLE; +#ifdef BUILD_HAS_MULTITHREADING status = fwk_thread_get_delayed_response( event->target_id, ctx->op.cookie, &hal_event); +#else + status = FWK_E_PARAM; +#endif + if (status != FWK_SUCCESS) return status; -- GitLab