diff options
author | Shaohua Li <shaohua.li@intel.com> | 2008-08-20 22:46:17 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-21 07:47:46 -0400 |
commit | bd07928c0f9c3dbe53baf28eae4de4c579772c4c (patch) | |
tree | 7210c0a3c96bd58517ba45365ef87092394870b4 /drivers | |
parent | 37acee10f49cf3caa323e05675e8dc9221ef4fd8 (diff) |
agp: add agp_generic_destroy_pages()
Add agp_generic_destroy_pages(), it uses new pageattr array interface API.
Signed-off-by: Dave Airlie <airlied@gmail.com>
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/agp/agp.h | 2 | ||||
-rw-r--r-- | drivers/char/agp/generic.c | 55 | ||||
-rw-r--r-- | drivers/char/agp/intel-agp.c | 14 |
3 files changed, 63 insertions, 8 deletions
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 55d2c9d14177..338b0b4dce9c 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -118,6 +118,7 @@ struct agp_bridge_driver { | |||
118 | void *(*agp_alloc_page)(struct agp_bridge_data *); | 118 | void *(*agp_alloc_page)(struct agp_bridge_data *); |
119 | int (*agp_alloc_pages)(struct agp_bridge_data *, struct agp_memory *, size_t); | 119 | int (*agp_alloc_pages)(struct agp_bridge_data *, struct agp_memory *, size_t); |
120 | void (*agp_destroy_page)(void *, int flags); | 120 | void (*agp_destroy_page)(void *, int flags); |
121 | void (*agp_destroy_pages)(struct agp_memory *); | ||
121 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); | 122 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); |
122 | void (*chipset_flush)(struct agp_bridge_data *); | 123 | void (*chipset_flush)(struct agp_bridge_data *); |
123 | }; | 124 | }; |
@@ -278,6 +279,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge); | |||
278 | int agp_generic_alloc_pages(struct agp_bridge_data *agp_bridge, | 279 | int agp_generic_alloc_pages(struct agp_bridge_data *agp_bridge, |
279 | struct agp_memory *memory, size_t page_count); | 280 | struct agp_memory *memory, size_t page_count); |
280 | void agp_generic_destroy_page(void *addr, int flags); | 281 | void agp_generic_destroy_page(void *addr, int flags); |
282 | void agp_generic_destroy_pages(struct agp_memory *memory); | ||
281 | void agp_free_key(int key); | 283 | void agp_free_key(int key); |
282 | int agp_num_entries(void); | 284 | int agp_num_entries(void); |
283 | u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 mode, u32 command); | 285 | u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 mode, u32 command); |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 13a5577ee434..dd370be00d68 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -201,14 +201,22 @@ void agp_free_memory(struct agp_memory *curr) | |||
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | if (curr->page_count != 0) { | 203 | if (curr->page_count != 0) { |
204 | for (i = 0; i < curr->page_count; i++) { | 204 | if (curr->bridge->driver->agp_destroy_pages) { |
205 | curr->memory[i] = (unsigned long)gart_to_virt(curr->memory[i]); | 205 | curr->bridge->driver->agp_destroy_pages(curr); |
206 | curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], | 206 | } else { |
207 | AGP_PAGE_DESTROY_UNMAP); | 207 | |
208 | } | 208 | for (i = 0; i < curr->page_count; i++) { |
209 | for (i = 0; i < curr->page_count; i++) { | 209 | curr->memory[i] = (unsigned long)gart_to_virt( |
210 | curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], | 210 | curr->memory[i]); |
211 | AGP_PAGE_DESTROY_FREE); | 211 | curr->bridge->driver->agp_destroy_page( |
212 | (void *)curr->memory[i], | ||
213 | AGP_PAGE_DESTROY_UNMAP); | ||
214 | } | ||
215 | for (i = 0; i < curr->page_count; i++) { | ||
216 | curr->bridge->driver->agp_destroy_page( | ||
217 | (void *)curr->memory[i], | ||
218 | AGP_PAGE_DESTROY_FREE); | ||
219 | } | ||
212 | } | 220 | } |
213 | } | 221 | } |
214 | agp_free_key(curr->key); | 222 | agp_free_key(curr->key); |
@@ -1236,6 +1244,37 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge) | |||
1236 | } | 1244 | } |
1237 | EXPORT_SYMBOL(agp_generic_alloc_page); | 1245 | EXPORT_SYMBOL(agp_generic_alloc_page); |
1238 | 1246 | ||
1247 | void agp_generic_destroy_pages(struct agp_memory *mem) | ||
1248 | { | ||
1249 | int i; | ||
1250 | void *addr; | ||
1251 | struct page *page; | ||
1252 | |||
1253 | if (!mem) | ||
1254 | return; | ||
1255 | |||
1256 | for (i = 0; i < mem->page_count; i++) | ||
1257 | mem->memory[i] = (unsigned long)gart_to_virt(mem->memory[i]); | ||
1258 | |||
1259 | #ifdef CONFIG_X86 | ||
1260 | set_memory_array_wb(mem->memory, mem->page_count); | ||
1261 | #endif | ||
1262 | |||
1263 | for (i = 0; i < mem->page_count; i++) { | ||
1264 | addr = (void *)mem->memory[i]; | ||
1265 | page = virt_to_page(addr); | ||
1266 | |||
1267 | #ifndef CONFIG_X86 | ||
1268 | unmap_page_from_agp(page); | ||
1269 | #endif | ||
1270 | |||
1271 | put_page(page); | ||
1272 | free_page((unsigned long)addr); | ||
1273 | atomic_dec(&agp_bridge->current_memory_agp); | ||
1274 | mem->memory[i] = 0; | ||
1275 | } | ||
1276 | } | ||
1277 | EXPORT_SYMBOL(agp_generic_destroy_pages); | ||
1239 | 1278 | ||
1240 | void agp_generic_destroy_page(void *addr, int flags) | 1279 | void agp_generic_destroy_page(void *addr, int flags) |
1241 | { | 1280 | { |
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 2cff0976a668..290a1cf63925 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -1705,6 +1705,7 @@ static const struct agp_bridge_driver intel_generic_driver = { | |||
1705 | .agp_alloc_page = agp_generic_alloc_page, | 1705 | .agp_alloc_page = agp_generic_alloc_page, |
1706 | .agp_alloc_pages = agp_generic_alloc_pages, | 1706 | .agp_alloc_pages = agp_generic_alloc_pages, |
1707 | .agp_destroy_page = agp_generic_destroy_page, | 1707 | .agp_destroy_page = agp_generic_destroy_page, |
1708 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1708 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1709 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1709 | }; | 1710 | }; |
1710 | 1711 | ||
@@ -1731,6 +1732,7 @@ static const struct agp_bridge_driver intel_810_driver = { | |||
1731 | .agp_alloc_page = agp_generic_alloc_page, | 1732 | .agp_alloc_page = agp_generic_alloc_page, |
1732 | .agp_alloc_pages = agp_generic_alloc_pages, | 1733 | .agp_alloc_pages = agp_generic_alloc_pages, |
1733 | .agp_destroy_page = agp_generic_destroy_page, | 1734 | .agp_destroy_page = agp_generic_destroy_page, |
1735 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1734 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1736 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1735 | }; | 1737 | }; |
1736 | 1738 | ||
@@ -1756,6 +1758,7 @@ static const struct agp_bridge_driver intel_815_driver = { | |||
1756 | .agp_alloc_page = agp_generic_alloc_page, | 1758 | .agp_alloc_page = agp_generic_alloc_page, |
1757 | .agp_alloc_pages = agp_generic_alloc_pages, | 1759 | .agp_alloc_pages = agp_generic_alloc_pages, |
1758 | .agp_destroy_page = agp_generic_destroy_page, | 1760 | .agp_destroy_page = agp_generic_destroy_page, |
1761 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1759 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1762 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1760 | }; | 1763 | }; |
1761 | 1764 | ||
@@ -1782,6 +1785,7 @@ static const struct agp_bridge_driver intel_830_driver = { | |||
1782 | .agp_alloc_page = agp_generic_alloc_page, | 1785 | .agp_alloc_page = agp_generic_alloc_page, |
1783 | .agp_alloc_pages = agp_generic_alloc_pages, | 1786 | .agp_alloc_pages = agp_generic_alloc_pages, |
1784 | .agp_destroy_page = agp_generic_destroy_page, | 1787 | .agp_destroy_page = agp_generic_destroy_page, |
1788 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1785 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | 1789 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
1786 | .chipset_flush = intel_i830_chipset_flush, | 1790 | .chipset_flush = intel_i830_chipset_flush, |
1787 | }; | 1791 | }; |
@@ -1808,6 +1812,7 @@ static const struct agp_bridge_driver intel_820_driver = { | |||
1808 | .agp_alloc_page = agp_generic_alloc_page, | 1812 | .agp_alloc_page = agp_generic_alloc_page, |
1809 | .agp_alloc_pages = agp_generic_alloc_pages, | 1813 | .agp_alloc_pages = agp_generic_alloc_pages, |
1810 | .agp_destroy_page = agp_generic_destroy_page, | 1814 | .agp_destroy_page = agp_generic_destroy_page, |
1815 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1811 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1816 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1812 | }; | 1817 | }; |
1813 | 1818 | ||
@@ -1833,6 +1838,7 @@ static const struct agp_bridge_driver intel_830mp_driver = { | |||
1833 | .agp_alloc_page = agp_generic_alloc_page, | 1838 | .agp_alloc_page = agp_generic_alloc_page, |
1834 | .agp_alloc_pages = agp_generic_alloc_pages, | 1839 | .agp_alloc_pages = agp_generic_alloc_pages, |
1835 | .agp_destroy_page = agp_generic_destroy_page, | 1840 | .agp_destroy_page = agp_generic_destroy_page, |
1841 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1836 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1842 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1837 | }; | 1843 | }; |
1838 | 1844 | ||
@@ -1858,6 +1864,7 @@ static const struct agp_bridge_driver intel_840_driver = { | |||
1858 | .agp_alloc_page = agp_generic_alloc_page, | 1864 | .agp_alloc_page = agp_generic_alloc_page, |
1859 | .agp_alloc_pages = agp_generic_alloc_pages, | 1865 | .agp_alloc_pages = agp_generic_alloc_pages, |
1860 | .agp_destroy_page = agp_generic_destroy_page, | 1866 | .agp_destroy_page = agp_generic_destroy_page, |
1867 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1861 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1868 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1862 | }; | 1869 | }; |
1863 | 1870 | ||
@@ -1883,6 +1890,7 @@ static const struct agp_bridge_driver intel_845_driver = { | |||
1883 | .agp_alloc_page = agp_generic_alloc_page, | 1890 | .agp_alloc_page = agp_generic_alloc_page, |
1884 | .agp_alloc_pages = agp_generic_alloc_pages, | 1891 | .agp_alloc_pages = agp_generic_alloc_pages, |
1885 | .agp_destroy_page = agp_generic_destroy_page, | 1892 | .agp_destroy_page = agp_generic_destroy_page, |
1893 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1886 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1894 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1887 | .chipset_flush = intel_i830_chipset_flush, | 1895 | .chipset_flush = intel_i830_chipset_flush, |
1888 | }; | 1896 | }; |
@@ -1909,6 +1917,7 @@ static const struct agp_bridge_driver intel_850_driver = { | |||
1909 | .agp_alloc_page = agp_generic_alloc_page, | 1917 | .agp_alloc_page = agp_generic_alloc_page, |
1910 | .agp_alloc_pages = agp_generic_alloc_pages, | 1918 | .agp_alloc_pages = agp_generic_alloc_pages, |
1911 | .agp_destroy_page = agp_generic_destroy_page, | 1919 | .agp_destroy_page = agp_generic_destroy_page, |
1920 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1912 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1921 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1913 | }; | 1922 | }; |
1914 | 1923 | ||
@@ -1934,6 +1943,7 @@ static const struct agp_bridge_driver intel_860_driver = { | |||
1934 | .agp_alloc_page = agp_generic_alloc_page, | 1943 | .agp_alloc_page = agp_generic_alloc_page, |
1935 | .agp_alloc_pages = agp_generic_alloc_pages, | 1944 | .agp_alloc_pages = agp_generic_alloc_pages, |
1936 | .agp_destroy_page = agp_generic_destroy_page, | 1945 | .agp_destroy_page = agp_generic_destroy_page, |
1946 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1937 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 1947 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
1938 | }; | 1948 | }; |
1939 | 1949 | ||
@@ -1960,6 +1970,7 @@ static const struct agp_bridge_driver intel_915_driver = { | |||
1960 | .agp_alloc_page = agp_generic_alloc_page, | 1970 | .agp_alloc_page = agp_generic_alloc_page, |
1961 | .agp_alloc_pages = agp_generic_alloc_pages, | 1971 | .agp_alloc_pages = agp_generic_alloc_pages, |
1962 | .agp_destroy_page = agp_generic_destroy_page, | 1972 | .agp_destroy_page = agp_generic_destroy_page, |
1973 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1963 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | 1974 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
1964 | .chipset_flush = intel_i915_chipset_flush, | 1975 | .chipset_flush = intel_i915_chipset_flush, |
1965 | }; | 1976 | }; |
@@ -1987,6 +1998,7 @@ static const struct agp_bridge_driver intel_i965_driver = { | |||
1987 | .agp_alloc_page = agp_generic_alloc_page, | 1998 | .agp_alloc_page = agp_generic_alloc_page, |
1988 | .agp_alloc_pages = agp_generic_alloc_pages, | 1999 | .agp_alloc_pages = agp_generic_alloc_pages, |
1989 | .agp_destroy_page = agp_generic_destroy_page, | 2000 | .agp_destroy_page = agp_generic_destroy_page, |
2001 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1990 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | 2002 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
1991 | .chipset_flush = intel_i915_chipset_flush, | 2003 | .chipset_flush = intel_i915_chipset_flush, |
1992 | }; | 2004 | }; |
@@ -2013,6 +2025,7 @@ static const struct agp_bridge_driver intel_7505_driver = { | |||
2013 | .agp_alloc_page = agp_generic_alloc_page, | 2025 | .agp_alloc_page = agp_generic_alloc_page, |
2014 | .agp_alloc_pages = agp_generic_alloc_pages, | 2026 | .agp_alloc_pages = agp_generic_alloc_pages, |
2015 | .agp_destroy_page = agp_generic_destroy_page, | 2027 | .agp_destroy_page = agp_generic_destroy_page, |
2028 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
2016 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | 2029 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
2017 | }; | 2030 | }; |
2018 | 2031 | ||
@@ -2039,6 +2052,7 @@ static const struct agp_bridge_driver intel_g33_driver = { | |||
2039 | .agp_alloc_page = agp_generic_alloc_page, | 2052 | .agp_alloc_page = agp_generic_alloc_page, |
2040 | .agp_alloc_pages = agp_generic_alloc_pages, | 2053 | .agp_alloc_pages = agp_generic_alloc_pages, |
2041 | .agp_destroy_page = agp_generic_destroy_page, | 2054 | .agp_destroy_page = agp_generic_destroy_page, |
2055 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
2042 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | 2056 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
2043 | .chipset_flush = intel_i915_chipset_flush, | 2057 | .chipset_flush = intel_i915_chipset_flush, |
2044 | }; | 2058 | }; |