Skip to contentSkip to conversation

xtensa: remove redundant flush_dcache_page and ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE macros

PATCH Applied Barry Song 3 participants 13 messages Mar 19, 2024 – Apr 29, 2024 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v2 1/1 xtensa: remove redundant flush_dcache_page and ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE macros

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

---
-v2: include asm-generic/cacheflush.h and remove lots of redundant macros

 arch/xtensa/include/asm/cacheflush.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/xtensa/include/asm/cacheflush.h +8 -16
index 38bcecb0e457..a2b6bb5429f5 100644
@@ -100,6 +100,10 @@ void flush_cache_range(struct vm_area_struct*, ulong, ulong);
 void flush_icache_range(unsigned long start, unsigned long end);
 void flush_cache_page(struct vm_area_struct*,
 			     unsigned long, unsigned long);
+#define flush_cache_all flush_cache_all
+#define flush_cache_range flush_cache_range
+#define flush_icache_range flush_icache_range
+#define flush_cache_page flush_cache_page
 #else
 #define flush_cache_all local_flush_cache_all
 #define flush_cache_range local_flush_cache_range
@@ -136,20 +140,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 
 #else
 
-#define flush_cache_all()				do { } while (0)
-#define flush_cache_mm(mm)				do { } while (0)
-#define flush_cache_dup_mm(mm)				do { } while (0)
-
-#define flush_cache_vmap(start,end)			do { } while (0)
-#define flush_cache_vmap_early(start,end)		do { } while (0)
-#define flush_cache_vunmap(start,end)			do { } while (0)
-
-#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)				do { } while (0)
-
 #define flush_icache_range local_flush_icache_range
-#define flush_cache_page(vma, addr, pfn)		do { } while (0)
-#define flush_cache_range(vma, start, end)		do { } while (0)
 
 #endif
 
@@ -162,15 +153,14 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 		__invalidate_icache_range(start,(end) - (start));	\
 	} while (0)
 
-#define flush_dcache_mmap_lock(mapping)			do { } while (0)
-#define flush_dcache_mmap_unlock(mapping)		do { } while (0)
-
 #if defined(CONFIG_MMU) && (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 extern void copy_to_user_page(struct vm_area_struct*, struct page*,
 		unsigned long, void*, const void*, unsigned long);
 extern void copy_from_user_page(struct vm_area_struct*, struct page*,
 		unsigned long, void*, const void*, unsigned long);
+#define copy_to_user_page copy_to_user_page
+#define copy_from_user_page copy_from_user_page
 
 #else
 
@@ -186,4 +176,6 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,
 
 #endif
 
+#include <asm-generic/cacheflush.h>
+
 #endif /* _XTENSA_CACHEFLUSH_H */
Signature · 1 line
2.34.1
author
#1 lore raw
Quoted 35 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 7 lines

Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:

(quoted diff) +0 -0

b/arch/xtensa/include/asm/cacheflush.h
index 38bcecb0e457..fdc692cf2b78 100644

arch/xtensa/include/asm/cacheflush.h +1 -1
@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 #define flush_cache_vunmap(start,end)                  do { } while (0)
 
 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)                                do { } while (0)
+#define flush_dcache_page(page)                                do {

(void)(page); } while (0)

#define flush_icache_range local_flush_icache_range
#define flush_cache_page(vma, addr, pfn) do { } while (0)

Quoted 71 lines
Fixes 77292bb8ca69 ("crypto: scomp - remove memcpy if sg_nents is 1 and pages are lowmem")

---
-v2: include asm-generic/cacheflush.h and remove lots of redundant macros

 arch/xtensa/include/asm/cacheflush.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/xtensa/include/asm/cacheflush.h +8 -17
index 38bcecb0e457..a2b6bb5429f5 100644
@@ -100,6 +100,10 @@ void flush_cache_range(struct vm_area_struct*, ulong, ulong);
 void flush_icache_range(unsigned long start, unsigned long end);
 void flush_cache_page(struct vm_area_struct*,
                             unsigned long, unsigned long);
