| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | yuv support |
|---|
| 3 | 4 | |
|---|
| 4 | 5 | Copyright (C) 2007 Ian Armstrong <ian@iarmst.demon.co.uk> |
|---|
| 5 | 6 | |
|---|
| 6 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - (at your option) any later version. |
|---|
| 10 | | - |
|---|
| 11 | | - This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - GNU General Public License for more details. |
|---|
| 15 | | - |
|---|
| 16 | | - You should have received a copy of the GNU General Public License |
|---|
| 17 | | - along with this program; if not, write to the Free Software |
|---|
| 18 | | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | |
|---|
| 21 | 9 | #include "ivtv-driver.h" |
|---|
| .. | .. |
|---|
| 42 | 30 | struct yuv_playback_info *yi = &itv->yuv_info; |
|---|
| 43 | 31 | u8 frame = yi->draw_frame; |
|---|
| 44 | 32 | struct yuv_frame_info *f = &yi->new_frame_info[frame]; |
|---|
| 45 | | - int i; |
|---|
| 46 | 33 | int y_pages, uv_pages; |
|---|
| 47 | 34 | unsigned long y_buffer_offset, uv_buffer_offset; |
|---|
| 48 | 35 | int y_decode_height, uv_decode_height, y_size; |
|---|
| .. | .. |
|---|
| 74 | 61 | ivtv_udma_get_page_info (&y_dma, (unsigned long)args->y_source, 720 * y_decode_height); |
|---|
| 75 | 62 | ivtv_udma_get_page_info (&uv_dma, (unsigned long)args->uv_source, 360 * uv_decode_height); |
|---|
| 76 | 63 | |
|---|
| 77 | | - /* Get user pages for DMA Xfer */ |
|---|
| 78 | | - y_pages = get_user_pages_unlocked(y_dma.uaddr, |
|---|
| 64 | + /* Pin user pages for DMA Xfer */ |
|---|
| 65 | + y_pages = pin_user_pages_unlocked(y_dma.uaddr, |
|---|
| 79 | 66 | y_dma.page_count, &dma->map[0], FOLL_FORCE); |
|---|
| 80 | 67 | uv_pages = 0; /* silence gcc. value is set and consumed only if: */ |
|---|
| 81 | 68 | if (y_pages == y_dma.page_count) { |
|---|
| 82 | | - uv_pages = get_user_pages_unlocked(uv_dma.uaddr, |
|---|
| 69 | + uv_pages = pin_user_pages_unlocked(uv_dma.uaddr, |
|---|
| 83 | 70 | uv_dma.page_count, &dma->map[y_pages], |
|---|
| 84 | 71 | FOLL_FORCE); |
|---|
| 85 | 72 | } |
|---|
| .. | .. |
|---|
| 93 | 80 | uv_pages, uv_dma.page_count); |
|---|
| 94 | 81 | |
|---|
| 95 | 82 | if (uv_pages >= 0) { |
|---|
| 96 | | - for (i = 0; i < uv_pages; i++) |
|---|
| 97 | | - put_page(dma->map[y_pages + i]); |
|---|
| 83 | + unpin_user_pages(&dma->map[y_pages], uv_pages); |
|---|
| 98 | 84 | rc = -EFAULT; |
|---|
| 99 | 85 | } else { |
|---|
| 100 | 86 | rc = uv_pages; |
|---|
| .. | .. |
|---|
| 105 | 91 | y_pages, y_dma.page_count); |
|---|
| 106 | 92 | } |
|---|
| 107 | 93 | if (y_pages >= 0) { |
|---|
| 108 | | - for (i = 0; i < y_pages; i++) |
|---|
| 109 | | - put_page(dma->map[i]); |
|---|
| 94 | + unpin_user_pages(dma->map, y_pages); |
|---|
| 110 | 95 | /* |
|---|
| 111 | 96 | * Inherit the -EFAULT from rc's |
|---|
| 112 | 97 | * initialization, but allow it to be |
|---|
| 113 | | - * overriden by uv_pages above if it was an |
|---|
| 98 | + * overridden by uv_pages above if it was an |
|---|
| 114 | 99 | * actual errno. |
|---|
| 115 | 100 | */ |
|---|
| 116 | 101 | } else { |
|---|
| .. | .. |
|---|
| 124 | 109 | /* Fill & map SG List */ |
|---|
| 125 | 110 | if (ivtv_udma_fill_sg_list (dma, &uv_dma, ivtv_udma_fill_sg_list (dma, &y_dma, 0)) < 0) { |
|---|
| 126 | 111 | IVTV_DEBUG_WARN("could not allocate bounce buffers for highmem userspace buffers\n"); |
|---|
| 127 | | - for (i = 0; i < dma->page_count; i++) { |
|---|
| 128 | | - put_page(dma->map[i]); |
|---|
| 129 | | - } |
|---|
| 112 | + unpin_user_pages(dma->map, dma->page_count); |
|---|
| 130 | 113 | dma->page_count = 0; |
|---|
| 131 | 114 | return -ENOMEM; |
|---|
| 132 | 115 | } |
|---|