mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
73f6a47d0d327e471910e7365f9050ce0d30d92c
Quickly plug and unplug the Type-C device with DP function test, there
is a low probability of unplugging the Type-C dongle, DP work cannot
acquire the mutex(port->lock), and it will always be stuck in the
tcpm_unregister_altmodes() function during the rest port process, causing
the Type-C device to be inserted again to fail to be detected or the reboot
system to be stuck. The exception process is as follows:
(1) Thread#1: unplug the Type-C device to trigger cc status changes interrupt, in the
tcpm_pd_event_handler() function, first acquire the mutex(port->lock),
then start state_machine work, and finally release the mutex(port->lock);
tcpm_cc_change()
-->tcpm_pd_event_handler()
-->mutex_lock(&port->lock) /* step 1 */
-->_tcpm_cc_change(port, cc1, cc2) /* step 2 */
-->tcpm_set_state(port, SRC_UNATTACHED, 0)
-->kthread_queue_work(port->wq, &port->state_machine) /* step 3 */
--> mutex_unlock(&port->lock) /* step 4 */
(2) Thread#2: before the execution of "step 2" is completed, DP work calls
the callback function registered by the tcpm framework to initiate a VDM
Message, such as Enter Mode Message, in the tcpm_altmode_enter() acquires
the mutex(port->lock) fails and goes to sleep;
dp_altmode_work()
--> typec_altmode_enter(dp->alt)
--> tcpm_altmode_enter()
--> mutex_lock(&port->lock) /* dp work enter sleep */
(3) After step 4, tcpm_altmode_enter() did not acquire for the mutex(port->lock),
but was preempted by the state_machine work to enter the reset port process.
In the reset port process, call the tcpm_unregister_altmodes() function to
release altmode and cancel dp work. Because tcpm_altmode_enter() did not
acquire the mutex(port->lock), causing it to be stuck in cancel dp work.
tcpm_state_machine_work()
-->mutex_lock(&port->lock)
-->tcpm_reset_port(port)
-->tcpm_unregister_altmodes(port)
......
--> dp_altmode_remove()
--> cancel_work_sync(&dp->work) /* always stuck in cancel dp work */
......
Therefore, after adding a new mutex to wait for the tcpm_pd_event_handler() function
to complete the processing, if the port is in the disconnect state, there is no need
to acquire the mutex(port->lock) in the tcpm_altmode_enter() function.
Change-Id: I364a035568ddc35ef7242b42f6d6d0ee3f5586fd
Signed-off-by: Wang Jie <dave.wang@rock-chips.com>
…
…
…
…
…
…
…
…
…
…
Linux kernel
============
There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.
In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``. The formatted documentation can also be read online at:
https://www.kernel.org/doc/html/latest/
There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.
Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.
Description
Languages
C
97.7%
Assembly
1.6%
Makefile
0.3%
Perl
0.1%