drm/sun4i: Implement endpoint parsing using kfifo
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 17 Oct 2017 09:06:08 +0000 (11:06 +0200)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 17 Oct 2017 14:31:31 +0000 (16:31 +0200)
commit8b11aaface2b182ee2b36509843d746c453f8750
tree9e364b2eb13df8da4c15b5f246715317e66211e6
parent4690803b09c6f1da33058336844091f8b7f3118f
drm/sun4i: Implement endpoint parsing using kfifo

The commit da82b8785eeb ("drm/sun4i: add components in breadth first
traversal order") implemented a breadth first traversal of our device tree
nodes graph. However, it was relying on the kernel linked lists, and those
are not really safe for addition.

Indeed, in a single pipeline stage, your first stage (ie, the mixer or
fronted) will be queued, and it will be the final iteration of that list as
far as list_for_each_entry_safe is concerned. Then, during that final
iteration, we'll queue another element (the TCON or the backend) that
list_for_each_entry_safe will not account for, and we will leave the loop
without having iterated over all the elements. And since we won't have
built our components list properly, the DRM driver will be left
non-functional.

We can instead use a kfifo to queue and enqueue components in-order, as was
the original intention. This also has the benefit of removing any dynamic
allocation, making the error handling path simpler too. The only thing
we're losing is the ability to tell whether an element has already been
queued, but that was only needed to remove spurious logs, and therefore
purely cosmetic.

This means that this commit effectively reverses e8afb7b67fba ("drm/sun4i:
don't add components that are already in the queue").

Fixes: da82b8785eeb ("drm/sun4i: add components in breadth first traversal order")
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/4ecb323e787918208f6a5d9f0ebba12c62583c98.1508231063.git-series.maxime.ripard@free-electrons.com
drivers/gpu/drm/sun4i/sun4i_drv.c