lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <02b301cd6e27$000e9cf0$002bd6d0$%szyprowski@samsung.com>
Date:	Mon, 30 Jul 2012 09:43:16 +0200
From:	Marek Szyprowski <m.szyprowski@...sung.com>
To:	'Hideki EIRAKU' <hdk@...l.co.jp>,
	'Russell King' <linux@....linux.org.uk>,
	'Pawel Osciak' <pawel@...iak.com>,
	'Kyungmin Park' <kyungmin.park@...sung.com>,
	'Mauro Carvalho Chehab' <mchehab@...radead.org>,
	'Florian Tobias Schandinat' <FlorianSchandinat@....de>,
	'Jaroslav Kysela' <perex@...ex.cz>,
	'Takashi Iwai' <tiwai@...e.de>
Cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	linux-media@...r.kernel.org, linux-fbdev@...r.kernel.org,
	alsa-devel@...a-project.org, 'Katsuya MATSUBARA' <matsu@...l.co.jp>
Subject: RE: [PATCH v2 3/4] media: videobuf2-dma-contig: use dma_mmap_coherent
 if available

Hello,

On Thursday, July 26, 2012 1:13 PM Hideki EIRAKU wrote:

> Previously the vb2_dma_contig_mmap() function was using a dma_addr_t as a
> physical address.  The two addressses are not necessarily the same.
> For example, when using the IOMMU funtion on certain platforms, dma_addr_t
> addresses are not directly mappable physical address.
> dma_mmap_coherent() maps the address correctly.
> It is available on ARM platforms.
> 
> Signed-off-by: Hideki EIRAKU <hdk@...l.co.jp>
> ---
>  drivers/media/video/videobuf2-dma-contig.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-
> contig.c
> index 4b71326..4dc85ab 100644
> --- a/drivers/media/video/videobuf2-dma-contig.c
> +++ b/drivers/media/video/videobuf2-dma-contig.c
> @@ -101,14 +101,32 @@ static unsigned int vb2_dma_contig_num_users(void *buf_priv)
>  static int vb2_dma_contig_mmap(void *buf_priv, struct vm_area_struct *vma)
>  {
>  	struct vb2_dc_buf *buf = buf_priv;
> +#ifdef ARCH_HAS_DMA_MMAP_COHERENT
> +	int ret;
> +#endif
> 
>  	if (!buf) {
>  		printk(KERN_ERR "No buffer to map\n");
>  		return -EINVAL;
>  	}
> 
> +#ifdef ARCH_HAS_DMA_MMAP_COHERENT
> +	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

The above line is not needed. It is up to dma_mmap_coherent() / dma_mmap_attrs() to set page
protection bits which match requested type of dma buffer mapping.

> +	ret = dma_mmap_coherent(buf->conf->dev, vma, buf->vaddr, buf->dma_addr,
> +				buf->size);
> +	if (ret) {
> +		pr_err("Remapping memory failed, error: %d\n", ret);
> +		return ret;
> +	}
> +	vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;
> +	vma->vm_private_data = &buf->handler;
> +	vma->vm_ops = &vb2_common_vm_ops;
> +	vma->vm_ops->open(vma);
> +	return 0;
> +#else
>  	return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,
>  				  &vb2_common_vm_ops, &buf->handler);
> +#endif
>  }
> 
>  static void *vb2_dma_contig_get_userptr(void *alloc_ctx, unsigned long vaddr,

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