From patchwork Wed Dec 4 17:12:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 20914 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VoG0h-0001XG-Ti; Wed, 04 Dec 2013 18:13:15 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1VoG0f-00065f-23; Wed, 04 Dec 2013 18:13:15 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932885Ab3LDRNL (ORCPT + 1 other); Wed, 4 Dec 2013 12:13:11 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:37172 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932684Ab3LDRNJ (ORCPT ); Wed, 4 Dec 2013 12:13:09 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MXA00A9LL5WBUB0@mailout3.samsung.com>; Thu, 05 Dec 2013 02:13:08 +0900 (KST) X-AuditID: cbfee61b-b7f006d000003e1f-48-529f62a3b5b8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 0C.F5.15903.3A26F925; Thu, 05 Dec 2013 02:13:08 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MXA00HNVL4BBJ20@mmp1.samsung.com>; Thu, 05 Dec 2013 02:13:07 +0900 (KST) From: Sylwester Nawrocki To: mturquette@linaro.org, linux-arm-kernel@lists.infradead.org Cc: linux@arm.linux.org.uk, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jiada_wang@mentor.com, laurent.pinchart@ideasonboard.com, kyungmin.park@samsung.com, Sylwester Nawrocki Subject: [RESEND PATCH v7 1/5] omap3isp: Modify clocks registration to avoid circular references Date: Wed, 04 Dec 2013 18:12:03 +0100 Message-id: <1386177127-2894-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1386177127-2894-1-git-send-email-s.nawrocki@samsung.com> References: <1386177127-2894-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKLMWRmVeSWpSXmKPExsVy+t9jAd0lSfODDL5tZLHo+VNpcbbpDbtF 58Ql7BabHl9jtbi8aw6bRc+GrawWty/zWjydcJHN4vCbdlYHTo+W5h42j9kdM1k97lzbw+ax eUm9x+6vTYwefVtWMXp83iQXwB7FZZOSmpNZllqkb5fAlXH00kXGgpviFT33NjI1MK4T7mLk 5JAQMJG41TaJCcIWk7hwbz1bFyMXh5DAIkaJua9uQTkdTBKHentZQKrYBAwleo/2MYLYIgL2 Eu0tL8CKmAXuMko8P/cQLCEskCTRuOMwK4jNIqAqcfH4azYQm1fAVaLpdA9zFyMH0DoFiTmT bEDCnAJuEvtmbAGbLwRUcn7nY/YJjLwLGBlWMYqmFiQXFCel5xrpFSfmFpfmpesl5+duYgQH 3jPpHYyrGiwOMQpwMCrx8L5InB8kxJpYVlyZe4hRgoNZSYR3ciBQiDclsbIqtSg/vqg0J7X4 EKM0B4uSOO/BVutAIYH0xJLU7NTUgtQimCwTB6dUA2Pj1YOfVRmO97zobjG7v+Or6Om1U/of FMsp2FfP1Jl+6oXmloWZnwOEc2WiE81l5s23nO+YFbpxZ2b61j3M3HF73vdUsPsEPzDvyeJk Xb02y3F23/2U+fa5cuusbB3tn+ib3dj1ctOk5bw2IjpFZ/+eDrYt4tKVE9Cr2vj6RqzRxk0T v1ZqhiqxFGckGmoxFxUnAgBwp2XiOAIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.12.4.170614 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' The clock core code is going to be modified so clk_get() takes reference on the clock provider module. Until the potential circular reference issue is properly addressed, we pass NULL as the first argument to clk_register(), in order to disallow sub-devices taking a reference on the ISP module back trough clk_get(). This should prevent locking the modules in memory. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Acked-by: Laurent Pinchart --- drivers/media/platform/omap3isp/isp.c | 22 ++++++++++++++++------ drivers/media/platform/omap3isp/isp.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 1c36080..5910662 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -290,9 +290,11 @@ static int isp_xclk_init(struct isp_device *isp) struct clk_init_data init; unsigned int i; + for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) + isp->xclks[i].clk = ERR_PTR(-EINVAL); + for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) { struct isp_xclk *xclk = &isp->xclks[i]; - struct clk *clk; xclk->isp = isp; xclk->id = i == 0 ? ISP_XCLK_A : ISP_XCLK_B; @@ -305,10 +307,15 @@ static int isp_xclk_init(struct isp_device *isp) init.num_parents = 1; xclk->hw.init = &init; - - clk = devm_clk_register(isp->dev, &xclk->hw); - if (IS_ERR(clk)) - return PTR_ERR(clk); + /* + * The first argument is NULL in order to avoid circular + * reference, as this driver takes reference on the + * sensor subdevice modules and the sensors would take + * reference on this module through clk_get(). + */ + xclk->clk = clk_register(NULL, &xclk->hw); + if (IS_ERR(xclk->clk)) + return PTR_ERR(xclk->clk); if (pdata->xclks[i].con_id == NULL && pdata->xclks[i].dev_id == NULL) @@ -320,7 +327,7 @@ static int isp_xclk_init(struct isp_device *isp) xclk->lookup->con_id = pdata->xclks[i].con_id; xclk->lookup->dev_id = pdata->xclks[i].dev_id; - xclk->lookup->clk = clk; + xclk->lookup->clk = xclk->clk; clkdev_add(xclk->lookup); } @@ -335,6 +342,9 @@ static void isp_xclk_cleanup(struct isp_device *isp) for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) { struct isp_xclk *xclk = &isp->xclks[i]; + if (!IS_ERR(xclk->clk)) + clk_unregister(xclk->clk); + if (xclk->lookup) clkdev_drop(xclk->lookup); } diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index ce65d3a..d1e857e 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -135,6 +135,7 @@ struct isp_xclk { struct isp_device *isp; struct clk_hw hw; struct clk_lookup *lookup; + struct clk *clk; enum isp_xclk_id id; spinlock_t lock; /* Protects enabled and divider */