mm/arch: use __free_reserved_page() to simplify the code
authorXishi Qiu <qiuxishi@huawei.com>
Tue, 12 Nov 2013 23:07:13 +0000 (15:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 13 Nov 2013 03:09:03 +0000 (12:09 +0900)
Use __free_reserved_page() to simplify the code in arch.

It used split_page() in consistent_alloc()/__dma_alloc_coherent()/dma_alloc_coherent(),
so page->_count == 1, and we can free it safely.

__free_reserved_page()
ClearPageReserved()
init_page_count()  // it won't change the value
__free_page()

Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/metag/kernel/dma.c
arch/microblaze/mm/consistent.c
arch/powerpc/mm/dma-noncoherent.c

index 8c00dedadc54a4431083afe316f8734c0e6b99ef..db589ad5dbc41e5bb1cb0bc52dfc4faefc9c1820 100644 (file)
@@ -305,9 +305,7 @@ void dma_free_coherent(struct device *dev, size_t size,
 
                        if (pfn_valid(pfn)) {
                                struct page *page = pfn_to_page(pfn);
-                               ClearPageReserved(page);
-
-                               __free_page(page);
+                               __free_reserved_page(page);
                                continue;
                        }
                }
index 5226b09cbbb28bae26605e082f24cfee8e672f85..dbbf2246a260fcb3e6d90e78b65655416ccf7d45 100644 (file)
@@ -176,8 +176,7 @@ void consistent_free(size_t size, void *vaddr)
        page = virt_to_page(vaddr);
 
        do {
-               ClearPageReserved(page);
-               __free_page(page);
+               __free_reserved_page(page);
                page++;
        } while (size -= PAGE_SIZE);
 #else
@@ -194,9 +193,7 @@ void consistent_free(size_t size, void *vaddr)
                        pte_clear(&init_mm, (unsigned int)vaddr, ptep);
                        if (pfn_valid(pfn)) {
                                page = pfn_to_page(pfn);
-
-                               ClearPageReserved(page);
-                               __free_page(page);
+                               __free_reserved_page(page);
                        }
                }
                vaddr += PAGE_SIZE;
index 6747eece84afd97e4d101e422b83f4616df61a67..7b6c10750179d163ff98e091d8e5dac863f2a2a0 100644 (file)
@@ -287,9 +287,7 @@ void __dma_free_coherent(size_t size, void *vaddr)
                        pte_clear(&init_mm, addr, ptep);
                        if (pfn_valid(pfn)) {
                                struct page *page = pfn_to_page(pfn);
-
-                               ClearPageReserved(page);
-                               __free_page(page);
+                               __free_reserved_page(page);
                        }
                }
                addr += PAGE_SIZE;