summaryrefslogtreecommitdiff
path: root/drivers/mxc
diff options
context:
space:
mode:
authorXianzhong <b07117@freescale.com>2014-03-20 02:45:18 +0800
committerRichard Liu <r66033@freescale.com>2014-05-15 15:08:32 +0800
commitb80333e3b23437b036ddd3523b8999a14035c14c (patch)
tree317ac435328ea28efe9577eb585d126c624053fb /drivers/mxc
parente1aef969535e4d90d79a679e706d07f7e1787a08 (diff)
ENGR00308899 [#1087] enhanced GPU database protection
the potential risk is found in special case when application exit, deleting record will cause the unexpected issue when process database is destoryed without atom protection the enhanced database patch should be applied to avoid the unexpected kernel issue Date: Apr 17, 2014 Signed-off-by: Xianzhong <b07117@freescale.com> Acked-by: Jason Liu
Diffstat (limited to 'drivers/mxc')
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c149
1 files changed, 78 insertions, 71 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c
index c175067fd05f..56bed68c6822 100644
--- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c
+++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c
@@ -165,7 +165,6 @@ gckKERNEL_FindDatabase(
gceSTATUS status;
gcsDATABASE_PTR database, previous;
gctSIZE_T slot;
- gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d LastProcessID=%d",
Kernel, ProcessID, LastProcessID);
@@ -173,11 +172,6 @@ gckKERNEL_FindDatabase(
/* Compute the hash for the database. */
slot = ProcessID % gcmCOUNTOF(Kernel->db->db);
- /* Acquire the database mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
- acquired = gcvTRUE;
-
/* Check whether we are getting the last known database. */
if (LastProcessID)
{
@@ -221,9 +215,6 @@ gckKERNEL_FindDatabase(
}
}
- /* Release the database mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
-
/* Return the database. */
*Database = database;
@@ -232,11 +223,6 @@ gckKERNEL_FindDatabase(
return gcvSTATUS_OK;
OnError:
- if (acquired)
- {
- /* Release the database mutex. */
- gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
- }
/* Return the status. */
gcmkFOOTER();
@@ -267,16 +253,10 @@ gckKERNEL_DeleteDatabase(
)
{
gceSTATUS status;
- gctBOOL acquired = gcvFALSE;
gcsDATABASE_PTR database;
gcmkHEADER_ARG("Kernel=0x%x Database=0x%x", Kernel, Database);
- /* Acquire the database mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
- acquired = gcvTRUE;
-
/* Check slot value. */
gcmkVERIFY_ARGUMENT(Database->slot < gcmCOUNTOF(Kernel->db->db));
@@ -323,19 +303,11 @@ gckKERNEL_DeleteDatabase(
/* Keep database as the last database. */
Kernel->db->lastDatabase = Database;
- /* Release the database mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
-
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
- if (acquired)
- {
- /* Release the database mutex. */
- gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
- }
/* Return the status. */
gcmkFOOTER();
@@ -371,16 +343,10 @@ gckKERNEL_NewRecord(
)
{
gceSTATUS status;
- gctBOOL acquired = gcvFALSE;
gcsDATABASE_RECORD_PTR record = gcvNULL;
gcmkHEADER_ARG("Kernel=0x%x Database=0x%x", Kernel, Database);
- /* Acquire the database mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
- acquired = gcvTRUE;
-
if (Kernel->db->freeRecord != gcvNULL)
{
/* Allocate the record from the free list. */
@@ -403,9 +369,6 @@ gckKERNEL_NewRecord(
record->next = Database->list[Slot];
Database->list[Slot] = record;
- /* Release the database mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
-
/* Return the record. */
*Record = record;
@@ -414,11 +377,6 @@ gckKERNEL_NewRecord(
return gcvSTATUS_OK;
OnError:
- if (acquired)
- {
- /* Release the database mutex. */
- gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
- }
if (record != gcvNULL)
{
gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, record));
@@ -464,19 +422,12 @@ gckKERNEL_DeleteRecord(
)
{
gceSTATUS status;
- gctBOOL acquired = gcvFALSE;
gcsDATABASE_RECORD_PTR record, previous;
gctUINT32 slot = _GetSlot(Database, Data);
gcmkHEADER_ARG("Kernel=0x%x Database=0x%x Type=%d Data=0x%x",
Kernel, Database, Type, Data);
- /* Acquire the database mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
- acquired = gcvTRUE;
-
-
/* Scan the database for this record. */
for (record = Database->list[slot], previous = gcvNULL;
record != gcvNULL;
@@ -520,19 +471,11 @@ gckKERNEL_DeleteRecord(
record->next = Kernel->db->freeRecord;
Kernel->db->freeRecord = record;
- /* Release the database mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
-
/* Success. */
gcmkFOOTER_ARG("*Bytes=%lu", gcmOPT_VALUE(Bytes));
return gcvSTATUS_OK;
OnError:
- if (acquired)
- {
- /* Release the database mutex. */
- gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
- }
/* Return the status. */
gcmkFOOTER();
@@ -574,18 +517,12 @@ gckKERNEL_FindRecord(
)
{
gceSTATUS status;
- gctBOOL acquired = gcvFALSE;
gcsDATABASE_RECORD_PTR record;
gctUINT32 slot = _GetSlot(Database, Data);
gcmkHEADER_ARG("Kernel=0x%x Database=0x%x Type=%d Data=0x%x",
Kernel, Database, Type, Data);
- /* Acquire the database mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
- acquired = gcvTRUE;
-
/* Scan the database for this record. */
for (record = Database->list[slot];
record != gcvNULL;
@@ -614,19 +551,11 @@ gckKERNEL_FindRecord(
gckOS_MemCopy(Record, record, sizeof(gcsDATABASE_RECORD)));
}
- /* Release the database mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
-
/* Success. */
gcmkFOOTER_ARG("Record=0x%x", Record);
return gcvSTATUS_OK;
OnError:
- if (acquired)
- {
- /* Release the database mutex. */
- gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
- }
/* Return the status. */
gcmkFOOTER();
@@ -807,6 +736,7 @@ gckKERNEL_AddProcessDB(
gcsDATABASE_PTR database;
gcsDATABASE_RECORD_PTR record = gcvNULL;
gcsDATABASE_COUNTERS * count;
+ gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d Type=%d Pointer=0x%x "
"Physical=0x%x Size=%lu",
@@ -815,6 +745,11 @@ gckKERNEL_AddProcessDB(
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
+ /* Acquire the database mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
+ acquired = gcvTRUE;
+
/* Special case the idle record. */
if (Type == gcvDB_IDLE)
{
@@ -869,6 +804,8 @@ gckKERNEL_AddProcessDB(
}
}
#endif
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
/* Success. */
gcmkFOOTER_NO();
@@ -878,6 +815,7 @@ gckKERNEL_AddProcessDB(
/* Verify the arguments. */
gcmkVERIFY_ARGUMENT(Pointer != gcvNULL);
+
/* Find the database. */
gcmkONERROR(gckKERNEL_FindDatabase(Kernel, ProcessID, gcvFALSE, &database));
@@ -943,11 +881,20 @@ gckKERNEL_AddProcessDB(
}
}
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
+ if (acquired)
+ {
+ /* Release the database mutex. */
+ gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+ }
+
/* Return the status. */
gcmkFOOTER();
return status;
@@ -987,6 +934,7 @@ gckKERNEL_RemoveProcessDB(
gceSTATUS status;
gcsDATABASE_PTR database;
gctSIZE_T bytes = 0;
+ gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d Type=%d Pointer=0x%x",
Kernel, ProcessID, Type, Pointer);
@@ -995,6 +943,11 @@ gckKERNEL_RemoveProcessDB(
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Pointer != gcvNULL);
+ /* Acquire the database mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
+ acquired = gcvTRUE;
+
/* Find the database. */
gcmkONERROR(gckKERNEL_FindDatabase(Kernel, ProcessID, gcvFALSE, &database));
@@ -1041,11 +994,20 @@ gckKERNEL_RemoveProcessDB(
break;
}
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
+ if (acquired)
+ {
+ /* Release the database mutex. */
+ gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+ }
+
/* Return the status. */
gcmkFOOTER();
return status;
@@ -1087,6 +1049,7 @@ gckKERNEL_FindProcessDB(
{
gceSTATUS status;
gcsDATABASE_PTR database;
+ gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d Type=%d Pointer=0x%x",
Kernel, ProcessID, ThreadID, Type, Pointer);
@@ -1095,6 +1058,11 @@ gckKERNEL_FindProcessDB(
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Pointer != gcvNULL);
+ /* Acquire the database mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
+ acquired = gcvTRUE;
+
/* Find the database. */
gcmkONERROR(gckKERNEL_FindDatabase(Kernel, ProcessID, gcvFALSE, &database));
@@ -1102,11 +1070,20 @@ gckKERNEL_FindProcessDB(
gcmkONERROR(
gckKERNEL_FindRecord(Kernel, database, Type, Pointer, Record));
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
+ if (acquired)
+ {
+ /* Release the database mutex. */
+ gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+ }
+
/* Return the status. */
gcmkFOOTER();
return status;
@@ -1145,12 +1122,18 @@ gckKERNEL_DestroyProcessDB(
gcuVIDMEM_NODE_PTR node;
gckKERNEL kernel = Kernel;
gctUINT32 i;
+ gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d", Kernel, ProcessID);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
+ /* Acquire the database mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
+ acquired = gcvTRUE;
+
/* Find the database. */
gcmkONERROR(gckKERNEL_FindDatabase(Kernel, ProcessID, gcvFALSE, &database));
@@ -1377,11 +1360,20 @@ gckKERNEL_DestroyProcessDB(
/* Delete the database. */
gcmkONERROR(gckKERNEL_DeleteDatabase(Kernel, database));
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
+ if (acquired)
+ {
+ /* Release the database mutex. */
+ gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+ }
+
/* Return the status. */
gcmkFOOTER();
return status;
@@ -1424,6 +1416,7 @@ gckKERNEL_QueryProcessDB(
{
gceSTATUS status;
gcsDATABASE_PTR database;
+ gctBOOL acquired = gcvFALSE;
gcmkHEADER_ARG("Kernel=0x%x ProcessID=%d Type=%d Info=0x%x",
Kernel, ProcessID, Type, Info);
@@ -1432,6 +1425,11 @@ gckKERNEL_QueryProcessDB(
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Info != gcvNULL);
+ /* Acquire the database mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Kernel->os, Kernel->db->dbMutex, gcvINFINITE));
+ acquired = gcvTRUE;
+
/* Find the database. */
gcmkONERROR(
gckKERNEL_FindDatabase(Kernel, ProcessID, LastProcessID, &database));
@@ -1496,11 +1494,20 @@ gckKERNEL_QueryProcessDB(
break;
}
+ /* Release the database mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
OnError:
+ if (acquired)
+ {
+ /* Release the database mutex. */
+ gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->db->dbMutex));
+ }
+
/* Return the status. */
gcmkFOOTER();
return status;