[PATCH RESEND] lib/scatterlist: Fix NULL pointer deference

2021-04-06 Thread Ricardo Ribalda
681021] sg_alloc_table_from_pages+0x11/0x30 [7.681511] vb2_dma_sg_alloc+0x162/0x280 [videobuf2_dma_sg] Cc: sta...@vger.kernel.org Fixes: efc42bc98058 ("scatterlist: add sg_alloc_table_from_pages function") Signed-off-by: Ricardo Ribalda --- lib/scatterlist.c | 3 +++ 1 file chang

Re: [PATCH v4 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-19 Thread Ricardo Ribalda
Hi Christoph On Fri, Mar 19, 2021 at 2:10 PM Christoph Hellwig wrote: > > On Fri, Mar 19, 2021 at 02:05:21PM +0100, Ricardo Ribalda wrote: > > > + uvc_urb->sgt, > > > + uvc_stream_dir(uvc_urb->

Re: [PATCH v4 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-19 Thread Ricardo Ribalda
Hi Christoph While backporting the patch I realised of a bug. On Sat, Mar 13, 2021 at 12:55 AM Ricardo Ribalda wrote: > > On architectures where there is no coherent caching such as ARM use the > dma_alloc_noncontiguous API and handle manually the cache flushing using > dma_

Re: [PATCH v4 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-15 Thread Ricardo Ribalda
On Mon, Mar 15, 2021 at 8:34 AM Christoph Hellwig wrote: > > On Mon, Mar 15, 2021 at 08:30:57AM +0100, Ricardo Ribalda wrote: > > Hi Christoph > > > > I guess you can merge this patch from your tree. I hope it is not too > > late in this release cycle. > > The

Re: [PATCH v4 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-15 Thread Ricardo Ribalda
Hi Christoph I guess you can merge this patch from your tree. I hope it is not too late in this release cycle. Have a great week! On Sat, Mar 13, 2021 at 12:55 AM Ricardo Ribalda wrote: > > On architectures where there is no coherent caching such as ARM use the > dma_alloc_nonconti

[PATCH v4 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-12 Thread Ricardo Ribalda
avg 21.827 std 6.095 min 255.153 max (uS) decode: 5/5000 uS/qty: 10.444 avg 7.137 std 1.874 min 71.103 max (uS) raw decode speed: 11.048 Gbits/s raw URB handling speed: 1.789 Gbits/s throughput: 17.253 Mbits/s URB decode CPU usage 0.156800 % Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinch

Re: [PATCH v2 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-12 Thread Ricardo Ribalda Delgado
Hi Laurent Thanks a lot for the review On Fri, Mar 12, 2021 at 10:19 PM Laurent Pinchart wrote: > > Hi Ricardo, > > Thank you for the patch. > > On Fri, Mar 12, 2021 at 01:57:09PM +0100, Ricardo Ribalda wrote: > > On architectures where there is no coherent

[PATCH v3 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-12 Thread Ricardo Ribalda
ing speed: 1.789 Gbits/s throughput: 17.253 Mbits/s URB decode CPU usage 0.156800 % Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart Reviewed-by: Tomasz Figa Signed-off-by: Christoph Hellwig --- Changelog from v2 (Thanks Laurent!): - Replace uvc_urb_dma_sync with uvc_submit_urb - Add x86

[PATCH v2 6/6] media: uvcvideo: Use dma_alloc_noncontiguous API

2021-03-12 Thread Ricardo Ribalda
80 std 1.615 min 2806.667 max (uS) raw decode speed: 365.470 Mbits/s raw URB handling speed: 295.986 Mbits/s throughput: 13.136 Mbits/s URB decode CPU usage 3.594500 % Signed-off-by: Ricardo Ribalda Reviewed-by: Tomasz Figa Signed-off-by: Christoph Hellwig --- Changelog from v2: (Thanks Laurent)

Re: add a new dma_alloc_noncontiguous API v3

2021-03-11 Thread Ricardo Ribalda
m uvcvideo > > ___ > > iommu mailing list > > iommu@lists.linux-foundation.org > > https://lists.linuxfoundation.org/mailman/listinfo/iommu > ---end quoted text--- -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: add a new dma_alloc_noncontiguous API v2

2021-02-11 Thread Ricardo Ribalda
HI Christoph On Thu, Feb 11, 2021 at 2:06 PM Christoph Hellwig wrote: > > On Thu, Feb 11, 2021 at 10:08:18AM +0100, Ricardo Ribalda wrote: > > Hi Christoph > > > > What are your merge plans for the uvc change? > > http://git.infradead.org/us

Re: add a new dma_alloc_noncontiguous API v2

2021-02-11 Thread Ricardo Ribalda
him? Thanks On Tue, Feb 9, 2021 at 6:02 PM Christoph Hellwig wrote: > > On Tue, Feb 09, 2021 at 03:46:13PM +0100, Ricardo Ribalda wrote: > > Hi Christoph > > > > I have tested it in both arm and x86, since there are not significant > > changes with the previous vers

Re: add a new dma_alloc_noncontiguous API v2

2021-02-09 Thread Ricardo Ribalda
Hi Christoph I have tested it in both arm and x86, since there are not significant changes with the previous version I did not do a performance test. Thanks! On Tue, Feb 9, 2021 at 9:29 AM Ricardo Ribalda wrote: > > Hi Christoph > > On Tue, Feb 9, 2021 at 9:22 AM Christoph He

Re: add a new dma_alloc_noncontiguous API v2

2021-02-09 Thread Ricardo Ribalda
gt; Ricardo, do the uvcvideo changes look good to you? I'd like to queue > the series up for this merge window. Let me test them in real hardware today. Thanks! -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lis

[PATCH v2 6/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-28 Thread Ricardo Ribalda
td 1.615 min 2806.667 max (uS) raw decode speed: 365.470 Mbits/s raw URB handling speed: 295.986 Mbits/s throughput: 13.136 Mbits/s URB decode CPU usage 3.594500 % Signed-off-by: Ricardo Ribalda Signed-off-by: Christoph Hellwig --- v2: - Replace DMA_BIDIRECTIONAL with DMA_FROM_

Re: [PATCH 6/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-28 Thread Ricardo Ribalda
idate_kernel_vmap_range calls for > VIVT architectures. We only read from the device to the cpu. Then can we run only invalidate_kernel_vmap_range() ? something like ? else { dma_sync_sgtable_for_cpu(dma_dev, uvc_urb->sgt, DMA_FROM_DEVICE); invalida

Re: [PATCH 6/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-28 Thread Ricardo Ribalda
On Thu, Jan 28, 2021 at 4:03 PM Christoph Hellwig wrote: > > From: Ricardo Ribalda > > On architectures where the is no coherent caching such as ARM use the > dma_alloc_noncontiguos API and handle manually the cache flushing using > dma_sync_sgtable(). > > With th

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-27 Thread Ricardo Ribalda
Hi Christoph On Wed, Jan 27, 2021 at 4:56 PM . Christoph Hellwig wrote: > > On Wed, Jan 27, 2021 at 12:29:08AM +0100, Ricardo Ribalda wrote: > > - Is there any platform where dma_alloc_noncontiguos can fail? > > This is, !ops->alloc_noncontiguous and !dev->coherent_dma

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-26 Thread Ricardo Ribalda
lloc_noncontiguous > > Warning: hot off the press, and only with the v4l conversion as that > seemed at little easier than uvcvideo. -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-15 Thread Ricardo Ribalda
On Mon, Jan 11, 2021 at 9:36 AM . Christoph Hellwig wrote: > > On Thu, Jan 07, 2021 at 03:14:08PM +0100, Ricardo Ribalda wrote: > > > So I think we do want these branches for coherent vs non-coherent as they > > > have very different semantics and I do not thin

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2021-01-07 Thread Ricardo Ribalda
think between your comments and those from Ricardo I have a good idea > for a somewhat updated API. I'll try to post something in the next days. Did you have time to look into this? No hurry, I just want to make sure that I didn't miss anything ;) Best regards! -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-30 Thread Ricardo Ribalda
it is all over > the media and drm code anyway, and duplicating this doesn't help anyone. > > Possibly including the fallback to the coherent allocating. Probably Sergey has best opinion of this than mine. I only had to look into one driver, he has been working with the vb2, which uses the API much more. -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v4 4/4] TEST-ONLY: media: uvcvideo: Add statistics for measuring performance

2020-11-30 Thread Ricardo Ribalda
From: Shik Chen Majorly based on [1], with the following tweaks: * Use div_u64 for u64 divisions * Calculate standard deviation * Fix an uninitialized |min| field for header * Apply clang-format [1]

[PATCH v4 2/4] WIP: add a dma_alloc_contiguous API

2020-11-30 Thread Ricardo Ribalda
From: Christoph Hellwig Add a new API that returns a virtually non-contigous array of pages and dma address. This API is only implemented for dma-iommu and will not be implemented for non-iommu DMA API instances that have to allocate contiguous memory. It is up to the caller to check if the

[PATCH v4 3/4] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-30 Thread Ricardo Ribalda
-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_video.c | 92 +++ drivers/media/usb/uvc/uvcvideo.h | 2 + 2 files changed, 72 insertions(+), 22 deletions(-) v4: Thanks to Crhistoph and Sergei - Remove the CONFIG_DMA_NONCOHERENT path - Do not pass __GFP_NOWARN

[PATCH v4 1/4] dma-mapping: remove the {alloc, free}_noncoherent methods

2020-11-30 Thread Ricardo Ribalda
From: Christoph Hellwig It turns out allowing non-contigous allocations here was a rather bad idea, as we'll now need to define ways to get the pages for mmaping or dma_buf sharing. Revert this change and stick to the original concept. A different API for the use case of non-contigous

[PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-25 Thread Ricardo Ribalda
-off-by: Ricardo Ribalda --- v3: Thanks to Marek Szyprowski Use dma_sync_sgtable and _for_cpu() drivers/media/usb/uvc/uvc_video.c | 93 +++ drivers/media/usb/uvc/uvcvideo.h | 2 + 2 files changed, 83 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc

[PATCH v2 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-25 Thread Ricardo Ribalda
-by: Ricardo Ribalda --- v2: Thanks to Robin! Use dma_sync_sg instead of dma_sync_single drivers/media/usb/uvc/uvc_video.c | 83 ++- drivers/media/usb/uvc/uvcvideo.h | 2 + 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc

Re: [PATCH 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-24 Thread Ricardo Ribalda
Hi Robin On Tue, Nov 24, 2020 at 5:29 PM Robin Murphy wrote: > > On 2020-11-24 15:38, Ricardo Ribalda wrote: > > On architectures where the is no coherent caching such as ARM use the > > dma_alloc_noncontiguos API and handle manually the cache flushing using &

[PATCH 6/6] TEST-ONLY: media: uvcvideo: Add statistics for measuring performance

2020-11-24 Thread Ricardo Ribalda
From: Shik Chen Majorly based on [1], with the following tweaks: * Use div_u64 for u64 divisions * Calculate standard deviation * Fix an uninitialized |min| field for header * Apply clang-format [1]

[PATCH 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-24 Thread Ricardo Ribalda
-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_video.c | 74 ++- drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index a6a441d92b94

[PATCH 3/6] dma-iommu: remove __iommu_dma_mmap

2020-11-24 Thread Ricardo Ribalda
From: Christoph Hellwig The function has a single caller, so open code it there and take advantage of the precalculated page count variable. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 17 + 1 file changed, 1 insertion(+), 16 deletions(-) diff --git

[PATCH 4/6] WIP: add a dma_alloc_contiguous API

2020-11-24 Thread Ricardo Ribalda
From: Christoph Hellwig Add a new API that returns a virtually non-contigous array of pages and dma address. This API is only implemented for dma-iommu and will not be implemented for non-iommu DMA API instances that have to allocate contiguous memory. It is up to the caller to check if the

[PATCH 2/6] dma-direct: use __GFP_ZERO in dma_direct_alloc_pages

2020-11-24 Thread Ricardo Ribalda
From: Christoph Hellwig Prepare for supporting the DMA_ATTR_NO_KERNEL_MAPPING flag in dma_alloc_pages. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index

[PATCH 1/6] dma-mapping: remove the {alloc,free}_noncoherent methods

2020-11-24 Thread Ricardo Ribalda
From: Christoph Hellwig It turns out allowing non-contigous allocations here was a rather bad idea, as we'll now need to define ways to get the pages for mmaping or dma_buf sharing. Revert this change and stick to the original concept. A different API for the use case of non-contigous

Re: [PATCH] WIP! media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-24 Thread Ricardo Ribalda
HI Christoph On Tue, Nov 24, 2020 at 12:35 PM Christoph Hellwig wrote: > > On Wed, Nov 18, 2020 at 03:25:46PM +0100, Ricardo Ribalda wrote: > > On architectures where the is no coherent caching such as ARM use the > > dma_alloc_noncontiguos API and handle manually the ca

[PATCH] WIP! media: uvcvideo: Use dma_alloc_noncontiguos API

2020-11-18 Thread Ricardo Ribalda
-off-by: Ricardo Ribalda --- This patch depends on dma_alloc_contiguous API1315351diffmboxseries https://lore.kernel.org/patchwork/patch/1315351/#1535182 drivers/media/usb/uvc/uvc_video.c | 69 +-- drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 58

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-11-17 Thread Ricardo Ribalda
e data > seems at best odd, and if we are unlucky papering over a bug somewhere. -- Ricardo Ribalda ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-11-10 Thread Ricardo Ribalda
Hi Christoph On Tue, Nov 10, 2020 at 10:25 AM Christoph Hellwig wrote: > > On Mon, Nov 09, 2020 at 03:53:55PM +0100, Ricardo Ribalda wrote: > > Hi Christoph > > > > I have started now to give a try to your patchset. Sorry for the delay. > > > > For uvc I

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-11-09 Thread Ricardo Ribalda
t; > + return ops && ops->free_noncontiguous; > > +} > > +EXPORT_SYMBOL_GPL(dma_can_alloc_noncontiguous); > > + > > +struct page **dma_alloc_noncontiguous(struct device *dev, size_t size, > > + dma_addr_t *dma_handle, gfp_t gfp, unsigned lo