Commit 92d450336eedf4c671f37c931fa8ccc28c6be3a9

Authored by Vijay Kumar B
Committed by Greg Kroah-Hartman
1 parent dad1740133

Staging: poch: Remove circular buffer header

Remove the circular buffer header. Which has been superseded by the
ioctl consume interface.

Signed-off-by: Vijay Kumar B <vijaykumar@bravegnu.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 3 changed files with 8 additions and 108 deletions Side-by-side Diff

drivers/staging/poch/README
1 1 TODO:
2 2 - Rx block size is limited to < 2048, hardware bug?
3 3 - Group size is limited to < page size, kernel alloc/mmap API issues
4   - - fix/workaround cache issues in circular buffer header
5 4 - test whether Tx is transmitting data from provided buffers
6 5 - handle device unplug case
7 6 - handle temperature above threshold
drivers/staging/poch/poch.c
... ... @@ -197,9 +197,6 @@
197 197  
198 198 /* Contains the header and circular buffer exported to userspace. */
199 199 spinlock_t group_offsets_lock;
200   - struct poch_cbuf_header *header;
201   - struct page *header_pg;
202   - unsigned long header_size;
203 200  
204 201 /* Last group consumed by user space. */
205 202 unsigned int consumed;
206 203  
207 204  
... ... @@ -329,14 +326,12 @@
329 326 int len;
330 327 unsigned long mmap_size;
331 328 unsigned long group_pages;
332   - unsigned long header_pages;
333 329 unsigned long total_group_pages;
334 330  
335 331 group_pages = npages(channel->group_size);
336   - header_pages = npages(channel->header_size);
337 332 total_group_pages = group_pages * channel->group_count;
338 333  
339   - mmap_size = (header_pages + total_group_pages) * PAGE_SIZE;
  334 + mmap_size = total_group_pages * PAGE_SIZE;
