From: Russell King <rmk+kernel@arm.linux.org.uk>
To: linux-rockchip@lists.infradead.org,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
mmind00@googlemail.com, David Airlie <airlied@linux.ie>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
dianders@chromium.org, djkurtz@chromium.org,
Philipp Zabel <p.zabel@pengutronix.de>,
marcheu@chromium.org, Andy Yan <andy.yan@rock-chips.com>,
mark.yao@rock-chips.com
Subject: [PATCH 2/3] drm: bridge/dw_hdmi: protect n/cts setting with a mutex
Date: Fri, 27 Mar 2015 11:13:50 +0000 [thread overview]
Message-ID: <E1YbSD0-0007z4-Uc@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20150327111320.GA4019@n2100.arm.linux.org.uk>
The HDMI n/cts settings need to be updated whenever the audio sample
rate or the video pixel clock changes. This needs to be protected
against concurrency as there is no synchronisation between these two
operations. Introduce a mutex (called audio_mutex) to protect against
two threads trying to update the video clock rate and pixel clock
simultaneously.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/gpu/drm/bridge/dw_hdmi.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 78363552d80e..b75922d4901e 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/hdmi.h>
+#include <linux/mutex.h>
#include <linux/of_device.h>
#include <drm/drm_of.h>
@@ -126,6 +127,7 @@ struct dw_hdmi {
struct i2c_adapter *ddc;
void __iomem *regs;
+ struct mutex audio_mutex;
unsigned int sample_rate;
int ratio;
@@ -357,12 +359,16 @@ static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
static void hdmi_init_clk_regenerator(struct dw_hdmi *hdmi)
{
+ mutex_lock(&hdmi->audio_mutex);
hdmi_set_clk_regenerator(hdmi, 74250000);
+ mutex_unlock(&hdmi->audio_mutex);
}
static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi)
{
+ mutex_lock(&hdmi->audio_mutex);
hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock);
+ mutex_unlock(&hdmi->audio_mutex);
}
/*
@@ -1565,6 +1571,8 @@ int dw_hdmi_bind(struct device *dev, struct device *master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
+ mutex_init(&hdmi->audio_mutex);
+
of_property_read_u32(np, "reg-io-width", &val);
switch (val) {
--
1.8.3.1
next prev parent reply other threads:[~2015-03-27 11:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 11:13 [PATCH 0/3] Improve dw-hdmi CTS/N setting Russell King - ARM Linux
2015-03-27 11:13 ` [PATCH 1/3] drm: bridge/dw_hdmi: combine hdmi_set_clock_regenerator_n() and hdmi_regenerate_cts() Russell King
2015-03-27 11:13 ` Russell King [this message]
[not found] ` <20150327111320.GA4019-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-03-27 11:13 ` [PATCH 3/3] drm: bridge/dw_hdmi: adjust n/cts setting order Russell King
2015-03-30 13:23 ` [PATCH 0/3] Improve dw-hdmi CTS/N setting Andy Yan
2015-03-30 9:43 ` Philipp Zabel
2015-03-30 12:25 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1YbSD0-0007z4-Uc@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel@arm.linux.org.uk \
--cc=airlied@linux.ie \
--cc=andy.yan@rock-chips.com \
--cc=dianders@chromium.org \
--cc=djkurtz@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fabio.estevam@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=marcheu@chromium.org \
--cc=mark.yao@rock-chips.com \
--cc=mmind00@googlemail.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox