Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread kbuild test robot
Hi Chintan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.16-rc7]
[also build test WARNING on next-20180328]
[cannot apply to arm64/for-next/core tip/x86/core asm-generic/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Chintan-Pandya/Fix-issues-with-huge-mapping-in-ioremap-for-ARM64/20180328-192254
config: x86_64-randconfig-x019-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c: In function 'pud_free_pmd_page':
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
  __r = !!(cond); \
   ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^

vim +/if +725 arch/x86//mm/pgtable.c

b6bdb751 Toshi Kani 2018-03-22  705  
b6bdb751 Toshi Kani 2018-03-22  706  /**
b6bdb751 Toshi Kani 2018-03-22  707   * pud_free_pmd_page - Clear pud entry 
and free pmd page.
b6bdb751 Toshi Kani 2018-03-22  708   * @pud: Pointer to a PUD.
5b7ee34c Chintan Pandya 2018-03-27  709   * @addr: Virtual address associated 
with pud.
b6bdb751 Toshi Kani 2018-03-22  710   *
b6bdb751 Toshi Kani 2018-03-22  711   * Context: The pud range has been 
unmaped and TLB purged.
b6bdb751 Toshi Kani 2018-03-22  712   * Return: 1 if clearing the entry 
succeeded. 0 otherwise.
b6bdb751 Toshi Kani 2018-03-22  713   */
5b7ee34c Chintan Pandya 2018-03-27  714  int pud_free_pmd_page(pud_t *pud, 
unsigned long addr)
b6bdb751 Toshi Kani 2018-03-22  715  {
28ee90fe Toshi Kani 2018-03-22  716 pmd_t *pmd;
28ee90fe Toshi Kani 2018-03-22  717 int i;
28ee90fe Toshi Kani 2018-03-22  718  
28ee90fe Toshi Kani 

Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread kbuild test robot
Hi Chintan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.16-rc7]
[also build test WARNING on next-20180328]
[cannot apply to arm64/for-next/core tip/x86/core asm-generic/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Chintan-Pandya/Fix-issues-with-huge-mapping-in-ioremap-for-ARM64/20180328-192254
config: x86_64-randconfig-x019-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c: In function 'pud_free_pmd_page':
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from arch/x86//mm/pgtable.c:2:
   arch/x86//mm/pgtable.c:725:8: error: too few arguments to function 
'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
  __r = !!(cond); \
   ^~~~
>> arch/x86//mm/pgtable.c:725:3: note: in expansion of macro 'if'
  if (!pmd_free_pte_page([i]))
  ^~
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86//mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^

vim +/if +725 arch/x86//mm/pgtable.c

b6bdb751 Toshi Kani 2018-03-22  705  
b6bdb751 Toshi Kani 2018-03-22  706  /**
b6bdb751 Toshi Kani 2018-03-22  707   * pud_free_pmd_page - Clear pud entry 
and free pmd page.
b6bdb751 Toshi Kani 2018-03-22  708   * @pud: Pointer to a PUD.
5b7ee34c Chintan Pandya 2018-03-27  709   * @addr: Virtual address associated 
with pud.
b6bdb751 Toshi Kani 2018-03-22  710   *
b6bdb751 Toshi Kani 2018-03-22  711   * Context: The pud range has been 
unmaped and TLB purged.
b6bdb751 Toshi Kani 2018-03-22  712   * Return: 1 if clearing the entry 
succeeded. 0 otherwise.
b6bdb751 Toshi Kani 2018-03-22  713   */
5b7ee34c Chintan Pandya 2018-03-27  714  int pud_free_pmd_page(pud_t *pud, 
unsigned long addr)
b6bdb751 Toshi Kani 2018-03-22  715  {
28ee90fe Toshi Kani 2018-03-22  716 pmd_t *pmd;
28ee90fe Toshi Kani 2018-03-22  717 int i;
28ee90fe Toshi Kani 2018-03-22  718  
28ee90fe Toshi Kani 

Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread Chintan Pandya



On 3/28/2018 5:20 PM, kbuild test robot wrote:

  @725  if (!pmd_free_pte_page([i]))

My bad ! Will fix this in v7

Chintan
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation
Collaborative Project


Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread Chintan Pandya



On 3/28/2018 5:20 PM, kbuild test robot wrote:

  @725  if (!pmd_free_pte_page([i]))

My bad ! Will fix this in v7

Chintan
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation
Collaborative Project


Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread kbuild test robot
Hi Chintan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[also build test ERROR on next-20180328]
[cannot apply to arm64/for-next/core tip/x86/core asm-generic/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Chintan-Pandya/Fix-issues-with-huge-mapping-in-ioremap-for-ARM64/20180328-192254
config: i386-randconfig-x014-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/mm/pgtable.c: In function 'pud_free_pmd_page':
>> arch/x86/mm/pgtable.c:725:8: error: too few arguments to function 
>> 'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86/mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^

vim +/pmd_free_pte_page +725 arch/x86/mm/pgtable.c

b6bdb751 Toshi Kani 2018-03-22  705  
b6bdb751 Toshi Kani 2018-03-22  706  /**
b6bdb751 Toshi Kani 2018-03-22  707   * pud_free_pmd_page - Clear pud entry 
and free pmd page.
b6bdb751 Toshi Kani 2018-03-22  708   * @pud: Pointer to a PUD.
5b7ee34c Chintan Pandya 2018-03-27  709   * @addr: Virtual address associated 
with pud.
b6bdb751 Toshi Kani 2018-03-22  710   *
b6bdb751 Toshi Kani 2018-03-22  711   * Context: The pud range has been 
unmaped and TLB purged.
b6bdb751 Toshi Kani 2018-03-22  712   * Return: 1 if clearing the entry 
succeeded. 0 otherwise.
b6bdb751 Toshi Kani 2018-03-22  713   */
5b7ee34c Chintan Pandya 2018-03-27  714  int pud_free_pmd_page(pud_t *pud, 
unsigned long addr)
b6bdb751 Toshi Kani 2018-03-22  715  {
28ee90fe Toshi Kani 2018-03-22  716 pmd_t *pmd;
28ee90fe Toshi Kani 2018-03-22  717 int i;
28ee90fe Toshi Kani 2018-03-22  718  
28ee90fe Toshi Kani 2018-03-22  719 if (pud_none(*pud))
28ee90fe Toshi Kani 2018-03-22  720 return 1;
28ee90fe Toshi Kani 2018-03-22  721  
28ee90fe Toshi Kani 2018-03-22  722 pmd = (pmd_t 
*)pud_page_vaddr(*pud);
28ee90fe Toshi Kani 2018-03-22  723  
28ee90fe Toshi Kani 2018-03-22  724 for (i = 0; i < PTRS_PER_PMD; 
i++)
28ee90fe Toshi Kani 2018-03-22 @725 if 
(!pmd_free_pte_page([i]))
28ee90fe Toshi Kani 2018-03-22  726 return 0;
28ee90fe Toshi Kani 2018-03-22  727  
28ee90fe Toshi Kani 2018-03-22  728 pud_clear(pud);
28ee90fe Toshi Kani 2018-03-22  729 free_page((unsigned long)pmd);
28ee90fe Toshi Kani 2018-03-22  730  
28ee90fe Toshi Kani 2018-03-22  731 return 1;
b6bdb751 Toshi Kani 2018-03-22  732  }
b6bdb751 Toshi Kani 2018-03-22  733  

:: The code at line 725 was first introduced by commit
:: 28ee90fe6048fa7b7ceaeb8831c0e4e454a4cf89 x86/mm: implement free pmd/pte 
page interfaces

:: TO: Toshi Kani 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-28 Thread kbuild test robot
Hi Chintan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[also build test ERROR on next-20180328]
[cannot apply to arm64/for-next/core tip/x86/core asm-generic/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Chintan-Pandya/Fix-issues-with-huge-mapping-in-ioremap-for-ARM64/20180328-192254
config: i386-randconfig-x014-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/mm/pgtable.c: In function 'pud_free_pmd_page':
>> arch/x86/mm/pgtable.c:725:8: error: too few arguments to function 
>> 'pmd_free_pte_page'
  if (!pmd_free_pte_page([i]))
   ^
   In file included from arch/x86/include/asm/pgtable.h:1292:0,
from include/linux/memremap.h:8,
from include/linux/mm.h:27,
from arch/x86/mm/pgtable.c:2:
   include/asm-generic/pgtable.h:987:5: note: declared here
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
^

vim +/pmd_free_pte_page +725 arch/x86/mm/pgtable.c

b6bdb751 Toshi Kani 2018-03-22  705  
b6bdb751 Toshi Kani 2018-03-22  706  /**
b6bdb751 Toshi Kani 2018-03-22  707   * pud_free_pmd_page - Clear pud entry 
and free pmd page.
b6bdb751 Toshi Kani 2018-03-22  708   * @pud: Pointer to a PUD.
5b7ee34c Chintan Pandya 2018-03-27  709   * @addr: Virtual address associated 
with pud.
b6bdb751 Toshi Kani 2018-03-22  710   *
b6bdb751 Toshi Kani 2018-03-22  711   * Context: The pud range has been 
unmaped and TLB purged.
b6bdb751 Toshi Kani 2018-03-22  712   * Return: 1 if clearing the entry 
succeeded. 0 otherwise.
b6bdb751 Toshi Kani 2018-03-22  713   */
5b7ee34c Chintan Pandya 2018-03-27  714  int pud_free_pmd_page(pud_t *pud, 
unsigned long addr)
b6bdb751 Toshi Kani 2018-03-22  715  {
28ee90fe Toshi Kani 2018-03-22  716 pmd_t *pmd;
28ee90fe Toshi Kani 2018-03-22  717 int i;
28ee90fe Toshi Kani 2018-03-22  718  
28ee90fe Toshi Kani 2018-03-22  719 if (pud_none(*pud))
28ee90fe Toshi Kani 2018-03-22  720 return 1;
28ee90fe Toshi Kani 2018-03-22  721  
28ee90fe Toshi Kani 2018-03-22  722 pmd = (pmd_t 
*)pud_page_vaddr(*pud);
28ee90fe Toshi Kani 2018-03-22  723  
28ee90fe Toshi Kani 2018-03-22  724 for (i = 0; i < PTRS_PER_PMD; 
i++)
28ee90fe Toshi Kani 2018-03-22 @725 if 
(!pmd_free_pte_page([i]))
28ee90fe Toshi Kani 2018-03-22  726 return 0;
28ee90fe Toshi Kani 2018-03-22  727  
28ee90fe Toshi Kani 2018-03-22  728 pud_clear(pud);
28ee90fe Toshi Kani 2018-03-22  729 free_page((unsigned long)pmd);
28ee90fe Toshi Kani 2018-03-22  730  
28ee90fe Toshi Kani 2018-03-22  731 return 1;
b6bdb751 Toshi Kani 2018-03-22  732  }
b6bdb751 Toshi Kani 2018-03-22  733  

:: The code at line 725 was first introduced by commit
:: 28ee90fe6048fa7b7ceaeb8831c0e4e454a4cf89 x86/mm: implement free pmd/pte 
page interfaces

:: TO: Toshi Kani 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-27 Thread Chintan Pandya
This patch ("mm/vmalloc: Add interfaces to free unmapped
page table") adds following 2 interfaces to free the page
table in case we implement huge mapping.

pud_free_pmd_page() and pmd_free_pte_page()

Some architectures (like arm64) needs to do proper TLB
maintanance after updating pagetable entry even in map.
Why ? Read this,
https://patchwork.kernel.org/patch/10134581/

Pass 'addr' in these interfaces so that proper TLB ops
can be performed.

Signed-off-by: Chintan Pandya 
---
No change in v5.

 arch/arm64/mm/mmu.c   | 4 ++--
 arch/x86/mm/pgtable.c | 6 --
 include/asm-generic/pgtable.h | 8 
 lib/ioremap.c | 4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 2dbb2c9..da98828 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -973,12 +973,12 @@ int pmd_clear_huge(pmd_t *pmdp)
return 1;
 }
 
-int pud_free_pmd_page(pud_t *pud)
+int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
return pud_none(*pud);
 }
 
-int pmd_free_pte_page(pmd_t *pmd)
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
return pmd_none(*pmd);
 }
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 34cda7e..f640ba3 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -706,11 +706,12 @@ int pmd_clear_huge(pmd_t *pmd)
 /**
  * pud_free_pmd_page - Clear pud entry and free pmd page.
  * @pud: Pointer to a PUD.
+ * @addr: Virtual address associated with pud.
  *
  * Context: The pud range has been unmaped and TLB purged.
  * Return: 1 if clearing the entry succeeded. 0 otherwise.
  */
-int pud_free_pmd_page(pud_t *pud)
+int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
pmd_t *pmd;
int i;
@@ -733,11 +734,12 @@ int pud_free_pmd_page(pud_t *pud)
 /**
  * pmd_free_pte_page - Clear pmd entry and free pte page.
  * @pmd: Pointer to a PMD.
+ * @addr: Virtual address associated with pmd.
  *
  * Context: The pmd range has been unmaped and TLB purged.
  * Return: 1 if clearing the entry succeeded. 0 otherwise.
  */
-int pmd_free_pte_page(pmd_t *pmd)
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
pte_t *pte;
 
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index bfbb44a..e6310f4 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -983,8 +983,8 @@ static inline int p4d_clear_huge(p4d_t *p4d)
 int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
 int pud_clear_huge(pud_t *pud);
 int pmd_clear_huge(pmd_t *pmd);
-int pud_free_pmd_page(pud_t *pud);
-int pmd_free_pte_page(pmd_t *pmd);
+int pud_free_pmd_page(pud_t *pud, unsigned long addr);
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
 #else  /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
 static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot)
 {
@@ -1010,11 +1010,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
 {
return 0;
 }
-static inline int pud_free_pmd_page(pud_t *pud)
+static inline int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
return 0;
 }
-static inline int pmd_free_pte_page(pmd_t *pmd)
+static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
return 0;
 }
diff --git a/lib/ioremap.c b/lib/ioremap.c
index 54e5bba..517f585 100644
--- a/lib/ioremap.c
+++ b/lib/ioremap.c
@@ -92,7 +92,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long 
addr,
if (ioremap_pmd_enabled() &&
((next - addr) == PMD_SIZE) &&
IS_ALIGNED(phys_addr + addr, PMD_SIZE) &&
-   pmd_free_pte_page(pmd)) {
+   pmd_free_pte_page(pmd, addr)) {
if (pmd_set_huge(pmd, phys_addr + addr, prot))
continue;
}
@@ -119,7 +119,7 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned 
long addr,
if (ioremap_pud_enabled() &&
((next - addr) == PUD_SIZE) &&
IS_ALIGNED(phys_addr + addr, PUD_SIZE) &&
-   pud_free_pmd_page(pud)) {
+   pud_free_pmd_page(pud, addr)) {
if (pud_set_huge(pud, phys_addr + addr, prot))
continue;
}
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation
Center, Inc., is a member of Code Aurora Forum, a Linux Foundation
Collaborative Project



[PATCH v5 1/4] ioremap: Update pgtable free interfaces with addr

2018-03-27 Thread Chintan Pandya
This patch ("mm/vmalloc: Add interfaces to free unmapped
page table") adds following 2 interfaces to free the page
table in case we implement huge mapping.

pud_free_pmd_page() and pmd_free_pte_page()

Some architectures (like arm64) needs to do proper TLB
maintanance after updating pagetable entry even in map.
Why ? Read this,
https://patchwork.kernel.org/patch/10134581/

Pass 'addr' in these interfaces so that proper TLB ops
can be performed.

Signed-off-by: Chintan Pandya 
---
No change in v5.

 arch/arm64/mm/mmu.c   | 4 ++--
 arch/x86/mm/pgtable.c | 6 --
 include/asm-generic/pgtable.h | 8 
 lib/ioremap.c | 4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 2dbb2c9..da98828 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -973,12 +973,12 @@ int pmd_clear_huge(pmd_t *pmdp)
return 1;
 }
 
-int pud_free_pmd_page(pud_t *pud)
+int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
return pud_none(*pud);
 }
 
