public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, Magnus Damm <magnus.damm@gmail.com>,
	m-karicheri2@ti.com, g.liakhovetski@gmx.de,
	mchehab@infradead.org
Subject: [PATCH] sh_mobile_ceu_camera: Add physical address alignment checks V2
Date: Fri, 11 Dec 2009 17:10:06 +0900	[thread overview]
Message-ID: <20091211081006.16358.10589.sendpatchset@rxone.opensource.se> (raw)

From: Magnus Damm <damm@opensource.se>

Make sure physical addresses are 32-bit aligned in the SuperH
Mobile CEU driver V2. The lowest two bits of the frame address
registers are fixed to zero so frame buffers have to be 32-bit
aligned. The V4L2 mmap() case is using dma_alloc_coherent() for
this driver which will return already aligned addresses, but in
the USERPTR case we must make sure that the user space pointer
is valid.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 Tested with a hacked up capture.c on a sh7722 Migo-R board.

 V2 moves the checks to sh_mobile_ceu_videobuf_prepare()

 drivers/media/video/sh_mobile_ceu_camera.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- 0010/drivers/media/video/sh_mobile_ceu_camera.c
+++ work/drivers/media/video/sh_mobile_ceu_camera.c	2009-12-11 16:52:19.000000000 +0900
@@ -339,7 +339,7 @@ static int sh_mobile_ceu_videobuf_prepar
 	}
 
 	vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
-	if (0 != vb->baddr && vb->bsize < vb->size) {
+	if (0 != vb->baddr && vb->bsize < vb->size && !(vb->width & 3)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -348,6 +348,13 @@ static int sh_mobile_ceu_videobuf_prepar
 		ret = videobuf_iolock(vq, vb, NULL);
 		if (ret)
 			goto fail;
+
+		/* the physical address must be 32-bit aligned (USERPTR) */
+		if (videobuf_to_dma_contig(vb) & 3) {
+			ret = -EINVAL;
+			goto fail;
+		}
+
 		vb->state = VIDEOBUF_PREPARED;
 	}
 

                 reply	other threads:[~2009-12-11  8:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20091211081006.16358.10589.sendpatchset@rxone.opensource.se \
    --to=magnus.damm@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=mchehab@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox