gpu: pvr: pdumpfs: add pdumpfs_mutex
authorLuc Verhaegen <libv@codethink.co.uk>
Fri, 11 Mar 2011 14:02:46 +0000 (15:02 +0100)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:43:04 +0000 (21:43 +0300)
Signed-off-by: Luc Verhaegen <libv@codethink.co.uk>
Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/pvr_pdump.c
pvr/pvr_pdumpfs.c
pvr/pvr_pdumpfs.h

index b333344..c9aa021 100644 (file)
@@ -174,6 +174,11 @@ void PDumpInit(void)
                               NULL) != PVRSRV_OK)
                        goto init_failed;
 
+       if (pdumpfs_init()) {
+               pr_err("%s: pdumpfs_init failed.\n", __func__);
+               goto init_failed;
+       }
+
        PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME);
        PDumpComment("Driver Product Version: %s (%s)",
                     PVRVERSION_STRING, PVRVERSION_FILE);
@@ -204,6 +209,8 @@ void PDumpInit(void)
 
 void PDumpDeInit(void)
 {
+       pdumpfs_cleanup();
+
        if (gpszFile) {
                OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX,
                          (void *)gpszFile, NULL);
index a1a3de7..8be0dd2 100644 (file)
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <linux/mutex.h>
+
 #include "img_defs.h"
 #include "services_headers.h"
 #include "pvr_pdump.h"
 #include "pvr_pdumpfs.h"
 
+static struct mutex pdumpfs_mutex[1];
+
 enum pdumpfs_mode {
        PDUMPFS_MODE_DISABLED,
        PDUMPFS_MODE_STANDARD,
@@ -33,40 +37,81 @@ static u32 pdumpfs_frame_number;
 void
 pdumpfs_frame_set(u32 frame)
 {
+       mutex_lock(pdumpfs_mutex);
+
        pdumpfs_frame_number = frame;
+
+       mutex_unlock(pdumpfs_mutex);
 }
 
 bool
 pdumpfs_capture_enabled(void)
 {
+       bool ret;
+
+       mutex_lock(pdumpfs_mutex);
+
        if (pdumpfs_mode == PDUMPFS_MODE_FULL)
-               return true;
+               ret = true;
        else
-               return false;
+               ret = false;
+
+       mutex_unlock(pdumpfs_mutex);
+
+       return ret;
 }
 
 bool
 pdumpfs_flags_check(u32 flags)
 {
+       bool ret;
+
        if (flags & PDUMP_FLAGS_NEVER)
                return false;
-       else if (pdumpfs_mode == PDUMPFS_MODE_FULL)
-               return true;
+
+       mutex_lock(pdumpfs_mutex);
+
+       if (pdumpfs_mode == PDUMPFS_MODE_FULL)
+               ret = true;
        else if ((pdumpfs_mode == PDUMPFS_MODE_STANDARD) &&
                 (flags & PDUMP_FLAGS_CONTINUOUS))
-               return true;
+               ret = true;
        else
-               return false;
+               ret = false;
+
+       mutex_unlock(pdumpfs_mutex);
+
+       return ret;
 }
 
 enum PVRSRV_ERROR
 pdumpfs_write_data(void *buffer, size_t size, bool from_user)
 {
+       mutex_lock(pdumpfs_mutex);
+
+       mutex_unlock(pdumpfs_mutex);
+
        return PVRSRV_OK;
 }
 
 void
 pdumpfs_write_string(char *string)
+{
+       mutex_lock(pdumpfs_mutex);
+
+       mutex_unlock(pdumpfs_mutex);
+}
+
+int
+pdumpfs_init(void)
+{
+       mutex_init(pdumpfs_mutex);
+
+       return 0;
+}
+
+void
+pdumpfs_cleanup(void)
 {
 
 }
index cc5c769..714f2db 100644 (file)
@@ -25,4 +25,7 @@ bool pdumpfs_flags_check(u32 flags);
 enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user);
 void pdumpfs_write_string(char *string);
 
+int pdumpfs_init(void);
+void pdumpfs_cleanup(void);
+
 #endif /* _PVR_PDUMPFS_H_ */