+#define flush_cache_all flush_cache_all
+#define flush_cache_range flush_cache_range
+#define flush_icache_range flush_icache_range
+#define flush_cache_page flush_cache_page
 #else
 #define flush_cache_all local_flush_cache_all
 #define flush_cache_range local_flush_cache_range
@@ -136,20 +140,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 
 #else
 
-#define flush_cache_all()                              do { } while (0)
-#define flush_cache_mm(mm)                             do { } while (0)
-#define flush_cache_dup_mm(mm)                         do { } while (0)
-
-#define flush_cache_vmap(start,end)                    do { } while (0)
-#define flush_cache_vmap_early(start,end)              do { } while (0)
-#define flush_cache_vunmap(start,end)                  do { } while (0)
-
-#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)                                do { } while (0)
-
 #define flush_icache_range local_flush_icache_range
-#define flush_cache_page(vma, addr, pfn)               do { } while (0)
-#define flush_cache_range(vma, start, end)             do { } while (0)
 
 #endif
 
@@ -162,15 +153,14 @@ void local_flush_cache_page(struct vm_area_struct *vma,
                __invalidate_icache_range(start,(end) - (start));       \
        } while (0)
 
-#define flush_dcache_mmap_lock(mapping)                        do { } while (0)
-#define flush_dcache_mmap_unlock(mapping)              do { } while (0)
-
 #if defined(CONFIG_MMU) && (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 extern void copy_to_user_page(struct vm_area_struct*, struct page*,
                unsigned long, void*, const void*, unsigned long);
 extern void copy_from_user_page(struct vm_area_struct*, struct page*,
                unsigned long, void*, const void*, unsigned long);
+#define copy_to_user_page copy_to_user_page
+#define copy_from_user_page copy_from_user_page
 
 #else
 
@@ -186,4 +176,6 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,
 
 #endif
 
+#include <asm-generic/cacheflush.h>
+
 #endif /* _XTENSA_CACHEFLUSH_H */
--
Quoted 2 lines

2.34.1

Thanks
Barry

maintainer
#2 lore raw
Quoted 24 lines · Barry Song
Quoted 23 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

I wonder why this warning is considered useful in the first place? If I'm missing something and it's indeed useful, should there be a rule in the Documentation/process/coding-style.rst saying that function-like macros should evaluate all their arguments?

Quoted 22 lines
Quoted 10 lines

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:

arch/xtensa/include/asm/cacheflush.h +0 -0
index 38bcecb0e457..fdc692cf2b78 100644

arch/xtensa/include/asm/cacheflush.h void local_flush_cache_page(struct vm_area_struct *vma, · line 149

Quoted 6 lines
arch/xtensa/include/asm/cacheflush.h +1 -1
@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 #define flush_cache_vunmap(start,end)                  do { } while (0)
 
 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)                                do { } while (0)
+#define flush_dcache_page(page)                                do {
 (void)(page); } while (0)

This looks like a good fix, IMO better than adding __maybe_unused to the variables reported in the warnings.

Signature · 2 lines
Thanks.
-- Max
author
#3 lore raw
Quoted 27 lines · Max Filippov
Quoted 25 lines · Barry Song
Quoted 24 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

I wonder why this warning is considered useful in the first place?

Guenter reported it as an error not a warning
"

Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page'"

is it because xtensa's toolchain is different with others?

Quoted 28 lines

If I'm missing something and it's indeed useful, should there be a rule in the Documentation/process/coding-style.rst saying that function-like macros should evaluate all their arguments?

Quoted 24 lines
Quoted 10 lines

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)
fix, a minimal fix might be:

arch/xtensa/include/asm/cacheflush.h +0 -0
index 38bcecb0e457..fdc692cf2b78 100644
@@ -145,7 +145,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
 #define flush_cache_vunmap(start,end)                  do { } while (0)
 
