* [PATCH 0/9] media: Exynos MFC driver improvements
[not found] <CGME20161116090517eucas1p195d48a2b5a1fd0146c40537b70a05048@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
[not found] ` <CGME20161116090517eucas1p1e9f8ba968ead194a4be0ea631ab25d26@eucas1p1.samsung.com>
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
Hi!
This is another collection of patches for Exynos MFC codec driver.
It includes rebase of some improvements posted some time ago (which never
got merged due to various reasons), huge rework of clock handling code
and addition of Exynos 5433 variant support.
Patches were tested on Odroid U3 and XU3 as well as TM2 boards (Exynos
4412, 5422 and 5433).
Patches are based on git://linuxtv.org/snawrocki/samsung.git for-v4.10/media/next
branch.
Best regards
Marek Szyprowski
Samsung R&D Institute Poland
Patch summary:
Douglas Anderson (1):
s5p-mfc: Set DMA_ATTR_ALLOC_SINGLE_PAGES
Marek Szyprowski (8):
s5p-mfc: Use printk_ratelimited for reporting ioctl errors
s5p-mfc: Remove special clock rate management
s5p-mfc: Ensure that clock is disabled before turning power off
s5p-mfc: Remove dead conditional code
s5p-mfc: Kill all IS_ERR_OR_NULL in clocks management code
s5p-mfc: Don't keep clock prepared all the time
s5p-mfc: Rework clock handling
s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs
.../devicetree/bindings/media/s5p-mfc.txt | 1 +
drivers/media/platform/s5p-mfc/s5p_mfc.c | 61 +++++----
drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 10 +-
drivers/media/platform/s5p-mfc/s5p_mfc_debug.h | 6 +
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +-
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +-
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 139 ++++++++-------------
7 files changed, 103 insertions(+), 118 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/9] s5p-mfc: Set DMA_ATTR_ALLOC_SINGLE_PAGES
[not found] ` <CGME20161116090517eucas1p1e9f8ba968ead194a4be0ea631ab25d26@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae,
Douglas Anderson
From: Douglas Anderson <dianders@chromium.org>
We do video allocation all the time and we need it to be fast. Plus TLB
efficiency isn't terribly important for video.
That means we want to set DMA_ATTR_ALLOC_SINGLE_PAGES.
See also the previous change (commit 14d3ae2efeed "ARM: dma-mapping: Use
DMA_ATTR_ALLOC_SINGLE_PAGES hint to optimize allocation").
Signed-off-by: Douglas Anderson <dianders@chromium.org>
[mszyprow: rebased patch onto v4.9-rc1 and adapted changes to latest videbuf2
changes, this simplifies code changes to only set proper dma attribute flag
and comment the reason for it, added commit id of arch/arm/mm patch]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 27b375e75555..a0a29194ccd1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -851,6 +851,11 @@ static int s5p_mfc_open(struct file *file)
ret = -ENOENT;
goto err_queue_init;
}
+ /*
+ * We'll do mostly sequential access, so sacrifice TLB efficiency for
+ * faster allocation.
+ */
+ q->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES;
q->mem_ops = &vb2_dma_contig_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(q);
@@ -881,6 +886,12 @@ static int s5p_mfc_open(struct file *file)
* will keep the value of bytesused intact.
*/
q->allow_zero_bytesused = 1;
+
+ /*
+ * We'll do mostly sequential access, so sacrifice TLB efficiency for
+ * faster allocation.
+ */
+ q->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES;
q->mem_ops = &vb2_dma_contig_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(q);
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/9] s5p-mfc: Use printk_ratelimited for reporting ioctl errors
[not found] ` <CGME20161116090518eucas1p17c506d8c8282f852cb3f4f10c5f82fa0@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
Some applications doesn't check error codes from QBUF/DQBUF ioctls, so
don't spam kernel log with errors if they fall into endless loop
trying to queue next buffer after a failure.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc_debug.h | 6 ++++++
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +-
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
index 5936923c631c..1936a5b868f5 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
@@ -39,6 +39,12 @@
__func__, __LINE__, ##args); \
} while (0)
+#define mfc_err_limited(fmt, args...) \
+ do { \
+ printk_ratelimited(KERN_ERR "%s:%d: " fmt, \
+ __func__, __LINE__, ##args); \
+ } while (0)
+
#define mfc_info(fmt, args...) \
do { \
printk(KERN_INFO "%s:%d: " fmt, \
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 52081ddc9bf2..47aceacee169 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -642,7 +642,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
int ret;
if (ctx->state == MFCINST_ERROR) {
- mfc_err("Call on DQBUF after unrecoverable error\n");
+ mfc_err_limited("Call on DQBUF after unrecoverable error\n");
return -EIO;
}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index fcc2e054c61f..e39d9e06e299 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1268,7 +1268,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
int ret;
if (ctx->state == MFCINST_ERROR) {
- mfc_err("Call on DQBUF after unrecoverable error\n");
+ mfc_err_limited("Call on DQBUF after unrecoverable error\n");
return -EIO;
}
if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/9] s5p-mfc: Remove special clock rate management
[not found] ` <CGME20161116090519eucas1p11aa58cad47673b61c9e077d4fcd29d0d@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
The maximum rate of special clock depends on SoC variant and should be set
in device tree via assigned-clock-rates property, so remove the code which
forces special clock to 200MHz.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index b5806ab7ac31..818c04646061 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -20,7 +20,6 @@
#define MFC_GATE_CLK_NAME "mfc"
#define MFC_SCLK_NAME "sclk_mfc"
-#define MFC_SCLK_RATE (200 * 1000000)
#define CLK_DEBUG
@@ -57,7 +56,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
mfc_info("Failed to get MFC special clock control\n");
pm->clock = NULL;
} else {
- clk_set_rate(pm->clock, MFC_SCLK_RATE);
ret = clk_prepare_enable(pm->clock);
if (ret) {
mfc_err("Failed to enable MFC special clock\n");
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/9] s5p-mfc: Ensure that clock is disabled before turning power off
[not found] ` <CGME20161116090519eucas1p1021f0aab03499906974608d33aeac4eb@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
Move clock disabling before turning power off. This will enable later to
add calls to clk_prepare/unprepare in the s5p_mfc_power_off() function
to avoid keeping clocks prepared all the time when driver is bound.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index a0a29194ccd1..30ceae7eabc5 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -963,11 +963,13 @@ static int s5p_mfc_release(struct file *file)
mfc_debug(2, "Last instance\n");
s5p_mfc_deinit_hw(dev);
del_timer_sync(&dev->watchdog_timer);
+ s5p_mfc_clock_off();
if (s5p_mfc_power_off() < 0)
mfc_err("Power off failed\n");
+ } else {
+ mfc_debug(2, "Shutting down clock\n");
+ s5p_mfc_clock_off();
}
- mfc_debug(2, "Shutting down clock\n");
- s5p_mfc_clock_off();
}
if (dev)
dev->ctx[ctx->num] = NULL;
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/9] s5p-mfc: Remove dead conditional code
[not found] ` <CGME20161116090520eucas1p151e1da5cba8c5b85f9fe63e77650c091@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
CONFIG_PM is always enabled on Exynos platforms, so remove dead code
related to early development of MFC driver on platform without PM support.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc.c | 22 ------------------
drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 1 -
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 30 +++++--------------------
3 files changed, 5 insertions(+), 48 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 30ceae7eabc5..72af819a4f47 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1404,31 +1404,9 @@ static int s5p_mfc_resume(struct device *dev)
}
#endif
-#ifdef CONFIG_PM
-static int s5p_mfc_runtime_suspend(struct device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev);
- struct s5p_mfc_dev *m_dev = platform_get_drvdata(pdev);
-
- atomic_set(&m_dev->pm.power, 0);
- return 0;
-}
-
-static int s5p_mfc_runtime_resume(struct device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev);
- struct s5p_mfc_dev *m_dev = platform_get_drvdata(pdev);
-
- atomic_set(&m_dev->pm.power, 1);
- return 0;
-}
-#endif
-
/* Power management */
static const struct dev_pm_ops s5p_mfc_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(s5p_mfc_suspend, s5p_mfc_resume)
- SET_RUNTIME_PM_OPS(s5p_mfc_runtime_suspend, s5p_mfc_runtime_resume,
- NULL)
};
static struct s5p_mfc_buf_size_v5 mfc_buf_size_v5 = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index c068ee3ece6e..58b15c212dd2 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -200,7 +200,6 @@ struct s5p_mfc_pm {
struct clk *clock;
struct clk *clock_gate;
bool use_clock_gating;
- atomic_t power;
struct device *device;
};
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 818c04646061..11a918eb7564 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -21,14 +21,9 @@
#define MFC_GATE_CLK_NAME "mfc"
#define MFC_SCLK_NAME "sclk_mfc"
-#define CLK_DEBUG
-
static struct s5p_mfc_pm *pm;
static struct s5p_mfc_dev *p_dev;
-
-#ifdef CLK_DEBUG
static atomic_t clk_ref;
-#endif
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
@@ -64,14 +59,10 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
}
}
- atomic_set(&pm->power, 0);
-#ifdef CONFIG_PM
pm->device = &dev->plat_dev->dev;
pm_runtime_enable(pm->device);
-#endif
-#ifdef CLK_DEBUG
atomic_set(&clk_ref, 0);
-#endif
+
return 0;
err_s_clk:
@@ -95,18 +86,16 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
clk_unprepare(pm->clock_gate);
clk_put(pm->clock_gate);
pm->clock_gate = NULL;
-#ifdef CONFIG_PM
pm_runtime_disable(pm->device);
-#endif
}
int s5p_mfc_clock_on(void)
{
int ret = 0;
-#ifdef CLK_DEBUG
+
atomic_inc(&clk_ref);
mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
-#endif
+
if (!pm->use_clock_gating)
return 0;
if (!IS_ERR_OR_NULL(pm->clock_gate))
@@ -116,10 +105,9 @@ int s5p_mfc_clock_on(void)
void s5p_mfc_clock_off(void)
{
-#ifdef CLK_DEBUG
atomic_dec(&clk_ref);
mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
-#endif
+
if (!pm->use_clock_gating)
return;
if (!IS_ERR_OR_NULL(pm->clock_gate))
@@ -130,13 +118,10 @@ int s5p_mfc_power_on(void)
{
int ret = 0;
-#ifdef CONFIG_PM
ret = pm_runtime_get_sync(pm->device);
if (ret)
return ret;
-#else
- atomic_set(&pm->power, 1);
-#endif
+
if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
ret = clk_enable(pm->clock_gate);
return ret;
@@ -146,12 +131,7 @@ int s5p_mfc_power_off(void)
{
if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
clk_disable(pm->clock_gate);
-#ifdef CONFIG_PM
return pm_runtime_put_sync(pm->device);
-#else
- atomic_set(&pm->power, 0);
- return 0;
-#endif
}
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/9] s5p-mfc: Kill all IS_ERR_OR_NULL in clocks management code
[not found] ` <CGME20161116090520eucas1p1014c941bfe4fbe11392f8d9028e6f4f1@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
After commit "s5p-mfc: Fix clock management in s5p_mfc_release function"
all clocks related functions are called only when MFC device is really
available, so there is no additional check needed for NULL
gate clocks. This patch simplifies the code and kills IS_ERR_OR_NULL
macro usage.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 11a918eb7564..b514584cf00d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -91,16 +91,12 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
int s5p_mfc_clock_on(void)
{
- int ret = 0;
-
atomic_inc(&clk_ref);
mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
if (!pm->use_clock_gating)
return 0;
- if (!IS_ERR_OR_NULL(pm->clock_gate))
- ret = clk_enable(pm->clock_gate);
- return ret;
+ return clk_enable(pm->clock_gate);
}
void s5p_mfc_clock_off(void)
@@ -110,8 +106,7 @@ void s5p_mfc_clock_off(void)
if (!pm->use_clock_gating)
return;
- if (!IS_ERR_OR_NULL(pm->clock_gate))
- clk_disable(pm->clock_gate);
+ clk_disable(pm->clock_gate);
}
int s5p_mfc_power_on(void)
@@ -122,14 +117,14 @@ int s5p_mfc_power_on(void)
if (ret)
return ret;
- if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
+ if (!pm->use_clock_gating)
ret = clk_enable(pm->clock_gate);
return ret;
}
int s5p_mfc_power_off(void)
{
- if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
+ if (!pm->use_clock_gating)
clk_disable(pm->clock_gate);
return pm_runtime_put_sync(pm->device);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/9] s5p-mfc: Don't keep clock prepared all the time
[not found] ` <CGME20161116090521eucas1p105428e9cd3affab0260a574e21a749f0@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
This patch moves preparation of clocks from s5p_mfc_init_pm()
(driver probe) to s5p_mfc_power_on() (start of device operation).
This change will allow to use runtime power usage optimization
on newer Samsung Exynos platforms (for example Exynos 5433).
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 52 ++++++++++++++++-------------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index b514584cf00d..796dac85746a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -39,23 +39,11 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
goto err_g_ip_clk;
}
- ret = clk_prepare(pm->clock_gate);
- if (ret) {
- mfc_err("Failed to prepare clock-gating control\n");
- goto err_p_ip_clk;
- }
-
if (dev->variant->version != MFC_VERSION_V6) {
pm->clock = clk_get(&dev->plat_dev->dev, MFC_SCLK_NAME);
if (IS_ERR(pm->clock)) {
mfc_info("Failed to get MFC special clock control\n");
pm->clock = NULL;
- } else {
- ret = clk_prepare_enable(pm->clock);
- if (ret) {
- mfc_err("Failed to enable MFC special clock\n");
- goto err_s_clk;
- }
}
}
@@ -65,10 +53,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
return 0;
-err_s_clk:
- clk_put(pm->clock);
- pm->clock = NULL;
-err_p_ip_clk:
clk_put(pm->clock_gate);
pm->clock_gate = NULL;
err_g_ip_clk:
@@ -79,11 +63,9 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
{
if (dev->variant->version != MFC_VERSION_V6 &&
pm->clock) {
- clk_disable_unprepare(pm->clock);
clk_put(pm->clock);
pm->clock = NULL;
}
- clk_unprepare(pm->clock_gate);
clk_put(pm->clock_gate);
pm->clock_gate = NULL;
pm_runtime_disable(pm->device);
@@ -111,22 +93,44 @@ void s5p_mfc_clock_off(void)
int s5p_mfc_power_on(void)
{
- int ret = 0;
+ int ret;
ret = pm_runtime_get_sync(pm->device);
if (ret)
return ret;
- if (!pm->use_clock_gating)
- ret = clk_enable(pm->clock_gate);
+ ret = clk_prepare_enable(pm->clock_gate);
+ if (ret)
+ goto err_pm;
+
+ if (pm->clock) {
+ ret = clk_prepare_enable(pm->clock);
+ if (ret)
+ goto err_gate;
+ }
+
+ if (pm->use_clock_gating)
+ clk_disable(pm->clock_gate);
+ return 0;
+
+err_gate:
+ clk_disable_unprepare(pm->clock_gate);
+err_pm:
+ pm_runtime_put_sync(pm->device);
return ret;
+
}
int s5p_mfc_power_off(void)
{
- if (!pm->use_clock_gating)
- clk_disable(pm->clock_gate);
+ if (pm->clock)
+ clk_disable_unprepare(pm->clock);
+
+ if (pm->use_clock_gating)
+ clk_unprepare(pm->clock_gate);
+ else
+ clk_disable_unprepare(pm->clock_gate);
+
return pm_runtime_put_sync(pm->device);
}
-
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 8/9] s5p-mfc: Rework clock handling
[not found] ` <CGME20161116090522eucas1p2110bfe357718cfb5aebd750201a1b22e@eucas1p2.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
0 siblings, 0 replies; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
This patch changes the code for handling clocks. Now clocks are defined
per each device variant, what is a preparation for adding support for
Exynos 5433 MFC V8, which has more clocks than all previous versions.
Also use devm_clk_get() to simplify cleanup path.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/platform/s5p-mfc/s5p_mfc.c | 8 ++
drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 9 ++-
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 98 ++++++++++---------------
3 files changed, 56 insertions(+), 59 deletions(-)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 72af819a4f47..fa674e8e09a8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1433,6 +1433,8 @@ static int s5p_mfc_resume(struct device *dev)
.buf_size = &buf_size_v5,
.buf_align = &mfc_buf_align_v5,
.fw_name[0] = "s5p-mfc.fw",
+ .clk_names = {"mfc", "sclk_mfc"},
+ .num_clocks = 2,
.use_clock_gating = true,
};
@@ -1466,6 +1468,8 @@ static int s5p_mfc_resume(struct device *dev)
* for init buffer command
*/
.fw_name[1] = "s5p-mfc-v6-v2.fw",
+ .clk_names = {"mfc"},
+ .num_clocks = 1,
};
static struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
@@ -1493,6 +1497,8 @@ static int s5p_mfc_resume(struct device *dev)
.buf_size = &buf_size_v7,
.buf_align = &mfc_buf_align_v7,
.fw_name[0] = "s5p-mfc-v7.fw",
+ .clk_names = {"mfc", "sclk_mfc"},
+ .num_clocks = 2,
};
static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
@@ -1520,6 +1526,8 @@ static int s5p_mfc_resume(struct device *dev)
.buf_size = &buf_size_v8,
.buf_align = &mfc_buf_align_v8,
.fw_name[0] = "s5p-mfc-v8.fw",
+ .clk_names = {"mfc"},
+ .num_clocks = 1,
};
static const struct of_device_id exynos_mfc_match[] = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 58b15c212dd2..ab23236aa942 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -104,6 +104,8 @@ static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET 16
#define S5P_MFC_R2H_CMD_ERR_RET 32
+#define MFC_MAX_CLOCKS 4
+
#define mfc_read(dev, offset) readl(dev->regs_base + (offset))
#define mfc_write(dev, data, offset) writel((data), dev->regs_base + \
(offset))
@@ -197,9 +199,12 @@ struct s5p_mfc_buf {
* struct s5p_mfc_pm - power management data structure
*/
struct s5p_mfc_pm {
- struct clk *clock;
struct clk *clock_gate;
+ const char **clk_names;
+ struct clk *clocks[MFC_MAX_CLOCKS];
+ int num_clocks;
bool use_clock_gating;
+
struct device *device;
};
@@ -235,6 +240,8 @@ struct s5p_mfc_variant {
struct s5p_mfc_buf_size *buf_size;
struct s5p_mfc_buf_align *buf_align;
char *fw_name[MFC_FW_MAX_VERSIONS];
+ const char *clk_names[MFC_MAX_CLOCKS];
+ int num_clocks;
bool use_clock_gating;
};
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 796dac85746a..eb85cedc5ef3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -18,56 +18,42 @@
#include "s5p_mfc_debug.h"
#include "s5p_mfc_pm.h"
-#define MFC_GATE_CLK_NAME "mfc"
-#define MFC_SCLK_NAME "sclk_mfc"
-
static struct s5p_mfc_pm *pm;
static struct s5p_mfc_dev *p_dev;
static atomic_t clk_ref;
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
- int ret = 0;
+ int i;
pm = &dev->pm;
p_dev = dev;
- pm->use_clock_gating = dev->variant->use_clock_gating;
- pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME);
- if (IS_ERR(pm->clock_gate)) {
- mfc_err("Failed to get clock-gating control\n");
- ret = PTR_ERR(pm->clock_gate);
- goto err_g_ip_clk;
- }
- if (dev->variant->version != MFC_VERSION_V6) {
- pm->clock = clk_get(&dev->plat_dev->dev, MFC_SCLK_NAME);
- if (IS_ERR(pm->clock)) {
- mfc_info("Failed to get MFC special clock control\n");
- pm->clock = NULL;
+ pm->num_clocks = dev->variant->num_clocks;
+ pm->clk_names = dev->variant->clk_names;
+ pm->device = &dev->plat_dev->dev;
+ pm->clock_gate = NULL;
+
+ /* clock control */
+ for (i = 0; i < pm->num_clocks; i++) {
+ pm->clocks[i] = devm_clk_get(pm->device, pm->clk_names[i]);
+ if (IS_ERR(pm->clocks[i])) {
+ mfc_err("Failed to get clock: %s\n",
+ pm->clk_names[i]);
+ return PTR_ERR(pm->clocks[i]);
}
}
- pm->device = &dev->plat_dev->dev;
+ if (dev->variant->use_clock_gating)
+ pm->clock_gate = pm->clocks[0];
+
pm_runtime_enable(pm->device);
atomic_set(&clk_ref, 0);
-
return 0;
-
- clk_put(pm->clock_gate);
- pm->clock_gate = NULL;
-err_g_ip_clk:
- return ret;
}
void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
{
- if (dev->variant->version != MFC_VERSION_V6 &&
- pm->clock) {
- clk_put(pm->clock);
- pm->clock = NULL;
- }
- clk_put(pm->clock_gate);
- pm->clock_gate = NULL;
pm_runtime_disable(pm->device);
}
@@ -76,8 +62,6 @@ int s5p_mfc_clock_on(void)
atomic_inc(&clk_ref);
mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
- if (!pm->use_clock_gating)
- return 0;
return clk_enable(pm->clock_gate);
}
@@ -86,50 +70,48 @@ void s5p_mfc_clock_off(void)
atomic_dec(&clk_ref);
mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
- if (!pm->use_clock_gating)
- return;
clk_disable(pm->clock_gate);
}
int s5p_mfc_power_on(void)
{
- int ret;
+ int i, ret = 0;
ret = pm_runtime_get_sync(pm->device);
- if (ret)
+ if (ret < 0)
return ret;
- ret = clk_prepare_enable(pm->clock_gate);
- if (ret)
- goto err_pm;
-
- if (pm->clock) {
- ret = clk_prepare_enable(pm->clock);
- if (ret)
- goto err_gate;
+ /* clock control */
+ for (i = 0; i < pm->num_clocks; i++) {
+ ret = clk_prepare_enable(pm->clocks[i]);
+ if (ret < 0) {
+ mfc_err("clock prepare failed for clock: %s\n",
+ pm->clk_names[i]);
+ i++;
+ goto err;
+ }
}
- if (pm->use_clock_gating)
- clk_disable(pm->clock_gate);
- return 0;
+ /* prepare for software clock gating */
+ clk_disable(pm->clock_gate);
-err_gate:
- clk_disable_unprepare(pm->clock_gate);
-err_pm:
- pm_runtime_put_sync(pm->device);
+ return 0;
+err:
+ while (--i > 0)
+ clk_disable_unprepare(pm->clocks[i]);
+ pm_runtime_put(pm->device);
return ret;
-
}
int s5p_mfc_power_off(void)
{
- if (pm->clock)
- clk_disable_unprepare(pm->clock);
+ int i;
+
+ /* finish software clock gating */
+ clk_enable(pm->clock_gate);
- if (pm->use_clock_gating)
- clk_unprepare(pm->clock_gate);
- else
- clk_disable_unprepare(pm->clock_gate);
+ for (i = 0; i < pm->num_clocks; i++)
+ clk_disable_unprepare(pm->clocks[i]);
return pm_runtime_put_sync(pm->device);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 9/9] s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs
[not found] ` <CGME20161116090523eucas1p12a4b95363e9d2b0a823141a2f1c226e1@eucas1p1.samsung.com>
@ 2016-11-16 9:04 ` Marek Szyprowski
2016-11-16 17:18 ` Krzysztof Kozlowski
0 siblings, 1 reply; 11+ messages in thread
From: Marek Szyprowski @ 2016-11-16 9:04 UTC (permalink / raw)
To: linux-media, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Krzysztof Kozlowski,
Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
Exynos5433 SoC has MFC v8 hardware module, but it has more complex clock
hierarchy, so a new compatible has been added.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
Documentation/devicetree/bindings/media/s5p-mfc.txt | 1 +
drivers/media/platform/s5p-mfc/s5p_mfc.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index 92c94f5ecbf1..2c901286d818 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -12,6 +12,7 @@ Required properties:
(b) "samsung,mfc-v6" for MFC v6 present in Exynos5 SoCs
(c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
(d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC
+ (e) "samsung,exynos5433-mfc" for MFC v8 present in Exynos5433 SoC
- reg : Physical base address of the IP registers and length of memory
mapped region.
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index fa674e8e09a8..d11a2405b3d2 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1530,6 +1530,17 @@ static int s5p_mfc_resume(struct device *dev)
.num_clocks = 1,
};
+static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
+ .version = MFC_VERSION_V8,
+ .version_bit = MFC_V8_BIT,
+ .port_num = MFC_NUM_PORTS_V8,
+ .buf_size = &buf_size_v8,
+ .buf_align = &mfc_buf_align_v8,
+ .fw_name[0] = "s5p-mfc-v8.fw",
+ .clk_names = {"pclk", "aclk", "aclk_xiu"},
+ .num_clocks = 3,
+};
+
static const struct of_device_id exynos_mfc_match[] = {
{
.compatible = "samsung,mfc-v5",
@@ -1543,6 +1554,9 @@ static int s5p_mfc_resume(struct device *dev)
}, {
.compatible = "samsung,mfc-v8",
.data = &mfc_drvdata_v8,
+ }, {
+ .compatible = "samsung,exynos5433-mfc",
+ .data = &mfc_drvdata_v8_5433,
},
{},
};
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 9/9] s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs
2016-11-16 9:04 ` [PATCH 9/9] s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs Marek Szyprowski
@ 2016-11-16 17:18 ` Krzysztof Kozlowski
0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2016-11-16 17:18 UTC (permalink / raw)
To: Marek Szyprowski
Cc: linux-media, linux-samsung-soc, Sylwester Nawrocki,
Krzysztof Kozlowski, Seung-Woo Kim, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Andrzej Hajda, Inki Dae
On Wed, Nov 16, 2016 at 10:04:58AM +0100, Marek Szyprowski wrote:
> Exynos5433 SoC has MFC v8 hardware module, but it has more complex clock
> hierarchy, so a new compatible has been added.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> Documentation/devicetree/bindings/media/s5p-mfc.txt | 1 +
> drivers/media/platform/s5p-mfc/s5p_mfc.c | 14 ++++++++++++++
> 2 files changed, 15 insertions(+)
>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-11-16 17:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20161116090517eucas1p195d48a2b5a1fd0146c40537b70a05048@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 0/9] media: Exynos MFC driver improvements Marek Szyprowski
[not found] ` <CGME20161116090517eucas1p1e9f8ba968ead194a4be0ea631ab25d26@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 1/9] s5p-mfc: Set DMA_ATTR_ALLOC_SINGLE_PAGES Marek Szyprowski
[not found] ` <CGME20161116090518eucas1p17c506d8c8282f852cb3f4f10c5f82fa0@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 2/9] s5p-mfc: Use printk_ratelimited for reporting ioctl errors Marek Szyprowski
[not found] ` <CGME20161116090519eucas1p11aa58cad47673b61c9e077d4fcd29d0d@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 3/9] s5p-mfc: Remove special clock rate management Marek Szyprowski
[not found] ` <CGME20161116090519eucas1p1021f0aab03499906974608d33aeac4eb@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 4/9] s5p-mfc: Ensure that clock is disabled before turning power off Marek Szyprowski
[not found] ` <CGME20161116090520eucas1p151e1da5cba8c5b85f9fe63e77650c091@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 5/9] s5p-mfc: Remove dead conditional code Marek Szyprowski
[not found] ` <CGME20161116090520eucas1p1014c941bfe4fbe11392f8d9028e6f4f1@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 6/9] s5p-mfc: Kill all IS_ERR_OR_NULL in clocks management code Marek Szyprowski
[not found] ` <CGME20161116090521eucas1p105428e9cd3affab0260a574e21a749f0@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 7/9] s5p-mfc: Don't keep clock prepared all the time Marek Szyprowski
[not found] ` <CGME20161116090522eucas1p2110bfe357718cfb5aebd750201a1b22e@eucas1p2.samsung.com>
2016-11-16 9:04 ` [PATCH 8/9] s5p-mfc: Rework clock handling Marek Szyprowski
[not found] ` <CGME20161116090523eucas1p12a4b95363e9d2b0a823141a2f1c226e1@eucas1p1.samsung.com>
2016-11-16 9:04 ` [PATCH 9/9] s5p-mfc: Add support for MFC v8 available in Exynos 5433 SoCs Marek Szyprowski
2016-11-16 17:18 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).