diff --git a/framework/src/fwk_multi_thread.c b/framework/src/fwk_multi_thread.c index a1a8e51a47f0bc14d45d6addbdb327587fe5dad2..5d03b7721fb2bd6996b90b9de0a5211eaaacc9f4 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 } } diff --git a/framework/src/fwk_thread.c b/framework/src/fwk_thread.c index e3bed4528ec32c141f6afea653127a4d36aae5a1..a5a879cc6a21a9395b8d310890b720db4f779bb5 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; diff --git a/module/clock/src/mod_clock.c b/module/clock/src/mod_clock.c index cecafc1180b8665917d467508dc1a904a95a363a..eb76e75b069bd90af82d0f231044fae2d13b9215 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, }; diff --git a/module/dvfs/src/mod_dvfs.c b/module/dvfs/src/mod_dvfs.c index 605c2d1d944a3f468aaa22921d4c19bc613e4817..2fab9e238f536b5c9db329575e18b3e4bfb5c1fa 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 @@ -656,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 @@ -674,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 @@ -1173,10 +1185,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; diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index 71395d4b3e1198e8d846327d8dfb97353d3df3b1..3e9c5b68809e98a9caa213994c562d944d553d8b 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 35f6d613b663eacf80643ff849400ad0b736f410..01e77116064b57effb1e93859c64fe6614d60e6d 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 @@ -582,6 +586,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 +608,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 +621,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 +660,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 } /* @@ -727,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) @@ -892,10 +906,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 +1134,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 +1149,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 +1159,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 +1177,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 +1193,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); @@ -1444,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; @@ -1505,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; @@ -1529,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; @@ -1553,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; @@ -1566,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, @@ -1575,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 */ @@ -1687,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, @@ -1945,6 +2001,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 +2062,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 +2146,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 +2164,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 }; diff --git a/module/psu/src/mod_psu.c b/module/psu/src/mod_psu.c index b89296eefc5b7668dbf90fba8d41bb3a29031f7d..928b902a2be1f946861cfde5b3889774eeb2c69a 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; diff --git a/module/reset_domain/src/mod_reset_domain.c b/module/reset_domain/src/mod_reset_domain.c index 5c60d0781bfb07c01a9e7149ed9db62cde575144..a6c96ea4e7358fa2a64433e54ee8200878aa9660 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 };