Quoted 7 lines

arch/xtensa/include/asm/cacheflush.h void local_flush_cache_page(struct vm_area_struct *vma,

Quoted 4 lines
arch/xtensa/include/asm/cacheflush.h +1 -1
 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)                                do { } while (0)
+#define flush_dcache_page(page)                                do {
 (void)(page); } while (0)

This looks like a good fix, IMO better than adding __maybe_unused to the variables reported in the warnings.

i don't like adding __maybe_unused either as it is not the fault of the drivers calling flush_dcache_page().

Quoted 4 lines

--
Thanks.
-- Max

#4 lore raw
Quoted 37 lines · Barry Song
Quoted 27 lines · Max Filippov
Quoted 25 lines · Barry Song
Quoted 24 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

  #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  #endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
      174 |                         struct page *dst_page = sg_page(req->dst);
          |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

I wonder why this warning is considered useful in the first place?

Quoted 9 lines

Guenter reported it as an error not a warning
"

Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page'"

is it because xtensa's toolchain is different with others?

It is because -Werror is now default in allmodconfig builds. Other test build systems may manually override that.

Guenter

#5 lore raw
In reply to Barry Song
Quoted 44 lines · Barry Song
Quoted 35 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

  #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  #endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

      174 |                         struct page *dst_page = sg_page(req->dst);
          |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 7 lines
Quoted 3 lines

Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)

I sent a Tested-by: tag to your patch. As far as my testing goes, it works fine, and I added your patch to my "testing" branch (which tries to be buildable and testable for all architectures).

Quoted 2 lines

fix, a minimal fix might be:

FWIW, I think a minimal fix would have been to mark the variable as __maybe_unused, but as others have pointed out it would be nice if there would be a guidance about optional API functions like this one that specifies if it may be implemented as macro and, if so, how it has to handle unused variables.

Thanks,
Guenter

author
#6 lore raw
Quoted 46 lines · Guenter Roeck
Quoted 44 lines · Barry Song
Quoted 42 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

  #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  #endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

      174 |                         struct page *dst_page = sg_page(req->dst);
          |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 7 lines
Quoted 3 lines

Hi Guenter,
I am not a xtensa guy, so I will need your help for a full test. if turns out it is a too big(ambitious)

I sent a Tested-by: tag to your patch. As far as my testing goes, it works fine, and I added your patch to my "testing" branch (which tries to be buildable and testable for all architectures).

Thank you very much, Guenter. It would be nice if xtensa can leverage the common cacheflush.h just like other architectures.

Quoted 5 lines
Quoted 3 lines

fix, a minimal fix might be:

FWIW, I think a minimal fix would have been to mark the variable as __maybe_unused,

I am not quite sure we want this as the point is that drivers should be independent of
architectural differences.

The driver code, for itself, seems quite innocent,

struct page *dst_page = sg_page(req->dst);

for (i = 0; i < nr_pages; i++)

            flush_dcache_page(dst_page + i);

The only problem is that xtensa's flush_dcache_page is a macro and doesn't use the "page"
parameter.
if we re-use the inline function in common cacheflush.h, it won't be a problem.

Quoted 3 lines

but as others have pointed out it would be nice if there would be a guidance about optional API functions like this one that specifies if it may be implemented as macro and, if so, how it has to handle unused variables.

I agree. personally I like this and will have a go in Documentation/process/coding-style.rst
and see others' opinions.

Quoted 3 lines

Thanks,
Guenter

Thanks
Barry

Tested-by on v2 1/1
#7 lore raw
In reply to Barry Song
Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

Guenter

#8 lore raw
In reply to Barry Song

Hi,

Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

The mainline kernel still fails to build xtensa:allmodconfig.

Building xtensa:allmodconfig ... failed
--------------
Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);

This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?

Thanks,
Guenter

