video: tegra: Include mutex to protect Kfuse reads
sharath [Fri, 2 Aug 2013 02:02:29 +0000 (19:02 -0700)]
Included a mutex to protect the simultaneous kfuse
reads by nvhost driver and nvhdcp driver.

bug 1179007

Change-Id: I780ead40352b081c5ffe533db9ea09f12d14c3e1
Signed-off-by: sharath <ssarangpur@nvidia.com>
Reviewed-on: http://git-master/r/257206
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/video/tegra/dc/nvhdcp.c
drivers/video/tegra/host/tsec/tsec.c
include/linux/nvhost.h

index fbdb089..b470a0a 100644 (file)
@@ -24,6 +24,8 @@
 #include <linux/uaccess.h>
 #include <linux/wait.h>
 #include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/nvhost.h>
 #include <asm/atomic.h>
 
 #include <mach/dc.h>
@@ -672,7 +674,9 @@ static int load_kfuse(struct tegra_dc_hdmi_data *hdmi)
        int retries;
 
        /* copy load kfuse into buffer - only needed for early Tegra parts */
+       mutex_lock(&kfuse_mutex);
        e = tegra_kfuse_read(buf, sizeof buf);
+       mutex_unlock(&kfuse_mutex);
        if (e) {
                nvhdcp_err("Kfuse read failure\n");
                return e;
index a9c4ffd..c9c91a7 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/mutex.h>
 #include "dev.h"
 #include "tsec.h"
 #include "hw_tsec.h"
@@ -52,6 +53,8 @@
 #define get_tsec(ndev) ((struct tsec *)(ndev)->dev.platform_data)
 #define set_tsec(ndev, f) ((ndev)->dev.platform_data = f)
 
+DEFINE_MUTEX(kfuse_mutex);
+
 /* The key value in ascii hex */
 static u8 otf_key[TSEC_KEY_LENGTH];
 
@@ -216,7 +219,7 @@ static int tsec_load_kfuse(struct platform_device *pdev)
 {
        u32 val;
        u32 timeout;
-
+       mutex_lock(&kfuse_mutex);
        val = nvhost_device_readl(pdev, tsec_tegra_ctl_r());
        val &= ~tsec_tegra_ctl_tkfi_kfuse_m();
        nvhost_device_writel(pdev, tsec_tegra_ctl_r(), val);
@@ -240,6 +243,7 @@ static int tsec_load_kfuse(struct platform_device *pdev)
        val = nvhost_device_readl(pdev, tsec_tegra_ctl_r());
        val |= tsec_tegra_ctl_tkfi_kfuse_m();
        nvhost_device_writel(pdev, tsec_tegra_ctl_r(), val);
+       mutex_unlock(&kfuse_mutex);
 
        if (timeout)
                return 0;
index c07445e..e144673 100644 (file)
@@ -199,4 +199,5 @@ int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id, u32 thre
 
 void nvhost_scale3d_set_throughput_hint(int hint);
 
+extern struct mutex kfuse_mutex;
 #endif