Re: [RFC PATCH V1 14/33] powerpc/mm: Use helper for finding pte bits mapping I/O area

2016-01-12 Thread Benjamin Herrenschmidt
On Tue, 2016-01-12 at 10:42 +0300, Denis Kirjanov wrote:
> > +static inline unsigned long pte_io_cache_bits(void)
> > +{
> > + return _PAGE_NO_CACHE | _PAGE_GUARDED;
> > +}
> This could be just plain #define

Or just use pgprot_noncached()

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC PATCH V1 14/33] powerpc/mm: Use helper for finding pte bits mapping I/O area

2016-01-12 Thread Benjamin Herrenschmidt
On Wed, 2016-01-13 at 11:37 +0530, Aneesh Kumar K.V wrote:
> Benjamin Herrenschmidt  writes:
> 
> > On Tue, 2016-01-12 at 10:42 +0300, Denis Kirjanov wrote:
> > > > +static inline unsigned long pte_io_cache_bits(void)
> > > > +{
> > > > + return _PAGE_NO_CACHE | _PAGE_GUARDED;
> > > > +}
> > > This could be just plain #define
> > 
> > Or just use pgprot_noncached()
> > 
> #define pgprot_noncached(prot)  (__pgprot((pgprot_val(prot) &
> ~_PAGE_CACHE_CTL) | \
>   _PAGE_NO_CACHE |
> _PAGE_GUARDED))
> 
> 
> That will return me a pgprot_t.  I can fix that by using
> pgprot_val(pgprot_noncached(0)). Is that what you are suggesting ?

Shouln't ioremap just use pgprot_noncached(PAGE_KERNEL) or similar ?

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC PATCH V1 14/33] powerpc/mm: Use helper for finding pte bits mapping I/O area

2016-01-12 Thread Aneesh Kumar K.V
Benjamin Herrenschmidt  writes:

> On Tue, 2016-01-12 at 10:42 +0300, Denis Kirjanov wrote:
>> > +static inline unsigned long pte_io_cache_bits(void)
>> > +{
>> > + return _PAGE_NO_CACHE | _PAGE_GUARDED;
>> > +}
>> This could be just plain #define
>
> Or just use pgprot_noncached()
>
#define pgprot_noncached(prot)(__pgprot((pgprot_val(prot) & 
~_PAGE_CACHE_CTL) | \
_PAGE_NO_CACHE | _PAGE_GUARDED))


That will return me a pgprot_t.  I can fix that by using
pgprot_val(pgprot_noncached(0)). Is that what you are suggesting ?

-aneesh

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC PATCH V1 14/33] powerpc/mm: Use helper for finding pte bits mapping I/O area

