Re: [RFC PATCH 06/12] vb2-dma-sg: add dmabuf import support
Hi Hans, Thank you for the patch. On Mon, Sep 8, 2014 at 10:14 PM, Hans Verkuil hverk...@xs4all.nl wrote: From: Hans Verkuil hans.verk...@cisco.com Add support for dmabuf to vb2-dma-sg. Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/v4l2-core/videobuf2-dma-sg.c | 125 +++-- 1 file changed, 118 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index abd5252..6d922c0 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -42,11 +42,15 @@ struct vb2_dma_sg_buf { int offset; enum dma_data_direction dma_dir; struct sg_table sg_table; + struct sg_table *dma_sgt; I think we should document and/or have a bit better naming here. Maybe sgt_in_use? size_t size; unsigned intnum_pages; atomic_trefcount; struct vb2_vmarea_handler handler; struct vm_area_struct *vma; + + /* DMABUF related */ + struct dma_buf_attachment *db_attach; }; static void vb2_dma_sg_put(void *buf_priv); @@ -113,6 +117,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, int write, /* size is already page aligned */ buf-num_pages = size PAGE_SHIFT; buf-dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + buf-dma_sgt = buf-sg_table; buf-pages = kzalloc(buf-num_pages * sizeof(struct page *), GFP_KERNEL); @@ -123,7 +128,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, int write, if (ret) goto fail_pages_alloc; - ret = sg_alloc_table_from_pages(buf-sg_table, buf-pages, + ret = sg_alloc_table_from_pages(buf-dma_sgt, buf-pages, buf-num_pages, 0, size, gfp_flags); if (ret) goto fail_table_alloc; @@ -161,7 +166,7 @@ static void vb2_dma_sg_put(void *buf_priv) buf-num_pages); if (buf-vaddr) vm_unmap_ram(buf-vaddr, buf-num_pages); - sg_free_table(buf-sg_table); + sg_free_table(buf-dma_sgt); while (--i = 0) __free_page(buf-pages[i]); kfree(buf-pages); @@ -173,7 +178,11 @@ static void vb2_dma_sg_put(void *buf_priv) static int vb2_dma_sg_prepare(void *buf_priv) { struct vb2_dma_sg_buf *buf = buf_priv; - struct sg_table *sgt = buf-sg_table; + struct sg_table *sgt = buf-dma_sgt; + + /* DMABUF exporter will flush the cache for us */ + if (buf-db_attach) + return 0; return dma_map_sg(buf-dev, sgt-sgl, sgt-nents, buf-dma_dir) ? 0 : -EIO; } @@ -181,7 +190,11 @@ static int vb2_dma_sg_prepare(void *buf_priv) static void vb2_dma_sg_finish(void *buf_priv) { struct vb2_dma_sg_buf *buf = buf_priv; - struct sg_table *sgt = buf-sg_table; + struct sg_table *sgt = buf-dma_sgt; + + /* DMABUF exporter will flush the cache for us */ + if (buf-db_attach) + return; dma_unmap_sg(buf-dev, sgt-sgl, sgt-nents, buf-dma_dir); } @@ -209,6 +222,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, buf-offset = vaddr ~PAGE_MASK; buf-size = size; buf-dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + buf-dma_sgt = buf-sg_table; first = (vaddrPAGE_MASK) PAGE_SHIFT; last = ((vaddr + size - 1) PAGE_MASK) PAGE_SHIFT; @@ -261,7 +275,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, if (num_pages_from_user != buf-num_pages) goto userptr_fail_get_user_pages; - if (sg_alloc_table_from_pages(buf-sg_table, buf-pages, + if (sg_alloc_table_from_pages(buf-dma_sgt, buf-pages, buf-num_pages, buf-offset, size, 0)) goto userptr_fail_alloc_table_from_pages; @@ -297,7 +311,7 @@ static void vb2_dma_sg_put_userptr(void *buf_priv) __func__, buf-num_pages); if (buf-vaddr) vm_unmap_ram(buf-vaddr, buf-num_pages); - sg_free_table(buf-sg_table); + sg_free_table(buf-dma_sgt); while (--i = 0) { if (buf-write) set_page_dirty_lock(buf-pages[i]); @@ -370,11 +384,104 @@ static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) return 0; } +/*/ +/* callbacks for DMABUF buffers*/ +/*/ + +static int
Re: [RFCv2 PATCH 10/14] vb2: add 'new_cookies' flag
Hi Hans, On Fri, Sep 12, 2014 at 8:59 PM, Hans Verkuil hverk...@xs4all.nl wrote: From: Hans Verkuil hans.verk...@cisco.com This flag helps drivers that need to reprogram their DMA engine whenever a plane cookie (== DMA address or DMA scatter-gather list) changes. Otherwise they would have to reprogram the DMA engine for every frame. Note that it is not possible to do this in buf_init() since dma_map_sg has to be done first, which happens just before buf_prepare() in the prepare() memop. It is dma_map_sg that sets up the dma addresses that are needed to configure the DMA engine. Perhaps I'm missing something, but couldn't we just dma_map_sg on allocation/get in dma-sg and unmap on put? -- Best regards, Pawel Osciak -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
DVICO Fusion Pro HD 0x9888:0x8229 possible regression linux 3.13.0-35 ?
My DVICO DVB card has stopped working after I did a release upgrade of my system (12.04 - 14.04). The driver looks good, but the dmesg shows me that the frontend device fails:- [ 21.412769] cx88[1]/2: subsystem: 18ac:db30, board: DViCO FusionHDTV DVB-T PRO [card=64] [ 21.412771] cx88[1]/2: cx2388x based DVB/ATSC card [ 21.412772] cx8802_alloc_frontends() allocating 1 frontend(s) [ 21.416208] asus_wmi: ASUS WMI generic driver loaded [ 21.416362] i2c i2c-2: sendbytes: NAK bailout. [ 21.416450] zl10353_read_register: readreg error (reg=127, ret==-5) [ 21.417321] cx88[1]/2: dvb frontend not attached. Can't attach xc3028 [ 21.417385] cx88[1]/2: dvb_register failed (err = -22) [ 21.417446] cx88[1]/2: cx8802 probe failed, err = -22 Kernel: Linux mythtv 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:01 UTC 2014 i686 i686 i686 GNU/Linux Ubuntu 3.13.0-35.62-generic 3.13.11.6 Lspci: 05:02.0 Multimedia video controller: Conexant Systems, Inc. CX23880/1/2/3 PCI Video and Audio Decoder (rev 05) Subsystem: DViCO Corporation Device db30 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium TAbort- TAbort- MAbort- SERR- PERR- INTx- Latency: 32 (5000ns min, 13750ns max), Cache Line Size: 64 bytes Interrupt: pin A routed to IRQ 19 Region 0: Memory at f200 (32-bit, non-prefetchable) [size=16M] Capabilities: access denied Kernel driver in use: cx8800 05:02.1 Multimedia controller: Conexant Systems, Inc. CX23880/1/2/3 PCI Video and Audio Decoder [Audio Port] (rev 05) Subsystem: DViCO Corporation Device db30 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium TAbort- TAbort- MAbort- SERR- PERR- INTx- Latency: 32 (1000ns min, 63750ns max), Cache Line Size: 64 bytes Interrupt: pin A routed to IRQ 19 Region 0: Memory at f100 (32-bit, non-prefetchable) [size=16M] Capabilities: access denied Kernel driver in use: cx88_audio 05:02.2 Multimedia controller: Conexant Systems, Inc. CX23880/1/2/3 PCI Video and Audio Decoder [MPEG Port] (rev 05) Subsystem: DViCO Corporation Device db30 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium TAbort- TAbort- MAbort- SERR- PERR- INTx- Latency: 32 (1500ns min, 22000ns max), Cache Line Size: 64 bytes Interrupt: pin A routed to IRQ 19 Region 0: Memory at f000 (32-bit, non-prefetchable) [size=16M] Capabilities: access denied Kernel driver in use: cx88-mpeg driver manager -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 06/14] vb2-dma-sg: add dmabuf import support
Hi Hans, Thank you for the patch. On Friday 12 September 2014 14:59:55 Hans Verkuil wrote: From: Hans Verkuil hans.verk...@cisco.com Add support for dmabuf to vb2-dma-sg. Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/v4l2-core/videobuf2-dma-sg.c | 125 -- 1 file changed, 118 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index abd5252..6d922c0 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -42,11 +42,15 @@ struct vb2_dma_sg_buf { int offset; enum dma_data_direction dma_dir; struct sg_table sg_table; + struct sg_table *dma_sgt; size_t size; unsigned intnum_pages; atomic_trefcount; struct vb2_vmarea_handler handler; struct vm_area_struct *vma; + + /* DMABUF related */ + struct dma_buf_attachment *db_attach; }; static void vb2_dma_sg_put(void *buf_priv); @@ -113,6 +117,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, int write, /* size is already page aligned */ buf-num_pages = size PAGE_SHIFT; buf-dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + buf-dma_sgt = buf-sg_table; buf-pages = kzalloc(buf-num_pages * sizeof(struct page *), GFP_KERNEL); @@ -123,7 +128,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, int write, if (ret) goto fail_pages_alloc; - ret = sg_alloc_table_from_pages(buf-sg_table, buf-pages, + ret = sg_alloc_table_from_pages(buf-dma_sgt, buf-pages, buf-num_pages, 0, size, gfp_flags); if (ret) goto fail_table_alloc; @@ -161,7 +166,7 @@ static void vb2_dma_sg_put(void *buf_priv) buf-num_pages); if (buf-vaddr) vm_unmap_ram(buf-vaddr, buf-num_pages); - sg_free_table(buf-sg_table); + sg_free_table(buf-dma_sgt); while (--i = 0) __free_page(buf-pages[i]); kfree(buf-pages); @@ -173,7 +178,11 @@ static void vb2_dma_sg_put(void *buf_priv) static int vb2_dma_sg_prepare(void *buf_priv) { struct vb2_dma_sg_buf *buf = buf_priv; - struct sg_table *sgt = buf-sg_table; + struct sg_table *sgt = buf-dma_sgt; + + /* DMABUF exporter will flush the cache for us */ This isn't only about cache flushing. DMABUF exporter will sync the memory for us would be more accurate. Same comment for vb2_dma_sg_finish. + if (buf-db_attach) + return 0; return dma_map_sg(buf-dev, sgt-sgl, sgt-nents, buf-dma_dir) ? 0 : -EIO; } @@ -181,7 +190,11 @@ static int vb2_dma_sg_prepare(void *buf_priv) static void vb2_dma_sg_finish(void *buf_priv) { struct vb2_dma_sg_buf *buf = buf_priv; - struct sg_table *sgt = buf-sg_table; + struct sg_table *sgt = buf-dma_sgt; + + /* DMABUF exporter will flush the cache for us */ + if (buf-db_attach) + return; dma_unmap_sg(buf-dev, sgt-sgl, sgt-nents, buf-dma_dir); } @@ -209,6 +222,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, buf-offset = vaddr ~PAGE_MASK; buf-size = size; buf-dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + buf-dma_sgt = buf-sg_table; first = (vaddrPAGE_MASK) PAGE_SHIFT; last = ((vaddr + size - 1) PAGE_MASK) PAGE_SHIFT; @@ -261,7 +275,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, if (num_pages_from_user != buf-num_pages) goto userptr_fail_get_user_pages; - if (sg_alloc_table_from_pages(buf-sg_table, buf-pages, + if (sg_alloc_table_from_pages(buf-dma_sgt, buf-pages, buf-num_pages, buf-offset, size, 0)) goto userptr_fail_alloc_table_from_pages; @@ -297,7 +311,7 @@ static void vb2_dma_sg_put_userptr(void *buf_priv) __func__, buf-num_pages); if (buf-vaddr) vm_unmap_ram(buf-vaddr, buf-num_pages); - sg_free_table(buf-sg_table); + sg_free_table(buf-dma_sgt); while (--i = 0) { if (buf-write) set_page_dirty_lock(buf-pages[i]); @@ -370,11 +384,104 @@ static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) return 0; } +/*/ +/* callbacks for DMABUF buffers*/ +/*/ + +static int vb2_dma_sg_map_dmabuf(void *mem_priv) +{ + struct vb2_dma_sg_buf *buf = mem_priv; + struct sg_table *sgt; + + if
[patch] ensure correct install of modules from drivers/{misc,staging}
Hi, On an ubuntu system the code builds ok but not all modules run properly; the issue I noticed was the cx23885 module gave these errors when loaded: [ 20.395552] cx23885: disagrees about version of symbol altera_init [ 20.395560] cx23885: Unknown symbol altera_init (err -22) The cause was that there were two altera-stapl modules in the /lib tree % find .-type f -name altera_stapl.ko ./kernel/drivers/misc/altera-stapl/altera-stapl.ko ./kernel/drivers/linux/drivers/misc/altera-stapl/altera-stapl.ko I traced that back to make_makefile.pl; it was not using the right directory names for any drivers in drivers/misc or drivers/staging. For example before the patch this line was being generated: n=0;for i in altera-stapl.ko;do if [ -f $i ]; then if [ $n -eq 0 ]; then echo -n ../linux/drivers/misc/altera-stapl/: ; install -d /lib/modules/3.13.0-35-generic/kernel/drivers/media/../linux/drivers/misc/altera-stapl; fi; n=$(($n+1)); if [ $n -eq 4 ]; then echo; echo -n ; n=1; fi; echo -n $i ; install -m 644 -c $i /lib/modules/3.13.0-35-generic/kernel/drivers/media/../linux/drivers/misc/altera-stapl; fi; done; if [ $n -ne 0 ]; then echo; strip --strip-debug /lib/modules/3.13.0-35-generic/kernel/drivers/media/../linux/drivers/misc/altera-stapl/*.ko; fi; after applying this patch the same line is: n=0;for i in altera-stapl.ko;do if [ -f $i ]; then if [ $n -eq 0 ]; then echo -n ../misc/altera-stapl/: ; install -d /lib/modules/3.13.0-35-generic/kernel/drivers/media/../misc/altera-stapl; fi; n=$(($n+1)); if [ $n -eq 4 ]; then echo; echo -n ; n=1; fi; echo -n $i ; install -m 644 -c $i /lib/modules/3.13.0-35-generic/kernel/drivers/media/../misc/altera-stapl; fi; done; if [ $n -ne 0 ]; then echo; strip --strip-debug /lib/modules/3.13.0-35-generic/kernel/drivers/media/../misc/altera-stapl/*.ko; fi; This also affects drivers in staging. The patch is below. Test system % cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION=Ubuntu 14.04.1 LTS % uname -a Linux ubuntu 3.13.0-25-generic #62-Ubuntu SMP Fri Aug 15 01:58:01 UTC 2014 i686 i686 i686 GNU/Linux Vince [patch] ensure correct install of modules from drivers/{misc,staging} v4l/scripts/make_mediafile.pl uses the %instdir hash to collate a list of directories in media_build/linux which contain Makefiles; it uses this data when constructing a dependency for the Makefile.media target. It also uses this hash to collate all the individual module names and generate code which installs the individual modules. But it gets the installation directory wrong in the case of modules outside the linux/drivers/media tree. To fix, do the collation of source locations and conversion into install locations as separate steps. signed-off-by: vincent.mcint...@gmail.com diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl index 134f717..6b9ae55 100755 --- a/v4l/scripts/make_makefile.pl +++ b/v4l/scripts/make_makefile.pl @@ -2,7 +2,9 @@ use FileHandle; use File::Find; -my %instdir = (); +my %srcdir = (); # keys are directory paths (relative to v4l dir), + # values are hashes with module file names as their keys +my %instdir = (); # derived from %srcdir # Take a Makefile line of the form: # obj-X = some_directory/ some_module.o @@ -12,6 +14,7 @@ my %instdir = (); # to install. Prints the edited line to OUT. # Arguments: directory Makefile is in, the objects, original line(s) from # Makefile (with newlines intact). +# Side effects: collates lists of files to install into %srcdir hash sub check_line($$$) { my $dir = shift; @@ -29,11 +32,9 @@ sub check_line($$$) next; } - # It's a file, add it to list of files to install + # It's a file, add it to the list of files s/\.o$/.ko/; - my $idir = $dir; - $idir =~ s|^../linux/drivers/media/?||; - $instdir{$idir}{$_} = 1; + $srcdir{$dir}{$_} = 1; $count++; } # Removing any tailling whitespace, just to be neat @@ -184,7 +185,7 @@ sub removeubuntu($) my $dest = /lib/modules/\$(KERNELRELEASE)/$udir; my $filelist; - while ( my ($dir, $files) = each(%instdir) ) { + while ( my ($dir, $files) = each(%srcdir) ) { $filelist .= ' '. join(' ', keys %$files); } while ( my ($dir, $files) = each(%obsolete) ) { @@ -232,6 +233,15 @@ removeubuntu(/updates/dkms); print OUT \t\@echo \Installing kernel modules under \$(DESTDIR)\$(KDIR26)/:\\n; +# change source dirs (relative to v4l dir) +# into install dirs (relative to DESTDIR/KDIR26) +while (my ($dir, $files) = each %srcdir) { + my $idir = $dir; + $idir =~ s|\.\./linux/drivers/|../|; + $idir =~ s|\.\./media/?||; + $instdir{$idir} = $files; +} + while (my ($dir, $files) = each
cron job: media_tree daily build: ERRORS
This message is generated daily by a cron job that builds media_tree for the kernels and architectures in the list below. Results of the daily build of media_tree: date: Mon Sep 15 04:00:20 CEST 2014 git branch: test git hash: f5281fc81e9a0a3e80b78720c5ae2ed06da3bfae gcc version:i686-linux-gcc (GCC) 4.9.1 sparse version: v0.5.0-20-g7abd8a7 host hardware: x86_64 host os:3.16-1.slh.4-amd64 linux-git-arm-at91: OK linux-git-arm-davinci: OK linux-git-arm-exynos: OK linux-git-arm-mx: OK linux-git-arm-omap: OK linux-git-arm-omap1: OK linux-git-arm-pxa: OK linux-git-blackfin: OK linux-git-i686: OK linux-git-m32r: OK linux-git-mips: OK linux-git-powerpc64: OK linux-git-sh: OK linux-git-x86_64: WARNINGS linux-2.6.32.27-i686: OK linux-2.6.33.7-i686: OK linux-2.6.34.7-i686: OK linux-2.6.35.9-i686: OK linux-2.6.36.4-i686: OK linux-2.6.37.6-i686: OK linux-2.6.38.8-i686: OK linux-2.6.39.4-i686: OK linux-3.0.60-i686: OK linux-3.1.10-i686: OK linux-3.2.37-i686: OK linux-3.3.8-i686: OK linux-3.4.27-i686: OK linux-3.5.7-i686: OK linux-3.6.11-i686: OK linux-3.7.4-i686: OK linux-3.8-i686: OK linux-3.9.2-i686: OK linux-3.10.1-i686: OK linux-3.11.1-i686: WARNINGS linux-3.12.23-i686: WARNINGS linux-3.13.11-i686: WARNINGS linux-3.14.9-i686: WARNINGS linux-3.15.2-i686: WARNINGS linux-3.16-i686: WARNINGS linux-3.17-rc1-i686: WARNINGS linux-2.6.32.27-x86_64: OK linux-2.6.33.7-x86_64: OK linux-2.6.34.7-x86_64: OK linux-2.6.35.9-x86_64: OK linux-2.6.36.4-x86_64: OK linux-2.6.37.6-x86_64: OK linux-2.6.38.8-x86_64: OK linux-2.6.39.4-x86_64: OK linux-3.0.60-x86_64: OK linux-3.1.10-x86_64: OK linux-3.2.37-x86_64: OK linux-3.3.8-x86_64: OK linux-3.4.27-x86_64: OK linux-3.5.7-x86_64: OK linux-3.6.11-x86_64: OK linux-3.7.4-x86_64: OK linux-3.8-x86_64: OK linux-3.9.2-x86_64: OK linux-3.10.1-x86_64: OK linux-3.11.1-x86_64: WARNINGS linux-3.12.23-x86_64: WARNINGS linux-3.13.11-x86_64: WARNINGS linux-3.14.9-x86_64: WARNINGS linux-3.15.2-x86_64: WARNINGS linux-3.16-x86_64: WARNINGS linux-3.17-rc1-x86_64: WARNINGS apps: OK spec-git: OK sparse: ERRORS sparse: ERRORS Detailed results are available here: http://www.xs4all.nl/~hverkuil/logs/Monday.log Full logs are available here: http://www.xs4all.nl/~hverkuil/logs/Monday.tar.bz2 The Media Infrastructure API from this daily build is here: http://www.xs4all.nl/~hverkuil/spec/media.html -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html