23 #include <linux/kernel.h>
25 #include <linux/slab.h>
34 static int spu_alloc_lscsa_std(
struct spu_state *csa)
36 struct spu_lscsa *lscsa;
39 lscsa =
vzalloc(
sizeof(
struct spu_lscsa));
51 static void spu_free_lscsa_std(
struct spu_state *csa)
56 if (csa->lscsa ==
NULL)
65 #ifdef CONFIG_SPU_FS_64K_LS
67 #define SPU_64K_PAGE_SHIFT 16
68 #define SPU_64K_PAGE_ORDER (SPU_64K_PAGE_SHIFT - PAGE_SHIFT)
69 #define SPU_64K_PAGE_COUNT (1ul << SPU_64K_PAGE_ORDER)
73 struct page **pgarray;
81 csa->use_big_pages = 1;
83 pr_debug(
"spu_alloc_lscsa(csa=0x%p), trying to allocate 64K pages\n",
91 for (i = 0; i < SPU_LSCSA_NUM_BIG_PAGES; i++) {
97 if (csa->lscsa_pages[i] ==
NULL)
101 pr_debug(
" success ! creating vmap...\n");
107 n_4k = SPU_64K_PAGE_COUNT * SPU_LSCSA_NUM_BIG_PAGES;
111 for (i = 0; i < SPU_LSCSA_NUM_BIG_PAGES; i++)
112 for (j = 0; j < SPU_64K_PAGE_COUNT; j++)
117 pgarray[i * SPU_64K_PAGE_COUNT + j] =
118 csa->lscsa_pages[i] + j;
121 if (csa->lscsa ==
NULL)
124 memset(csa->lscsa, 0,
sizeof(
struct spu_lscsa));
139 pr_debug(
"spufs: failed to allocate lscsa 64K pages, falling back\n");
141 return spu_alloc_lscsa_std(csa);
149 if (!csa->use_big_pages) {
150 spu_free_lscsa_std(csa);
153 csa->use_big_pages = 0;
155 if (csa->lscsa ==
NULL)
166 for (i = 0; i < SPU_LSCSA_NUM_BIG_PAGES; i++)
167 if (csa->lscsa_pages[i])
175 return spu_alloc_lscsa_std(csa);
180 spu_free_lscsa_std(csa);