-int pmd_free_pte_page(pmd_t *pmd)
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
return pmd_none(*pmd);
 }
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 34cda7e..f640ba3 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -706,11 +706,12 @@ int pmd_clear_huge(pmd_t *pmd)
 /**
  * pud_free_pmd_page - Clear pud entry and free pmd page.
  * @pud: Pointer to a PUD.
+ * @addr: Virtual address associated with pud.
  *
  * Context: The pud range has been unmaped and TLB purged.
  * Return: 1 if clearing the entry succeeded. 0 otherwise.
  */
-int pud_free_pmd_page(pud_t *pud)
+int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
pmd_t *pmd;
int i;
@@ -733,11 +734,12 @@ int pud_free_pmd_page(pud_t *pud)
 /**
  * pmd_free_pte_page - Clear pmd entry and free pte page.
  * @pmd: Pointer to a PMD.
+ * @addr: Virtual address associated with pmd.
  *
  * Context: The pmd range has been unmaped and TLB purged.
  * Return: 1 if clearing the entry succeeded. 0 otherwise.
  */
-int pmd_free_pte_page(pmd_t *pmd)
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
pte_t *pte;
 
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index bfbb44a..e6310f4 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -983,8 +983,8 @@ static inline int p4d_clear_huge(p4d_t *p4d)
 int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
 int pud_clear_huge(pud_t *pud);
 int pmd_clear_huge(pmd_t *pmd);
