hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/pci/ivtv/ivtv-yuv.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 yuv support
34
45 Copyright (C) 2007 Ian Armstrong <ian@iarmst.demon.co.uk>
56
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
197 */
208
219 #include "ivtv-driver.h"
....@@ -42,7 +30,6 @@
4230 struct yuv_playback_info *yi = &itv->yuv_info;
4331 u8 frame = yi->draw_frame;
4432 struct yuv_frame_info *f = &yi->new_frame_info[frame];
45
- int i;
4633 int y_pages, uv_pages;
4734 unsigned long y_buffer_offset, uv_buffer_offset;
4835 int y_decode_height, uv_decode_height, y_size;
....@@ -74,12 +61,12 @@
7461 ivtv_udma_get_page_info (&y_dma, (unsigned long)args->y_source, 720 * y_decode_height);
7562 ivtv_udma_get_page_info (&uv_dma, (unsigned long)args->uv_source, 360 * uv_decode_height);
7663
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,
7966 y_dma.page_count, &dma->map[0], FOLL_FORCE);
8067 uv_pages = 0; /* silence gcc. value is set and consumed only if: */
8168 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,
8370 uv_dma.page_count, &dma->map[y_pages],
8471 FOLL_FORCE);
8572 }
....@@ -93,8 +80,7 @@
9380 uv_pages, uv_dma.page_count);
9481
9582 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);
9884 rc = -EFAULT;
9985 } else {
10086 rc = uv_pages;
....@@ -105,12 +91,11 @@
10591 y_pages, y_dma.page_count);
10692 }
10793 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);
11095 /*
11196 * Inherit the -EFAULT from rc's
11297 * 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
11499 * actual errno.
115100 */
116101 } else {
....@@ -124,9 +109,7 @@
124109 /* Fill & map SG List */
125110 if (ivtv_udma_fill_sg_list (dma, &uv_dma, ivtv_udma_fill_sg_list (dma, &y_dma, 0)) < 0) {
126111 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);
130113 dma->page_count = 0;
131114 return -ENOMEM;
132115 }