2016-01-12 Thread Denis Kirjanov
On 1/12/16, Aneesh Kumar K.V  wrote:
> We will have different values for hash and radix. Hence we
> cannot use #define constants. Add helper
>
> Signed-off-by: Aneesh Kumar K.V 
> ---
>  arch/powerpc/include/asm/book3s/32/pgtable.h | 5 +
>  arch/powerpc/include/asm/book3s/64/hash.h| 5 +
>  arch/powerpc/include/asm/nohash/pgtable.h| 5 +
>  arch/powerpc/kernel/isa-bridge.c | 4 ++--
>  arch/powerpc/kernel/pci_64.c | 2 +-
>  arch/powerpc/mm/pgtable_64.c | 2 +-
>  6 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h
> b/arch/powerpc/include/asm/book3s/32/pgtable.h
> index 3ed3303c1295..77adada2f3b4 100644
> --- a/arch/powerpc/include/asm/book3s/32/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
> @@ -478,6 +478,11 @@ static inline pgprot_t pgprot_writecombine(pgprot_t
> prot)
>   return pgprot_noncached_wc(prot);
>  }
>
> +static inline unsigned long pte_io_cache_bits(void)
> +{
> + return _PAGE_NO_CACHE | _PAGE_GUARDED;
> +}
This could be just plain #define
> +
>  #endif /* !__ASSEMBLY__ */
>
>  #endif /*  _ASM_POWERPC_BOOK3S_32_PGTABLE_H */
> diff --git a/arch/powerpc/include/asm/book3s/64/hash.h
> b/arch/powerpc/include/asm/book3s/64/hash.h
> index ced3aed63af2..1b27c0c8effa 100644
> --- a/arch/powerpc/include/asm/book3s/64/hash.h
> +++ b/arch/powerpc/include/asm/book3s/64/hash.h
> @@ -578,6 +578,11 @@ static inline pgprot_t pgprot_writecombine(pgprot_t
> prot)
>  extern pgprot_t vm_get_page_prot(unsigned long vm_flags);
>  #define vm_get_page_prot vm_get_page_prot
>
> +static inline unsigned long pte_io_cache_bits(void)
> +{
> + return _PAGE_NO_CACHE | _PAGE_GUARDED;
> +}
> +
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>  extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long
> addr,
>  pmd_t *pmdp, unsigned long old_pmd);
> diff --git a/arch/powerpc/include/asm/nohash/pgtable.h
> b/arch/powerpc/include/asm/nohash/pgtable.h
> index 11e3767216c0..8c4bb8fda0de 100644
> --- a/arch/powerpc/include/asm/nohash/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/pgtable.h
> @@ -224,6 +224,11 @@ extern pgprot_t phys_mem_access_prot(struct file *file,
> unsigned long pfn,
>unsigned long size, pgprot_t vma_prot);
>  #define __HAVE_PHYS_MEM_ACCESS_PROT
>
> +static inline unsigned long pte_io_cache_bits(void)
> +{
> + return _PAGE_NO_CACHE | _PAGE_GUARDED;
> +}
> +
>  #ifdef CONFIG_HUGETLB_PAGE
>  static inline int hugepd_ok(hugepd_t hpd)
>  {
> diff --git a/arch/powerpc/kernel/isa-bridge.c
> b/arch/powerpc/kernel/isa-bridge.c
> index 0f1997097960..d81185f025fa 100644
> --- a/arch/powerpc/kernel/isa-bridge.c
> +++ b/arch/powerpc/kernel/isa-bridge.c
> @@ -109,14 +109,14 @@ static void pci_process_ISA_OF_ranges(struct
> device_node *isa_node,
>   size = 0x1;
>
>   __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE,
> -  size, _PAGE_NO_CACHE|_PAGE_GUARDED);
> +  size, pte_io_cache_bits());
>   return;
>
>  inval_range:
>   printk(KERN_ERR "no ISA IO ranges or unexpected isa range, "
>  "mapping 64k\n");
>   __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE,
> -  0x1, _PAGE_NO_CACHE|_PAGE_GUARDED);
> +  0x1, pte_io_cache_bits());
>  }
>
>
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index 60bb187cb46a..7fe1dfd214a1 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -159,7 +159,7 @@ static int pcibios_map_phb_io_space(struct
> pci_controller *hose)
>
>   /* Establish the mapping */
>   if (__ioremap_at(phys_page, area->addr, size_page,
> -  _PAGE_NO_CACHE | _PAGE_GUARDED) == NULL)
> +  pte_io_cache_bits()) == NULL)
>   return -ENOMEM;
>
>   /* Fixup hose IO resource */
> diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
> index e5f600d19326..6d161cec2e32 100644
> --- a/arch/powerpc/mm/pgtable_64.c
> +++ b/arch/powerpc/mm/pgtable_64.c
> @@ -253,7 +253,7 @@ void __iomem * __ioremap(phys_addr_t addr, unsigned long
> size,
>
>  void __iomem * ioremap(phys_addr_t addr, unsigned long size)
>  {
> - unsigned long flags = _PAGE_NO_CACHE | _PAGE_GUARDED;
> + unsigned long flags = pte_io_cache_bits();
>   void *caller = __builtin_return_address(0);
>
>   if (ppc_md.ioremap)
> --
> 2.5.0
>
> ___
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH V1 14/33] powerpc/mm: Use helper for finding pte bits mapping I/O area

2016-01-11 Thread Aneesh Kumar K.V
We will have different values for hash and radix. Hence we
cannot use #define constants. Add helper

Signed-off-by: Aneesh Kumar K.V 
---
 arch/powerpc/include/asm/book3s/32/pgtable.h | 5 +
 arch/powerpc/include/asm/book3s/64/hash.h| 5 +
 arch/powerpc/include/asm/nohash/pgtable.h| 5 +
 arch/powerpc/kernel/isa-bridge.c | 4 ++--
 arch/powerpc/kernel/pci_64.c | 2 +-
 arch/powerpc/mm/pgtable_64.c | 2 +-
 6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h 
b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 3ed3303c1295..77adada2f3b4 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -478,6 +478,11 @@ static inline pgprot_t pgprot_writecombine(pgprot_t prot)
return pgprot_noncached_wc(prot);
 }
 
