<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/sound/soc/codecs/rt5682.c, branch linus/master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/sound/soc/codecs/rt5682.c?h=linus%2Fmaster</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/sound/soc/codecs/rt5682.c?h=linus%2Fmaster'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-04-07T17:29:34Z</updated>
<entry>
<title>ASoC: rt711/5682: check if bus is active before deferred jack detection</title>
<updated>2022-04-07T17:29:34Z</updated>
<author>
<name>Pierre-Louis Bossart</name>
<email>pierre-louis.bossart@linux.intel.com</email>
</author>
<published>2022-04-06T19:20:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=770f3d992a3f7330f801dfeee98429b2885c9fdb'/>
<id>urn:sha1:770f3d992a3f7330f801dfeee98429b2885c9fdb</id>
<content type='text'>
This patch takes a defensive programming and paranoid approach in case
the parent device (SoundWire) is pm_runtime resumed but the rt711
device is not. In that case, during the attachment and initialization,
a jack detection workqueue can be scheduled. Since the pm_runtime
suspend routines will not be invoked, the sequence to cancel all
deferred work is not executed, and the jack detection could happen
after the bus stops operating, leading to a timeout.

This patch applies the same solution to rt5682, based on the
similarities between codec drivers. The race condition with rt5682 was
not detected experimentally though.

BugLink: https://github.com/thesofproject/linux/issues/3459
Signed-off-by: Pierre-Louis Bossart &lt;pierre-louis.bossart@linux.intel.com&gt;
Reviewed-by: Rander Wang &lt;rander.wang@intel.com&gt;
Reviewed-by: Bard Liao &lt;yung-chuan.liao@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20220406192005.262996-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: fix an incorrect NULL check on list iterator</title>
<updated>2022-04-05T09:24:48Z</updated>
<author>
<name>Xiaomeng Tong</name>
<email>xiam0nd.tong@gmail.com</email>
</author>
<published>2022-03-27T08:10:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=c8618d65007ba68d7891130642d73e89372101e8'/>
<id>urn:sha1:c8618d65007ba68d7891130642d73e89372101e8</id>
<content type='text'>
The bug is here:
	if (!dai) {

The list iterator value 'dai' will *always* be set and non-NULL
by for_each_component_dais(), so it is incorrect to assume that
the iterator value will be NULL if the list is empty or no element
is found (In fact, it will be a bogus pointer to an invalid struct
object containing the HEAD). Otherwise it will bypass the check
'if (!dai) {' (never call dev_err() and never return -ENODEV;)
and lead to invalid memory access lately when calling
'rt5682_set_bclk1_ratio(dai, factor);'.

To fix the bug, just return rt5682_set_bclk1_ratio(dai, factor);
when found the 'dai', otherwise dev_err() and return -ENODEV;

Cc: stable@vger.kernel.org
Fixes: ebbfabc16d23d ("ASoC: rt5682: Add CCF usage for providing I2S clks")
Signed-off-by: Xiaomeng Tong &lt;xiam0nd.tong@gmail.com&gt;
Link: https://lore.kernel.org/r/20220327081002.12684-1-xiam0nd.tong@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: do not block workqueue if card is unbound</title>
<updated>2022-02-08T13:37:46Z</updated>
<author>
<name>Kai Vehmanen</name>
<email>kai.vehmanen@linux.intel.com</email>
</author>
<published>2022-02-07T15:30:00Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4c33de0673ced9c7c37b3bbd9bfe0fda72340b2a'/>
<id>urn:sha1:4c33de0673ced9c7c37b3bbd9bfe0fda72340b2a</id>
<content type='text'>
The current rt5682_jack_detect_handler() assumes the component
and card will always show up and implements an infinite usleep
loop waiting for them to show up.

This does not hold true if a codec interrupt (or other
event) occurs when the card is unbound. The codec driver's
remove  or shutdown functions cannot cancel the workqueue due
to the wait loop. As a result, code can either end up blocking
the workqueue, or hit a kernel oops when the card is freed.

Fix the issue by rescheduling the jack detect handler in
case the card is not ready. In case card never shows up,
the shutdown/remove/suspend calls can now cancel the detect
task.

Signed-off-by: Kai Vehmanen &lt;kai.vehmanen@linux.intel.com&gt;
Reviewed-by: Bard Liao &lt;yung-chuan.liao@linux.intel.com&gt;
Reviewed-by: Ranjani Sridharan &lt;ranjani.sridharan@linux.intel.com&gt;
Reviewed-by: Pierre-Louis Bossart &lt;pierre-louis.bossart@linux.intel.com&gt;
Reviewed-by: Péter Ujfalusi &lt;peter.ujfalusi@linux.intel.com&gt;
Reviewed-by: Shuming Fan &lt;shumingf@realtek.com&gt;
Link: https://lore.kernel.org/r/20220207153000.3452802-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: Fix deadlock on resume</title>
<updated>2022-01-28T15:59:20Z</updated>
<author>
<name>Peter Ujfalusi</name>
<email>peter.ujfalusi@linux.intel.com</email>
</author>
<published>2022-01-26T10:03:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4045daf0fa87846a27f56329fddad2deeb5ca354'/>
<id>urn:sha1:4045daf0fa87846a27f56329fddad2deeb5ca354</id>
<content type='text'>
On resume from suspend the following chain of events can happen:
A rt5682_resume() -&gt; mod_delayed_work() for jack_detect_work
B DAPM sequence starts ( DAPM is locked now)

A1. rt5682_jack_detect_handler() scheduled
 - Takes both jdet_mutex and calibrate_mutex
 - Calls in to rt5682_headset_detect() which tries to take DAPM lock, it
   starts to wait for it as B path took it already.
B1. DAPM sequence reaches the "HP Amp", rt5682_hp_event() tries to take
    the jdet_mutex, but it is locked in A1, so it waits.

Deadlock.

To solve the deadlock, drop the jdet_mutex, use the jack_detect_work to do
the jack removal handling, move the dapm lock up one level to protect the
most of the rt5682_jack_detect_handler(), but not the jack reporting as it
might trigger a DAPM sequence.
The rt5682_headset_detect() can be changed to static as well.

Fixes: 8deb34a90f063 ("ASoC: rt5682: fix the wrong jack type detected")
Signed-off-by: Peter Ujfalusi &lt;peter.ujfalusi@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20220126100325.16513-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: Merge fixes</title>
<updated>2021-12-31T13:23:28Z</updated>
<author>
<name>Mark Brown</name>
<email>broonie@kernel.org</email>
</author>
<published>2021-12-31T13:21:39Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=8b974c122bc649895bc07191ec34633d8087323e'/>
<id>urn:sha1:8b974c122bc649895bc07191ec34633d8087323e</id>
<content type='text'>
So we can send to Linus.
</content>
</entry>
<entry>
<title>ASoC: rt5682: Register wclk with its parent_hws instead of parent_data</title>
<updated>2021-12-29T12:45:49Z</updated>
<author>
<name>Derek Fang</name>
<email>derek.fang@realtek.com</email>
</author>
<published>2021-12-27T05:54:46Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=cc5c9788106fb1b9e03c8c57d8d7166073a54416'/>
<id>urn:sha1:cc5c9788106fb1b9e03c8c57d8d7166073a54416</id>
<content type='text'>
The mclk might not be registered as a fixed clk name "mclk" on some
platforms.
In those platforms, if the mclk needed to be controlled by codec driver
and acquired by a fixed name, it would be a problem.

This patch to fix the issue that wclk becomes an orphan due to the fixed
mclk's name.

Signed-off-by: Derek Fang &lt;derek.fang@realtek.com&gt;
Link: https://lore.kernel.org/r/20211227055446.27563-1-derek.fang@realtek.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: fix the wrong jack type detected</title>
<updated>2021-12-14T13:37:35Z</updated>
<author>
<name>Derek Fang</name>
<email>derek.fang@realtek.com</email>
</author>
<published>2021-12-14T10:50:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=8deb34a90f06374fd26f722c2a79e15160f66be7'/>
<id>urn:sha1:8deb34a90f06374fd26f722c2a79e15160f66be7</id>
<content type='text'>
Some powers were changed during the jack insert detection
and clk's enable/disable in CCF.
If in parallel, the influence has a chance to detect
the wrong jack type, so add a lock.

Signed-off-by: Derek Fang &lt;derek.fang@realtek.com&gt;
Link: https://lore.kernel.org/r/20211214105033.471-1-derek.fang@realtek.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: Fix crash due to out of scope stack vars</title>
<updated>2021-11-26T13:24:09Z</updated>
<author>
<name>Rob Clark</name>
<email>robdclark@chromium.org</email>
</author>
<published>2021-11-18T01:04:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4999d703c0e66f9f196b6edc0b8fdeca8846b8b6'/>
<id>urn:sha1:4999d703c0e66f9f196b6edc0b8fdeca8846b8b6</id>
<content type='text'>
Move the declaration of temporary arrays to somewhere that won't go out
of scope before the devm_clk_hw_register() call, lest we be at the whim
of the compiler for whether those stack variables get overwritten.

Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)

Fixes: edbd24ea1e5c ("ASoC: rt5682: Drop usage of __clk_get_name()")
Signed-off-by: Rob Clark &lt;robdclark@chromium.org&gt;
Reviewed-by: Stephen Boyd &lt;swboyd@chromium.org&gt;
Link: https://lore.kernel.org/r/20211118010453.843286-1-robdclark@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: Re-detect the combo jack after resuming</title>
<updated>2021-11-12T18:16:43Z</updated>
<author>
<name>Derek Fang</name>
<email>derek.fang@realtek.com</email>
</author>
<published>2021-11-09T09:54:50Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=2cd9b0ef82d936623d789bb3fbb6fcf52c500367'/>
<id>urn:sha1:2cd9b0ef82d936623d789bb3fbb6fcf52c500367</id>
<content type='text'>
Sometimes, end-users change the jack type under suspending,
so it needs to re-detect the combo jack type after resuming to
avoid any unexpected behaviors.

Signed-off-by: Derek Fang &lt;derek.fang@realtek.com&gt;
Link: https://lore.kernel.org/r/20211109095450.12950-2-derek.fang@realtek.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>ASoC: rt5682: Avoid the unexpected IRQ event during going to suspend</title>
<updated>2021-11-12T18:16:42Z</updated>
<author>
<name>Derek Fang</name>
<email>derek.fang@realtek.com</email>
</author>
<published>2021-11-09T09:54:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=a3774a2a6544a7a4a85186e768afc07044aa507f'/>
<id>urn:sha1:a3774a2a6544a7a4a85186e768afc07044aa507f</id>
<content type='text'>
When the system suspends, the codec driver will set SAR to
power saving mode if a headset is plugged in.
There is a chance to generate an unexpected IRQ, and leads to
issues after resuming such as noise from OMTP type headsets.

Signed-off-by: Derek Fang &lt;derek.fang@realtek.com&gt;
Link: https://lore.kernel.org/r/20211109095450.12950-1-derek.fang@realtek.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
</feed>
