linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync
@ 2015-10-07 11:23 Sakari Ailus
  2015-10-07 11:23 ` [PATCH v3 1/2] media: vb2 dma-contig: Fully cache synchronise buffers in prepare and finish Sakari Ailus
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sakari Ailus @ 2015-10-07 11:23 UTC (permalink / raw)
  To: linux-media; +Cc: tiffany.lin

Hi Tiffany and others,

I split the patches into two as they need to be applied since different
stable kernel versions, and added cc stable. I intend to send a pull
request later today.

-- 
Kind regards,
Sakari


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] media: vb2 dma-contig: Fully cache synchronise buffers in prepare and finish
  2015-10-07 11:23 [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Sakari Ailus
@ 2015-10-07 11:23 ` Sakari Ailus
  2015-10-07 11:23 ` [PATCH v3 2/2] media: vb2 dma-sg: " Sakari Ailus
  2015-10-08  1:47 ` [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Tiffany Lin (林慧珊)
  2 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2015-10-07 11:23 UTC (permalink / raw)
  To: linux-media; +Cc: tiffany.lin

From: Tiffany Lin <tiffany.lin@mediatek.com>

In videobuf2 dma-contig memory type the prepare and finish ops, instead of
passing the number of entries in the original scatterlist as the "nents"
parameter to dma_sync_sg_for_device() and dma_sync_sg_for_cpu(), the value
returned by dma_map_sg() was used. Albeit this has been suggested in
comments of some implementations (which have since been corrected), this
is wrong.

Cc: stable@vger.kernel.org # for v3.8 and up
Fixes: 199d101efdba ("v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator")
Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index ea33d69..c331272 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -100,7 +100,8 @@ static void vb2_dc_prepare(void *buf_priv)
 	if (!sgt || buf->db_attach)
 		return;
 
-	dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+	dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents,
+			       buf->dma_dir);
 }
 
 static void vb2_dc_finish(void *buf_priv)
@@ -112,7 +113,7 @@ static void vb2_dc_finish(void *buf_priv)
 	if (!sgt || buf->db_attach)
 		return;
 
-	dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+	dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
 }
 
 /*********************************************/
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] media: vb2 dma-sg: Fully cache synchronise buffers in prepare and finish
  2015-10-07 11:23 [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Sakari Ailus
  2015-10-07 11:23 ` [PATCH v3 1/2] media: vb2 dma-contig: Fully cache synchronise buffers in prepare and finish Sakari Ailus
@ 2015-10-07 11:23 ` Sakari Ailus
  2015-10-08  1:47 ` [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Tiffany Lin (林慧珊)
  2 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2015-10-07 11:23 UTC (permalink / raw)
  To: linux-media; +Cc: tiffany.lin

From: Tiffany Lin <tiffany.lin@mediatek.com>

In videobuf2 dma-sg memory types the prepare and finish ops, instead
of passing the number of entries in the original scatterlist as the
"nents" parameter to dma_sync_sg_for_device() and dma_sync_sg_for_cpu(),
the value returned by dma_map_sg() was used. Albeit this has been
suggested in comments of some implementations (which have since been
corrected), this is wrong.

Cc: stable@vger.kernel.org # for v3.19 and up
Fixes: d790b7eda953 ("vb2-dma-sg: move dma_(un)map_sg here")
Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/videobuf2-dma-sg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 34b6778..9985c89 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -210,7 +210,8 @@ static void vb2_dma_sg_prepare(void *buf_priv)
 	if (buf->db_attach)
 		return;
 
-	dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+	dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents,
+			       buf->dma_dir);
 }
 
 static void vb2_dma_sg_finish(void *buf_priv)
@@ -222,7 +223,7 @@ static void vb2_dma_sg_finish(void *buf_priv)
 	if (buf->db_attach)
 		return;
 
-	dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+	dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
 }
 
 static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync
  2015-10-07 11:23 [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Sakari Ailus
  2015-10-07 11:23 ` [PATCH v3 1/2] media: vb2 dma-contig: Fully cache synchronise buffers in prepare and finish Sakari Ailus
  2015-10-07 11:23 ` [PATCH v3 2/2] media: vb2 dma-sg: " Sakari Ailus
@ 2015-10-08  1:47 ` Tiffany Lin (林慧珊)
  2 siblings, 0 replies; 4+ messages in thread
From: Tiffany Lin (林慧珊) @ 2015-10-08  1:47 UTC (permalink / raw)
  To: Sakari Ailus, linux-media

Hi Sakari,

Thanks for your help. :)

Best regards,
Tiffany

-----Original Message-----
From: Sakari Ailus [mailto:sakari.ailus@iki.fi] 
Sent: Wednesday, October 07, 2015 7:24 PM
To: linux-media@vger.kernel.org
Cc: Tiffany Lin (林慧珊)
Subject: [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync

Hi Tiffany and others,

I split the patches into two as they need to be applied since different stable kernel versions, and added cc stable. I intend to send a pull request later today.

--
Kind regards,
Sakari


************* Email Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-08  1:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-07 11:23 [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Sakari Ailus
2015-10-07 11:23 ` [PATCH v3 1/2] media: vb2 dma-contig: Fully cache synchronise buffers in prepare and finish Sakari Ailus
2015-10-07 11:23 ` [PATCH v3 2/2] media: vb2 dma-sg: " Sakari Ailus
2015-10-08  1:47 ` [PATCH v3 0/2] vb2: Fix dma sg and dma contig cache sync Tiffany Lin (林慧珊)

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).