Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbbHSIqe (ORCPT ); Wed, 19 Aug 2015 04:46:34 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:21952 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752970AbbHSIq3 (ORCPT ); Wed, 19 Aug 2015 04:46:29 -0400 X-AuditID: cbfec7f4-f79c56d0000012ee-5c-55d44263a9c8 Message-id: <55D4425F.4050806@samsung.com> Date: Wed, 19 Aug 2015 10:46:23 +0200 From: Andrzej Hajda User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-version: 1.0 To: Archit Taneja , dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, treding@nvidia.com, inki.dae@samsung.com, linux-kernel@vger.kernel.org, airlied@linux.ie, daniel@ffwll.ch, jani.nikula@linux.intel.com Subject: Re: [RFC 2/2] drm/dsi: Get DSI host by DT device node References: <1435641851-27295-1-git-send-email-architt@codeaurora.org> <1435641851-27295-3-git-send-email-architt@codeaurora.org> In-reply-to: <1435641851-27295-3-git-send-email-architt@codeaurora.org> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsVy+t/xa7rJTldCDWbeU7HoPXeSyaKp4y2r xf9tE5ktrnx9z2Yx6f4EFovll9czWkzcf5bd4vKuOWwWt3/zOXB6XO7rZfLY+20Bi8f2bw9Y PeadDPS4332cyaO3+R2bR9+WVYwenzfJBXBEcdmkpOZklqUW6dslcGWcfL2MrWCeVMWNqe/Y GhjPinYxcnJICJhInOr9xw5hi0lcuLeerYuRi0NIYCmjxLbWf1DOc0aJt43trCBVvAJaEjc+ tIB1sAioSry8/IkFxGYT0JT4u/kmG4gtKhAhsXz1SUaIekGJH5PvgdWICHhLzFndBxZnFljL KPFqvzaILSxgJzHrwVR2iGXNjBIv968EG8Qp4C6xZ90ZoAYOoAY9ifsXtSB65SU2r3nLPIFR YBaSFbMQqmYhqVrAyLyKUTS1NLmgOCk911CvODG3uDQvXS85P3cTIyQmvuxgXHzM6hCjAAej Eg/vjG2XQ4VYE8uKK3MPMUpwMCuJ8PKaXwkV4k1JrKxKLcqPLyrNSS0+xCjNwaIkzjt31/sQ IYH0xJLU7NTUgtQimCwTB6dUA6PjHf6M4wndzYIX/eyWHczffte43GHtq667ldyRE3jbLBf6 91xcs5L5XPWxuHKHu3qGFeZ8U3adsiuNOOt1V32ejyS/a3brN91zrz9cST3k5HVqo+On9jTu +fYl85Sea5644ayidLCb81Nbv9zS3Gf3ntTtXdgnKZct/4W5+7gnx7Y1DiJR/5RYijMSDbWY i4oTAdBeujSFAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3497 Lines: 111 On 06/30/2015 07:24 AM, Archit Taneja wrote: > mipi_dsi_devices are inherently aware of their host because they > share a parent-child hierarchy in the device tree. > > Non-dsi drivers that create a dummy dsi device don't have this data. > In order to get this information, they require to a phandle to the dsi > host in the device tree. > > Maintain a list of all the hosts DSI that are currently registered. > > This list will be used to find the mipi_dsi_host corresponding to the > device_node passed in of_find_mipi_dsi_host_by_node. The lock protects only the list, there is no guarantee that mipi_dsi_host returned by of_find_mipi_dsi_host_by_node is still valid, or will be valid long enough. But this issue affects many kernel frameworks so I am not sure if it should block this particular patch. Reviewed-by: Andrzej Hajda Regards Andrzej > > Signed-off-by: Archit Taneja > --- > drivers/gpu/drm/drm_mipi_dsi.c | 30 ++++++++++++++++++++++++++++++ > include/drm/drm_mipi_dsi.h | 2 ++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c > index 9bfe215..81ddb73 100644 > --- a/drivers/gpu/drm/drm_mipi_dsi.c > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > @@ -239,6 +239,28 @@ struct mipi_dsi_device *mipi_dsi_new_dummy(struct mipi_dsi_host *host, u32 reg) > return dsi; > } > > +static DEFINE_MUTEX(host_lock); > +static LIST_HEAD(host_list); > + > +struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) > +{ > + struct mipi_dsi_host *host; > + > + mutex_lock(&host_lock); > + > + list_for_each_entry(host, &host_list, list) { > + if (host->dev->of_node == node) { > + mutex_unlock(&host_lock); > + return host; > + } > + } > + > + mutex_unlock(&host_lock); > + > + return NULL; > +} > +EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node); > + > int mipi_dsi_host_register(struct mipi_dsi_host *host) > { > struct device_node *node; > @@ -250,6 +272,10 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) > of_mipi_dsi_device_add(host, node); > } > > + mutex_lock(&host_lock); > + list_add_tail(&host->list, &host_list); > + mutex_unlock(&host_lock); > + > return 0; > } > EXPORT_SYMBOL(mipi_dsi_host_register); > @@ -266,6 +292,10 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv) > void mipi_dsi_host_unregister(struct mipi_dsi_host *host) > { > device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn); > + > + mutex_lock(&host_lock); > + list_del_init(&host->list); > + mutex_unlock(&host_lock); > } > EXPORT_SYMBOL(mipi_dsi_host_unregister); > > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h > index d06ba99..1684a0e 100644 > --- a/include/drm/drm_mipi_dsi.h > +++ b/include/drm/drm_mipi_dsi.h > @@ -100,10 +100,12 @@ struct mipi_dsi_host_ops { > struct mipi_dsi_host { > struct device *dev; > const struct mipi_dsi_host_ops *ops; > + struct list_head list; > }; > > int mipi_dsi_host_register(struct mipi_dsi_host *host); > void mipi_dsi_host_unregister(struct mipi_dsi_host *host); > +struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); > > /* DSI mode flags */ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/