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/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 3283841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A776CC0D4B for ; Wed, 4 Dec 2013 17:13:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7566420502 for ; Wed, 4 Dec 2013 17:13:45 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8CC9204EC for ; Wed, 4 Dec 2013 17:13:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoG13-0005ki-PX; Wed, 04 Dec 2013 17:13:38 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoG11-0002nP-4c; Wed, 04 Dec 2013 17:13:35 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoG0x-0002mP-Jm for linux-arm-kernel@lists.infradead.org; Wed, 04 Dec 2013 17:13:32 +0000 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> for linux-arm-kernel@lists.infradead.org; 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 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131204_121331_875739_20A79910 X-CRM114-Status: GOOD ( 13.45 ) X-Spam-Score: -6.9 (------) Cc: linux@arm.linux.org.uk, jiada_wang@mentor.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, Sylwester Nawrocki , linux-media@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 */