340 335 len = sprintf(buf, "%lu\n", mmap_size);
341 336 return len;
342 337 }
343 338  
... ... @@ -369,10 +364,8 @@
369 364 {
370 365 unsigned long i;
371 366 unsigned long group_pages;
372   - unsigned long header_pages;
373 367  
374 368 group_pages = npages(channel->group_size);
375   - header_pages = npages(channel->header_size);
376 369  
377 370 for (i = 0; i < channel->group_count; i++) {
378 371 struct poch_group_info *group;
... ... @@ -402,8 +395,7 @@
402 395 * this?
403 396 */
404 397 group->dma_addr = page_to_pfn(group->pg) * PAGE_SIZE;
405   - group->user_offset =
406   - (header_pages + (i * group_pages)) * PAGE_SIZE;
  398 + group->user_offset = (i * group_pages) * PAGE_SIZE;
407 399  
408 400 printk(KERN_INFO PFX "%ld: user_offset: 0x%lx\n", i,
409 401 group->user_offset);
... ... @@ -525,56 +517,6 @@
525 517  
526 518 }
527 519  
528   -static int poch_channel_alloc_header(struct channel_info *channel)
529   -{
530   - struct poch_cbuf_header *header = channel->header;
531   - unsigned long group_offset_size;
532   - unsigned long tot_group_offsets_size;
533   -
534   - /* Allocate memory to hold header exported userspace */
535   - group_offset_size = sizeof(header->group_offsets[0]);
536   - tot_group_offsets_size = group_offset_size * channel->group_count;
537   - channel->header_size = sizeof(*header) + tot_group_offsets_size;
538   - channel->header_pg = alloc_pages(GFP_KERNEL | __GFP_ZERO,
539   - get_order(channel->header_size));
540   - if (!channel->header_pg)
541   - return -ENOMEM;
542   -
543   - channel->header = page_address(channel->header_pg);
544   -
545   - return 0;
546   -}
547   -
548   -static void poch_channel_free_header(struct channel_info *channel)
549   -{
550   - unsigned int order;
551   -
552   - order = get_order(channel->header_size);
553   - __free_pages(channel->header_pg, order);
554   -}
555   -
556   -static void poch_channel_init_header(struct channel_info *channel)
557   -{
558   - int i;
559   - struct poch_group_info *groups;
560   - s32 *group_offsets;
561   -
562   - channel->header->group_size_bytes = channel->group_size;
563   - channel->header->group_count = channel->group_count;
564   -
565   - spin_lock_init(&channel->group_offsets_lock);
566   -
567   - group_offsets = channel->header->group_offsets;
568   - groups = channel->groups;
569   -
570   - for (i = 0; i < channel->group_count; i++) {
571   - if (channel->dir == CHANNEL_DIR_RX)
572   - group_offsets[i] = -1;
573   - else
574   - group_offsets[i] = groups[i].user_offset;
575   - }
576   -}
577   -
578 520 static void __poch_channel_clear_counters(struct channel_info *channel)
579 521 {
580 522 channel->counters.pll_unlock = 0;
... ... @@ -617,12 +559,6 @@
617 559 goto out_free_group_info;
618 560 }
619 561  
620   - ret = poch_channel_alloc_header(channel);
621   - if (ret) {
622   - dev_err(dev, "error allocating user space header\n");
623   - goto out_free_groups;
624   - }
625   -
626 562 channel->fpga_iomem = poch_dev->fpga_iomem;
627 563 channel->bridge_iomem = poch_dev->bridge_iomem;
628 564 channel->iomem_lock = &poch_dev->iomem_lock;
629 565  
... ... @@ -630,14 +566,8 @@
630 566  
631 567 __poch_channel_clear_counters(channel);
632 568  
633   - printk(KERN_WARNING "poch_channel_init_header\n");
634   -
635   - poch_channel_init_header(channel);
636   -
637 569 return 0;
638 570  
639   - out_free_groups:
640   - poch_channel_free_groups(channel);
641 571 out_free_group_info:
642 572 kfree(channel->groups);
643 573 out:
... ... @@ -881,7 +811,6 @@
881 811 }
882 812  
883 813 atomic_dec(&channel->inited);
884   - poch_channel_free_header(channel);
885 814 poch_channel_free_groups(channel);
886 815 kfree(channel->groups);
887 816 atomic_inc(&channel->free);
... ... @@ -890,7 +819,7 @@
890 819 }
891 820  
892 821 /*
893   - * Map the header and the group buffers, to user space.
  822 + * Map the the group buffers, to user space.
894 823 */
895 824 static int poch_mmap(struct file *filp, struct vm_area_struct *vma)
896 825 {
... ... @@ -900,7 +829,6 @@
900 829 unsigned long size;
901 830  
902 831 unsigned long group_pages;
903   - unsigned long header_pages;
904 832 unsigned long total_group_pages;
905 833  
906 834 int pg_num;
907 835  
908 836  
... ... @@ -917,30 +845,16 @@
917 845 }
918 846  
919 847 group_pages = npages(channel->group_size);
920   - header_pages = npages(channel->header_size);
921 848 total_group_pages = group_pages * channel->group_count;
922 849  
923 850 size = vma->vm_end - vma->vm_start;
924   - if (size != (header_pages + total_group_pages) * PAGE_SIZE) {
  851 + if (size != total_group_pages * PAGE_SIZE) {
925 852 printk(KERN_WARNING PFX "required %lu bytes\n", size);
926 853 return -EINVAL;
927 854 }
928 855  
929 856 start = vma->vm_start;
930 857  
931   - /* FIXME: Cleanup required on failure? */
932   - pg = channel->header_pg;
933   - for (pg_num = 0; pg_num < header_pages; pg_num++, pg++) {
934   - printk(KERN_DEBUG PFX "page_count: %d\n", page_count(pg));
935   - printk(KERN_DEBUG PFX "%d: header: 0x%lx\n", pg_num, start);
936   - ret = vm_insert_page(vma, start, pg);
937   - if (ret) {
938   - printk(KERN_DEBUG "vm_insert 1 failed at %lx\n", start);
939   - return ret;
940   - }
941   - start += PAGE_SIZE;
942   - }
943   -
944 858 for (i = 0; i < channel->group_count; i++) {
945 859 pg = channel->groups[i].pg;
946 860 for (pg_num = 0; pg_num < group_pages; pg_num++, pg++) {
947 861  
948 862  
... ... @@ -967,20 +881,16 @@
967 881 */
968 882 static int poch_channel_available(struct channel_info *channel)
969 883 {
970   - int i;
  884 + int available = 0;
971 885  
972 886 spin_lock_irq(&channel->group_offsets_lock);
973 887  
974   - for (i = 0; i < channel->group_count; i++) {
975   - if (channel->header->group_offsets[i] != -1) {
976   - spin_unlock_irq(&channel->group_offsets_lock);
977   - return 1;
978   - }
979   - }
  888 + if (channel->consumed != channel->transfer)
  889 + available = 1;
980 890  
981 891 spin_unlock_irq(&channel->group_offsets_lock);
982 892  
983   - return 0;
  893 + return available;
984 894 }
985 895  
986 896 static unsigned int poch_poll(struct file *filp, poll_table *pt)
... ... @@ -1138,7 +1048,6 @@
1138 1048 long groups_done;
1139 1049 unsigned long i, j;
1140 1050 struct poch_group_info *groups;
1141   - s32 *group_offsets;
1142 1051 u32 curr_group_reg;
1143 1052  
1144 1053 if (!atomic_read(&channel->inited))
1145 1054  
... ... @@ -1158,14 +1067,12 @@
1158 1067 if (groups_done <= 0)
1159 1068 groups_done += channel->group_count;
1160 1069  
1161   - group_offsets = channel->header->group_offsets;
1162 1070 groups = channel->groups;
1163 1071  
1164 1072 spin_lock(&channel->group_offsets_lock);
1165 1073  
1166 1074 for (i = 0; i < groups_done; i++) {
1167 1075 j = (prev_transfer + i) % channel->group_count;
1168   - group_offsets[j] = groups[j].user_offset;
1169 1076  
1170 1077 channel->transfer += 1;
1171 1078 channel->transfer %= channel->group_count;
drivers/staging/poch/poch.h
... ... @@ -7,12 +7,6 @@
7 7 * include/linux for final version.
8 8 *
9 9 */
10   -struct poch_cbuf_header {
11   - __s32 group_size_bytes;
12   - __s32 group_count;
13   - __s32 group_offsets[0];
14   -};
15   -
16 10 struct poch_counters {
17 11 __u32 fifo_empty;
18 12 __u32 fifo_overflow;