From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Thierry Escande <thierry.escande@collabora.com>,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 5/9] [media] s5p-jpeg: Add IOMMU support
Date: Fri, 2 Jun 2017 23:43:25 +0200 [thread overview]
Message-ID: <22caa512-6feb-449c-e6c4-8d647b2d2e8d@gmail.com> (raw)
In-Reply-To: <1496419376-17099-6-git-send-email-thierry.escande@collabora.com>
Cc Marek Szyprowski.
Marek, could you share your opinion about this patch?
On 06/02/2017 06:02 PM, Thierry Escande wrote:
> From: Tony K Nadackal <tony.kn@samsung.com>
>
> This patch adds support for IOMMU s5p-jpeg driver if the Exynos IOMMU
> and ARM DMA IOMMU configurations are supported. The address space is
> created with size limited to 256M and base address set to 0x20000000.
>
> Signed-off-by: Tony K Nadackal <tony.kn@samsung.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> ---
> drivers/media/platform/s5p-jpeg/jpeg-core.c | 77 +++++++++++++++++++++++++++++
> 1 file changed, 77 insertions(+)
>
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index 770a709..5569b99 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -28,6 +28,14 @@
> #include <media/v4l2-ioctl.h>
> #include <media/videobuf2-v4l2.h>
> #include <media/videobuf2-dma-contig.h>
> +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
> +#include <asm/dma-iommu.h>
> +#include <linux/dma-iommu.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/iommu.h>
> +#include <linux/kref.h>
> +#include <linux/of_platform.h>
> +#endif
>
> #include "jpeg-core.h"
> #include "jpeg-hw-s5p.h"
> @@ -35,6 +43,10 @@
> #include "jpeg-hw-exynos3250.h"
> #include "jpeg-regs.h"
>
> +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
> +static struct dma_iommu_mapping *mapping;
> +#endif
> +
> static struct s5p_jpeg_fmt sjpeg_formats[] = {
> {
> .name = "JPEG JFIF",
> @@ -956,6 +968,60 @@ static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx)
> }
> }
>
> +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
> +static int jpeg_iommu_init(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + int err;
> +
> + mapping = arm_iommu_create_mapping(&platform_bus_type, 0x20000000,
> + SZ_512M);
> + if (IS_ERR(mapping)) {
> + dev_err(dev, "IOMMU mapping failed\n");
> + return PTR_ERR(mapping);
> + }
> +
> + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
> + if (!dev->dma_parms) {
> + err = -ENOMEM;
> + goto error_alloc;
> + }
> +
> + err = dma_set_max_seg_size(dev, 0xffffffffu);
> + if (err)
> + goto error;
> +
> + err = arm_iommu_attach_device(dev, mapping);
> + if (err)
> + goto error;
> +
> + return 0;
> +
> +error:
> + devm_kfree(dev, dev->dma_parms);
> + dev->dma_parms = NULL;
> +
> +error_alloc:
> + arm_iommu_release_mapping(mapping);
> + mapping = NULL;
> +
> + return err;
> +}
> +
> +static void jpeg_iommu_deinit(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> +
> + if (mapping) {
> + arm_iommu_detach_device(dev);
> + devm_kfree(dev, dev->dma_parms);
> + dev->dma_parms = NULL;
> + arm_iommu_release_mapping(mapping);
> + mapping = NULL;
> + }
> +}
> +#endif
> +
> /*
> * ============================================================================
> * Device file operations
> @@ -2816,6 +2882,13 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
> spin_lock_init(&jpeg->slock);
> jpeg->dev = &pdev->dev;
>
> +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
> + ret = jpeg_iommu_init(pdev);
> + if (ret) {
> + dev_err(&pdev->dev, "IOMMU Initialization failed\n");
> + return ret;
> + }
> +#endif
> /* memory-mapped registers */
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>
> @@ -2962,6 +3035,10 @@ static int s5p_jpeg_remove(struct platform_device *pdev)
> clk_disable_unprepare(jpeg->clocks[i]);
> }
>
> +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
> + jpeg_iommu_deinit(pdev);
> +#endif
> +
> return 0;
> }
>
>
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2017-06-02 21:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 16:02 [PATCH 0/9] [media] s5p-jpeg: Various fixes and improvements Thierry Escande
2017-06-02 16:02 ` [PATCH 1/9] [media] s5p-jpeg: Reset the Codec before doing a soft reset Thierry Escande
2017-06-02 19:50 ` Jacek Anaszewski
2017-06-07 12:34 ` Thierry Escande
2017-06-13 18:46 ` Jacek Anaszewski
2017-06-14 12:03 ` Andrzej Pietrasiewicz
2017-06-02 16:02 ` [PATCH 2/9] [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf Thierry Escande
2017-06-02 21:27 ` Jacek Anaszewski
2017-06-02 16:02 ` [PATCH 3/9] [media] s5p-jpeg: Correct WARN_ON statement for checking subsampling Thierry Escande
2017-06-02 16:02 ` [PATCH 4/9] [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format Thierry Escande
2017-06-02 21:34 ` Jacek Anaszewski
2017-06-02 16:02 ` [PATCH 5/9] [media] s5p-jpeg: Add IOMMU support Thierry Escande
2017-06-02 21:43 ` Jacek Anaszewski [this message]
2017-06-19 6:16 ` Marek Szyprowski
2017-06-03 0:46 ` Shuah Khan
[not found] ` <CGME20170605113718epcas5p3edec0d42b03181649f06ae9b5bbd6a65@epcas5p3.samsung.com>
2017-06-05 11:37 ` Sylwester Nawrocki
2017-06-02 16:02 ` [PATCH 6/9] [media] s5p-jpeg: Add support for resolution change event Thierry Escande
2017-06-02 21:53 ` Jacek Anaszewski
2017-06-07 15:27 ` Thierry Escande
2017-06-02 16:02 ` [PATCH 7/9] [media] s5p-jpeg: Change sclk_jpeg to 166MHz for Exynos5250 Thierry Escande
2017-06-02 21:58 ` Jacek Anaszewski
2017-06-05 10:26 ` Sylwester Nawrocki
2017-06-02 16:02 ` [PATCH 8/9] [media] s5p-jpeg: Add stream error handling for Exynos5420 Thierry Escande
2017-06-02 16:02 ` [PATCH 9/9] [media] s5p-jpeg: Add support for multi-planar APIs Thierry Escande
2017-06-02 22:04 ` Jacek Anaszewski
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=22caa512-6feb-449c-e6c4-8d647b2d2e8d@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=andrzej.p@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=thierry.escande@collabora.com \
/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).