+static inline unsigned long pte_io_cache_bits(void)
+{
+   return _PAGE_NO_CACHE | _PAGE_GUARDED;
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /*  _ASM_POWERPC_BOOK3S_32_PGTABLE_H */
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h 
b/arch/powerpc/include/asm/book3s/64/hash.h
index ced3aed63af2..1b27c0c8effa 100644
--- a/arch/powerpc/include/asm/book3s/64/hash.h
+++ b/arch/powerpc/include/asm/book3s/64/hash.h
@@ -578,6 +578,11 @@ static inline pgprot_t pgprot_writecombine(pgprot_t prot)
 extern pgprot_t vm_get_page_prot(unsigned long vm_flags);
 #define vm_get_page_prot vm_get_page_prot
 
+static inline unsigned long pte_io_cache_bits(void)
+{
+   return _PAGE_NO_CACHE | _PAGE_GUARDED;
+}
+
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
   pmd_t *pmdp, unsigned long old_pmd);
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h 
b/arch/powerpc/include/asm/nohash/pgtable.h
index 11e3767216c0..8c4bb8fda0de 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -224,6 +224,11 @@ extern pgprot_t phys_mem_access_prot(struct file *file, 
unsigned long pfn,
 unsigned long size, pgprot_t vma_prot);
 #define __HAVE_PHYS_MEM_ACCESS_PROT
 
+static inline unsigned long pte_io_cache_bits(void)
+{
+   return _PAGE_NO_CACHE | _PAGE_GUARDED;
+}
+
 #ifdef CONFIG_HUGETLB_PAGE
 static inline int hugepd_ok(hugepd_t hpd)
 {
diff --git a/arch/powerpc/kernel/isa-bridge.c b/arch/powerpc/kernel/isa-bridge.c
index 0f1997097960..d81185f025fa 100644
--- a/arch/powerpc/kernel/isa-bridge.c
+++ b/arch/powerpc/kernel/isa-bridge.c
@@ -109,14 +109,14 @@ static void pci_process_ISA_OF_ranges(struct device_node 
*isa_node,
size = 0x1;
 
__ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE,
-size, _PAGE_NO_CACHE|_PAGE_GUARDED);
+size, pte_io_cache_bits());
return;
 
 inval_range:
printk(KERN_ERR "no ISA IO ranges or unexpected isa range, "
   "mapping 64k\n");
__ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE,
-0x1, _PAGE_NO_CACHE|_PAGE_GUARDED);
+0x1, pte_io_cache_bits());
 }
 
 
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 60bb187cb46a..7fe1dfd214a1 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -159,7 +159,7 @@ static int pcibios_map_phb_io_space(struct pci_controller 
*hose)
 
/* Establish the mapping */
if (__ioremap_at(phys_page, area->addr, size_page,
-_PAGE_NO_CACHE | _PAGE_GUARDED) == NULL)
+pte_io_cache_bits()) == NULL)
return -ENOMEM;
 
/* Fixup hose IO resource */
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index e5f600d19326..6d161cec2e32 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -253,7 +253,7 @@ void __iomem * __ioremap(phys_addr_t addr, unsigned long 
size,
 
 void __iomem * ioremap(phys_addr_t addr, unsigned long size)
 {
-   unsigned long flags = _PAGE_NO_CACHE | _PAGE_GUARDED;
+   unsigned long flags = pte_io_cache_bits();
void *caller = __builtin_return_address(0);
 
if (ppc_md.ioremap)
-- 
2.5.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev