.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Scatter-Gather buffer |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) by Takashi Iwai <tiwai@suse.de> |
---|
5 | | - * |
---|
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 | | - * |
---|
20 | 6 | */ |
---|
21 | 7 | |
---|
22 | 8 | #include <linux/slab.h> |
---|
.. | .. |
---|
43 | 29 | dmab->area = NULL; |
---|
44 | 30 | |
---|
45 | 31 | tmpb.dev.type = SNDRV_DMA_TYPE_DEV; |
---|
| 32 | + if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_UC_SG) |
---|
| 33 | + tmpb.dev.type = SNDRV_DMA_TYPE_DEV_UC; |
---|
46 | 34 | tmpb.dev.dev = sgbuf->dev; |
---|
47 | 35 | for (i = 0; i < sgbuf->pages; i++) { |
---|
48 | 36 | if (!(sgbuf->table[i].addr & ~PAGE_MASK)) |
---|
.. | .. |
---|
72 | 60 | struct snd_dma_buffer tmpb; |
---|
73 | 61 | struct snd_sg_page *table; |
---|
74 | 62 | struct page **pgtable; |
---|
| 63 | + int type = SNDRV_DMA_TYPE_DEV; |
---|
| 64 | + pgprot_t prot = PAGE_KERNEL; |
---|
75 | 65 | |
---|
76 | 66 | dmab->area = NULL; |
---|
77 | 67 | dmab->addr = 0; |
---|
78 | 68 | dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); |
---|
79 | 69 | if (! sgbuf) |
---|
80 | 70 | return NULL; |
---|
| 71 | + if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_UC_SG) { |
---|
| 72 | + type = SNDRV_DMA_TYPE_DEV_UC; |
---|
| 73 | +#ifdef pgprot_noncached |
---|
| 74 | + prot = pgprot_noncached(PAGE_KERNEL); |
---|
| 75 | +#endif |
---|
| 76 | + } |
---|
81 | 77 | sgbuf->dev = device; |
---|
82 | 78 | pages = snd_sgbuf_aligned_pages(size); |
---|
83 | 79 | sgbuf->tblsize = sgbuf_align_table(pages); |
---|
.. | .. |
---|
98 | 94 | if (chunk > maxpages) |
---|
99 | 95 | chunk = maxpages; |
---|
100 | 96 | chunk <<= PAGE_SHIFT; |
---|
101 | | - if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, device, |
---|
| 97 | + if (snd_dma_alloc_pages_fallback(type, device, |
---|
102 | 98 | chunk, &tmpb) < 0) { |
---|
103 | 99 | if (!sgbuf->pages) |
---|
104 | 100 | goto _failed; |
---|
.. | .. |
---|
125 | 121 | } |
---|
126 | 122 | |
---|
127 | 123 | sgbuf->size = size; |
---|
128 | | - dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, PAGE_KERNEL); |
---|
| 124 | + dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, prot); |
---|
129 | 125 | if (! dmab->area) |
---|
130 | 126 | goto _failed; |
---|
131 | 127 | if (res_size) |
---|
.. | .. |
---|
146 | 142 | struct snd_sg_buf *sg = dmab->private_data; |
---|
147 | 143 | unsigned int start, end, pg; |
---|
148 | 144 | |
---|
| 145 | + if (!sg) |
---|
| 146 | + return size; |
---|
| 147 | + |
---|
149 | 148 | start = ofs >> PAGE_SHIFT; |
---|
150 | 149 | end = (ofs + size - 1) >> PAGE_SHIFT; |
---|
151 | 150 | /* check page continuity */ |
---|