From: Inki Dae <inki.dae@samsung.com>
To: Hyungwon Hwang <human.hwang@samsung.com>
Cc: dri-devel@lists.freedesktop.org,
linux-samsung-soc@vger.kernel.org, sw0312.kim@samsung.com,
jy0922.shim@samsung.com
Subject: Re: [PATCH 2/2] drm/exynos: ipp: validate a GEM handle with multiple planes
Date: Thu, 11 Jun 2015 23:53:23 +0900 [thread overview]
Message-ID: <5579A0E3.3060503@samsung.com> (raw)
In-Reply-To: <1433821515-8952-2-git-send-email-human.hwang@samsung.com>
On 2015년 06월 09일 12:45, Hyungwon Hwang wrote:
> FIMC & GSC driver can calculate the offset of planes. So there are
> use cases which IPP receives just one GEM handle of an image with
> multiple plane. This patch extends ipp_validate_mem_node() to validate
> this case.
Applied.
Thanks,
Inki Dae
>
> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
> ---
> drivers/gpu/drm/exynos/exynos_drm_ipp.c | 51 ++++++++++++++++++++++++---------
> 1 file changed, 38 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> index 54c5cf4..b3dc778 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> @@ -482,8 +482,8 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev,
> {
> struct drm_exynos_ipp_config *ipp_cfg;
> unsigned int num_plane;
> - unsigned long min_size, size;
> - unsigned int bpp;
> + unsigned long size, buf_size = 0, plane_size, img_size = 0;
> + unsigned int bpp, width, height;
> int i;
>
> ipp_cfg = &c_node->property.config[m_node->ops_id];
> @@ -497,20 +497,45 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev,
> * but it seems more than enough
> */
> for (i = 0; i < num_plane; ++i) {
> - if (!m_node->buf_info.handles[i]) {
> - DRM_ERROR("invalid handle for plane %d\n", i);
> - return -EINVAL;
> - }
> + width = ipp_cfg->sz.hsize;
> + height = ipp_cfg->sz.vsize;
> bpp = drm_format_plane_cpp(ipp_cfg->fmt, i);
> - min_size = (ipp_cfg->sz.hsize * ipp_cfg->sz.vsize * bpp) >> 3;
> - size = exynos_drm_gem_get_size(drm_dev,
> - m_node->buf_info.handles[i],
> - c_node->filp);
> - if (min_size > size) {
> - DRM_ERROR("invalid size for plane %d\n", i);
> - return -EINVAL;
> +
> + /*
> + * The result of drm_format_plane_cpp() for chroma planes must
> + * be used with drm_format_xxxx_chroma_subsampling() for
> + * correct result.
> + */
> + if (i > 0) {
> + width /= drm_format_horz_chroma_subsampling(
> + ipp_cfg->fmt);
> + height /= drm_format_vert_chroma_subsampling(
> + ipp_cfg->fmt);
> }
> + plane_size = width * height * bpp;
> + img_size += plane_size;
> +
> + if (m_node->buf_info.handles[i]) {
> + size = exynos_drm_gem_get_size(drm_dev,
> + m_node->buf_info.handles[i],
> + c_node->filp);
> + if (plane_size > size) {
> + DRM_ERROR(
> + "buffer %d is smaller than required\n",
> + i);
> + return -EINVAL;
> + }
> +
> + buf_size += size;
> + }
> + }
> +
> + if (buf_size < img_size) {
> + DRM_ERROR("size of buffers(%lu) is smaller than image(%lu)\n",
> + buf_size, img_size);
> + return -EINVAL;
> }
> +
> return 0;
> }
>
>
next prev parent reply other threads:[~2015-06-11 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 3:45 [PATCH 1/2] drm/exynos: ipp: fix wrong index referencing a config element Hyungwon Hwang
2015-06-09 3:45 ` [PATCH 2/2] drm/exynos: ipp: validate a GEM handle with multiple planes Hyungwon Hwang
2015-06-11 14:53 ` Inki Dae [this message]
2015-06-11 14:53 ` [PATCH 1/2] drm/exynos: ipp: fix wrong index referencing a config element Inki Dae
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=5579A0E3.3060503@samsung.com \
--to=inki.dae@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=human.hwang@samsung.com \
--cc=jy0922.shim@samsung.com \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=sw0312.kim@samsung.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