Skip to content

Commit d2c8f54

Browse files
authored
Merge pull request #42 from intel/nayana_dev_11363
Changes for 11363 release for Chrome
2 parents d732418 + 0f6cd86 commit d2c8f54

File tree

9 files changed

+159
-34
lines changed

9 files changed

+159
-34
lines changed

Common/Ver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
#define VER_MAJOR 1
2222
#define VER_MINOR 0
2323
#define VER_HOTFIX 11363
24-
#define VER_BUILD 34041
24+
#define VER_BUILD 34997

DPTF/Sources/DptfVer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define VER_MAJOR 9
2222
#define VER_MINOR 0
2323
#define VER_HOTFIX 11363
24-
#define VER_BUILD 34041
24+
#define VER_BUILD 34997
2525

2626
#define ARG_TOSTR(arg) #arg
2727
#define VER_TOSTR(arg) ARG_TOSTR(arg)

ESIF/Products/ESIF_UF/Sources/esif_uf_domain.c

+22-17
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,18 @@ static void EsifUpDomain_PollState(
935935
{
936936
eEsifError rc = ESIF_OK;
937937
EsifUpDomainPtr self = (EsifUpDomainPtr) ctx;
938-
938+
EsifUpPtr upPtr = NULL;
939+
939940
if (self == NULL) {
940941
goto exit;
941942
}
942943

944+
upPtr = EsifUpPm_GetAvailableParticipantByInstance(self->participantId);
945+
if (upPtr == NULL) {
946+
rc = ESIF_E_INVALID_HANDLE;
947+
goto exit;
948+
}
949+
943950
rc = EsifUpDomain_CheckState(self);
944951

945952
/* If another type of polling was started, skip the timer reset */
@@ -949,7 +956,10 @@ static void EsifUpDomain_PollState(
949956

950957
rc = EsifUpDomain_StartStatePollPriv(self);
951958
exit:
952-
959+
if (upPtr != NULL) {
960+
EsifUp_PutRef(upPtr);
961+
}
962+
953963
if (rc != ESIF_OK) {
954964
ESIF_TRACE_DEBUG("Unable to set poll timer on %s %s : %s(%d)\n", self->participantName, self->domainName, esif_rc_str(rc), rc);
955965
}
@@ -962,34 +972,19 @@ static void EsifUpDomain_PollTemp(
962972
{
963973
eEsifError rc = ESIF_OK;
964974
EsifUpDomainPtr self = (EsifUpDomainPtr) ctx;
965-
EsifDspPtr dspPtr = NULL;
966975
EsifUpPtr upPtr = NULL;
967976
UInt32 pollPeriod = 0;
968977

969978
if (self == NULL) {
970979
goto exit;
971980
}
972981

973-
974-
/* check to see if anyone has killed the action manager or dsp manager
975-
in between polls */
976982
upPtr = EsifUpPm_GetAvailableParticipantByInstance(self->participantId);
977983
if (upPtr == NULL) {
978984
rc = ESIF_E_INVALID_HANDLE;
979985
goto exit;
980986
}
981987

982-
dspPtr = EsifUp_GetDsp(upPtr);
983-
if (dspPtr == NULL) {
984-
rc = ESIF_E_INVALID_HANDLE;
985-
goto exit;
986-
}
987-
988-
if (dspPtr->type == NULL) {
989-
rc = ESIF_E_INVALID_HANDLE;
990-
goto exit;
991-
}
992-
993988
rc = EsifUpDomain_CheckTemp(self);
994989

995990
/* If another type of polling was started, skip the timer reset */
@@ -1228,6 +1223,16 @@ void EsifUpDomain_StopTempPoll(
12281223
self->tempPollType = ESIF_POLL_NONE;
12291224
}
12301225

1226+
void EsifUpDomain_StopStatePoll(
1227+
EsifUpDomainPtr self
1228+
)
1229+
{
1230+
esif_ccb_timer_kill_w_wait(&self->statePollTimer);
1231+
1232+
self->statePollInitialized = ESIF_FALSE;
1233+
self->statePollType = ESIF_POLL_NONE;
1234+
}
1235+
12311236
eEsifError EsifUpDomain_SetTempPollPeriod(
12321237
EsifUpDomainPtr self,
12331238
UInt32 sampleTime

ESIF/Products/ESIF_UF/Sources/esif_uf_domain.h

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ void EsifUpDomain_StopTempPoll(
147147
EsifUpDomainPtr self
148148
);
149149

150+
void EsifUpDomain_StopStatePoll(
151+
EsifUpDomainPtr self
152+
);
153+
150154
eEsifError EsifUpDomain_Poll(EsifUpDomainPtr self);
151155

152156
eEsifError EsifUpDomain_CheckTemp(EsifUpDomainPtr self);

ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.c

+103-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "esif_uf_eventmgr.h"
2626
#include "esif_queue.h"
2727
#include "esif_uf_sensors.h"
28+
#include "esif_uf_ccb_timedwait.h"
2829

2930

3031
#define NUM_EVENT_LISTS 64
@@ -56,6 +57,9 @@ typedef struct EsifEventMgr_s {
5657
esif_ccb_lock_t appUnregisterListLock;
5758
Bool delayedAppUnregistrationEnabled;
5859
Bool delayAppUnregistration;
60+
61+
/* Used to control destruction of the context for synchronous events */
62+
esif_ccb_lock_t synchronousEventLock;
5963
}EsifEventMgr, *EsifEventMgrPtr;
6064

6165
typedef struct EventMgrEntry_s {
@@ -73,13 +77,20 @@ typedef struct EventMgrEntry_s {
7377
Bool markedForDelete; /* Indicates the event is marked for deletion */
7478
} EventMgrEntry, *EventMgrEntryPtr;
7579

80+
81+
typedef struct EsifEventMgr_SynchronousEventContext_s {
82+
Bool useComplete;
83+
esif_ccb_event_t completionEvent;
84+
} EsifEventMgr_SynchronousEventContext;
85+
7686
typedef struct EsifEventQueueItem_s {
7787
esif_handle_t participantId;
7888
UInt16 domainId;
7989
eEsifEventType eventType;
8090
EsifData eventData;
8191
Bool isLfEvent;
8292
Bool isUnfiltered;
93+
EsifEventMgr_SynchronousEventContext *syncContextPtr;
8394
}EsifEventQueueItem, *EsifEventQueueItemPtr;
8495

8596

@@ -166,12 +177,16 @@ static eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local (
166177
eEsifEventType eventType,
167178
const EsifDataPtr eventDataPtr,
168179
Bool isLfEvent,
169-
Bool isFilteredEvent
180+
Bool isFilteredEvent,
181+
EsifEventMgr_SynchronousEventContext *syncContextPtr
170182
);
171183

172184
static Bool EsifEventMgr_IsEventFiltered(eEsifEventType eventType);
173185
static Bool EsifEventMgr_IsEventCacheable(eEsifEventType eventType);
174186

187+
static void DestroySynchronizationContext(EsifEventMgr_SynchronousEventContext *syncContextPtr);
188+
189+
175190
/*
176191
* Friend function: Target is determined only once removed from queue and all
177192
* others before it have been processed
@@ -191,7 +206,69 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent(
191206
const EsifDataPtr eventDataPtr
192207
)
193208
{
194-
return EsifEventMgr_SignalEvent_Local(participantId, domainId, eventType, eventDataPtr, ESIF_FALSE, ESIF_TRUE);
209+
return EsifEventMgr_SignalEvent_Local(participantId, domainId, eventType, eventDataPtr, ESIF_FALSE, ESIF_TRUE, NULL);
210+
}
211+
212+
/*
213+
* Used to signal an event that will be processed synchronously for up to the
214+
* specified wait time
215+
* NOTE: Maximum allowed wait time is EVENT_MGR_SYNCHRONOUS_EVENT_TIME_MAX
216+
*/
217+
eEsifError ESIF_CALLCONV EsifEventMgr_SignalSynchronousEvent(
218+
esif_handle_t participantId,
219+
UInt16 domainId,
220+
eEsifEventType eventType,
221+
const EsifDataPtr eventDataPtr,
222+
esif_ccb_time_t msWait
223+
)
224+
{
225+
esif_error_t rc = ESIF_OK;
226+
EsifEventMgr_SynchronousEventContext *syncContextPtr = NULL;
227+
228+
syncContextPtr = (EsifEventMgr_SynchronousEventContext *)esif_ccb_malloc(sizeof(*syncContextPtr));
229+
if (!syncContextPtr) {
230+
rc = ESIF_E_NO_MEMORY;
231+
goto exit;
232+
}
233+
esif_ccb_event_init(&syncContextPtr->completionEvent);
234+
esif_ccb_event_reset(&syncContextPtr->completionEvent);
235+
236+
rc = EsifEventMgr_SignalEvent_Local(participantId, domainId, eventType, eventDataPtr, ESIF_FALSE, ESIF_TRUE, syncContextPtr);
237+
238+
EsifTimedEventWait(&syncContextPtr->completionEvent, esif_ccb_min(msWait, EVENT_MGR_SYNCHRONOUS_EVENT_TIME_MAX));
239+
240+
DestroySynchronizationContext(syncContextPtr);
241+
exit:
242+
return rc;
243+
}
244+
245+
246+
static void DestroySynchronizationContext(
247+
EsifEventMgr_SynchronousEventContext *syncContextPtr
248+
)
249+
{
250+
Bool canDestroyContext = ESIF_FALSE;
251+
252+
if (syncContextPtr) {
253+
esif_ccb_write_lock(&g_EsifEventMgr.synchronousEventLock);
254+
255+
if (syncContextPtr->useComplete) {
256+
/* If other thread is already done, mark to destroy context by current thread */
257+
canDestroyContext = ESIF_TRUE;
258+
}
259+
else {
260+
/* Indicate current thread is done using context so it can be destroyed by other thread */
261+
syncContextPtr->useComplete = ESIF_TRUE;
262+
}
263+
264+
esif_ccb_write_unlock(&g_EsifEventMgr.synchronousEventLock);
265+
266+
/* Destroy context outside locks if needed */
267+
if (canDestroyContext) {
268+
esif_ccb_event_uninit(&syncContextPtr->completionEvent);
269+
esif_ccb_free(syncContextPtr);
270+
}
271+
}
195272
}
196273

197274

@@ -206,7 +283,7 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalLfEvent(
206283
const EsifDataPtr eventDataPtr
207284
)
208285
{
209-
return EsifEventMgr_SignalEvent_Local(targetId, domainId, eventType, eventDataPtr, ESIF_TRUE, ESIF_TRUE);
286+
return EsifEventMgr_SignalEvent_Local(targetId, domainId, eventType, eventDataPtr, ESIF_TRUE, ESIF_TRUE, NULL);
210287
}
211288

212289

@@ -217,17 +294,18 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalUnfilteredEvent(
217294
const EsifDataPtr eventDataPtr
218295
)
219296
{
220-
return EsifEventMgr_SignalEvent_Local(participantId, domainId, eventType, eventDataPtr, ESIF_FALSE, ESIF_FALSE);
297+
return EsifEventMgr_SignalEvent_Local(participantId, domainId, eventType, eventDataPtr, ESIF_FALSE, ESIF_FALSE, NULL);
221298
}
222299

223300

224-
eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local(
301+
static eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local(
225302
esif_handle_t participantId,
226303
UInt16 domainId,
227304
eEsifEventType eventType,
228305
const EsifDataPtr eventDataPtr,
229306
Bool isLfEvent,
230-
Bool isFilteredEvent
307+
Bool isFilteredEvent,
308+
EsifEventMgr_SynchronousEventContext *syncContextPtr
231309
)
232310
{
233311
eEsifError rc = ESIF_OK;
@@ -250,7 +328,10 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local(
250328
rc = ESIF_E_NO_MEMORY;
251329
goto exit;
252330
}
253-
331+
/*
332+
* Make a copy of the data as the thread exposing it will continue and may
333+
* destroy it
334+
*/
254335
if ((eventDataPtr != NULL) &&
255336
(eventDataPtr->buf_ptr != NULL) &&
256337
(eventDataPtr->buf_len > 0) &&
@@ -275,6 +356,7 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local(
275356
queueEventPtr->domainId = domainId;
276357
queueEventPtr->eventType = eventType;
277358
queueEventPtr->isLfEvent = isLfEvent;
359+
queueEventPtr->syncContextPtr = syncContextPtr;
278360

279361
ESIF_TRACE_INFO("Queuing %s event for Part. %u Dom. 0x%04X\n",
280362
esif_event_type_str(eventType),
@@ -290,7 +372,11 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent_Local(
290372
if (rc != ESIF_OK) {
291373
esif_ccb_free(queueEventPtr);
292374
esif_ccb_free(queueDataPtr);
293-
375+
if (syncContextPtr) {
376+
/* Release synchronous waiter and destroy context if needed */
377+
esif_ccb_event_set(&syncContextPtr->completionEvent);
378+
DestroySynchronizationContext(syncContextPtr);
379+
}
294380
}
295381
return rc;
296382
}
@@ -334,6 +420,12 @@ static void *ESIF_CALLCONV EsifEventMgr_EventQueueThread(void *ctxPtr)
334420
queueEventPtr->eventType,
335421
&queueEventPtr->eventData);
336422
}
423+
424+
/* Release any synchronous event waiters */
425+
if (queueEventPtr->syncContextPtr) {
426+
esif_ccb_event_set(&queueEventPtr->syncContextPtr->completionEvent);
427+
DestroySynchronizationContext(queueEventPtr->syncContextPtr);
428+
}
337429
esif_ccb_free(queueEventPtr->eventData.buf_ptr);
338430
esif_ccb_free(queueEventPtr);
339431
}
@@ -1243,6 +1335,8 @@ eEsifError EsifEventMgr_Init(void)
12431335

12441336
esif_ccb_lock_init(&g_EsifEventMgr.listLock);
12451337
esif_ccb_lock_init(&g_EsifEventMgr.appUnregisterListLock);
1338+
esif_ccb_lock_init(&g_EsifEventMgr.synchronousEventLock);
1339+
12461340

12471341
for (i = 0; i < NUM_EVENT_LISTS; i++) {
12481342
g_EsifEventMgr.observerLists[i] = esif_link_list_create();
@@ -1343,6 +1437,7 @@ void EsifEventMgr_Exit(void)
13431437
g_EsifEventMgr.garbageList = NULL;
13441438
esif_ccb_write_unlock(&g_EsifEventMgr.listLock);
13451439

1440+
esif_ccb_lock_uninit(&g_EsifEventMgr.synchronousEventLock);
13461441
esif_ccb_lock_uninit(&g_EsifEventMgr.listLock);
13471442
esif_ccb_lock_uninit(&g_EsifEventMgr.appUnregisterListLock);
13481443

ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.h

+14
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#define ESIF_UF_EVENT_QUEUE_SIZE 0xFFFFFFFF
8181
#define ESIF_UF_EVENT_QUEUE_NAME "UfQueue"
8282
#define ESIF_UF_EVENT_QUEUE_TIMEOUT ESIF_QUEUE_TIMEOUT_INFINITE /* No timeout */
83+
#define EVENT_MGR_SYNCHRONOUS_EVENT_TIME_MAX 10000 /* ms */
8384

8485
#include "lin/esif_uf_sensor_manager_os_lin.h"
8586

@@ -170,6 +171,19 @@ eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent(
170171
const EsifDataPtr eventData
171172
);
172173

174+
/*
175+
* Used to signal an event that will be processed synchronously for up to the
176+
* specified wait time
177+
* NOTE: Maximum allowed wait time is EVENT_MGR_SYNCHRONOUS_EVENT_TIME_MAX
178+
*/
179+
eEsifError ESIF_CALLCONV EsifEventMgr_SignalSynchronousEvent(
180+
esif_handle_t participantId,
181+
UInt16 domainId,
182+
eEsifEventType eventType,
183+
const EsifDataPtr eventData,
184+
esif_ccb_time_t waitTime
185+
);
186+
173187
/* For simulation/shell use */
174188
eEsifError ESIF_CALLCONV EsifEventMgr_SignalUnfilteredEvent(
175189
esif_handle_t participantId,

ESIF/Products/ESIF_UF/Sources/esif_uf_participant.c

+4
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,10 @@ eEsifError EsifUp_SuspendParticipant(
10471047
}
10481048

10491049
EsifUpDomain_StopTempPoll(domainPtr);
1050+
/* Perf state detection handled in upper framework for Sysfs model */
1051+
#ifdef ESIF_FEAT_OPT_ACTION_SYSFS
1052+
EsifUpDomain_StopStatePoll(domainPtr);
1053+
#endif
10501054
rc = EsifUpDomain_GetNextUd(&udIter, &domainPtr);
10511055
}
10521056

ESIF/Products/ESIF_UF/Sources/esif_uf_pm.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ static eEsifError EsifUpPm_ResumeParticipant(
802802
rc = EsifAppMgr_CreateParticipantInAllApps(upPtr);
803803
}
804804

805-
ESIF_TRACE_INFO("Reregistered participant, instant id = " ESIF_HANDLE_FMT "\n", esif_ccb_handle2llu(upInstance));
805+
ESIF_TRACE_INFO("Reregistered participant, instant id = " ESIF_HANDLE_FMT " Participant State : %d\n", esif_ccb_handle2llu(upInstance), entryPtr->fState);
806806
exit:
807807
if (upPtr != NULL) {
808808
EsifUp_PutRef(upPtr);
@@ -836,7 +836,6 @@ eEsifError EsifUpPm_ResumeParticipants()
836836
return ESIF_OK;
837837
}
838838

839-
840839
/* Suspend Upper Participant Instance */
841840
static eEsifError EsifUpPm_SuspendParticipant(
842841
const esif_handle_t upInstance
@@ -883,7 +882,7 @@ static eEsifError EsifUpPm_SuspendParticipant(
883882
rc = EsifAppMgr_DestroyParticipantInAllApps(upPtr);
884883
}
885884

886-
ESIF_TRACE_INFO("Suspended participant, instant id = " ESIF_HANDLE_FMT "\n", esif_ccb_handle2llu(upInstance));
885+
ESIF_TRACE_INFO("Suspended participant, instant id = " ESIF_HANDLE_FMT " state : %d \n", esif_ccb_handle2llu(upInstance),entryPtr->fState);
887886
exit:
888887
EsifUp_PutRef(upPtr);
889888
return rc;

0 commit comments

Comments
 (0)