-int pud_free_pmd_page(pud_t *pud);
-int pmd_free_pte_page(pmd_t *pmd);
+int pud_free_pmd_page(pud_t *pud, unsigned long addr);
+int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
 #else  /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
 static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot)
 {
@@ -1010,11 +1010,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
 {
return 0;
 }
-static inline int pud_free_pmd_page(pud_t *pud)
+static inline int pud_free_pmd_page(pud_t *pud, unsigned long addr)
 {
return 0;
 }
-static inline int pmd_free_pte_page(pmd_t *pmd)
+static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 {
return 0;
 }
diff --git a/lib/ioremap.c b/lib/ioremap.c
index 54e5bba..517f585 100644
--- a/lib/ioremap.c
+++ b/lib/ioremap.c
@@ -92,7 +92,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long 
addr,
if (ioremap_pmd_enabled() &&
((next - addr) == PMD_SIZE) &&
IS_ALIGNED(phys_addr + addr, PMD_SIZE) &&
-   pmd_free_pte_page(pmd)) {
+   pmd_free_pte_page(pmd, addr)) {
if (pmd_set_huge(pmd, phys_addr + addr, prot))
continue;
}
@@ -119,7 +119,7 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned 
long addr,
if (ioremap_pud_enabled() &&
((next - addr) == PUD_SIZE) &&
IS_ALIGNED(phys_addr + addr, PUD_SIZE) &&
-   pud_free_pmd_page(pud)) {
+   pud_free_pmd_page(pud, addr)) {
if (pud_set_huge(pud, phys_addr + addr, prot))
continue;
}
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation
Center, Inc., is a member of Code Aurora Forum, a Linux Foundation
Collaborative Project