All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 1/5] omap3isp: Modify clocks registration to avoid circular references
Date: Tue, 29 Oct 2013 19:51:04 +0000	[thread overview]
Message-ID: <1383076268-8984-2-git-send-email-s.nawrocki@samsung.com> (raw)
In-Reply-To: <1383076268-8984-1-git-send-email-s.nawrocki@samsung.com>

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 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.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch has been "compile tested" only.

---
 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 df3a0ec..286027a 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 cd3eff4..1498f2b 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 */
--
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: linux-arm-kernel@lists.infradead.org, mturquette@linaro.org
Cc: linux@arm.linux.org.uk, jiada_wang@mentor.com,
	kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com,
	linux-kernel@vger.kernel.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-mips@linux-mips.org, linux-sh@vger.kernel.org,
	Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: [PATCH v7 1/5] omap3isp: Modify clocks registration to avoid circular references
Date: Tue, 29 Oct 2013 20:51:04 +0100	[thread overview]
Message-ID: <1383076268-8984-2-git-send-email-s.nawrocki@samsung.com> (raw)
In-Reply-To: <1383076268-8984-1-git-send-email-s.nawrocki@samsung.com>

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 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.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch has been "compile tested" only.

---
 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 df3a0ec..286027a 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 cd3eff4..1498f2b 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 */
--
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: s.nawrocki@samsung.com (Sylwester Nawrocki)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 1/5] omap3isp: Modify clocks registration to avoid circular references
Date: Tue, 29 Oct 2013 20:51:04 +0100	[thread overview]
Message-ID: <1383076268-8984-2-git-send-email-s.nawrocki@samsung.com> (raw)
In-Reply-To: <1383076268-8984-1-git-send-email-s.nawrocki@samsung.com>

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 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.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch has been "compile tested" only.

---
 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 df3a0ec..286027a 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 cd3eff4..1498f2b 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 */
--
1.7.9.5

  reply	other threads:[~2013-10-29 19:51 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29 19:51 [PATCH v7 0/5] clk: clock deregistration support Sylwester Nawrocki
2013-10-29 19:51 ` Sylwester Nawrocki
2013-10-29 19:51 ` Sylwester Nawrocki
2013-10-29 19:51 ` Sylwester Nawrocki [this message]
2013-10-29 19:51   ` [PATCH v7 1/5] omap3isp: Modify clocks registration to avoid circular references Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 22:28   ` Laurent Pinchart
2013-10-29 22:28     ` Laurent Pinchart
2013-10-29 22:28     ` Laurent Pinchart
2013-10-29 23:28     ` Sebastian Reichel
2013-10-29 23:28       ` Sebastian Reichel
2013-10-29 23:28       ` Sebastian Reichel
2013-10-29 23:55       ` Laurent Pinchart
2013-10-29 23:55         ` Laurent Pinchart
2013-10-29 23:55         ` Laurent Pinchart
2013-10-29 23:57     ` Sylwester Nawrocki
2013-10-29 23:57       ` Sylwester Nawrocki
2013-10-29 23:57       ` Sylwester Nawrocki
2013-10-29 19:51 ` [PATCH v7 2/5] clk: Provide not locked variant of of_clk_get_from_provider() Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51 ` [PATCH v7 3/5] clkdev: Fix race condition in clock lookup from device tree Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51 ` [PATCH v7 4/5] clk: Add common __clk_get(), __clk_put() implementations Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-30  0:19   ` Russell King - ARM Linux
2013-10-30  0:19     ` Russell King - ARM Linux
2013-10-30  0:19     ` Russell King - ARM Linux
2013-10-29 19:51 ` [PATCH v7 5/5] clk: Implement clk_unregister() Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-29 19:51   ` Sylwester Nawrocki
2013-10-31 18:32   ` Stephen Warren
2013-10-31 18:32     ` Stephen Warren
2013-10-31 18:32     ` Stephen Warren
2013-10-31 18:55     ` Sylwester Nawrocki
2013-10-31 18:55       ` Sylwester Nawrocki
2013-10-31 18:55       ` Sylwester Nawrocki
2013-10-31 19:07       ` Stephen Warren
2013-10-31 19:07         ` Stephen Warren
2013-10-31 19:07         ` Stephen Warren
2013-10-30 19:42 ` [PATCH v7 0/5] clk: clock deregistration support Mike Turquette
2013-10-30 19:42   ` Mike Turquette
2013-10-30 19:42   ` Mike Turquette
2013-10-30 19:42   ` Mike Turquette
2013-11-01 13:56 ` Jonas Jensen
2013-11-01 13:56   ` Jonas Jensen
2013-11-01 13:56   ` Jonas Jensen
2013-11-01 13:56   ` Jonas Jensen
2013-11-01 16:41   ` Sylwester Nawrocki
2013-11-01 16:41     ` Sylwester Nawrocki
2013-11-01 16:41     ` Sylwester Nawrocki
2013-11-01 16:41     ` Sylwester Nawrocki
2013-11-04  8:43     ` Jonas Jensen
2013-11-04  8:43       ` Jonas Jensen
2013-11-04  8:43       ` Jonas Jensen
2013-11-04  8:43       ` Jonas Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383076268-8984-2-git-send-email-s.nawrocki@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.