Gentoo Archives: gentoo-commits

From: "Christian Heim (phreak)" <phreak@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in media-sound/alsa-driver/files: alsa-driver-1.0.14-seq_file.patch digest-alsa-driver-1.0.14-r1
Date: Wed, 03 Oct 2007 14:28:02
Message-Id: E1Id4cJ-0005j0-3x@stork.gentoo.org
1 phreak 07/10/03 13:50:23
2
3 Added: alsa-driver-1.0.14-seq_file.patch
4 digest-alsa-driver-1.0.14-r1
5 Log:
6 Revision bump, containing a fix for #193796.
7 (Portage version: 2.1.3.9)
8
9 Revision Changes Path
10 1.1 media-sound/alsa-driver/files/alsa-driver-1.0.14-seq_file.patch
11
12 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-driver/files/alsa-driver-1.0.14-seq_file.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-driver/files/alsa-driver-1.0.14-seq_file.patch?rev=1.1&content-type=text/plain
14
15 Index: alsa-driver-1.0.14-seq_file.patch
16 ===================================================================
17 --- a/acore/Makefile
18 +++ b/acore/Makefile
19 @@ -36,5 +36,5 @@ init.c: init.patch $(SND_TOPDIR)/alsa-ke
20 rawmidi.c: rawmidi.patch $(SND_TOPDIR)/alsa-kernel/core/rawmidi.c
21 sound.c: sound.patch $(SND_TOPDIR)/alsa-kernel/core/sound.c
22 timer.c: timer.patch $(SND_TOPDIR)/alsa-kernel/core/timer.c
23 -memalloc.c: memalloc.patch memalloc.inc memalloc.inc1 $(SND_TOPDIR)/alsa-kernel/core/memalloc.c
24 +memalloc.c: memalloc.inc memalloc.inc1 $(SND_TOPDIR)/alsa-kernel/core/memalloc.c
25 misc.c: misc.patch $(SND_TOPDIR)/alsa-kernel/core/misc.c
26 --- a/alsa-kernel/core/memalloc.c
27 +++ b/alsa-kernel/core/memalloc.c
28 @@ -1,3 +1,4 @@
29 +#include "memalloc.inc"
30 /*
31 * Copyright (c) by Jaroslav Kysela <perex@××××.cz>
32 * Takashi Iwai <tiwai@××××.de>
33 @@ -82,7 +83,50 @@ struct snd_mem_list {
34 * Hacks
35 */
36
37 -#if defined(__i386__)
38 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
39 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 5)
40 +static void *snd_dma_alloc_coherent1(struct device *dev, size_t size,
41 + dma_addr_t *dma_handle, int flags)
42 +{
43 + if (dev)
44 + return dma_alloc_coherent(dev, size, dma_handle, flags);
45 + else /* FIXME: dma_alloc_coherent does't always accept dev=NULL */
46 + return pci_alloc_consistent(NULL, size, dma_handle);
47 +}
48 +
49 +static void snd_dma_free_coherent1(struct device *dev, size_t size, void *dma_addr,
50 + dma_addr_t dma_handle)
51 +{
52 + if (dev)
53 + return dma_free_coherent(dev, size, dma_addr, dma_handle);
54 + else
55 + return pci_free_consistent(NULL, size, dma_addr, dma_handle);
56 +}
57 +
58 +#undef dma_alloc_coherent
59 +#define dma_alloc_coherent snd_dma_alloc_coherent1
60 +#undef dma_free_coherent
61 +#define dma_free_coherent snd_dma_free_coherent1
62 +#endif /* < 2.6.5 */
63 +
64 +#else
65 +
66 +/* for 2.2/2.4 kernels */
67 +#if defined(CONFIG_PCI) || defined(CONFIG_ISA) || defined(__i386__)
68 +#define dma_alloc_coherent(dev,size,addr,flags) pci_alloc_consistent((struct pci_dev *)(dev),size,addr)
69 +#define dma_free_coherent(dev,size,ptr,addr) pci_free_consistent((struct pci_dev *)(dev),size,ptr,addr)
70 +#elif CONFIG_SBUS
71 +#define dma_alloc_coherent(dev,size,addr,flags) sbus_alloc_consistent((struct sbus_dev *)(dev),size,addr)
72 +#define dma_free_coherent(dev,size,ptr,addr) sbus_free_consistent((struct sbus_dev *)(dev),size,ptr,addr)
73 +#else
74 +#error "Need a bus for dma_alloc_coherent()"
75 +#endif
76 +
77 +#endif /* >= 2.6.0 */
78 +
79 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
80 +#if defined(__i386__) || defined(__ppc__) || defined(__x86_64__)
81 +
82 /*
83 * A hack to allocate large buffers via dma_alloc_coherent()
84 *
85 @@ -99,6 +143,30 @@ struct snd_mem_list {
86 * so dma_mask doesn't have to be messed with.
87 */
88
89 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
90 +#define VALID_DMA_MASK(dev) (dev)->dma_mask
91 +#define GET_DMA_MASK(dev) *(dev)->dma_mask
92 +#define SET_DMA_MASK(dev,val) (*(dev)->dma_mask = (val))
93 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 5)
94 +#define GET_COHERENT_DMA_MASK(dev) (dev)->coherent_dma_mask
95 +#define SET_COHERENT_DMA_MASK(dev,val) ((dev)->coherent_dma_mask = (val))
96 +#else
97 +#define GET_COHERENT_DMA_MASK(dev) 0 /* dummy */
98 +#define SET_COHERENT_DMA_MASK(dev,val)
99 +#endif
100 +#else /* 2.4.x */
101 +#define VALID_DMA_MASK(dev) 1
102 +#define GET_DMA_MASK(dev) ((struct pci_dev *)(dev))->dma_mask
103 +#define SET_DMA_MASK(dev,val) (((struct pci_dev *)(dev))->dma_mask = (val))
104 +#ifdef CONFIG_HAVE_PCI_CONSISTENT_DMA_MASK
105 +#define GET_COHERENT_DMA_MASK(dev) ((struct pci_dev *)(dev))->consistent_dma_mask
106 +#define SET_COHERENT_DMA_MASK(dev,val) (((struct pci_dev *)(dev))->consistent_dma_mask = (val))
107 +#else
108 +#define GET_COHERENT_DMA_MASK(dev) 0 /* dummy */
109 +#define SET_COHERENT_DMA_MASK(dev,val)
110 +#endif
111 +#endif
112 +
113 static void *snd_dma_hack_alloc_coherent(struct device *dev, size_t size,
114 dma_addr_t *dma_handle,
115 gfp_t flags)
116 @@ -106,15 +174,15 @@ static void *snd_dma_hack_alloc_coherent
117 void *ret;
118 u64 dma_mask, coherent_dma_mask;
119
120 - if (dev == NULL || !dev->dma_mask)
121 + if (dev == NULL || !VALID_DMA_MASK(dev))
122 return dma_alloc_coherent(dev, size, dma_handle, flags);
123 - dma_mask = *dev->dma_mask;
124 - coherent_dma_mask = dev->coherent_dma_mask;
125 - *dev->dma_mask = 0xffffffff; /* do without masking */
126 - dev->coherent_dma_mask = 0xffffffff; /* do without masking */
127 + dma_mask = GET_DMA_MASK(dev);
128 + coherent_dma_mask = GET_COHERENT_DMA_MASK(dev);
129 + SET_DMA_MASK(dev, 0xffffffff); /* do without masking */
130 + SET_COHERENT_DMA_MASK(dev, 0xffffffff); /* do without masking */
131 ret = dma_alloc_coherent(dev, size, dma_handle, flags);
132 - *dev->dma_mask = dma_mask; /* restore */
133 - dev->coherent_dma_mask = coherent_dma_mask; /* restore */
134 + SET_DMA_MASK(dev, dma_mask); /* restore */
135 + SET_COHERENT_DMA_MASK(dev, coherent_dma_mask) /* restore */;
136 if (ret) {
137 /* obtained address is out of range? */
138 if (((unsigned long)*dma_handle + size - 1) & ~dma_mask) {
139 @@ -139,6 +207,8 @@ static void *snd_dma_hack_alloc_coherent
140 #define dma_alloc_coherent snd_dma_hack_alloc_coherent
141
142 #endif /* arch */
143 +#endif /* >= 2.4.0 */
144 +
145
146 /*
147 *
148 @@ -158,6 +228,24 @@ static inline void dec_snd_pages(int ord
149 snd_allocated_pages -= 1 << order;
150 }
151
152 +static void mark_pages(struct page *page, int order)
153 +{
154 +#if ! defined(__arm__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
155 + struct page *last_page = page + (1 << order);
156 + while (page < last_page)
157 + SetPageReserved(page++);
158 +#endif
159 +}
160 +
161 +static void unmark_pages(struct page *page, int order)
162 +{
163 +#if ! defined(__arm__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
164 + struct page *last_page = page + (1 << order);
165 + while (page < last_page)
166 + ClearPageReserved(page++);
167 +#endif
168 +}
169 +
170 /**
171 * snd_malloc_pages - allocate pages with the given size
172 * @size: the size to allocate in bytes
173 @@ -176,8 +264,10 @@ void *snd_malloc_pages(size_t size, gfp_
174 snd_assert(gfp_flags != 0, return NULL);
175 gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */
176 pg = get_order(size);
177 - if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL)
178 + if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) {
179 + mark_pages(virt_to_page(res), pg);
180 inc_snd_pages(pg);
181 + }
182 return res;
183 }
184
185 @@ -196,6 +286,7 @@ void snd_free_pages(void *ptr, size_t si
186 return;
187 pg = get_order(size);
188 dec_snd_pages(pg);
189 + unmark_pages(virt_to_page(ptr), pg);
190 free_pages((unsigned long) ptr, pg);
191 }
192
193 @@ -220,8 +311,10 @@ static void *snd_malloc_dev_pages(struct
194 | __GFP_NORETRY /* don't trigger OOM-killer */
195 | __GFP_NOWARN; /* no stack trace print - this call is non-critical */
196 res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
197 - if (res != NULL)
198 + if (res != NULL) {
199 + mark_pages(virt_to_page(res), pg);
200 inc_snd_pages(pg);
201 + }
202
203 return res;
204 }
205 @@ -236,6 +329,7 @@ static void snd_free_dev_pages(struct de
206 return;
207 pg = get_order(size);
208 dec_snd_pages(pg);
209 + unmark_pages(virt_to_page(ptr), pg);
210 dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
211 }
212
213 @@ -481,53 +575,55 @@ static void free_all_reserved_pages(void
214 #define SND_MEM_PROC_FILE "driver/snd-page-alloc"
215 static struct proc_dir_entry *snd_mem_proc;
216
217 -static int snd_mem_proc_read(char *page, char **start, off_t off,
218 - int count, int *eof, void *data)
219 +static int snd_mem_proc_read(struct seq_file *seq, void *offset)
220 {
221 - int len = 0;
222 long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
223 struct snd_mem_list *mem;
224 int devno;
225 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
226
227 + seq_printf(seq, "pages : %li bytes (%li pages per %likB)\n",
228 + pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
229 mutex_lock(&list_mutex);
230 - len += snprintf(page + len, count - len,
231 - "pages : %li bytes (%li pages per %likB)\n",
232 - pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
233 devno = 0;
234 list_for_each_entry(mem, &mem_list_head, list) {
235 devno++;
236 - len += snprintf(page + len, count - len,
237 - "buffer %d : ID %08x : type %s\n",
238 - devno, mem->id, types[mem->buffer.dev.type]);
239 - len += snprintf(page + len, count - len,
240 - " addr = 0x%lx, size = %d bytes\n",
241 - (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes);
242 + seq_printf(seq, "buffer %d : ID %08x : type %s\n",
243 + devno, mem->id, types[mem->buffer.dev.type]);
244 + seq_printf(seq, " addr = 0x%lx, size = %d bytes\n",
245 + (unsigned long)mem->buffer.addr,
246 + (int)mem->buffer.bytes);
247 }
248 mutex_unlock(&list_mutex);
249 - return len;
250 + return 0;
251 +}
252 +
253 +static int snd_mem_proc_open(struct inode *inode, struct file *file)
254 +{
255 + return single_open(file, snd_mem_proc_read, NULL);
256 }
257
258 /* FIXME: for pci only - other bus? */
259 #ifdef CONFIG_PCI
260 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
261 #define gettoken(bufp) strsep(bufp, " \t\n")
262
263 -static int snd_mem_proc_write(struct file *file, const char __user *buffer,
264 - unsigned long count, void *data)
265 +static ssize_t snd_mem_proc_write(struct file *file, const char __user * buffer,
266 + size_t count, loff_t * ppos)
267 {
268 char buf[128];
269 char *token, *p;
270
271 - if (count > ARRAY_SIZE(buf) - 1)
272 - count = ARRAY_SIZE(buf) - 1;
273 + if (count > sizeof(buf) - 1)
274 + return -EINVAL;
275 if (copy_from_user(buf, buffer, count))
276 return -EFAULT;
277 - buf[ARRAY_SIZE(buf) - 1] = '\0';
278 + buf[count] = '\0';
279
280 p = buf;
281 token = gettoken(&p);
282 if (! token || *token == '#')
283 - return (int)count;
284 + return count;
285 if (strcmp(token, "add") == 0) {
286 char *endp;
287 int vendor, device, size, buffers;
288 @@ -596,9 +692,22 @@ static int snd_mem_proc_write(struct fil
289 free_all_reserved_pages();
290 else
291 printk(KERN_ERR "snd-page-alloc: invalid proc cmd\n");
292 - return (int)count;
293 + return count;
294 }
295 +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) */
296 #endif /* CONFIG_PCI */
297 +
298 +static const struct file_operations snd_mem_proc_fops = {
299 + .owner = THIS_MODULE,
300 + .open = snd_mem_proc_open,
301 + .read = seq_read,
302 +#ifdef CONFIG_PCI
303 + .write = snd_mem_proc_write,
304 +#endif
305 + .llseek = seq_lseek,
306 + .release = single_release,
307 +};
308 +
309 #endif /* CONFIG_PROC_FS */
310
311 /*
312 @@ -609,12 +718,8 @@ static int __init snd_mem_init(void)
313 {
314 #ifdef CONFIG_PROC_FS
315 snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL);
316 - if (snd_mem_proc) {
317 - snd_mem_proc->read_proc = snd_mem_proc_read;
318 -#ifdef CONFIG_PCI
319 - snd_mem_proc->write_proc = snd_mem_proc_write;
320 -#endif
321 - }
322 + if (snd_mem_proc)
323 + snd_mem_proc->proc_fops = &snd_mem_proc_fops;
324 #endif
325 return 0;
326 }
327 @@ -644,3 +749,5 @@ EXPORT_SYMBOL(snd_dma_reserve_buf);
328
329 EXPORT_SYMBOL(snd_malloc_pages);
330 EXPORT_SYMBOL(snd_free_pages);
331 +
332 +#include "memalloc.inc1"
333
334
335
336 1.1 media-sound/alsa-driver/files/digest-alsa-driver-1.0.14-r1
337
338 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-driver/files/digest-alsa-driver-1.0.14-r1?rev=1.1&view=markup
339 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-driver/files/digest-alsa-driver-1.0.14-r1?rev=1.1&content-type=text/plain
340
341 Index: digest-alsa-driver-1.0.14-r1
342 ===================================================================
343 MD5 78232c1c38db6a1f4e1d304e2cc1f660 alsa-driver-1.0.14.tar.bz2 2600096
344 RMD160 2d017ed11bd037e450ffa969602f84cc104e5b72 alsa-driver-1.0.14.tar.bz2 2600096
345 SHA256 4987c05fd5516f9cb36ff4b73ccb77300124423b2bd6c66260eed73317529eca alsa-driver-1.0.14.tar.bz2 2600096
346
347
348
349 --
350 gentoo-commits@g.o mailing list