Lines 81-86
Link Here
|
81 |
* @pool_txphys: txphys[p] = dma_addr(txtbl[p]). |
81 |
* @pool_txphys: txphys[p] = dma_addr(txtbl[p]). |
82 |
* @kpool_virt: virt[p]: txnum[p] page_addr. |
82 |
* @kpool_virt: virt[p]: txnum[p] page_addr. |
83 |
* @kpool_phys: phys[p][i] = dma_addr(virt[p][i]). |
83 |
* @kpool_phys: phys[p][i] = dma_addr(virt[p][i]). |
|
|
84 |
* @kpool_uaddr: kpool_uaddr[p] = DMA-buffer's userland-address |
84 |
* @kpool_size: TBD. |
85 |
* @kpool_size: TBD. |
85 |
* @num_rss: TBD. |
86 |
* @num_rss: TBD. |
86 |
* @open_flag: TBD. |
87 |
* @open_flag: TBD. |
Lines 102-109
Link Here
|
102 |
/* Kernel DMA pools. */ |
103 |
/* Kernel DMA pools. */ |
103 |
unsigned long **kpool_virt[MAX_POOLS]; |
104 |
unsigned long **kpool_virt[MAX_POOLS]; |
104 |
unsigned long *kpool_phys[MAX_POOLS]; |
105 |
unsigned long *kpool_phys[MAX_POOLS]; |
|
|
106 |
unsigned long kpool_uaddr[MAX_POOLS]; |
105 |
u32 kpool_size[MAX_POOLS]; |
107 |
u32 kpool_size[MAX_POOLS]; |
106 |
|
108 |
|
107 |
/* Board config. */ |
109 |
/* Board config. */ |
108 |
u32 num_ge; |
110 |
u32 num_ge; |
109 |
u32 num_rss; |
111 |
u32 num_rss; |
Lines 151-156
Link Here
|
151 |
|
153 |
|
152 |
/* ----------------------------------------------------------------------- */ |
154 |
/* ----------------------------------------------------------------------- */ |
153 |
/* Gory details */ |
155 |
/* Gory details */ |
|
|
156 |
#define PAR(p) (*((struct impact_par *)(p)->par)) |
154 |
#define MMIO (((struct impact_par *)info->par)->mmio_virt) |
157 |
#define MMIO (((struct impact_par *)info->par)->mmio_virt) |
155 |
|
158 |
|
156 |
/** |
159 |
/** |
Lines 877-882
Link Here
|
877 |
/* ----------------------------------------------------------------------- */ |
880 |
/* ----------------------------------------------------------------------- */ |
878 |
/* Userland access */ |
881 |
/* Userland access */ |
879 |
|
882 |
|
|
|
883 |
static int |
884 |
impact_cacheflush(struct fb_info *info, int pool, const struct impact_cf_args *arg) |
885 |
{ |
886 |
struct impact_par *par = info->par; |
887 |
unsigned short w = arg->box.ws_xpixel << 2; |
888 |
unsigned short h = arg->box.ws_ypixel; |
889 |
|
890 |
if (w && h) |
891 |
{ |
892 |
unsigned long a = arg->bpitch*arg->box.ws_row + (arg->box.ws_col << 2); |
893 |
unsigned long b = arg->base + par->kpool_size[pool] - w; |
894 |
|
895 |
for (a += arg->base; h; h--, a += arg->bpitch) |
896 |
{ |
897 |
if (!access_ok(VERIFY_WRITE, (void __user*)a, w)) |
898 |
return -EFAULT; |
899 |
if (b <= a) |
900 |
return -EINVAL; |
901 |
dma_cache_wback_inv(a, w); |
902 |
} |
903 |
} |
904 |
return 0; |
905 |
} |
906 |
|
880 |
/** |
907 |
/** |
881 |
* impact_fb_ioctl - framebuffer ioctl() access (unimplemented). |
908 |
* impact_fb_ioctl - framebuffer ioctl() access (unimplemented). |
882 |
* @info: struct fb_info pointer to framebuffer data. |
909 |
* @info: struct fb_info pointer to framebuffer data. |
Lines 886-891
Link Here
|
886 |
static int |
913 |
static int |
887 |
impact_fb_ioctl(struct fb_info *info, u32 cmd, unsigned long arg) |
914 |
impact_fb_ioctl(struct fb_info *info, u32 cmd, unsigned long arg) |
888 |
{ |
915 |
{ |
|
|
916 |
#ifdef SGI_INDIGO2 |
917 |
if (TCFLSH == cmd) { |
918 |
struct impact_par *par = info->par; |
919 |
static struct impact_cf_args cfpar; |
920 |
int i; |
921 |
|
922 |
if ( copy_from_user(&cfpar, (void __user*)arg, sizeof(cfpar)) ) |
923 |
return -EFAULT; |
924 |
|
925 |
if (!cfpar.base) |
926 |
return -EINVAL; |
927 |
|
928 |
for (i = 0; i < MAX_POOLS; i++) { |
929 |
if (cfpar.base == par->kpool_uaddr[i]) { |
930 |
int r = impact_cacheflush(info, i, &cfpar); |
931 |
/* Might be munmapped behind our back. */ |
932 |
if (-EFAULT == r) { |
933 |
printk(KERN_INFO "impact_ioctl: shut down user" |
934 |
" cache-flush for DMA-pool %d (%p)\n", |
935 |
i, (void*)cfpar.base); |
936 |
par->kpool_uaddr[i] = 0; |
937 |
} |
938 |
return r; |
939 |
} |
940 |
} |
941 |
} |
942 |
#endif |
889 |
return -EINVAL; |
943 |
return -EINVAL; |
890 |
} |
944 |
} |
891 |
/* ----------------------------------------------------------------------- */ |
945 |
/* ----------------------------------------------------------------------- */ |
Lines 912-919
Link Here
|
912 |
|
966 |
|
913 |
switch (offset) { |
967 |
switch (offset) { |
914 |
case 0x0000000: |
968 |
case 0x0000000: |
915 |
default: |
969 |
#ifndef SGI_INDIGO2 |
916 |
if (unlikely((offset + size) > 0x200000)) |
970 |
if (unlikely((offset + size) > 0x200000)) |
|
|
971 |
#else |
972 |
if (unlikely((offset + size) > 0x400000)) |
973 |
#endif |
917 |
return -EINVAL; |
974 |
return -EINVAL; |
918 |
|
975 |
|
919 |
if (unlikely(vma->vm_pgoff > (~0UL >> PAGE_SHIFT))) |
976 |
if (unlikely(vma->vm_pgoff > (~0UL >> PAGE_SHIFT))) |
Lines 947-956
Link Here
|
947 |
pfn = (par->kpool_phys[pool][i] >> PAGE_SHIFT); |
1004 |
pfn = (par->kpool_phys[pool][i] >> PAGE_SHIFT); |
948 |
ret = remap_pfn_range(vma, start, pfn, PAGE_SIZE, |
1005 |
ret = remap_pfn_range(vma, start, pfn, PAGE_SIZE, |
949 |
vma->vm_page_prot); |
1006 |
vma->vm_page_prot); |
950 |
if (unlikely(ret)) |
1007 |
if (unlikely(ret)) { |
|
|
1008 |
par->kpool_uaddr[pool] = 0; |
951 |
return -EAGAIN; |
1009 |
return -EAGAIN; |
|
|
1010 |
} |
952 |
start += PAGE_SIZE; |
1011 |
start += PAGE_SIZE; |
953 |
} |
1012 |
} |
|
|
1013 |
par->kpool_uaddr[pool] = vma->vm_start; |
1014 |
break; |
1015 |
default: |
1016 |
return -EINVAL; |
954 |
} |
1017 |
} |
955 |
|
1018 |
|
956 |
return 0; |
1019 |
return 0; |