From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: Eddie James <eajames@linux.ibm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org, linux-media@vger.kernel.org,
Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Subject: [PATCH 2/7] media: aspeed: refine clock control logic
Date: Thu, 2 May 2019 12:13:12 -0700 [thread overview]
Message-ID: <20190502191317.29698-3-jae.hyun.yoo@linux.intel.com> (raw)
In-Reply-To: <20190502191317.29698-1-jae.hyun.yoo@linux.intel.com>
Currently, this driver calls clk_prepare and clk_unprepare from
interrupt context too but these should be called from sleepable
context only. To fix this issue, this commit splits out
clk_enable/disable and clk_prepare/unprepare, and it places
clk_prepare/unprepare calls into the module probe/remove function.
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
---
drivers/media/platform/aspeed-video.c | 38 ++++++++++++++++++++-------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index 2dac6d20b180..8f4cac41da14 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -491,8 +491,8 @@ static void aspeed_video_off(struct aspeed_video *video)
aspeed_video_write(video, VE_INTERRUPT_CTRL, 0);
/* Turn off the relevant clocks */
- clk_disable_unprepare(video->vclk);
- clk_disable_unprepare(video->eclk);
+ clk_disable(video->vclk);
+ clk_disable(video->eclk);
clear_bit(VIDEO_CLOCKS_ON, &video->flags);
}
@@ -503,8 +503,8 @@ static void aspeed_video_on(struct aspeed_video *video)
return;
/* Turn on the relevant clocks */
- clk_prepare_enable(video->eclk);
- clk_prepare_enable(video->vclk);
+ clk_enable(video->eclk);
+ clk_enable(video->vclk);
set_bit(VIDEO_CLOCKS_ON, &video->flags);
}
@@ -1628,12 +1628,21 @@ static int aspeed_video_init(struct aspeed_video *video)
return PTR_ERR(video->eclk);
}
+ rc = clk_prepare(video->eclk);
+ if (rc)
+ return rc;
+
video->vclk = devm_clk_get(dev, "vclk");
if (IS_ERR(video->vclk)) {
dev_err(dev, "Unable to get VCLK\n");
- return PTR_ERR(video->vclk);
+ rc = PTR_ERR(video->vclk);
+ goto err_unprepare_eclk;
}
+ rc = clk_prepare(video->vclk);
+ if (rc)
+ goto err_unprepare_eclk;
+
rc = of_reserved_mem_device_init(dev);
if (rc) {
dev_err(dev, "Unable to reserve memory\n");
@@ -1643,20 +1652,26 @@ static int aspeed_video_init(struct aspeed_video *video)
rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(dev, "Failed to set DMA mask\n");
- of_reserved_mem_device_release(dev);
- return rc;
+ goto err_release_reserved_mem;
}
if (!aspeed_video_alloc_buf(video, &video->jpeg,
VE_JPEG_HEADER_SIZE)) {
dev_err(dev, "Failed to allocate DMA for JPEG header\n");
- of_reserved_mem_device_release(dev);
- return rc;
+ goto err_release_reserved_mem;
}
aspeed_video_init_jpeg_table(video->jpeg.virt, video->yuv420);
return 0;
+
+err_release_reserved_mem:
+ of_reserved_mem_device_release(dev);
+ clk_unprepare(video->vclk);
+err_unprepare_eclk:
+ clk_unprepare(video->eclk);
+
+ return rc;
}
static int aspeed_video_probe(struct platform_device *pdev)
@@ -1700,6 +1715,11 @@ static int aspeed_video_remove(struct platform_device *pdev)
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct aspeed_video *video = to_aspeed_video(v4l2_dev);
+ aspeed_video_off(video);
+
+ clk_unprepare(video->vclk);
+ clk_unprepare(video->eclk);
+
video_unregister_device(&video->vdev);
vb2_queue_release(&video->queue);
--
2.21.0
next prev parent reply other threads:[~2019-05-02 19:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 19:13 [PATCH 0/7] Improve stability of Aspeed video engine driver Jae Hyun Yoo
2019-05-02 19:13 ` [PATCH 1/7] media: aspeed: fix a kernel warning on clk control Jae Hyun Yoo
2019-05-08 6:31 ` Benjamin Herrenschmidt
2019-05-08 22:19 ` Jae Hyun Yoo
2019-05-09 1:08 ` Benjamin Herrenschmidt
[not found] ` <3786afed-c34d-e3f0-4cd5-620185807091@linux.intel.com>
2019-05-09 2:16 ` Benjamin Herrenschmidt
2019-05-09 15:19 ` Eddie James
2019-05-09 17:19 ` Jae Hyun Yoo
2019-05-09 23:19 ` Benjamin Herrenschmidt
2019-05-09 23:51 ` Jae Hyun Yoo
2019-05-10 3:01 ` Benjamin Herrenschmidt
2019-05-10 4:28 ` Jae Hyun Yoo
2019-05-02 19:13 ` Jae Hyun Yoo [this message]
2019-05-02 19:13 ` [PATCH 3/7] media: aspeed: change irq to threaded irq Jae Hyun Yoo
2019-05-02 19:13 ` [PATCH 4/7] media: aspeed: remove IRQF_SHARED flag Jae Hyun Yoo
2019-05-02 19:13 ` [PATCH 5/7] media: aspeed: reduce noisy log printing outs Jae Hyun Yoo
2019-05-02 19:13 ` [PATCH 6/7] media: aspeed: remove checking of VE_INTERRUPT_CAPTURE_COMPLETE Jae Hyun Yoo
2019-05-02 19:13 ` [PATCH 7/7] media: aspeed: refine interrupt handling logic Jae Hyun Yoo
2019-05-02 21:04 ` Eddie James
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=20190502191317.29698-3-jae.hyun.yoo@linux.intel.com \
--to=jae.hyun.yoo@linux.intel.com \
--cc=andrew@aj.id.au \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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 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).