Revert "video: tegra: hdcp: Fix Locking Issue"
Matt Wagner [Wed, 22 Aug 2012 21:29:46 +0000 (14:29 -0700)]
This reverts commit 51f746421b73f8f378bd7908b35fd6c79687e239.

This commit caused issues with Suspend/Resume

Bug 1030468

Change-Id: I2bcf6c01e388d5ba795decd0d2da768fa541fa81
Signed-off-by: Matt Wagner <mwagner@nvidia.com>
Reviewed-on: http://git-master/r/125336
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/video/tegra/dc/nvhdcp.c

index b509a6c..3566e2b 100644 (file)
@@ -78,7 +78,6 @@ struct tegra_nvhdcp {
        struct tegra_dc_hdmi_data       *hdmi;
        struct workqueue_struct         *downstream_wq;
        struct mutex                    lock;
-       struct mutex                    state_lock;
        struct miscdevice               miscdev;
        char                            name[12];
        unsigned                        id;
@@ -981,9 +980,7 @@ static void nvhdcp_downstream_worker(struct work_struct *work)
 
        nvhdcp_vdbg("CRYPT enabled\n");
 
-       mutex_lock(&nvhdcp->state_lock);
        nvhdcp->state = STATE_LINK_VERIFY;
-       mutex_unlock(&nvhdcp->state_lock);
        nvhdcp_info("link verified!\n");
 
        while (1) {
@@ -1010,39 +1007,30 @@ failure:
        if(nvhdcp->fail_count > 5) {
                nvhdcp_err("nvhdcp failure - too many failures, giving up!\n");
        } else {
-               if (!nvhdcp_is_plugged(nvhdcp)) {
-                       nvhdcp_err("nvhdcp failure\n");
-                       goto lost_hdmi;
-               }
                nvhdcp_err("nvhdcp failure - renegotiating in 1 second\n");
+               if (!nvhdcp_is_plugged(nvhdcp))
+                       goto lost_hdmi;
                queue_delayed_work(nvhdcp->downstream_wq, &nvhdcp->work,
                                                msecs_to_jiffies(1000));
        }
 
 lost_hdmi:
-       mutex_lock(&nvhdcp->state_lock);
        nvhdcp->state = STATE_UNAUTHENTICATED;
-       mutex_unlock(&nvhdcp->state_lock);
        hdcp_ctrl_run(hdmi, 0);
 
 err:
        mutex_unlock(&nvhdcp->lock);
        return;
 disable:
-       mutex_lock(&nvhdcp->state_lock);
        nvhdcp->state = STATE_OFF;
        nvhdcp_set_plugged(nvhdcp, false);
-       mutex_unlock(&nvhdcp->state_lock);
        mutex_unlock(&nvhdcp->lock);
        return;
 }
 
 static int tegra_nvhdcp_on(struct tegra_nvhdcp *nvhdcp)
 {
-       mutex_lock(&nvhdcp->state_lock);
-       nvhdcp_set_plugged(nvhdcp, true);
        nvhdcp->state = STATE_UNAUTHENTICATED;
-       mutex_unlock(&nvhdcp->state_lock);
        if (nvhdcp_is_plugged(nvhdcp)) {
                nvhdcp->fail_count = 0;
                queue_delayed_work(nvhdcp->downstream_wq, &nvhdcp->work,
@@ -1053,10 +1041,10 @@ static int tegra_nvhdcp_on(struct tegra_nvhdcp *nvhdcp)
 
 static int tegra_nvhdcp_off(struct tegra_nvhdcp *nvhdcp)
 {
-       mutex_lock(&nvhdcp->state_lock);
+       mutex_lock(&nvhdcp->lock);
        nvhdcp->state = STATE_OFF;
        nvhdcp_set_plugged(nvhdcp, false);
-       mutex_unlock(&nvhdcp->state_lock);
+       mutex_unlock(&nvhdcp->lock);
        wake_up_interruptible(&wq_worker);
        flush_workqueue(nvhdcp->downstream_wq);
        return 0;
@@ -1067,6 +1055,7 @@ void tegra_nvhdcp_set_plug(struct tegra_nvhdcp *nvhdcp, bool hpd)
        nvhdcp_debug("hdmi hotplug detected (hpd = %d)\n", hpd);
 
        if (hpd) {
+               nvhdcp_set_plugged(nvhdcp, true);
                tegra_nvhdcp_on(nvhdcp);
        } else {
                tegra_nvhdcp_off(nvhdcp);
@@ -1091,9 +1080,9 @@ int tegra_nvhdcp_set_policy(struct tegra_nvhdcp *nvhdcp, int pol)
 
 static int tegra_nvhdcp_renegotiate(struct tegra_nvhdcp *nvhdcp)
 {
-       mutex_lock(&nvhdcp->state_lock);
+       mutex_lock(&nvhdcp->lock);
        nvhdcp->state = STATE_RENEGOTIATE;
-       mutex_unlock(&nvhdcp->state_lock);
+       mutex_unlock(&nvhdcp->lock);
        tegra_nvhdcp_on(nvhdcp);
        return 0;
 }
@@ -1212,7 +1201,6 @@ struct tegra_nvhdcp *tegra_nvhdcp_create(struct tegra_dc_hdmi_data *hdmi,
        snprintf(nvhdcp->name, sizeof(nvhdcp->name), "nvhdcp%u", id);
        nvhdcp->hdmi = hdmi;
        mutex_init(&nvhdcp->lock);
-       mutex_init(&nvhdcp->state_lock);
 
        strlcpy(nvhdcp->info.type, nvhdcp->name, sizeof(nvhdcp->info.type));
        nvhdcp->bus = bus;
@@ -1236,9 +1224,7 @@ struct tegra_nvhdcp *tegra_nvhdcp_create(struct tegra_dc_hdmi_data *hdmi,
                goto free_nvhdcp;
        }
 
-       mutex_lock(&nvhdcp->state_lock);
        nvhdcp->state = STATE_UNAUTHENTICATED;
-       mutex_unlock(&nvhdcp->state_lock);
 
        nvhdcp->downstream_wq = create_singlethread_workqueue(nvhdcp->name);
        INIT_DELAYED_WORK(&nvhdcp->work, nvhdcp_downstream_worker);