author
#9 lore raw
Quoted 58 lines · Guenter Roeck

Hi,

Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

The mainline kernel still fails to build xtensa:allmodconfig.

Building xtensa:allmodconfig ... failed
--------------
Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);

Quoted 2 lines

This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?

I'd prefer this can be applied upstream.

Hi Andrew, would you like to pull it?

Quoted 3 lines

Thanks,
Guenter

Thanks
Barry

maintainer Applied
#10 lore raw
In reply to Guenter Roeck
Quoted 58 lines · Guenter Roeck

Hi,

Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

The mainline kernel still fails to build xtensa:allmodconfig.

Building xtensa:allmodconfig ... failed
--------------
Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);

Quoted 2 lines

This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?

Applied to my xtensa tree.
I was still hoping to see rationale for why this is a useful warning.

Signature · 2 lines
Thanks.
-- Max
author
#11 lore raw
Quoted 60 lines · Max Filippov
Quoted 58 lines · Guenter Roeck

Hi,

Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]

      76 |                 struct page *page;
         |                              ^~~~

crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

     174 |                         struct page *dst_page = sg_page(req->dst);
         |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

The mainline kernel still fails to build xtensa:allmodconfig.

Building xtensa:allmodconfig ... failed
--------------
Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);

Quoted 4 lines
Quoted 2 lines

This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?

Applied to my xtensa tree.

Thanks for taking care of this, Max!

Quoted 1 line

I was still hoping to see rationale for why this is a useful warning.

Personally, I think the reason is quite obvious.

This warning serves as a valuable alert, highlighting an issue where Xtensa fails to properly implement flush_dcache_page(). The problem lies in a macro definition that neglects to evaluate its argument. Such discrepancies can impact driver functionality across various architectures, rendering them independent of specific architectural considerations.

Quoted 4 lines

--
Thanks.
-- Max

Thanks
Barry

#12 lore raw
In reply to Max Filippov
Quoted 59 lines · Max Filippov
Quoted 58 lines · Guenter Roeck

Hi,

Quoted 34 lines · Barry Song

From: Barry Song <[email protected]>

xtensa's flush_dcache_page() can be a no-op sometimes. There is a generic implementation for this case in include/asm-generic/ cacheflush.h.
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
static inline void flush_dcache_page(struct page *page) {
}

  #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  #endif

So remove the superfluous flush_dcache_page() definition, which also helps silence potential build warnings complaining the page variable passed to flush_dcache_page() is not used.

In file included from crypto/scompress.c:12:
include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
76 | struct page *page;
| ^~~~
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':

Quoted 1 line
Quoted 1 line

crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]

      174 |                         struct page *dst_page = sg_page(req->dst);
          |

The issue was originally reported on LoongArch by kernel test robot (Huacai fixed it on LoongArch), then reported by Guenter and me on xtensa.

This patch also removes lots of redundant macros which have been defined by asm-generic/cacheflush.h.

Quoted 10 lines

The mainline kernel still fails to build xtensa:allmodconfig.

Building xtensa:allmodconfig ... failed
--------------
Error log:
crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
crypto/scompress.c:174:38: error: unused variable 'dst_page' [-Werror=unused-variable]
174 | struct page *dst_page = sg_page(req->dst);

Quoted 6 lines
Quoted 2 lines

This patch fixes the problem. Is there a chance to get it applied to the upstream kernel, or should I just stop build testing xtensa:allmodconfig ?

Applied to my xtensa tree.
I was still hoping to see rationale for why this is a useful warning.

Useful in general or here ? In general it helps a lot to identify unnecessary or buggy code, and I think it is very useful. In this case, the other option would have been to declare the variable as __maybe_unused. I think that has been discussed. Personally I preferred the more comprehensive patch because it makes the code more generic, but at this point in the release cycle I really only want to know what to do with xtensa:allmodconfig test builds.

Thanks,
Guenter