Re: [PATCH] Clean up asm/pgalloc.h include (sh)

Paul Mundt
2004-04-20T16:20:40Z

[-- Attachment #1: Type: text/plain, Size: 4829 bytes --]

On Tue, Apr 20, 2004 at 05:01:17PM +0100, Hugh Dickins wrote:
> On Tue, 20 Apr 2004, Paul Mundt wrote:
> > Failed to compile. sh has ptep_get_and_clear in asm/pgalloc.h.
> > This moves it out of the way, and your patch builds fine.
>
> Paul, the patch you show reflects how ptep_get_and_clear looked in
> 2.6.5, but not how it now looks in 2.6.6-rc1-bk - should be using
> page_mapping(page) and mapping_writably_mapped(mapping).
>
> I dare say you're referring to a master tree into which the recent
> mainline changes need to be ported (I CC'ed gniibe@m17n.org when
> sending those changes to akpm): I'm not saying your version is
> wrong, just trying to make sure that two sets of changes in the
> same area don't end up with one set getting lost.
>
Yes, this was against the 2.6.5-based SH tree, not current BK. Attached
is a patch against current BK that seems to reflect your changes.

Please CC me on any future SH-related issues, NIIBE-san is no longer
active in the SH community.

===== arch/sh/mm/tlb-sh4.c 1.2 vs edited =====
--- 1.2/arch/sh/mm/tlb-sh4.c Tue Mar 23 05:05:26 2004
+++ edited/arch/sh/mm/tlb-sh4.c Tue Apr 20 12:16:08 2004
@@ -24,7 +24,6 @@
#include <asm/system.h>
#include <asm/io.h>
#include <asm/uaccess.h>
-#include <asm/pgalloc.h>
#include <asm/hardirq.h>
#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
@@ -93,5 +92,25 @@
jump_to_P2();
ctrl_outl(data, addr);
back_to_P1();
+}
+
+/*
+ * For SH-4, we have our own implementation for ptep_get_and_clear
+ */
+inline pte_t ptep_get_and_clear(pte_t *ptep)
+{
+ pte_t pte = *ptep;
+
+ pte_clear(ptep);
+ if (!pte_not_present(pte)) {
+ unsigned long pfn = pte_pfn(pte);
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+ struct address_space *mapping = page_mapping(page);
+ if (!mapping || !mapping_writably_mapped(mapping))
+ __clear_bit(PG_mapped, &page->flags);
+ }
+ }
+ return pte;
}

===== include/asm-sh/pgalloc.h 1.12 vs edited =====
--- 1.12/include/asm-sh/pgalloc.h Sun Apr 18 12:13:10 2004
+++ edited/include/asm-sh/pgalloc.h Tue Apr 20 12:17:20 2004
@@ -85,69 +85,9 @@
#define __pmd_free_tlb(tlb,x) do { } while (0)
#define pgd_populate(mm, pmd, pte) BUG()

-#if defined(CONFIG_CPU_SH4)
+#ifdef CONFIG_CPU_SH4
#define PG_mapped PG_arch_1
-
-/*
- * For SH-4, we have our own implementation for ptep_get_and_clear
- */
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
-{
- pte_t pte = *ptep;
-
- pte_clear(ptep);
- if (!pte_not_present(pte)) {
- unsigned long pfn = pte_pfn(pte);
- if (pfn_valid(pfn)) {
- struct page *page = pfn_to_page(pfn);
- struct address_space *mapping = page_mapping(page);
- if (!mapping || !mapping_writably_mapped(mapping))
- __clear_bit(PG_mapped, &page->flags);
- }
- }
- return pte;
-}
-#else
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
-{
- pte_t pte = *ptep;
- pte_clear(ptep);
- return pte;
-}
#endif
-
-/*
- * Following functions are same as generic ones.
- */
-static inline int ptep_test_and_clear_young(pte_t *ptep)
-{
- pte_t pte = *ptep;
- if (!pte_young(pte))
- return 0;
- set_pte(ptep, pte_mkold(pte));
- return 1;
-}
-
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
-{
- pte_t pte = *ptep;
- if (!pte_dirty(pte))
- return 0;
- set_pte(ptep, pte_mkclean(pte));
- return 1;
-}
-
-static inline void ptep_set_wrprotect(pte_t *ptep)
-{
- pte_t old_pte = *ptep;
- set_pte(ptep, pte_wrprotect(old_pte));
-}
-
-static inline void ptep_mkdirty(pte_t *ptep)
-{
- pte_t old_pte = *ptep;
- set_pte(ptep, pte_mkdirty(old_pte));
-}

#define check_pgt_cache() do { } while (0)

===== include/asm-sh/pgtable.h 1.22 vs edited =====
--- 1.22/include/asm-sh/pgtable.h Tue Mar 23 05:05:27 2004
+++ edited/include/asm-sh/pgtable.h Tue Apr 20 12:13:49 2004
@@ -264,16 +264,6 @@
#define pte_to_pgoff(pte) (pte_val(pte))
#define pgoff_to_pte(off) ((pte_t) { (off) | _PAGE_FILE })

-/*
- * Routines for update of PTE
- *
- * We just can use generic implementation, as SuperH has no SMP feature.
- * (We needed atomic implementation for SMP)
- *
- */
-
-#define pte_same(A,B) (pte_val(A) == pte_val(B))
-
typedef pte_t *pte_addr_t;

#endif /* !__ASSEMBLY__ */
@@ -291,12 +281,11 @@
extern unsigned int kobjsize(const void *objp);
#endif /* !CONFIG_MMU */

-#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
-#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#ifdef CONFIG_CPU_SH4
#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
-#define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
-#define __HAVE_ARCH_PTE_SAME
+extern inline pte_t ptep_get_and_clear(pte_t *ptep);
+#endif
+
#include <asm-generic/pgtable.h>

#endif /* __ASM_SH_PAGE_H */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]