From e1fc2afcd55f35ea9dc05dd8587e3526ebfe2ac8 Mon Sep 17 00:00:00 2001
From: hang cheng <hang.cheng@amlogic.com>
Date: Tue, 29 Jun 2021 20:59:51 +0800
Subject: [PATCH] hdmitx: fix edid parse crash [1/1]

PD#SWPL-56548

Problem:
may block during spinlock cause crash

Solution:
move block outside of spinlock

Verify:
AB311

Change-Id: If0086cf3dd53b3426c8c2132e4718e36d06cb866
Signed-off-by: hang cheng <hang.cheng@amlogic.com>
---
 .../vout/hdmitx/hdmi_tx_20/hdmi_tx_edid.c     |  1 -
 .../vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c     | 25 +++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_edid.c b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_edid.c
index b8a0a78d6b92..854d16ad9f55 100644
--- a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_edid.c
+++ b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_edid.c
@@ -395,7 +395,6 @@ static void set_vsdb_phy_addr(struct hdmitx_dev *hdev,
 		   ((vsdb->c & 0xf) <<  4) |
 		   ((vsdb->d & 0xf) <<  0);
 	hdev->physical_addr = phy_addr;
-	hdmitx_event_notify(HDMITX_PHY_ADDR_VALID, &phy_addr);
 }
 
 static void set_vsdb_dc_cap(struct rx_cap *prxcap)
diff --git a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c
index 795c9d170867..17f7ce3611d1 100644
--- a/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c
+++ b/drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c
@@ -4424,6 +4424,26 @@ static ssize_t store_sysctrl_enable(struct device *dev,
 	return count;
 }
 
+static ssize_t hdr_mute_frame_show(struct device *dev,
+	struct device_attribute *attr, char *buf)
+{
+	int pos = 0;
+
+	pos += snprintf(buf + pos, PAGE_SIZE, "%d\r\n", hdr_mute_frame);
+	return pos;
+}
+
+static ssize_t hdr_mute_frame_store(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count)
+{
+	unsigned long mute_frame = 0;
+
+	pr_info("set hdr_mute_frame: %s\n", buf);
+	if (kstrtoul(buf, 10, &mute_frame) == 0)
+		hdr_mute_frame = mute_frame;
+	return count;
+}
+
 #undef pr_fmt
 #define pr_fmt(fmt) "" fmt
 void print_drm_config_data(void)
@@ -5109,6 +5129,8 @@ static DEVICE_ATTR(hdmi_rx_info, 0444, show_hdmirx_info, NULL);
 static DEVICE_ATTR(hdmi_hsty_config_info, 0444, show_hdmi_hsty_config, NULL);
 static DEVICE_ATTR(sysctrl_enable, 0664,
 	show_sysctrl_enable, store_sysctrl_enable);
+static DEVICE_ATTR(hdr_mute_frame, 0664,
+		   hdr_mute_frame_show, hdr_mute_frame_store);
 
 static struct vinfo_s *hdmitx_get_current_vinfo(void)
 {
@@ -5480,6 +5502,7 @@ static void hdmitx_get_edid(struct hdmitx_dev *hdev)
 		pr_info("clear dv_info\n");
 	}
 	spin_unlock_irqrestore(&hdev->edid_spinlock, flags);
+	hdmitx_event_notify(HDMITX_PHY_ADDR_VALID, &hdev->physical_addr);
 	hdmitx_edid_buf_compare_print(hdev);
 	mutex_unlock(&getedid_mutex);
 }
@@ -6497,6 +6520,7 @@ static int amhdmitx_probe(struct platform_device *pdev)
 	ret = device_create_file(dev, &dev_attr_hdmi_hsty_config_info);
 	ret = device_create_file(dev, &dev_attr_drm_mode_setting);
 	ret = device_create_file(dev, &dev_attr_sysctrl_enable);
+	ret = device_create_file(dev, &dev_attr_hdr_mute_frame);
 
 #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND
 	register_early_suspend(&hdmitx_early_suspend_handler);
@@ -6617,6 +6641,7 @@ static int amhdmitx_remove(struct platform_device *pdev)
 	device_remove_file(dev, &dev_attr_hdmi_hsty_config_info);
 	device_remove_file(dev, &dev_attr_drm_mode_setting);
 	device_remove_file(dev, &dev_attr_sysctrl_enable);
+	device_remove_file(dev, &dev_attr_hdr_mute_frame);
 
 	cdev_del(&hdmitx_device.cdev);
 
-- 
GitLab