Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932124AbeAINpe (ORCPT + 1 other); Tue, 9 Jan 2018 08:45:34 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:53705 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751383AbeAINpd (ORCPT ); Tue, 9 Jan 2018 08:45:33 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180109134530euoutp0165c248ae178ae1bb906207c35cdc9e44~IKEAj4uwd1629016290euoutp01o X-AuditID: cbfec7f2-f793b6d000003243-f2-5a54c7794b25 Subject: Re: [PATCH] drm/bridge/synopsis: stop clobbering drvdata To: Laurent Pinchart , Philippe CORNU Cc: Brian Norris , Archit Taneja , David Airlie , Yannick FERTRE , Benjamin Gaignard , Vincent ABRIOU , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , Sean Paul , Nickey Yang , "hl@rock-chips.com" , "linux-rockchip@lists.infradead.org" , "mka@chromium.org" From: Andrzej Hajda Message-id: <1446c2ab-cedb-cd8a-adfc-79bcef99c134@samsung.com> Date: Tue, 09 Jan 2018 14:45:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-version: 1.0 In-reply-to: <2473674.qmHiHju6p6@avalon> Content-type: text/plain; charset="utf-8" Content-transfer-encoding: 7bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djPc7qVx0OiDJ5N0rLoPXeSyaKp4y2r RdOhU2wWmz6+Z7W48vU9m8WPDaeYLTonLmG3uLxrDpvFpwf/mS0+b3jMaLH09ztGiwctL1gt 7m44y2hx5uoBFov2zlY2B36P2Q0XWTwu9/UyeczumMnqcefaHjaP7d8esHrc7z7O5LF5Sb3H 31n7WTye/tjL7PF5k1wAVxSXTUpqTmZZapG+XQJXxtoLvewFj2wrm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cmCFtM4sK99WxdjFwcQgJLGCX6+2cxQjjPGCWe/p7ABlIlLOAo0TJ7LTOILSKQJPH8 3U8WkCJmgW8sEnuXv2CF6JjAJDFj72KwuWwCmhJ/N98E6+YVsJO4//gYWDeLgKrE81srWEBs UYEIiaaZc1khagQlfky+BxbnFNCQ+Nr+BCjOAbRBXWLKlFyQMLOAvMTmNW+ZIWxxiebWmywT GAVnIemehdAxC0nHLCQdCxhZVjGKpJYW56bnFhvqFSfmFpfmpesl5+duYgRG5bZjPzfvYLy0 MfgQowAHoxIPb0F7cJQQa2JZcWXuIUYJDmYlEV7f+UAh3pTEyqrUovz4otKc1OJDjNIcLEri vL17VkcKCaQnlqRmp6YWpBbBZJk4OKUaGN2DV3+wnCgT5iWaceyDQ9ylMpW3axsecj84tefg ufyIVX+fTD2y3jdt4qrrvT84gpRsUvccMth91VIvUPwn+5xHv/fL/pJY/HTyLgt2tybXU5O0 XwQ9i+fN/XIkRSl6eherzpIT7PYzzys4l3yeuKPI5aJexavlfVt6lnBeWPwn7WQ6l0mAWL8S S3FGoqEWc1FxIgC7zBsixgIAAA== X-CMS-MailID: 20180109134529eucas1p1ce8a1f61ced0926c4e93a159e00d9516 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180109133704epcas5p4a64298ac65ecfc30dbb87470c95428d8 X-RootMTR: 20180109133704epcas5p4a64298ac65ecfc30dbb87470c95428d8 References: <20171128010538.119114-1-briannorris@chromium.org> <348421ad-a6f5-0943-f38d-d9a6de60e32e@st.com> <2473674.qmHiHju6p6@avalon> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 09.01.2018 14:37, Laurent Pinchart wrote: > Hi Philippe, > > On Tuesday, 9 January 2018 15:01:02 EET Philippe CORNU wrote: >> Hi Archit, Andrzej & Laurent, >> >> Regarding this patch from Brian, I think it could be nice to merge it >> (1xAcked-by, 2xReviewed-by). >> >> Could you please have a look? >> >> Only the small "typo" in the headline needs to be changed. >> >> Many thanks, > I've just replied to Brian in this mail thread. Sorry for the delay, it > slipped through the cracks. Thank you for pinging me. I have just pushed the patch to drm-misc-next. I am sorry, if you wanted to polish it more, from the thread it looked it can be merged as is. Regards Andrzej >> On 11/28/2017 10:34 AM, Philippe CORNU wrote: >> >>> Hi Brian, >>> >>> On 11/28/2017 02:05 AM, Brian Norris wrote: >>> >>>> Bridge drivers/helpers shouldn't be clobbering the drvdata, since a >>>> parent driver might need to own this. Instead, let's return our >>>> 'dw_mipi_dsi' object and have callers pass that back to us for removal. >>> >>> And many thanks for this cleanup. >>> (please update the headline with "synopsys") >>> >>> Successfully tested on stm. >>> >>> Acked-by: Philippe Cornu >>> >>> Many thanks, >>> Philippe :-) >>> >>>> >>>> Signed-off-by: Brian Norris >>>> --- >>>> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 36 >>>> ++++++++++----------------- >>>> drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 14 +++++++---- >>>> include/drm/bridge/dw_mipi_dsi.h | 17 ++++++++----- >>>> 3 files changed, 33 insertions(+), 34 deletions(-) >>>> >>>> >>>> >>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c >>>> b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c >>>> index d9cca4fd66ec..c39c7dce20ed 100644 >>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c >>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c >>>> @@ -922,8 +922,6 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, >>>> dsi->bridge.of_node = pdev->dev.of_node; >>>> #endif >>>> - dev_set_drvdata(dev, dsi); >>>> - >>>> return dsi; >>>> } >>>> @@ -935,23 +933,16 @@ static void __dw_mipi_dsi_remove(struct >>>> dw_mipi_dsi *dsi) >>>> /* >>>> * Probe/remove API, used from platforms based on the DRM bridge API. >>>> */ >>>> -int dw_mipi_dsi_probe(struct platform_device *pdev, >>>> - const struct dw_mipi_dsi_plat_data *plat_data) >>>> +struct dw_mipi_dsi * >>>> +dw_mipi_dsi_probe(struct platform_device *pdev, >>>> + const struct dw_mipi_dsi_plat_data *plat_data) >>>> { >>>> - struct dw_mipi_dsi *dsi; >>>> - >>>> - dsi = __dw_mipi_dsi_probe(pdev, plat_data); >>>> - if (IS_ERR(dsi)) >>>> - return PTR_ERR(dsi); >>>> - >>>> - return 0; >>>> + return __dw_mipi_dsi_probe(pdev, plat_data); >>>> } >>>> EXPORT_SYMBOL_GPL(dw_mipi_dsi_probe); >>>> -void dw_mipi_dsi_remove(struct platform_device *pdev) >>>> +void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi) >>>> { >>>> - struct dw_mipi_dsi *dsi = platform_get_drvdata(pdev); >>>> - >>>> mipi_dsi_host_unregister(&dsi->dsi_host); >>>> __dw_mipi_dsi_remove(dsi); >>>> @@ -961,31 +952,30 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove); >>>> /* >>>> * Bind/unbind API, used from platforms based on the component >>>> framework. >>>> */ >>>> -int dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder >>>> *encoder, >>>> - const struct dw_mipi_dsi_plat_data *plat_data) >>>> +struct dw_mipi_dsi * >>>> +dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder >>>> *encoder, >>>> + const struct dw_mipi_dsi_plat_data *plat_data) >>>> { >>>> struct dw_mipi_dsi *dsi; >>>> int ret; >>>> dsi = __dw_mipi_dsi_probe(pdev, plat_data); >>>> if (IS_ERR(dsi)) >>>> - return PTR_ERR(dsi); >>>> + return dsi; >>>> ret = drm_bridge_attach(encoder, &dsi->bridge, NULL); >>>> if (ret) { >>>> - dw_mipi_dsi_remove(pdev); >>>> + dw_mipi_dsi_remove(dsi); >>>> DRM_ERROR("Failed to initialize bridge with drm\n"); >>>> - return ret; >>>> + return ERR_PTR(ret); >>>> } >>>> - return 0; >>>> + return dsi; >>>> } >>>> EXPORT_SYMBOL_GPL(dw_mipi_dsi_bind); >>>> -void dw_mipi_dsi_unbind(struct device *dev) >>>> +void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi) >>>> { >>>> - struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); >>>> - >>>> __dw_mipi_dsi_remove(dsi); >>>> } >>>> EXPORT_SYMBOL_GPL(dw_mipi_dsi_unbind); >>>> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c >>>> b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c >>>> index e5b6310240fe..7ed0ef7f6ec2 100644 >>>> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c >>>> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c >>>> @@ -66,6 +66,7 @@ enum dsi_color { >>>> struct dw_mipi_dsi_stm { >>>> void __iomem *base; >>>> struct clk *pllref_clk; >>>> + struct dw_mipi_dsi *dsi; >>>> }; >>>> static inline void dsi_write(struct dw_mipi_dsi_stm *dsi, u32 reg, >>>> u32 val) >>>> @@ -318,21 +319,24 @@ static int dw_mipi_dsi_stm_probe(struct >>>> platform_device *pdev) >>>> dw_mipi_dsi_stm_plat_data.base = dsi->base; >>>> dw_mipi_dsi_stm_plat_data.priv_data = dsi; >>>> - ret = dw_mipi_dsi_probe(pdev, &dw_mipi_dsi_stm_plat_data); >>>> - if (ret) { >>>> + platform_set_drvdata(pdev, dsi); >>>> + >>>> + dsi->dsi = dw_mipi_dsi_probe(pdev, &dw_mipi_dsi_stm_plat_data); >>>> + if (IS_ERR(dsi->dsi)) { >>>> DRM_ERROR("Failed to initialize mipi dsi host\n"); >>>> clk_disable_unprepare(dsi->pllref_clk); >>>> + return PTR_ERR(dsi->dsi); >>>> } >>>> - return ret; >>>> + return 0; >>>> } >>>> static int dw_mipi_dsi_stm_remove(struct platform_device *pdev) >>>> { >>>> - struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data; >>>> + struct dw_mipi_dsi_stm *dsi = platform_get_drvdata(pdev); >>>> clk_disable_unprepare(dsi->pllref_clk); >>>> - dw_mipi_dsi_remove(pdev); >>>> + dw_mipi_dsi_remove(dsi->dsi); >>>> return 0; >>>> } >>>> diff --git a/include/drm/bridge/dw_mipi_dsi.h >>>> b/include/drm/bridge/dw_mipi_dsi.h >>>> index 9b30fec302c8..d9c6d549f971 100644 >>>> --- a/include/drm/bridge/dw_mipi_dsi.h >>>> +++ b/include/drm/bridge/dw_mipi_dsi.h >>>> @@ -10,6 +10,8 @@ >>>> #ifndef __DW_MIPI_DSI__ >>>> #define __DW_MIPI_DSI__ >>>> +struct dw_mipi_dsi; >>>> + >>>> struct dw_mipi_dsi_phy_ops { >>>> int (*init)(void *priv_data); >>>> int (*get_lane_mbps)(void *priv_data, struct drm_display_mode >>>> *mode, >>>> @@ -29,11 +31,14 @@ struct dw_mipi_dsi_plat_data { >>>> void *priv_data; >>>> }; >>>> -int dw_mipi_dsi_probe(struct platform_device *pdev, >>>> - const struct dw_mipi_dsi_plat_data *plat_data); >>>> -void dw_mipi_dsi_remove(struct platform_device *pdev); >>>> -int dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder >>>> *encoder, >>>> - const struct dw_mipi_dsi_plat_data *plat_data); >>>> -void dw_mipi_dsi_unbind(struct device *dev); >>>> +struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev, >>>> + const struct dw_mipi_dsi_plat_data >>>> + *plat_data); >>>> +void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi); >>>> +struct dw_mipi_dsi *dw_mipi_dsi_bind(struct platform_device *pdev, >>>> + struct drm_encoder *encoder, >>>> + const struct dw_mipi_dsi_plat_data >>>> + *plat_data); >>>> +void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi); >>>> #endif /* __DW_MIPI_DSI__ */ >