* [PATCH v4 2/5] powerpc/vdso: Rework VDSO32 makefile to add a prefix to object files
From: Christophe Leroy @ 2022-01-21 16:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
masahiroy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <c2cbb8f046b7efc251053521dc39b752795e26b7.1642782130.git.christophe.leroy@csgroup.eu>
In order to merge vdso32 and vdso64 build in following patch, rework
Makefile is order to add -32 suffix to VDSO32 object files.
Also change sigtramp.S to sigtramp32.S as VDSO64 sigtramp.S is too
different to be squashed into VDSO32 sigtramp.S at the first place.
gen_vdso_offsets.sh also becomes gen_vdso32_offsets.sh
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/kernel/vdso32/Makefile | 47 +++++++++----------
..._vdso_offsets.sh => gen_vdso32_offsets.sh} | 0
.../vdso32/{sigtramp.S => sigtramp32.S} | 0
3 files changed, 21 insertions(+), 26 deletions(-)
rename arch/powerpc/kernel/vdso32/{gen_vdso_offsets.sh => gen_vdso32_offsets.sh} (100%)
rename arch/powerpc/kernel/vdso32/{sigtramp.S => sigtramp32.S} (100%)
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index 7d9a6fee0e3d..7d7b38d90ca5 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -5,15 +5,16 @@
ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
include $(srctree)/lib/vdso/Makefile
-obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
+obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
ifneq ($(c-gettimeofday-y),)
- CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
- CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
- CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector)
- CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING
- CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables
- CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
+ CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y)
+ CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
+ CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector)
+ CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING
+ CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
+ CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
+ CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
endif
# Build rules
@@ -24,13 +25,7 @@ else
VDSOCC := $(CC)
endif
-CC32FLAGS :=
-ifdef CONFIG_PPC64
-CC32FLAGS += -m32
-KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc,$(KBUILD_CFLAGS))
-endif
-
-targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o
+targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o
obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
GCOV_PROFILE := n
@@ -38,36 +33,36 @@ KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
-ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
- -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
-asflags-y := -D__VDSO32__ -s
+ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
+
+CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
+AS32FLAGS := -D__VDSO32__ -s
-obj-y += vdso32_wrapper.o
targets += vdso32.lds
CPPFLAGS_vdso32.lds += -P -C -Upowerpc
# link rule for the .so file, .lds has to be first
-$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE
+$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE
$(call if_changed,vdso32ld_and_check)
# assembly rules for the .S files
-$(obj-vdso32): %.o: %.S FORCE
+$(obj-vdso32): %-32.o: %.S FORCE
$(call if_changed_dep,vdso32as)
-$(obj)/vgettimeofday.o: %.o: %.c FORCE
+$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE
$(call if_changed_dep,vdso32cc)
# Generate VDSO offsets using helper script
-gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
-quiet_cmd_vdsosym = VDSOSYM $@
- cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
+gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh
+quiet_cmd_vdso32sym = VDSO32SYM $@
+ cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@
include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
- $(call if_changed,vdsosym)
+ $(call if_changed,vdso32sym)
# actual build commands
quiet_cmd_vdso32ld_and_check = VDSO32L $@
cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
quiet_cmd_vdso32as = VDSO32A $@
- cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
+ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
quiet_cmd_vdso32cc = VDSO32C $@
cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
diff --git a/arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh b/arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh
similarity index 100%
rename from arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh
rename to arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh
diff --git a/arch/powerpc/kernel/vdso32/sigtramp.S b/arch/powerpc/kernel/vdso32/sigtramp32.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/sigtramp.S
rename to arch/powerpc/kernel/vdso32/sigtramp32.S
--
2.33.1
^ permalink raw reply related
* [PATCH v4 1/5] powerpc/vdso: augment VDSO32 functions to support 64 bits build
From: Christophe Leroy @ 2022-01-21 16:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
masahiroy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
VDSO64 cacheflush.S datapage.S gettimeofday.S and vgettimeofday.c
are very similar to their VDSO32 counterpart.
VDSO32 counterpart is already more complete than the VDSO64 version
as it supports both PPC32 vdso and 32 bits VDSO for PPC64.
Use compat macros wherever necessary in PPC32 files
so that they can also be used to build VDSO64.
vdso64/note.S is already a link to vdso32/note.S so
no change is required.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/asm-compat.h | 2 ++
arch/powerpc/kernel/vdso32/cacheflush.S | 4 ++--
arch/powerpc/kernel/vdso32/datapage.S | 10 ++++++++--
arch/powerpc/kernel/vdso32/getcpu.S | 4 ++--
arch/powerpc/kernel/vdso32/gettimeofday.S | 8 ++++++--
arch/powerpc/kernel/vdso32/vgettimeofday.c | 23 ++++++++++++++++++----
6 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 2b736d9fbb1b..2bc53c646ccd 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -21,6 +21,7 @@
#define PPC_STLCX stringify_in_c(stdcx.)
#define PPC_CNTLZL stringify_in_c(cntlzd)
#define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
+#define PPC_SRL stringify_in_c(srd)
#define PPC_LR_STKOFF 16
#define PPC_MIN_STKFRM 112
@@ -54,6 +55,7 @@
#define PPC_STLCX stringify_in_c(stwcx.)
#define PPC_CNTLZL stringify_in_c(cntlzw)
#define PPC_MTOCRF stringify_in_c(mtcrf)
+#define PPC_SRL stringify_in_c(srw)
#define PPC_LR_STKOFF 4
#define PPC_MIN_STKFRM 16
diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso32/cacheflush.S
index f340e82d1981..d4e43ab2d5df 100644
--- a/arch/powerpc/kernel/vdso32/cacheflush.S
+++ b/arch/powerpc/kernel/vdso32/cacheflush.S
@@ -46,7 +46,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
add r8,r8,r5 /* ensure we get enough */
#ifdef CONFIG_PPC64
lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
- srw. r8,r8,r9 /* compute line count */
+ PPC_SRL. r8,r8,r9 /* compute line count */
#else
srwi. r8, r8, L1_CACHE_SHIFT
mr r7, r6
@@ -72,7 +72,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
subf r8,r6,r4 /* compute length */
add r8,r8,r5
lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
- srw. r8,r8,r9 /* compute line count */
+ PPC_SRL. r8,r8,r9 /* compute line count */
crclr cr0*4+so
beqlr /* nothing to do? */
#endif
diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S
index 65244416ab94..db8e167f0166 100644
--- a/arch/powerpc/kernel/vdso32/datapage.S
+++ b/arch/powerpc/kernel/vdso32/datapage.S
@@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map)
mr. r4,r3
get_datapage r3
mtlr r12
+#ifdef __powerpc64__
+ addi r3,r3,CFG_SYSCALL_MAP64
+#else
addi r3,r3,CFG_SYSCALL_MAP32
+#endif
+ crclr cr0*4+so
beqlr
li r0,NR_syscalls
stw r0,0(r4)
- crclr cr0*4+so
blr
.cfi_endproc
V_FUNCTION_END(__kernel_get_syscall_map)
@@ -49,8 +53,10 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq)
mflr r12
.cfi_register lr,r12
get_datapage r3
+#ifndef __powerpc64__
lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3)
- lwz r3,CFG_TB_TICKS_PER_SEC(r3)
+#endif
+ PPC_LL r3,CFG_TB_TICKS_PER_SEC(r3)
mtlr r12
crclr cr0*4+so
blr
diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso32/getcpu.S
index ff5e214fec41..8e08ccf19062 100644
--- a/arch/powerpc/kernel/vdso32/getcpu.S
+++ b/arch/powerpc/kernel/vdso32/getcpu.S
@@ -19,8 +19,8 @@
V_FUNCTION_BEGIN(__kernel_getcpu)
.cfi_startproc
mfspr r5,SPRN_SPRG_VDSO_READ
- cmpwi cr0,r3,0
- cmpwi cr1,r4,0
+ PPC_LCMPI cr0,r3,0
+ PPC_LCMPI cr1,r4,0
clrlwi r6,r5,16
rlwinm r7,r5,16,31-15,31-0
beq cr0,1f
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
index d21d08140a5e..c875312274aa 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
- * Userland implementation of gettimeofday() for 32 bits processes in a
- * ppc64 kernel for use in the vDSO
+ * Userland implementation of gettimeofday() for processes
+ * for use in the vDSO
*
* Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org,
* IBM Corp.
@@ -41,9 +41,11 @@ V_FUNCTION_END(__kernel_clock_gettime)
* int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
*
*/
+#ifndef __powerpc64__
V_FUNCTION_BEGIN(__kernel_clock_gettime64)
cvdso_call __c_kernel_clock_gettime64
V_FUNCTION_END(__kernel_clock_gettime64)
+#endif
/*
* Exact prototype of clock_getres()
@@ -69,6 +71,7 @@ V_FUNCTION_END(__kernel_time)
/* Routines for restoring integer registers, called by the compiler. */
/* Called with r11 pointing to the stack header word of the caller of the */
/* function, just beyond the end of the integer restore area. */
+#ifndef __powerpc64__
_GLOBAL(_restgpr_31_x)
_GLOBAL(_rest32gpr_31_x)
lwz r0,4(r11)
@@ -76,3 +79,4 @@ _GLOBAL(_rest32gpr_31_x)
mtlr r0
mr r1,r11
blr
+#endif
diff --git a/arch/powerpc/kernel/vdso32/vgettimeofday.c b/arch/powerpc/kernel/vdso32/vgettimeofday.c
index 65fb03fb1731..55a287c9a736 100644
--- a/arch/powerpc/kernel/vdso32/vgettimeofday.c
+++ b/arch/powerpc/kernel/vdso32/vgettimeofday.c
@@ -2,8 +2,22 @@
/*
* Powerpc userspace implementations of gettimeofday() and similar.
*/
+#include <linux/time.h>
#include <linux/types.h>
+#ifdef __powerpc64__
+int __c_kernel_clock_gettime(clockid_t clock, struct __kernel_timespec *ts,
+ const struct vdso_data *vd)
+{
+ return __cvdso_clock_gettime_data(vd, clock, ts);
+}
+
+int __c_kernel_clock_getres(clockid_t clock_id, struct __kernel_timespec *res,
+ const struct vdso_data *vd)
+{
+ return __cvdso_clock_getres_data(vd, clock_id, res);
+}
+#else
int __c_kernel_clock_gettime(clockid_t clock, struct old_timespec32 *ts,
const struct vdso_data *vd)
{
@@ -16,16 +30,17 @@ int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts,
return __cvdso_clock_gettime_data(vd, clock, ts);
}
-int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
+int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res,
const struct vdso_data *vd)
{
- return __cvdso_gettimeofday_data(vd, tv, tz);
+ return __cvdso_clock_getres_time32_data(vd, clock_id, res);
}
+#endif
-int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res,
+int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
const struct vdso_data *vd)
{
- return __cvdso_clock_getres_time32_data(vd, clock_id, res);
+ return __cvdso_gettimeofday_data(vd, tv, tz);
}
__kernel_old_time_t __c_kernel_time(__kernel_old_time_t *time, const struct vdso_data *vd)
--
2.33.1
^ permalink raw reply related
* [PATCH v4 4/5] powerpc/vdso: Remove cvdso_call_time macro
From: Christophe Leroy @ 2022-01-21 16:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
masahiroy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <c2cbb8f046b7efc251053521dc39b752795e26b7.1642782130.git.christophe.leroy@csgroup.eu>
cvdso_call_time macro is very similar to cvdso_call macro.
Add a call_time argument to cvdso_call which is 0 by default
and set to 1 when using cvdso_call to call __c_kernel_time().
Return returned value as is with CR[SO] cleared when it is used
for time().
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/vdso/gettimeofday.h | 37 ++++++--------------
arch/powerpc/kernel/vdso/gettimeofday.S | 2 +-
2 files changed, 11 insertions(+), 28 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index 1faff0be1111..df00e91c9a90 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -9,12 +9,12 @@
#include <asm/ppc_asm.h>
/*
- * The macros sets two stack frames, one for the caller and one for the callee
+ * The macro sets two stack frames, one for the caller and one for the callee
* because there are no requirement for the caller to set a stack frame when
* calling VDSO so it may have omitted to set one, especially on PPC64
*/
-.macro cvdso_call funct
+.macro cvdso_call funct call_time=0
.cfi_startproc
PPC_STLU r1, -PPC_MIN_STKFRM(r1)
mflr r0
@@ -25,45 +25,28 @@
PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
#endif
get_datapage r5
+ .ifeq \call_time
addi r5, r5, VDSO_DATA_OFFSET
+ .else
+ addi r4, r5, VDSO_DATA_OFFSET
+ .endif
bl DOTSYM(\funct)
PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
#ifdef __powerpc64__
PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
#endif
+ .ifeq \call_time
cmpwi r3, 0
+ .endif
mtlr r0
.cfi_restore lr
addi r1, r1, 2 * PPC_MIN_STKFRM
crclr so
+ .ifeq \call_time
beqlr+
crset so
neg r3, r3
- blr
- .cfi_endproc
-.endm
-
-.macro cvdso_call_time funct
- .cfi_startproc
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
- mflr r0
- .cfi_register lr, r0
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
- PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-#ifdef __powerpc64__
- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-#endif
- get_datapage r4
- addi r4, r4, VDSO_DATA_OFFSET
- bl DOTSYM(\funct)
- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-#ifdef __powerpc64__
- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-#endif
- crclr so
- mtlr r0
- .cfi_restore lr
- addi r1, r1, 2 * PPC_MIN_STKFRM
+ .endif
blr
.cfi_endproc
.endm
diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S
index c875312274aa..397f290015bc 100644
--- a/arch/powerpc/kernel/vdso/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso/gettimeofday.S
@@ -65,7 +65,7 @@ V_FUNCTION_END(__kernel_clock_getres)
*
*/
V_FUNCTION_BEGIN(__kernel_time)
- cvdso_call_time __c_kernel_time
+ cvdso_call __c_kernel_time call_time=1
V_FUNCTION_END(__kernel_time)
/* Routines for restoring integer registers, called by the compiler. */
--
2.33.1
^ permalink raw reply related
* [PATCH v4 3/5] powerpc/vdso: Merge vdso64 and vdso32 into a single directory
From: Christophe Leroy @ 2022-01-21 16:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
masahiroy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <c2cbb8f046b7efc251053521dc39b752795e26b7.1642782130.git.christophe.leroy@csgroup.eu>
merge vdso64 into vdso32 and rename it vdso.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/Makefile | 4 +-
arch/powerpc/kernel/Makefile | 6 +-
.../kernel/{vdso64 => vdso}/.gitignore | 2 +
arch/powerpc/kernel/{vdso32 => vdso}/Makefile | 35 +++++++++
.../kernel/{vdso32 => vdso}/cacheflush.S | 0
.../kernel/{vdso32 => vdso}/datapage.S | 0
.../{vdso32 => vdso}/gen_vdso32_offsets.sh | 0
.../gen_vdso64_offsets.sh} | 0
arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S | 0
.../kernel/{vdso32 => vdso}/gettimeofday.S | 0
arch/powerpc/kernel/{vdso32 => vdso}/note.S | 0
.../kernel/{vdso32 => vdso}/sigtramp32.S | 0
.../{vdso64/sigtramp.S => vdso/sigtramp64.S} | 0
.../kernel/{vdso32 => vdso}/vdso32.lds.S | 0
.../kernel/{vdso64 => vdso}/vdso64.lds.S | 0
.../kernel/{vdso32 => vdso}/vgettimeofday.c | 0
arch/powerpc/kernel/vdso32/.gitignore | 3 -
arch/powerpc/kernel/vdso32_wrapper.S | 2 +-
arch/powerpc/kernel/vdso64/Makefile | 56 --------------
arch/powerpc/kernel/vdso64/cacheflush.S | 75 -------------------
arch/powerpc/kernel/vdso64/datapage.S | 59 ---------------
arch/powerpc/kernel/vdso64/getcpu.S | 33 --------
arch/powerpc/kernel/vdso64/gettimeofday.S | 58 --------------
arch/powerpc/kernel/vdso64/note.S | 1 -
arch/powerpc/kernel/vdso64/vgettimeofday.c | 29 -------
arch/powerpc/kernel/vdso64_wrapper.S | 2 +-
26 files changed, 44 insertions(+), 321 deletions(-)
rename arch/powerpc/kernel/{vdso64 => vdso}/.gitignore (72%)
rename arch/powerpc/kernel/{vdso32 => vdso}/Makefile (56%)
rename arch/powerpc/kernel/{vdso32 => vdso}/cacheflush.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/datapage.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/gen_vdso32_offsets.sh (100%)
rename arch/powerpc/kernel/{vdso64/gen_vdso_offsets.sh => vdso/gen_vdso64_offsets.sh} (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/gettimeofday.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/note.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/sigtramp32.S (100%)
rename arch/powerpc/kernel/{vdso64/sigtramp.S => vdso/sigtramp64.S} (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/vdso32.lds.S (100%)
rename arch/powerpc/kernel/{vdso64 => vdso}/vdso64.lds.S (100%)
rename arch/powerpc/kernel/{vdso32 => vdso}/vgettimeofday.c (100%)
delete mode 100644 arch/powerpc/kernel/vdso32/.gitignore
delete mode 100644 arch/powerpc/kernel/vdso64/Makefile
delete mode 100644 arch/powerpc/kernel/vdso64/cacheflush.S
delete mode 100644 arch/powerpc/kernel/vdso64/datapage.S
delete mode 100644 arch/powerpc/kernel/vdso64/getcpu.S
delete mode 100644 arch/powerpc/kernel/vdso64/gettimeofday.S
delete mode 100644 arch/powerpc/kernel/vdso64/note.S
delete mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 5f16ac1583c5..ddc5a706760a 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -421,9 +421,9 @@ ifeq ($(KBUILD_EXTMOD),)
prepare: vdso_prepare
vdso_prepare: prepare0
$(if $(CONFIG_VDSO32),$(Q)$(MAKE) \
- $(build)=arch/powerpc/kernel/vdso32 include/generated/vdso32-offsets.h)
+ $(build)=arch/powerpc/kernel/vdso include/generated/vdso32-offsets.h)
$(if $(CONFIG_PPC64),$(Q)$(MAKE) \
- $(build)=arch/powerpc/kernel/vdso64 include/generated/vdso64-offsets.h)
+ $(build)=arch/powerpc/kernel/vdso include/generated/vdso64-offsets.h)
endif
archprepare: checkbin
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 4d7829399570..4ddd161aef32 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -194,8 +194,8 @@ targets += prom_init_check
clean-files := vmlinux.lds
# Force dependency (incbin is bad)
-$(obj)/vdso32_wrapper.o : $(obj)/vdso32/vdso32.so.dbg
-$(obj)/vdso64_wrapper.o : $(obj)/vdso64/vdso64.so.dbg
+$(obj)/vdso32_wrapper.o : $(obj)/vdso/vdso32.so.dbg
+$(obj)/vdso64_wrapper.o : $(obj)/vdso/vdso64.so.dbg
# for cleaning
-subdir- += vdso32 vdso64
+subdir- += vdso
diff --git a/arch/powerpc/kernel/vdso64/.gitignore b/arch/powerpc/kernel/vdso/.gitignore
similarity index 72%
rename from arch/powerpc/kernel/vdso64/.gitignore
rename to arch/powerpc/kernel/vdso/.gitignore
index 84151a7ba31d..dd9bdd67758b 100644
--- a/arch/powerpc/kernel/vdso64/.gitignore
+++ b/arch/powerpc/kernel/vdso/.gitignore
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
+vdso32.lds
+vdso32.so.dbg
vdso64.lds
vdso64.so.dbg
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso/Makefile
similarity index 56%
rename from arch/powerpc/kernel/vdso32/Makefile
rename to arch/powerpc/kernel/vdso/Makefile
index 7d7b38d90ca5..954974287ee7 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -6,6 +6,7 @@ ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_
include $(srctree)/lib/vdso/Makefile
obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
+obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o note-64.o getcpu-64.o
ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y)
@@ -15,6 +16,17 @@ ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
+ CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
+ CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
+ CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
+ CFLAGS_vgettimeofday-64.o += -DDISABLE_BRANCH_PROFILING
+ CFLAGS_vgettimeofday-64.o += -ffreestanding -fasynchronous-unwind-tables
+ CFLAGS_REMOVE_vgettimeofday-64.o = $(CC_FLAGS_FTRACE)
+# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true
+# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is
+# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code
+# generation is minimal, it will just use r29 instead.
+ CFLAGS_vgettimeofday-64.o += $(call cc-option, -ffixed-r30)
endif
# Build rules
@@ -27,6 +39,8 @@ endif
targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o
obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
+targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o
+obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
GCOV_PROFILE := n
KCOV_INSTRUMENT := n
@@ -38,26 +52,42 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
AS32FLAGS := -D__VDSO32__ -s
+CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
+AS64FLAGS := -D__VDSO64__ -s
+
targets += vdso32.lds
CPPFLAGS_vdso32.lds += -P -C -Upowerpc
+targets += vdso64.lds
+CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
# link rule for the .so file, .lds has to be first
$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE
$(call if_changed,vdso32ld_and_check)
+$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o FORCE
+ $(call if_changed,vdso64ld_and_check)
# assembly rules for the .S files
$(obj-vdso32): %-32.o: %.S FORCE
$(call if_changed_dep,vdso32as)
$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE
$(call if_changed_dep,vdso32cc)
+$(obj-vdso64): %-64.o: %.S FORCE
+ $(call if_changed_dep,vdso64as)
+$(obj)/vgettimeofday-64.o: %-64.o: %.c FORCE
+ $(call if_changed_dep,cc_o_c)
# Generate VDSO offsets using helper script
gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh
quiet_cmd_vdso32sym = VDSO32SYM $@
cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@
+gen-vdso64sym := $(srctree)/$(src)/gen_vdso64_offsets.sh
+quiet_cmd_vdso64sym = VDSO64SYM $@
+ cmd_vdso64sym = $(NM) $< | $(gen-vdso64sym) | LC_ALL=C sort > $@
include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
$(call if_changed,vdso32sym)
+include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
+ $(call if_changed,vdso64sym)
# actual build commands
quiet_cmd_vdso32ld_and_check = VDSO32L $@
@@ -66,3 +96,8 @@ quiet_cmd_vdso32as = VDSO32A $@
cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
quiet_cmd_vdso32cc = VDSO32C $@
cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
+
+quiet_cmd_vdso64ld_and_check = VDSO64L $@
+ cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
+quiet_cmd_vdso64as = VDSO64A $@
+ cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso/cacheflush.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/cacheflush.S
rename to arch/powerpc/kernel/vdso/cacheflush.S
diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso/datapage.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/datapage.S
rename to arch/powerpc/kernel/vdso/datapage.S
diff --git a/arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh b/arch/powerpc/kernel/vdso/gen_vdso32_offsets.sh
similarity index 100%
rename from arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh
rename to arch/powerpc/kernel/vdso/gen_vdso32_offsets.sh
diff --git a/arch/powerpc/kernel/vdso64/gen_vdso_offsets.sh b/arch/powerpc/kernel/vdso/gen_vdso64_offsets.sh
similarity index 100%
rename from arch/powerpc/kernel/vdso64/gen_vdso_offsets.sh
rename to arch/powerpc/kernel/vdso/gen_vdso64_offsets.sh
diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso/getcpu.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/getcpu.S
rename to arch/powerpc/kernel/vdso/getcpu.S
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/gettimeofday.S
rename to arch/powerpc/kernel/vdso/gettimeofday.S
diff --git a/arch/powerpc/kernel/vdso32/note.S b/arch/powerpc/kernel/vdso/note.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/note.S
rename to arch/powerpc/kernel/vdso/note.S
diff --git a/arch/powerpc/kernel/vdso32/sigtramp32.S b/arch/powerpc/kernel/vdso/sigtramp32.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/sigtramp32.S
rename to arch/powerpc/kernel/vdso/sigtramp32.S
diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S b/arch/powerpc/kernel/vdso/sigtramp64.S
similarity index 100%
rename from arch/powerpc/kernel/vdso64/sigtramp.S
rename to arch/powerpc/kernel/vdso/sigtramp64.S
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso/vdso32.lds.S
similarity index 100%
rename from arch/powerpc/kernel/vdso32/vdso32.lds.S
rename to arch/powerpc/kernel/vdso/vdso32.lds.S
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso/vdso64.lds.S
similarity index 100%
rename from arch/powerpc/kernel/vdso64/vdso64.lds.S
rename to arch/powerpc/kernel/vdso/vdso64.lds.S
diff --git a/arch/powerpc/kernel/vdso32/vgettimeofday.c b/arch/powerpc/kernel/vdso/vgettimeofday.c
similarity index 100%
rename from arch/powerpc/kernel/vdso32/vgettimeofday.c
rename to arch/powerpc/kernel/vdso/vgettimeofday.c
diff --git a/arch/powerpc/kernel/vdso32/.gitignore b/arch/powerpc/kernel/vdso32/.gitignore
deleted file mode 100644
index 824b863ec6bd..000000000000
--- a/arch/powerpc/kernel/vdso32/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-vdso32.lds
-vdso32.so.dbg
diff --git a/arch/powerpc/kernel/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32_wrapper.S
index 3f5ef035b0a9..10f92f265d51 100644
--- a/arch/powerpc/kernel/vdso32_wrapper.S
+++ b/arch/powerpc/kernel/vdso32_wrapper.S
@@ -7,7 +7,7 @@
.globl vdso32_start, vdso32_end
.balign PAGE_SIZE
vdso32_start:
- .incbin "arch/powerpc/kernel/vdso32/vdso32.so.dbg"
+ .incbin "arch/powerpc/kernel/vdso/vdso32.so.dbg"
.balign PAGE_SIZE
vdso32_end:
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
deleted file mode 100644
index 3c5baaa6f1e7..000000000000
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# List of files in the vdso, has to be asm only for now
-
-ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
-include $(srctree)/lib/vdso/Makefile
-
-obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
-
-ifneq ($(c-gettimeofday-y),)
- CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
- CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
- CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector)
- CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING
- CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables
- CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
-endif
-
-# Build rules
-
-targets := $(obj-vdso64) vdso64.so.dbg vgettimeofday.o
-obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
-
-GCOV_PROFILE := n
-KCOV_INSTRUMENT := n
-UBSAN_SANITIZE := n
-KASAN_SANITIZE := n
-
-ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
- -Wl,-soname=linux-vdso64.so.1 -Wl,--hash-style=both
-
-# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true
-# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is
-# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code
-# generation is minimal, it will just use r29 instead.
-ccflags-y += $(call cc-option, -ffixed-r30)
-
-asflags-y := -D__VDSO64__ -s
-
-targets += vdso64.lds
-CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
-
-# link rule for the .so file, .lds has to be first
-$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday.o FORCE
- $(call if_changed,vdso64ld_and_check)
-
-# Generate VDSO offsets using helper script
-gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
-quiet_cmd_vdsosym = VDSOSYM $@
- cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
-
-include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
- $(call if_changed,vdsosym)
-
-# actual build commands
-quiet_cmd_vdso64ld_and_check = VDSO64L $@
- cmd_vdso64ld_and_check = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
diff --git a/arch/powerpc/kernel/vdso64/cacheflush.S b/arch/powerpc/kernel/vdso64/cacheflush.S
deleted file mode 100644
index 76c3c8cf8ece..000000000000
--- a/arch/powerpc/kernel/vdso64/cacheflush.S
+++ /dev/null
@@ -1,75 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * vDSO provided cache flush routines
- *
- * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
- * IBM Corp.
- */
-#include <asm/processor.h>
-#include <asm/ppc_asm.h>
-#include <asm/vdso.h>
-#include <asm/vdso_datapage.h>
-#include <asm/asm-offsets.h>
-
- .text
-
-/*
- * Default "generic" version of __kernel_sync_dicache.
- *
- * void __kernel_sync_dicache(unsigned long start, unsigned long end)
- *
- * Flushes the data cache & invalidate the instruction cache for the
- * provided range [start, end[
- */
-V_FUNCTION_BEGIN(__kernel_sync_dicache)
- .cfi_startproc
-BEGIN_FTR_SECTION
- b 3f
-END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
- mflr r12
- .cfi_register lr,r12
- get_datapage r10
- mtlr r12
- .cfi_restore lr
-
- lwz r7,CFG_DCACHE_BLOCKSZ(r10)
- addi r5,r7,-1
- andc r6,r3,r5 /* round low to line bdy */
- subf r8,r6,r4 /* compute length */
- add r8,r8,r5 /* ensure we get enough */
- lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
- srd. r8,r8,r9 /* compute line count */
- crclr cr0*4+so
- beqlr /* nothing to do? */
- mtctr r8
-1: dcbst 0,r6
- add r6,r6,r7
- bdnz 1b
- sync
-
-/* Now invalidate the instruction cache */
-
- lwz r7,CFG_ICACHE_BLOCKSZ(r10)
- addi r5,r7,-1
- andc r6,r3,r5 /* round low to line bdy */
- subf r8,r6,r4 /* compute length */
- add r8,r8,r5
- lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
- srd. r8,r8,r9 /* compute line count */
- crclr cr0*4+so
- beqlr /* nothing to do? */
- mtctr r8
-2: icbi 0,r6
- add r6,r6,r7
- bdnz 2b
- isync
- li r3,0
- blr
-3:
- crclr cr0*4+so
- sync
- isync
- li r3,0
- blr
- .cfi_endproc
-V_FUNCTION_END(__kernel_sync_dicache)
diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S
deleted file mode 100644
index 00760dc69d68..000000000000
--- a/arch/powerpc/kernel/vdso64/datapage.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Access to the shared data page by the vDSO & syscall map
- *
- * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp.
- */
-
-#include <asm/processor.h>
-#include <asm/ppc_asm.h>
-#include <asm/asm-offsets.h>
-#include <asm/unistd.h>
-#include <asm/vdso.h>
-#include <asm/vdso_datapage.h>
-
- .text
-
-/*
- * void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
- *
- * returns a pointer to the syscall map. the map is agnostic to the
- * size of "long", unlike kernel bitops, it stores bits from top to
- * bottom so that memory actually contains a linear bitmap
- * check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of
- * 32 bits int at N >> 5.
- */
-V_FUNCTION_BEGIN(__kernel_get_syscall_map)
- .cfi_startproc
- mflr r12
- .cfi_register lr,r12
- mr r4,r3
- get_datapage r3
- mtlr r12
- addi r3,r3,CFG_SYSCALL_MAP64
- cmpldi cr0,r4,0
- crclr cr0*4+so
- beqlr
- li r0,NR_syscalls
- stw r0,0(r4)
- blr
- .cfi_endproc
-V_FUNCTION_END(__kernel_get_syscall_map)
-
-
-/*
- * void unsigned long __kernel_get_tbfreq(void);
- *
- * returns the timebase frequency in HZ
- */
-V_FUNCTION_BEGIN(__kernel_get_tbfreq)
- .cfi_startproc
- mflr r12
- .cfi_register lr,r12
- get_datapage r3
- ld r3,CFG_TB_TICKS_PER_SEC(r3)
- mtlr r12
- crclr cr0*4+so
- blr
- .cfi_endproc
-V_FUNCTION_END(__kernel_get_tbfreq)
diff --git a/arch/powerpc/kernel/vdso64/getcpu.S b/arch/powerpc/kernel/vdso64/getcpu.S
deleted file mode 100644
index 12bbf236cdc4..000000000000
--- a/arch/powerpc/kernel/vdso64/getcpu.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *
- * Copyright (C) IBM Corporation, 2012
- *
- * Author: Anton Blanchard <anton@au.ibm.com>
- */
-#include <asm/ppc_asm.h>
-#include <asm/vdso.h>
-
- .text
-/*
- * Exact prototype of getcpu
- *
- * int __kernel_getcpu(unsigned *cpu, unsigned *node);
- *
- */
-V_FUNCTION_BEGIN(__kernel_getcpu)
- .cfi_startproc
- mfspr r5,SPRN_SPRG_VDSO_READ
- cmpdi cr0,r3,0
- cmpdi cr1,r4,0
- clrlwi r6,r5,16
- rlwinm r7,r5,16,31-15,31-0
- beq cr0,1f
- stw r6,0(r3)
-1: beq cr1,2f
- stw r7,0(r4)
-2: crclr cr0*4+so
- li r3,0 /* always success */
- blr
- .cfi_endproc
-V_FUNCTION_END(__kernel_getcpu)
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
deleted file mode 100644
index d7a7bfb51081..000000000000
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Userland implementation of gettimeofday() for 64 bits processes in a
- * ppc64 kernel for use in the vDSO
- *
- * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
- * IBM Corp.
- */
-#include <asm/processor.h>
-#include <asm/ppc_asm.h>
-#include <asm/vdso.h>
-#include <asm/vdso_datapage.h>
-#include <asm/asm-offsets.h>
-#include <asm/unistd.h>
-#include <asm/vdso/gettimeofday.h>
-
- .text
-/*
- * Exact prototype of gettimeofday
- *
- * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz);
- *
- */
-V_FUNCTION_BEGIN(__kernel_gettimeofday)
- cvdso_call __c_kernel_gettimeofday
-V_FUNCTION_END(__kernel_gettimeofday)
-
-
-/*
- * Exact prototype of clock_gettime()
- *
- * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp);
- *
- */
-V_FUNCTION_BEGIN(__kernel_clock_gettime)
- cvdso_call __c_kernel_clock_gettime
-V_FUNCTION_END(__kernel_clock_gettime)
-
-
-/*
- * Exact prototype of clock_getres()
- *
- * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res);
- *
- */
-V_FUNCTION_BEGIN(__kernel_clock_getres)
- cvdso_call __c_kernel_clock_getres
-V_FUNCTION_END(__kernel_clock_getres)
-
-/*
- * Exact prototype of time()
- *
- * time_t time(time *t);
- *
- */
-V_FUNCTION_BEGIN(__kernel_time)
- cvdso_call_time __c_kernel_time
-V_FUNCTION_END(__kernel_time)
diff --git a/arch/powerpc/kernel/vdso64/note.S b/arch/powerpc/kernel/vdso64/note.S
deleted file mode 100644
index dc2a509f7e8a..000000000000
--- a/arch/powerpc/kernel/vdso64/note.S
+++ /dev/null
@@ -1 +0,0 @@
-#include "../vdso32/note.S"
diff --git a/arch/powerpc/kernel/vdso64/vgettimeofday.c b/arch/powerpc/kernel/vdso64/vgettimeofday.c
deleted file mode 100644
index 5b5500058344..000000000000
--- a/arch/powerpc/kernel/vdso64/vgettimeofday.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Powerpc userspace implementations of gettimeofday() and similar.
- */
-#include <linux/time.h>
-#include <linux/types.h>
-
-int __c_kernel_clock_gettime(clockid_t clock, struct __kernel_timespec *ts,
- const struct vdso_data *vd)
-{
- return __cvdso_clock_gettime_data(vd, clock, ts);
-}
-
-int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
- const struct vdso_data *vd)
-{
- return __cvdso_gettimeofday_data(vd, tv, tz);
-}
-
-int __c_kernel_clock_getres(clockid_t clock_id, struct __kernel_timespec *res,
- const struct vdso_data *vd)
-{
- return __cvdso_clock_getres_data(vd, clock_id, res);
-}
-
-__kernel_old_time_t __c_kernel_time(__kernel_old_time_t *time, const struct vdso_data *vd)
-{
- return __cvdso_time_data(vd, time);
-}
diff --git a/arch/powerpc/kernel/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64_wrapper.S
index 1d56d81fe3b3..839d1a61411d 100644
--- a/arch/powerpc/kernel/vdso64_wrapper.S
+++ b/arch/powerpc/kernel/vdso64_wrapper.S
@@ -7,7 +7,7 @@
.globl vdso64_start, vdso64_end
.balign PAGE_SIZE
vdso64_start:
- .incbin "arch/powerpc/kernel/vdso64/vdso64.so.dbg"
+ .incbin "arch/powerpc/kernel/vdso/vdso64.so.dbg"
.balign PAGE_SIZE
vdso64_end:
--
2.33.1
^ permalink raw reply related
* [PATCH v4 5/5] powerpc/vdso: Move cvdso_call macro into gettimeofday.S
From: Christophe Leroy @ 2022-01-21 16:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
masahiroy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <c2cbb8f046b7efc251053521dc39b752795e26b7.1642782130.git.christophe.leroy@csgroup.eu>
Now that gettimeofday.S is unique, move cvdso_call macro
into that file which is the only user.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/vdso/gettimeofday.h | 52 +-------------------
arch/powerpc/kernel/vdso/gettimeofday.S | 44 ++++++++++++++++-
2 files changed, 45 insertions(+), 51 deletions(-)
diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h
index df00e91c9a90..f0a4cf01e85c 100644
--- a/arch/powerpc/include/asm/vdso/gettimeofday.h
+++ b/arch/powerpc/include/asm/vdso/gettimeofday.h
@@ -2,57 +2,9 @@
#ifndef _ASM_POWERPC_VDSO_GETTIMEOFDAY_H
#define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H
-#include <asm/page.h>
-
-#ifdef __ASSEMBLY__
-
-#include <asm/ppc_asm.h>
-
-/*
- * The macro sets two stack frames, one for the caller and one for the callee
- * because there are no requirement for the caller to set a stack frame when
- * calling VDSO so it may have omitted to set one, especially on PPC64
- */
-
-.macro cvdso_call funct call_time=0
- .cfi_startproc
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
- mflr r0
- .cfi_register lr, r0
- PPC_STLU r1, -PPC_MIN_STKFRM(r1)
- PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-#ifdef __powerpc64__
- PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-#endif
- get_datapage r5
- .ifeq \call_time
- addi r5, r5, VDSO_DATA_OFFSET
- .else
- addi r4, r5, VDSO_DATA_OFFSET
- .endif
- bl DOTSYM(\funct)
- PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
-#ifdef __powerpc64__
- PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
-#endif
- .ifeq \call_time
- cmpwi r3, 0
- .endif
- mtlr r0
- .cfi_restore lr
- addi r1, r1, 2 * PPC_MIN_STKFRM
- crclr so
- .ifeq \call_time
- beqlr+
- crset so
- neg r3, r3
- .endif
- blr
- .cfi_endproc
-.endm
-
-#else
+#ifndef __ASSEMBLY__
+#include <asm/page.h>
#include <asm/vdso/timebase.h>
#include <asm/barrier.h>
#include <asm/unistd.h>
diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S
index 397f290015bc..eb9c81e1c218 100644
--- a/arch/powerpc/kernel/vdso/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso/gettimeofday.S
@@ -12,7 +12,49 @@
#include <asm/vdso_datapage.h>
#include <asm/asm-offsets.h>
#include <asm/unistd.h>
-#include <asm/vdso/gettimeofday.h>
+
+/*
+ * The macro sets two stack frames, one for the caller and one for the callee
+ * because there are no requirement for the caller to set a stack frame when
+ * calling VDSO so it may have omitted to set one, especially on PPC64
+ */
+
+.macro cvdso_call funct call_time=0
+ .cfi_startproc
+ PPC_STLU r1, -PPC_MIN_STKFRM(r1)
+ mflr r0
+ .cfi_register lr, r0
+ PPC_STLU r1, -PPC_MIN_STKFRM(r1)
+ PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
+#ifdef __powerpc64__
+ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
+#endif
+ get_datapage r5
+ .ifeq \call_time
+ addi r5, r5, VDSO_DATA_OFFSET
+ .else
+ addi r4, r5, VDSO_DATA_OFFSET
+ .endif
+ bl DOTSYM(\funct)
+ PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
+#ifdef __powerpc64__
+ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
+#endif
+ .ifeq \call_time
+ cmpwi r3, 0
+ .endif
+ mtlr r0
+ .cfi_restore lr
+ addi r1, r1, 2 * PPC_MIN_STKFRM
+ crclr so
+ .ifeq \call_time
+ beqlr+
+ crset so
+ neg r3, r3
+ .endif
+ blr
+ .cfi_endproc
+.endm
.text
/*
--
2.33.1
^ permalink raw reply related
* Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
From: Segher Boessenkool @ 2022-01-21 18:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel@vger.kernel.org, Paul Mackerras,
linux-spdx@vger.kernel.org, Thomas Gleixner,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <YerO8MjbXlvbMEsZ@kroah.com>
On Fri, Jan 21, 2022 at 04:19:12PM +0100, Greg Kroah-Hartman wrote:
> On Fri, Jan 21, 2022 at 03:13:50PM +0000, Christophe Leroy wrote:
> > >> - * This file is free software; you can redistribute it and/or modify it
> > >> - * under the terms of the GNU General Public License as published by the
> > >> - * Free Software Foundation; either version 2, or (at your option) any
> > >> - * later version.
[ ... ]
> > >> * As a special exception, if you link this library with files
> > >> * compiled with GCC to produce an executable, this does not cause
> > >> * the resulting executable to be covered by the GNU General Public License.
The "as a special exception" refers to "This file is free software;
you can redistribute it and/or modify it". It is meaningless without
having anything it is an exception *to* :-)
In general, you should never edit licence texts.
> > > Look at that "special exception", why are you ignoring it here? You
> > > can't do that :(
> >
> > I'm not ignoring it, that's the reason why I left it.
>
> You ignore that part of the license in the SPDX line, why?
>
> > Isn't it the correct way to do ? How should it be done ?
>
> You need to properly describe this in the SPDX line. You did not do so
> here, which means that any tool just looking at the SPDX line would get
> this license wrong.
A new label needs to be defined and documented. Should be pretty
mechanical to do, but that should see a wider audience than the powerpc
hackers :-)
Segher
^ permalink raw reply
* [PATCH v3 00/10] powerpc/pseries/vas: NXGZIP support with DLPAR
From: Haren Myneni @ 2022-01-21 19:52 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
PowerPC provides HW compression with NX coprocessor. This feature
is available on both PowerNV and PowerVM and included in Linux.
Since each powerpc chip has one NX coprocessor, the VAS introduces
the concept of windows / credits to manage access to this hardware
resource. On powerVM, these limited resources should be available
across all LPARs. So the hypervisor assigns the specific credits
to each LPAR based on processor entitlement so that one LPAR does
not overload NX. The hypervisor can reject the window open request
to a partition if exceeds its credit limit (1 credit per window).
So the total number of target credits in a partition can be changed
if the core configuration is modified. The hypervisor expects the
partition to modify its window usage depends on new target
credits. For example, if the partition uses more credits than the
new target credits, it should close the excessive windows so that
the NX resource will be available to other partitions.
This patch series enables OS to support this dynamic credit
management with DLPAR core removal/add.
Core removal operation:
- Get new VAS capabilities from the hypervisor when the DLPAR
notifier is received. This capabilities provides the new target
credits based on new processor entitlement. In the case of QoS
credit changes, the notification will be issued by updating
the target_creds via sysfs.
- If the partition is already used more than the new target credits,
the kernel selects windows, unmap the current paste address and
close them in the hypervisor, It uses LIFO to identify these
windows - last windows that are opened are the first ones to be
closed.
- When the user space issue requests on these windows, NX generates
page fault on the unmap paste address. The kernel handles the
fault by returning the paste instruction failure if the window is
not active (means unmap paste). Then up to the library / user
space to fall back to SW compression or manage with the current
windows.
Core add operation:
- The kernel can see increased target credits from the new VAS
capabilities.
- Scans the window list for the closed windows in the hypervisor
due to lost credit before and selects windows based on same LIFO.
- Make these corresponding windows active and create remap with
the same VMA on the new paste address in the fault handler.
- Then the user space should expect paste successful later.
Patch 1: Define common names for sysfs target/used/avail_creds so
that same sysfs entries can be used even on PowerNV later.
Patch 2: Add VAS notifier for DLPAR core add / removal
Patch 3: Save LPID in the vas window struct during initial window
open and use it when reopen later.
Patch 4: When credits are available, reopen windows that are closed
before with core removal.
Patch 5: Close windows in the hypervisor when the partition exceeds
its usage than the new target credits.
Patch 6: If the window is closed in the hypervisor before the user
space issue the initial mmap(), return -EACCES failure.
Patch 7: Add new mmap fault handler which handles the page fault
from NX on paste address.
Patch 8: Return the paste instruction failure if the window is not
active.
Patch 9 & 10: The user space determines the credit usage with sysfs
target/avail/used_creds interfaces. drmgr uses target_creds
to notify OS for QoS credit changes.
Thanks to Nicholas Piggin and Aneesh Kumar for the valuable suggestions
on the NXGZIP design to support DLPAR operations.
Changes in v2:
- Rebase 5.16-rc5
- Use list safe functions to iterate windows list
- Changes to show the actual value in sysfs used_credits even though
some windows are inactive with core removal. Reflects -ve value in
sysfs avail_creds to let userspace know that it opened more windows
than the current maximum LPAR credits.
Changes in v3:
- Rebase 5.16
- Reconfigure VAS windows only for CPU hotplug events.
Haren Myneni (10):
powerpc/pseries/vas: Use common names in VAS capability structure
powerpc/pseries/vas: Add notifier for DLPAR core removal/add
powerpc/pseries/vas: Save partition PID in pseries_vas_window struct
powerpc/pseries/vas: Reopen windows with DLPAR core add
powerpc/pseries/vas: Close windows with DLPAR core removal
powerpc/vas: Map paste address only if window is active
powerpc/vas: Add paste address mmap fault handler
powerpc/vas: Return paste instruction failure if window is not active
powerpc/pseries/vas: sysfs interface to export capabilities
powerpc/pseries/vas: Write 'target_creds' for QoS credits change
arch/powerpc/include/asm/ppc-opcode.h | 2 +
arch/powerpc/include/asm/vas.h | 17 ++
arch/powerpc/platforms/book3s/vas-api.c | 129 ++++++++-
arch/powerpc/platforms/pseries/Makefile | 2 +-
arch/powerpc/platforms/pseries/vas-sysfs.c | 250 ++++++++++++++++
arch/powerpc/platforms/pseries/vas.c | 319 +++++++++++++++++++--
arch/powerpc/platforms/pseries/vas.h | 23 +-
7 files changed, 715 insertions(+), 27 deletions(-)
create mode 100644 arch/powerpc/platforms/pseries/vas-sysfs.c
--
2.27.0
^ permalink raw reply
* [PATCH v3 01/10] powerpc/pseries/vas: Use common names in VAS capability structure
From: Haren Myneni @ 2022-01-21 19:54 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
target/used/avail_creds provides credits usage to user space via
sysfs and the same interface can be used on PowerNV in future.
Remove "lpar" from these names so that applicable on both PowerVM
and PowerNV.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas.c | 10 +++++-----
arch/powerpc/platforms/pseries/vas.h | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index d243ddc58827..c0737379cc7b 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -310,8 +310,8 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags,
cop_feat_caps = &caps->caps;
- if (atomic_inc_return(&cop_feat_caps->used_lpar_creds) >
- atomic_read(&cop_feat_caps->target_lpar_creds)) {
+ if (atomic_inc_return(&cop_feat_caps->used_creds) >
+ atomic_read(&cop_feat_caps->target_creds)) {
pr_err("Credits are not available to allocate window\n");
rc = -EINVAL;
goto out;
@@ -385,7 +385,7 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags,
free_irq_setup(txwin);
h_deallocate_vas_window(txwin->vas_win.winid);
out:
- atomic_dec(&cop_feat_caps->used_lpar_creds);
+ atomic_dec(&cop_feat_caps->used_creds);
kfree(txwin);
return ERR_PTR(rc);
}
@@ -445,7 +445,7 @@ static int vas_deallocate_window(struct vas_window *vwin)
}
list_del(&win->win_list);
- atomic_dec(&caps->used_lpar_creds);
+ atomic_dec(&caps->used_creds);
mutex_unlock(&vas_pseries_mutex);
put_vas_user_win_ref(&vwin->task_ref);
@@ -521,7 +521,7 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
}
caps->max_lpar_creds = be16_to_cpu(hv_caps->max_lpar_creds);
caps->max_win_creds = be16_to_cpu(hv_caps->max_win_creds);
- atomic_set(&caps->target_lpar_creds,
+ atomic_set(&caps->target_creds,
be16_to_cpu(hv_caps->target_lpar_creds));
if (feat == VAS_GZIP_DEF_FEAT) {
caps->def_lpar_creds = be16_to_cpu(hv_caps->def_lpar_creds);
diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h
index 4ecb3fcabd10..fa7ce74f1e49 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -72,9 +72,9 @@ struct vas_cop_feat_caps {
};
/* Total LPAR available credits. Can be different from max LPAR */
/* credits due to DLPAR operation */
- atomic_t target_lpar_creds;
- atomic_t used_lpar_creds; /* Used credits so far */
- u16 avail_lpar_creds; /* Remaining available credits */
+ atomic_t target_creds;
+ atomic_t used_creds; /* Used credits so far */
+ u16 avail_creds; /* Remaining available credits */
};
/*
--
2.27.0
^ permalink raw reply related
* [PATCH v3 02/10] powerpc/pseries/vas: Add notifier for DLPAR core removal/add
From: Haren Myneni @ 2022-01-21 19:54 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The hypervisor assigns credits for each LPAR based on number of
cores configured in that system. So expects to release credits
(means windows) when the core is removed. This patch adds notifier
for core removal/add so that the OS closes windows if the system
looses credits due to core removal and reopen windows when the
credits available later.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas.c | 37 ++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index c0737379cc7b..d2c8292bfb33 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -538,6 +538,39 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
return 0;
}
+/*
+ * Total number of default credits available (target_credits)
+ * in LPAR depends on number of cores configured. It varies based on
+ * whether processors are in shared mode or dedicated mode.
+ * Get the notifier when CPU configuration is changed with DLPAR
+ * operation so that get the new target_credits (vas default capabilities)
+ * and then update the existing windows usage if needed.
+ */
+static int pseries_vas_notifier(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct of_reconfig_data *rd = data;
+ struct device_node *dn = rd->dn;
+ const __be32 *intserv = NULL;
+ int len, rc = 0;
+
+ if ((action == OF_RECONFIG_ATTACH_NODE) ||
+ (action == OF_RECONFIG_DETACH_NODE))
+ intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
+ &len);
+ /*
+ * Processor config is not changed
+ */
+ if (!intserv)
+ return NOTIFY_OK;
+
+ return rc;
+}
+
+static struct notifier_block pseries_vas_nb = {
+ .notifier_call = pseries_vas_notifier,
+};
+
static int __init pseries_vas_init(void)
{
struct hv_vas_cop_feat_caps *hv_cop_caps;
@@ -591,6 +624,10 @@ static int __init pseries_vas_init(void)
goto out_cop;
}
+ /* Processors can be added/removed only on LPAR */
+ if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR))
+ of_reconfig_notifier_register(&pseries_vas_nb);
+
pr_info("GZIP feature is available\n");
out_cop:
--
2.27.0
^ permalink raw reply related
* [PATCH v3 03/10] powerpc/pseries/vas: Save LPID in pseries_vas_window struct
From: Haren Myneni @ 2022-01-21 19:55 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The kernel sets the VAS window with partition PID when is opened in
the hypervisor. During DLPAR operation, windows can be closed and
reopened in the hypervisor when the credit is available. So saves
this PID in pseries_vas_window struct when the window is opened
initially and reuse it later during DLPAR operation.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas.c | 7 ++++---
arch/powerpc/platforms/pseries/vas.h | 1 +
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/vas.c
b/arch/powerpc/platforms/pseries/vas.c
index d2c8292bfb33..2ef56157634f 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -107,7 +107,6 @@ static int h_deallocate_vas_window(u64 winid)
static int h_modify_vas_window(struct pseries_vas_window *win)
{
long rc;
- u32 lpid = mfspr(SPRN_PID);
/*
* AMR value is not supported in Linux VAS implementation.
@@ -115,7 +114,7 @@ static int h_modify_vas_window(struct
pseries_vas_window *win)
*/
do {
rc = plpar_hcall_norets(H_MODIFY_VAS_WINDOW,
- win->vas_win.winid, lpid, 0,
+ win->vas_win.winid, win->lpid,
0,
VAS_MOD_WIN_FLAGS, 0);
rc = hcall_return_busy_check(rc);
@@ -125,7 +124,7 @@ static int h_modify_vas_window(struct
pseries_vas_window *win)
return 0;
pr_err("H_MODIFY_VAS_WINDOW error: %ld, winid %u lpid %u\n",
- rc, win->vas_win.winid, lpid);
+ rc, win->vas_win.winid, win->lpid);
return -EIO;
}
@@ -338,6 +337,8 @@ static struct vas_window *vas_allocate_window(int
vas_id, u64 flags,
}
}
+ txwin->lpid = mfspr(SPRN_PID);
+
/*
* Allocate / Deallocate window hcalls and setup / free IRQs
* have to be protected with mutex.
diff --git a/arch/powerpc/platforms/pseries/vas.h
b/arch/powerpc/platforms/pseries/vas.h
index fa7ce74f1e49..0538760d13be 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -115,6 +115,7 @@ struct pseries_vas_window {
u64 domain[6]; /* Associativity domain Ids */
/* this window is allocated */
u64 util;
+ u32 lpid;
/* List of windows opened which is used for LPM */
struct list_head win_list;
--
2.27.0
^ permalink raw reply related
* [PATCH v3 04/10] powerpc/pseries/vas: Reopen windows with DLPAR core add
From: Haren Myneni @ 2022-01-21 19:56 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
VAS windows can be closed in the hypervisor due to lost credits
when the core is removed. If these credits are available later
for core add, reopen these windows and set them active. When the
kernel sees page fault on the paste address, it creates new mapping
on the new paste address. Then the user space can continue to use
these windows and send HW compression requests to NX successfully.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/include/asm/vas.h | 16 +++
arch/powerpc/platforms/book3s/vas-api.c | 1 +
arch/powerpc/platforms/pseries/vas.c | 144 ++++++++++++++++++++++++
arch/powerpc/platforms/pseries/vas.h | 8 +-
4 files changed, 163 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index 57573d9c1e09..f1efe86563cc 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -29,6 +29,19 @@
#define VAS_THRESH_FIFO_GT_QTR_FULL 2
#define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3
+/*
+ * VAS window status
+ */
+#define VAS_WIN_ACTIVE 0x0 /* Used in platform independent */
+ /* vas mmap() */
+/* The hypervisor returns these values */
+#define VAS_WIN_CLOSED 0x00000001
+#define VAS_WIN_INACTIVE 0x00000002 /* Inactive due to HW failure */
+#define VAS_WIN_MOD_IN_PROCESS 0x00000003 /* Process of being modified, */
+ /* deallocated, or quiesced */
+/* Linux status bits */
+#define VAS_WIN_NO_CRED_CLOSE 0x00000004 /* Window is closed due to */
+ /* lost credit */
/*
* Get/Set bit fields
*/
@@ -59,6 +72,8 @@ struct vas_user_win_ref {
struct pid *pid; /* PID of owner */
struct pid *tgid; /* Thread group ID of owner */
struct mm_struct *mm; /* Linux process mm_struct */
+ struct mutex mmap_mutex; /* protects paste address mmap() */
+ /* with DLPAR close/open windows */
};
/*
@@ -67,6 +82,7 @@ struct vas_user_win_ref {
struct vas_window {
u32 winid;
u32 wcreds_max; /* Window credits */
+ u32 status;
enum vas_cop_type cop;
struct vas_user_win_ref task_ref;
char *dbgname;
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 4d82c92ddd52..2b0ced611f32 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -316,6 +316,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
return PTR_ERR(txwin);
}
+ mutex_init(&txwin->task_ref.mmap_mutex);
cp_inst->txwin = txwin;
return 0;
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index 2ef56157634f..d9ff73d7704d 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -501,6 +501,7 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
memset(vcaps, 0, sizeof(*vcaps));
INIT_LIST_HEAD(&vcaps->list);
+ vcaps->feat = feat;
caps = &vcaps->caps;
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, feat,
@@ -539,6 +540,145 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
return 0;
}
+/*
+ * VAS windows can be closed due to lost credits when the core is
+ * removed. So reopen them if credits are available due to DLPAR
+ * core add and set the window active status. When NX sees the page
+ * fault on the unmapped paste address, the kernel handles the fault
+ * by setting the remapping to new paste address if the window is
+ * active.
+ */
+static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
+{
+ long domain[PLPAR_HCALL9_BUFSIZE] = {VAS_DEFAULT_DOMAIN_ID};
+ struct vas_cop_feat_caps *caps = &vcaps->caps;
+ struct pseries_vas_window *win = NULL, *tmp;
+ int rc, mv_ents = 0;
+
+ /*
+ * Nothing to do if there are no closed windows.
+ */
+ if (!vcaps->close_wins)
+ return 0;
+
+ /*
+ * For the core removal, the hypervisor reduces the credits
+ * assigned to the LPAR and the kernel closes VAS windows
+ * in the hypervisor depends on reduced credits. The kernel
+ * uses LIFO (the last windows that are opened will be closed
+ * first) and expects to open in the same order when credits
+ * are available.
+ * For example, 40 windows are closed when the LPAR lost 2 cores
+ * (dedicated). If 1 core is added, this LPAR can have 20 more
+ * credits. It means the kernel can reopen 20 windows. So move
+ * 20 entries in the VAS windows lost and reopen next 20 windows.
+ */
+ if (vcaps->close_wins > creds)
+ mv_ents = vcaps->close_wins - creds;
+
+ list_for_each_entry_safe(win, tmp, &vcaps->list, win_list) {
+ if (!mv_ents)
+ break;
+
+ mv_ents--;
+ }
+
+ list_for_each_entry_safe_from(win, tmp, &vcaps->list, win_list) {
+ /*
+ * Nothing to do on this window if it is not closed
+ * with VAS_WIN_NO_CRED_CLOSE
+ */
+ if (!(win->vas_win.status & VAS_WIN_NO_CRED_CLOSE))
+ continue;
+
+ rc = allocate_setup_window(win, (u64 *)&domain[0],
+ caps->win_type);
+ if (rc)
+ return rc;
+
+ rc = h_modify_vas_window(win);
+ if (rc)
+ goto out;
+
+ mutex_lock(&win->vas_win.task_ref.mmap_mutex);
+ /*
+ * Set window status to active
+ */
+ win->vas_win.status &= ~VAS_WIN_NO_CRED_CLOSE;
+ mutex_unlock(&win->vas_win.task_ref.mmap_mutex);
+ win->win_type = caps->win_type;
+ if (!--vcaps->close_wins)
+ break;
+ }
+
+ return 0;
+out:
+ /*
+ * Window modify HCALL failed. So close the window to the
+ * hypervisor and return.
+ */
+ free_irq_setup(win);
+ h_deallocate_vas_window(win->vas_win.winid);
+ return rc;
+}
+
+/*
+ * Get new VAS capabilities when the core add/removal configuration
+ * changes. Reconfig window configurations based on the credits
+ * availability from this new capabilities.
+ */
+static int vas_reconfig_capabilties(u8 type)
+{
+ struct hv_vas_cop_feat_caps *hv_caps;
+ struct vas_cop_feat_caps *caps;
+ int lpar_creds, new_creds;
+ struct vas_caps *vcaps;
+ int rc = 0;
+
+ if (type >= VAS_MAX_FEAT_TYPE) {
+ pr_err("Invalid credit type %d\n", type);
+ return -EINVAL;
+ }
+
+ vcaps = &vascaps[type];
+ caps = &vcaps->caps;
+
+ hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL);
+ if (!hv_caps)
+ return -ENOMEM;
+
+ mutex_lock(&vas_pseries_mutex);
+ rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
+ (u64)virt_to_phys(hv_caps));
+ if (rc)
+ goto out;
+
+ new_creds = be16_to_cpu(hv_caps->target_lpar_creds);
+
+ lpar_creds = atomic_read(&caps->target_creds);
+
+ atomic_set(&caps->target_creds, new_creds);
+ /*
+ * The total number of available credits may be decreased or
+ * inceased with DLPAR operation. Means some windows have to be
+ * closed / reopened. Hold the vas_pseries_mutex so that the
+ * the user space can not open new windows.
+ */
+ if (lpar_creds < new_creds) {
+ /*
+ * If the existing target credits is less than the new
+ * target, reopen windows if they are closed due to
+ * the previous DLPAR (core removal).
+ */
+ rc = reconfig_open_windows(vcaps, new_creds - lpar_creds);
+ }
+
+out:
+ mutex_unlock(&vas_pseries_mutex);
+ kfree(hv_caps);
+ return rc;
+}
+
/*
* Total number of default credits available (target_credits)
* in LPAR depends on number of cores configured. It varies based on
@@ -565,6 +705,10 @@ static int pseries_vas_notifier(struct notifier_block *nb,
if (!intserv)
return NOTIFY_OK;
+ rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE);
+ if (rc)
+ pr_err("Failed reconfig VAS capabilities with DLPAR\n");
+
return rc;
}
diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h
index 0538760d13be..45b62565955b 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -21,12 +21,6 @@
#define VAS_MOD_WIN_FLAGS (VAS_MOD_WIN_JOBS_KILL | VAS_MOD_WIN_DR | \
VAS_MOD_WIN_PR | VAS_MOD_WIN_SF)
-#define VAS_WIN_ACTIVE 0x0
-#define VAS_WIN_CLOSED 0x1
-#define VAS_WIN_INACTIVE 0x2 /* Inactive due to HW failure */
-/* Process of being modified, deallocated, or quiesced */
-#define VAS_WIN_MOD_IN_PROCESS 0x3
-
#define VAS_COPY_PASTE_USER_MODE 0x00000001
#define VAS_COP_OP_USER_MODE 0x00000010
@@ -84,6 +78,8 @@ struct vas_cop_feat_caps {
struct vas_caps {
struct vas_cop_feat_caps caps;
struct list_head list; /* List of open windows */
+ int close_wins; /* closed windows in the hypervisor for DLPAR */
+ u8 feat; /* Feature type */
};
/*
--
2.27.0
^ permalink raw reply related
* [PATCH v3 05/10] powerpc/pseries/vas: Close windows with DLPAR core removal
From: Haren Myneni @ 2022-01-21 19:57 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The hypervisor reduces the available credits if the core is removed
from the LPAR. So there is possibility of using excessive credits
(windows) in the LPAR and the hypervisor expects the system to close
the excessive windows. Even though the user space can continue to use
these windows to send compression requests to NX, the hypervisor expects
the LPAR to reduce these windows usage so that NX load can be equally
distributed across all LPARs in the system.
When the DLPAR notifier is received, get the new VAS capabilities from
the hypervisor and close the excessive windows in the hypervisor. Also
the kernel unmaps the paste address so that the user space receives paste
failure until these windows are active with the later DLPAR (core add).
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/include/asm/vas.h | 1 +
arch/powerpc/platforms/book3s/vas-api.c | 2 +
arch/powerpc/platforms/pseries/vas.c | 117 ++++++++++++++++++++++--
arch/powerpc/platforms/pseries/vas.h | 1 +
4 files changed, 112 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index f1efe86563cc..ddc05a8fc2e3 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -74,6 +74,7 @@ struct vas_user_win_ref {
struct mm_struct *mm; /* Linux process mm_struct */
struct mutex mmap_mutex; /* protects paste address mmap() */
/* with DLPAR close/open windows */
+ struct vm_area_struct *vma; /* Save VMA and used in DLPAR ops */
};
/*
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 2b0ced611f32..a63fd48e34a7 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -399,6 +399,8 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
pr_devel("%s(): paste addr %llx at %lx, rc %d\n", __func__,
paste_addr, vma->vm_start, rc);
+ txwin->task_ref.vma = vma;
+
return rc;
}
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index d9ff73d7704d..75ccd0a599ec 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -370,13 +370,28 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags,
if (rc)
goto out_free;
- vas_user_win_add_mm_context(&txwin->vas_win.task_ref);
txwin->win_type = cop_feat_caps->win_type;
mutex_lock(&vas_pseries_mutex);
- list_add(&txwin->win_list, &caps->list);
+ /*
+ * Possible to loose the acquired credit with DLPAR core
+ * removal after the window is opened. So if there are any
+ * closed windows (means with lost credits), do not give new
+ * window to user space. New windows will be opened only
+ * after the existing windows are reopened when credits are
+ * available.
+ */
+ if (!caps->close_wins) {
+ list_add(&txwin->win_list, &caps->list);
+ caps->num_wins++;
+ mutex_unlock(&vas_pseries_mutex);
+ vas_user_win_add_mm_context(&txwin->vas_win.task_ref);
+ return &txwin->vas_win;
+ }
mutex_unlock(&vas_pseries_mutex);
- return &txwin->vas_win;
+ put_vas_user_win_ref(&txwin->vas_win.task_ref);
+ rc = -EBUSY;
+ pr_err("No credit is available to allocate window\n");
out_free:
/*
@@ -439,14 +454,24 @@ static int vas_deallocate_window(struct vas_window *vwin)
caps = &vascaps[win->win_type].caps;
mutex_lock(&vas_pseries_mutex);
- rc = deallocate_free_window(win);
- if (rc) {
- mutex_unlock(&vas_pseries_mutex);
- return rc;
- }
+ /*
+ * VAS window is already closed in the hypervisor when
+ * lost the credit. So just remove the entry from
+ * the list, remove task references and free vas_window
+ * struct.
+ */
+ if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) {
+ rc = deallocate_free_window(win);
+ if (rc) {
+ mutex_unlock(&vas_pseries_mutex);
+ return rc;
+ }
+ } else
+ vascaps[win->win_type].close_wins--;
list_del(&win->win_list);
atomic_dec(&caps->used_creds);
+ vascaps[win->win_type].num_wins--;
mutex_unlock(&vas_pseries_mutex);
put_vas_user_win_ref(&vwin->task_ref);
@@ -622,6 +647,72 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
return rc;
}
+/*
+ * The hypervisor reduces the available credits if the LPAR lost core. It
+ * means the excessive windows should not be active and the user space
+ * should not be using these windows to send compression requests to NX.
+ * So the kernel closes the excessive windows and unmap the paste address
+ * such that the user space receives paste instruction failure. Then up to
+ * the user space to fall back to SW compression and manage with the
+ * existing windows.
+ */
+static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
+{
+ struct pseries_vas_window *win, *tmp;
+ struct vas_user_win_ref *task_ref;
+ struct vm_area_struct *vma;
+ int rc = 0;
+
+ list_for_each_entry_safe(win, tmp, &vcap->list, win_list) {
+ /*
+ * This window is already closed due to lost credit
+ * before. Go for next window.
+ */
+ if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE)
+ continue;
+
+ task_ref = &win->vas_win.task_ref;
+ mutex_lock(&task_ref->mmap_mutex);
+ vma = task_ref->vma;
+ /*
+ * Number of available credits are reduced, So select
+ * and close windows.
+ */
+ win->vas_win.status |= VAS_WIN_NO_CRED_CLOSE;
+
+ mmap_write_lock(task_ref->mm);
+ /*
+ * vma is set in the original mapping. But this mapping
+ * is done with mmap() after the window is opened with ioctl.
+ * so we may not see the original mapping if the core remove
+ * is done before the original mmap() and after the ioctl.
+ */
+ if (vma)
+ zap_page_range(vma, vma->vm_start,
+ vma->vm_end - vma->vm_start);
+
+ mmap_write_unlock(task_ref->mm);
+ mutex_unlock(&task_ref->mmap_mutex);
+ /*
+ * Close VAS window in the hypervisor, but do not
+ * free vas_window struct since it may be reused
+ * when the credit is available later (DLPAR with
+ * adding cores). This struct will be used
+ * later when the process issued with close(FD).
+ */
+ rc = deallocate_free_window(win);
+ if (rc)
+ return rc;
+
+ vcap->close_wins++;
+
+ if (!--excess_creds)
+ break;
+ }
+
+ return 0;
+}
+
/*
* Get new VAS capabilities when the core add/removal configuration
* changes. Reconfig window configurations based on the credits
@@ -633,7 +724,7 @@ static int vas_reconfig_capabilties(u8 type)
struct vas_cop_feat_caps *caps;
int lpar_creds, new_creds;
struct vas_caps *vcaps;
- int rc = 0;
+ int rc = 0, active_wins;
if (type >= VAS_MAX_FEAT_TYPE) {
pr_err("Invalid credit type %d\n", type);
@@ -671,6 +762,14 @@ static int vas_reconfig_capabilties(u8 type)
* the previous DLPAR (core removal).
*/
rc = reconfig_open_windows(vcaps, new_creds - lpar_creds);
+ } else {
+ /*
+ * # active windows is more than new LPAR available
+ * credits. So close the excessive windows.
+ */
+ active_wins = vcaps->num_wins - vcaps->close_wins;
+ if (active_wins > new_creds)
+ rc = reconfig_close_windows(vcaps, active_wins - new_creds);
}
out:
diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h
index 45b62565955b..8ce9b84693e8 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -79,6 +79,7 @@ struct vas_caps {
struct vas_cop_feat_caps caps;
struct list_head list; /* List of open windows */
int close_wins; /* closed windows in the hypervisor for DLPAR */
+ int num_wins; /* Number of windows opened */
u8 feat; /* Feature type */
};
--
2.27.0
^ permalink raw reply related
* [PATCH v3 06/10] powerpc/vas: Map paste address only if window is active
From: Haren Myneni @ 2022-01-21 19:58 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The paste address mapping is done with mmap() after the window is
opened with ioctl. But the window can be closed due to lost credit
due to core removal before mmap(). So if the window is not active,
return mmap() failure with -EACCES and expects the user space reissue
mmap() when the window is active or open new window when the credit
is available.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/book3s/vas-api.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index a63fd48e34a7..2d06bd1b1935 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -379,10 +379,27 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
return -EACCES;
}
+ /*
+ * The initial mapping is done after the window is opened
+ * with ioctl. But this window might have been closed
+ * due to lost credit (core removal on PowerVM) before mmap().
+ * So if the window is not active, return mmap() failure
+ * with -EACCES and expects the user space reconfigure (mmap)
+ * window when it is active again or open new window when
+ * the credit is available.
+ */
+ mutex_lock(&txwin->task_ref.mmap_mutex);
+ if (txwin->status != VAS_WIN_ACTIVE) {
+ pr_err("%s(): Window is not active\n", __func__);
+ rc = -EACCES;
+ goto out;
+ }
+
paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
if (!paste_addr) {
pr_err("%s(): Window paste address failed\n", __func__);
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
pfn = paste_addr >> PAGE_SHIFT;
@@ -401,6 +418,8 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
txwin->task_ref.vma = vma;
+out:
+ mutex_unlock(&txwin->task_ref.mmap_mutex);
return rc;
}
--
2.27.0
^ permalink raw reply related
* [PATCH v3 07/10] powerpc/vas: Add paste address mmap fault handler
From: Haren Myneni @ 2022-01-21 19:59 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The user space opens VAS windows and issues NX requests by pasting
CRB on the corresponding paste address mmap. When the system looses
credits due to core removal, the kernel has to close the window in
the hypervisor and make the window inactive by unmapping this paste
address. Also the OS has to handle NX request page faults if the user
space issue NX requests.
This handler remap the new paste address with the same VMA when the
window is active again (due to core add with DLPAR). Otherwise
returns paste failure.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/book3s/vas-api.c | 60 +++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 2d06bd1b1935..5ceba75c13eb 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -351,6 +351,65 @@ static int coproc_release(struct inode *inode, struct file *fp)
return 0;
}
+/*
+ * This fault handler is invoked when the VAS/NX generates page fault on
+ * the paste address. Happens if the kernel closes window in hypervisor
+ * (on PowerVM) due to lost credit or the paste address is not mapped.
+ */
+static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
+{
+ struct vm_area_struct *vma = vmf->vma;
+ struct file *fp = vma->vm_file;
+ struct coproc_instance *cp_inst = fp->private_data;
+ struct vas_window *txwin;
+ u64 paste_addr;
+ int ret;
+
+ /*
+ * window is not opened. Shouldn't expect this error.
+ */
+ if (!cp_inst || !cp_inst->txwin) {
+ pr_err("%s(): No send window open?\n", __func__);
+ return VM_FAULT_SIGBUS;
+ }
+
+ txwin = cp_inst->txwin;
+ /*
+ * Fault is coming due to missing from the original mmap.
+ * Can happen only when the window is closed due to lost
+ * credit before mmap() or the user space issued NX request
+ * without mapping.
+ */
+ if (txwin->task_ref.vma != vmf->vma) {
+ pr_err("%s(): No previous mapping with paste address\n",
+ __func__);
+ return VM_FAULT_SIGBUS;
+ }
+
+ mutex_lock(&txwin->task_ref.mmap_mutex);
+ /*
+ * The window may be inactive due to lost credit (Ex: core
+ * removal with DLPAR). When the window is active again when
+ * the credit is available, remap with the new paste address.
+ */
+ if (txwin->status == VAS_WIN_ACTIVE) {
+ paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
+ if (paste_addr) {
+ ret = vmf_insert_pfn(vma, vma->vm_start,
+ (paste_addr >> PAGE_SHIFT));
+ mutex_unlock(&txwin->task_ref.mmap_mutex);
+ return ret;
+ }
+ }
+ mutex_unlock(&txwin->task_ref.mmap_mutex);
+
+ return VM_FAULT_SIGBUS;
+
+}
+static const struct vm_operations_struct vas_vm_ops = {
+ .fault = vas_mmap_fault,
+};
+
static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
{
struct coproc_instance *cp_inst = fp->private_data;
@@ -417,6 +476,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
paste_addr, vma->vm_start, rc);
txwin->task_ref.vma = vma;
+ vma->vm_ops = &vas_vm_ops;
out:
mutex_unlock(&txwin->task_ref.mmap_mutex);
--
2.27.0
^ permalink raw reply related
* [PATCH v3 08/10] powerpc/vas: Return paste instruction failure if no active window
From: Haren Myneni @ 2022-01-21 19:59 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The VAS window may not be active if the system looses credits and
the NX generates page fault when it receives request on unmap
paste address.
The kernel handles the fault by remap new paste address if the
window is active again, Otherwise return the paste instruction
failure if the executed instruction that caused the fault was
a paste.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/include/asm/ppc-opcode.h | 2 ++
arch/powerpc/platforms/book3s/vas-api.c | 47 ++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index efad07081cc0..fe2a69206588 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -262,6 +262,8 @@
#define PPC_INST_MFSPR_PVR 0x7c1f42a6
#define PPC_INST_MFSPR_PVR_MASK 0xfc1ffffe
#define PPC_INST_MTMSRD 0x7c000164
+#define PPC_INST_PASTE 0x7c20070d
+#define PPC_INST_PASTE_MASK 0xfc2007ff
#define PPC_INST_POPCNTB 0x7c0000f4
#define PPC_INST_POPCNTB_MASK 0xfc0007fe
#define PPC_INST_RFEBB 0x4c000124
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 5ceba75c13eb..2ffd34bc4032 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -351,6 +351,41 @@ static int coproc_release(struct inode *inode, struct file *fp)
return 0;
}
+/*
+ * If the executed instruction that caused the fault was a paste, then
+ * clear regs CR0[EQ], advance NIP, and return 0. Else return error code.
+ */
+static int do_fail_paste(void)
+{
+ struct pt_regs *regs = current->thread.regs;
+ u32 instword;
+
+ if (WARN_ON_ONCE(!regs))
+ return -EINVAL;
+
+ if (WARN_ON_ONCE(!user_mode(regs)))
+ return -EINVAL;
+
+ /*
+ * If we couldn't translate the instruction, the driver should
+ * return success without handling the fault, it will be retried
+ * or the instruction fetch will fault.
+ */
+ if (get_user(instword, (u32 __user *)(regs->nip)))
+ return -EAGAIN;
+
+ /*
+ * Not a paste instruction, driver may fail the fault.
+ */
+ if ((instword & PPC_INST_PASTE_MASK) != PPC_INST_PASTE)
+ return -ENOENT;
+
+ regs->ccr &= ~0xe0000000; /* Clear CR0[0-2] to fail paste */
+ regs_add_return_ip(regs, 4); /* Skip the paste */
+
+ return 0;
+}
+
/*
* This fault handler is invoked when the VAS/NX generates page fault on
* the paste address. Happens if the kernel closes window in hypervisor
@@ -403,9 +438,19 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
}
mutex_unlock(&txwin->task_ref.mmap_mutex);
- return VM_FAULT_SIGBUS;
+ /*
+ * Received this fault due to closing the actual window.
+ * It can happen during migration or lost credits.
+ * Since no mapping, return the paste instruction failure
+ * to the user space.
+ */
+ ret = do_fail_paste();
+ if (!ret)
+ return VM_FAULT_NOPAGE;
+ return VM_FAULT_SIGBUS;
}
+
static const struct vm_operations_struct vas_vm_ops = {
.fault = vas_mmap_fault,
};
--
2.27.0
^ permalink raw reply related
* [PATCH v3 09/10] powerpc/pseries/vas: sysfs interface to export capabilities
From: Haren Myneni @ 2022-01-21 20:00 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
The hypervisor provides the available VAS GZIP capabilities such
as default or QoS window type and the target available credits in
each type. This patch creates sysfs entries and exports the target,
used and the available credits for each feature.
This interface can be used by the user space to determine the credits
usage or to set the target credits in the case of QoS type (for DLPAR).
/sys/devices/vas/vas0/gzip/def_caps: (default GZIP capabilities)
avail_creds /* Available credits to use */
target_creds /* Total credits available. Can be
/* changed with DLPAR operation */
used_creds /* Used credits */
/sys/devices/vas/vas0/gzip/qos_caps (QoS GZIP capabilities)
avail_creds
target_creds
used_creds
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/Makefile | 2 +-
arch/powerpc/platforms/pseries/vas-sysfs.c | 218 +++++++++++++++++++++
arch/powerpc/platforms/pseries/vas.c | 6 +
arch/powerpc/platforms/pseries/vas.h | 6 +
4 files changed, 231 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/platforms/pseries/vas-sysfs.c
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index ee60b59024b4..29b522d2c755 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -29,6 +29,6 @@ obj-$(CONFIG_PPC_SVM) += svm.o
obj-$(CONFIG_FA_DUMP) += rtas-fadump.o
obj-$(CONFIG_SUSPEND) += suspend.o
-obj-$(CONFIG_PPC_VAS) += vas.o
+obj-$(CONFIG_PPC_VAS) += vas.o vas-sysfs.o
obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o
diff --git a/arch/powerpc/platforms/pseries/vas-sysfs.c b/arch/powerpc/platforms/pseries/vas-sysfs.c
new file mode 100644
index 000000000000..f7609cdef8f8
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/vas-sysfs.c
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2016-17 IBM Corp.
+ */
+
+#define pr_fmt(fmt) "vas: " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/kobject.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+
+#include "vas.h"
+
+#ifdef CONFIG_SYSFS
+static struct kobject *pseries_vas_kobj;
+static struct kobject *gzip_caps_kobj;
+
+struct vas_caps_entry {
+ struct kobject kobj;
+ struct vas_cop_feat_caps *caps;
+};
+
+#define to_caps_entry(entry) container_of(entry, struct vas_caps_entry, kobj)
+
+static ssize_t avail_creds_show(struct vas_cop_feat_caps *caps, char *buf)
+{
+ /*
+ * avail_creds may be -ve if used_creds is oversubscribed,
+ * can happen if target_creds is reduced with DLPAR core removal.
+ */
+ int avail_creds = atomic_read(&caps->target_creds) -
+ atomic_read(&caps->used_creds);
+ return sprintf(buf, "%d\n", avail_creds);
+}
+
+#define sysfs_capbs_entry_read(_name) \
+static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \
+{ \
+ return sprintf(buf, "%d\n", atomic_read(&caps->_name)); \
+}
+
+struct vas_sysfs_entry {
+ struct attribute attr;
+ ssize_t (*show)(struct vas_cop_feat_caps *, char *);
+ ssize_t (*store)(struct vas_cop_feat_caps *, const char *, size_t);
+};
+
+#define VAS_ATTR_RO(_name) \
+ sysfs_capbs_entry_read(_name); \
+ static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \
+ 0444, _name##_show, NULL);
+
+VAS_ATTR_RO(target_creds);
+VAS_ATTR_RO(used_creds);
+
+static struct vas_sysfs_entry avail_creds_attribute =
+ __ATTR(avail_creds, 0444, avail_creds_show, NULL);
+
+static struct attribute *vas_capab_attrs[] = {
+ &target_creds_attribute.attr,
+ &used_creds_attribute.attr,
+ &avail_creds_attribute.attr,
+ NULL,
+};
+
+static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct vas_caps_entry *centry;
+ struct vas_cop_feat_caps *caps;
+ struct vas_sysfs_entry *entry;
+
+ centry = to_caps_entry(kobj);
+ caps = centry->caps;
+ entry = container_of(attr, struct vas_sysfs_entry, attr);
+
+ if (!entry->show)
+ return -EIO;
+
+ return entry->show(caps, buf);
+}
+
+static ssize_t vas_type_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ struct vas_caps_entry *centry;
+ struct vas_cop_feat_caps *caps;
+ struct vas_sysfs_entry *entry;
+
+ centry = to_caps_entry(kobj);
+ caps = centry->caps;
+ entry = container_of(attr, struct vas_sysfs_entry, attr);
+ if (!entry->store)
+ return -EIO;
+
+ return entry->store(caps, buf, count);
+}
+
+static void vas_type_release(struct kobject *kobj)
+{
+ struct vas_caps_entry *centry = to_caps_entry(kobj);
+ kfree(centry);
+}
+
+static const struct sysfs_ops vas_sysfs_ops = {
+ .show = vas_type_show,
+ .store = vas_type_store,
+};
+
+static struct kobj_type vas_attr_type = {
+ .release = vas_type_release,
+ .sysfs_ops = &vas_sysfs_ops,
+ .default_attrs = vas_capab_attrs,
+};
+
+static char *vas_caps_kobj_name(struct vas_cop_feat_caps *caps,
+ struct kobject **kobj)
+{
+ if (caps->descriptor == VAS_GZIP_QOS_CAPABILITIES) {
+ *kobj = gzip_caps_kobj;
+ return "qos_caps";
+ } else if (caps->descriptor == VAS_GZIP_DEFAULT_CAPABILITIES) {
+ *kobj = gzip_caps_kobj;
+ return "def_caps";
+ } else
+ return "Unknown";
+}
+
+/*
+ * Add feature specific capability dir entry.
+ * Ex: VDefGzip or VQosGzip
+ */
+int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps)
+{
+ struct vas_caps_entry *centry;
+ struct kobject *kobj = NULL;
+ int ret = 0;
+ char *name;
+
+ centry = kzalloc(sizeof(*centry), GFP_KERNEL);
+ if (!centry)
+ return -ENOMEM;
+
+ kobject_init(¢ry->kobj, &vas_attr_type);
+ centry->caps = caps;
+ name = vas_caps_kobj_name(caps, &kobj);
+
+ if (kobj) {
+ ret = kobject_add(¢ry->kobj, kobj, "%s", name);
+
+ if (ret) {
+ pr_err("VAS: sysfs kobject add / event failed %d\n",
+ ret);
+ kobject_put(¢ry->kobj);
+ }
+ }
+
+ return ret;
+}
+
+static struct miscdevice vas_miscdev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "vas",
+};
+
+/*
+ * Add VAS and VasCaps (overall capabilities) dir entries.
+ */
+int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps)
+{
+ int ret;
+
+ ret = misc_register(&vas_miscdev);
+ if (ret < 0) {
+ pr_err("%s: register vas misc device failed\n", __func__);
+ return ret;
+ }
+
+ /*
+ * The hypervisor does not expose multiple VAS instances, but can
+ * see multiple VAS instances on PowerNV. So create 'vas0' directory
+ * on PowerVM.
+ */
+ pseries_vas_kobj = kobject_create_and_add("vas0",
+ &vas_miscdev.this_device->kobj);
+ if (!pseries_vas_kobj) {
+ pr_err("Failed to create VAS sysfs entry\n");
+ return -ENOMEM;
+ }
+
+ if ((vas_caps->feat_type & VAS_GZIP_QOS_FEAT_BIT) ||
+ (vas_caps->feat_type & VAS_GZIP_DEF_FEAT_BIT)) {
+ gzip_caps_kobj = kobject_create_and_add("gzip",
+ pseries_vas_kobj);
+ if (!gzip_caps_kobj) {
+ pr_err("Failed to create VAS GZIP capability entry\n");
+ kobject_put(pseries_vas_kobj);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+#else
+int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps)
+{
+ return 0;
+}
+
+int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps)
+{
+ return 0;
+}
+#endif
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index 75ccd0a599ec..32098e4a2786 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -560,6 +560,10 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
}
}
+ rc = sysfs_add_vas_caps(caps);
+ if (rc)
+ return rc;
+
copypaste_feat = true;
return 0;
@@ -843,6 +847,8 @@ static int __init pseries_vas_init(void)
caps_all.descriptor = be64_to_cpu(hv_caps->descriptor);
caps_all.feat_type = be64_to_cpu(hv_caps->feat_type);
+ sysfs_pseries_vas_init(&caps_all);
+
hv_cop_caps = kmalloc(sizeof(*hv_cop_caps), GFP_KERNEL);
if (!hv_cop_caps) {
rc = -ENOMEM;
diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h
index 8ce9b84693e8..bc393bd74030 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -24,6 +24,9 @@
#define VAS_COPY_PASTE_USER_MODE 0x00000001
#define VAS_COP_OP_USER_MODE 0x00000010
+#define VAS_GZIP_QOS_CAPABILITIES 0x56516F73477A6970
+#define VAS_GZIP_DEFAULT_CAPABILITIES 0x56446566477A6970
+
/*
* Co-processor feature - GZIP QoS windows or GZIP default windows
*/
@@ -120,4 +123,7 @@ struct pseries_vas_window {
char *name;
int fault_virq;
};
+
+int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
+int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
#endif /* _VAS_H */
--
2.27.0
^ permalink raw reply related
* [PATCH v3 10/10] powerpc/pseries/vas: Write 'target_creds' for QoS credits change
From: Haren Myneni @ 2022-01-21 20:01 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin
In-Reply-To: <7d175313528ea7aae20d9141f0efa2e57f44c9f4.camel@linux.ibm.com>
PowerVM support two types of credits - Default (uses normal priority
FIFO) and Qality of service (QoS uses high priproty FIFO). The user
decides the number of QoS credits and sets this value with HMC
interface. With the core add/removal, this value can be changed in HMC
which invokes drmgr to communicate to the kernel.
This patch adds an interface so that drmgr command can write the new
target QoS credits in sysfs. But the kernel gets the new QoS
capabilities from the hypervisor whenever target_creds is updated
to make sure sync with the values in the hypervisor.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas-sysfs.c | 34 +++++++++++++++++++++-
arch/powerpc/platforms/pseries/vas.c | 2 +-
arch/powerpc/platforms/pseries/vas.h | 1 +
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/vas-sysfs.c b/arch/powerpc/platforms/pseries/vas-sysfs.c
index f7609cdef8f8..66f1a0224811 100644
--- a/arch/powerpc/platforms/pseries/vas-sysfs.c
+++ b/arch/powerpc/platforms/pseries/vas-sysfs.c
@@ -36,6 +36,34 @@ static ssize_t avail_creds_show(struct vas_cop_feat_caps *caps, char *buf)
return sprintf(buf, "%d\n", avail_creds);
}
+/*
+ * This function is used to get the notification from the drmgr when
+ * QoS credits are changed as part of DLPAR core add/removal. Though
+ * receiving the total QoS credits here, get the official QoS
+ * capabilities from the hypervisor.
+ */
+static ssize_t target_creds_store(struct vas_cop_feat_caps *caps,
+ const char *buf, size_t count)
+{
+ int err;
+ u16 creds;
+
+ /*
+ * Nothing to do for default credit type.
+ */
+ if (caps->win_type == VAS_GZIP_DEF_FEAT_TYPE)
+ return -EOPNOTSUPP;
+
+ err = kstrtou16(buf, 0, &creds);
+ if (!err)
+ err = vas_reconfig_capabilties(caps->win_type);
+
+ if (err)
+ return -EINVAL;
+
+ return count;
+}
+
#define sysfs_capbs_entry_read(_name) \
static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \
{ \
@@ -52,8 +80,12 @@ struct vas_sysfs_entry {
sysfs_capbs_entry_read(_name); \
static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \
0444, _name##_show, NULL);
+#define VAS_ATTR(_name) \
+ sysfs_capbs_entry_read(_name); \
+ static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \
+ 0644, _name##_show, _name##_store)
-VAS_ATTR_RO(target_creds);
+VAS_ATTR(target_creds);
VAS_ATTR_RO(used_creds);
static struct vas_sysfs_entry avail_creds_attribute =
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index 32098e4a2786..3400f4fc6609 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -722,7 +722,7 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
* changes. Reconfig window configurations based on the credits
* availability from this new capabilities.
*/
-static int vas_reconfig_capabilties(u8 type)
+int vas_reconfig_capabilties(u8 type)
{
struct hv_vas_cop_feat_caps *hv_caps;
struct vas_cop_feat_caps *caps;
diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h
index bc393bd74030..4cf1d0ef66a5 100644
--- a/arch/powerpc/platforms/pseries/vas.h
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -125,5 +125,6 @@ struct pseries_vas_window {
};
int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
+int vas_reconfig_capabilties(u8 type);
int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
#endif /* _VAS_H */
--
2.27.0
^ permalink raw reply related
* [PATCH 09/31] macintosh: changing LED_* from enum led_brightness to actual value
From: Luiz Sampaio @ 2022-01-21 16:54 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, linux-kernel, Luiz Sampaio
In-Reply-To: <20220121165436.30956-1-sampaio.ime@gmail.com>
The enum led_brightness, which contains the declaration of LED_OFF,
LED_ON, LED_HALF and LED_FULL is obsolete, as the led class now supports
max_brightness.
---
drivers/macintosh/via-pmu-led.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index ae067ab2373d..b0a727ad0157 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -54,7 +54,7 @@ static void pmu_led_set(struct led_classdev *led_cdev,
spin_lock_irqsave(&pmu_blink_lock, flags);
switch (brightness) {
- case LED_OFF:
+ case 0:
requested_change = 0;
break;
case LED_FULL:
--
2.34.1
^ permalink raw reply related
* [PATCH 08/31] leds: changing LED_* from enum led_brightness to actual value
From: Luiz Sampaio @ 2022-01-21 16:54 UTC (permalink / raw)
To: Pavel Machek, Matthias Brugger, Michael Hennerich,
Support Opensource, Bartosz Golaszewski, Andreas Werner,
Vadim Pasternak, Sean Wang, Riku Voipio, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Orson Zhai, Baolin Wang,
Chunyan Zhang
Cc: patches, linux-kernel, linux-mediatek, linux-leds, linuxppc-dev,
linux-arm-kernel, Luiz Sampaio
In-Reply-To: <20220121165436.30956-1-sampaio.ime@gmail.com>
The enum led_brightness, which contains the declaration of LED_OFF,
LED_ON, LED_HALF and LED_FULL is obsolete, as the led class now supports
max_brightness.
---
drivers/leds/blink/leds-lgm-sso.c | 8 +++----
drivers/leds/flash/leds-ktd2692.c | 4 ++--
drivers/leds/flash/leds-lm3601x.c | 10 ++++----
drivers/leds/flash/leds-mt6360.c | 10 ++++----
drivers/leds/flash/leds-rt4505.c | 8 +++----
drivers/leds/flash/leds-rt8515.c | 4 ++--
drivers/leds/flash/leds-sgm3140.c | 4 ++--
drivers/leds/led-class.c | 6 ++---
drivers/leds/led-core.c | 8 +++----
drivers/leds/led-triggers.c | 4 ++--
drivers/leds/leds-adp5520.c | 2 +-
drivers/leds/leds-an30259a.c | 8 +++----
drivers/leds/leds-apu.c | 6 ++---
drivers/leds/leds-ariel.c | 8 +++----
drivers/leds/leds-asic3.c | 2 +-
drivers/leds/leds-aw2013.c | 6 ++---
drivers/leds/leds-bcm6328.c | 14 +++++------
drivers/leds/leds-bcm6358.c | 14 +++++------
drivers/leds/leds-bd2802.c | 14 +++++------
drivers/leds/leds-clevo-mail.c | 6 ++---
drivers/leds/leds-cobalt-qube.c | 2 +-
drivers/leds/leds-cpcap.c | 10 ++++----
drivers/leds/leds-da903x.c | 4 ++--
drivers/leds/leds-da9052.c | 4 ++--
drivers/leds/leds-dac124s085.c | 2 +-
drivers/leds/leds-el15203000.c | 4 ++--
drivers/leds/leds-gpio.c | 4 ++--
drivers/leds/leds-is31fl319x.c | 2 +-
drivers/leds/leds-lm3530.c | 4 ++--
drivers/leds/leds-lm3532.c | 8 +++----
drivers/leds/leds-lm3533.c | 4 ++--
drivers/leds/leds-lm3692x.c | 2 +-
drivers/leds/leds-lm3697.c | 6 ++---
drivers/leds/leds-lp3952.c | 4 ++--
drivers/leds/leds-lt3593.c | 2 +-
drivers/leds/leds-max77650.c | 4 ++--
drivers/leds/leds-menf21bmc.c | 2 +-
drivers/leds/leds-mlxcpld.c | 22 ++++++++---------
drivers/leds/leds-mlxreg.c | 10 ++++----
drivers/leds/leds-mt6323.c | 2 +-
drivers/leds/leds-netxbig.c | 4 ++--
drivers/leds/leds-nic78bx.c | 2 +-
drivers/leds/leds-ns2.c | 4 ++--
drivers/leds/leds-ot200.c | 2 +-
drivers/leds/leds-pca9532.c | 6 ++---
drivers/leds/leds-pca955x.c | 30 ++++++++++++------------
drivers/leds/leds-pca963x.c | 4 ++--
drivers/leds/leds-pm8058.c | 8 +++----
drivers/leds/leds-powernv.c | 12 +++++-----
drivers/leds/leds-pwm.c | 2 +-
drivers/leds/leds-rb532.c | 2 +-
drivers/leds/leds-regulator.c | 2 +-
drivers/leds/leds-sc27xx-bltc.c | 6 ++---
drivers/leds/leds-spi-byte.c | 2 +-
drivers/leds/leds-ss4200.c | 12 +++++-----
drivers/leds/leds-sunfire.c | 2 +-
drivers/leds/leds-syscon.c | 2 +-
drivers/leds/leds-tca6507.c | 8 +++----
drivers/leds/leds-wm831x-status.c | 8 +++----
drivers/leds/leds-wm8350.c | 8 +++----
drivers/leds/simple/simatic-ipc-leds.c | 10 ++++----
drivers/leds/trigger/ledtrig-activity.c | 2 +-
drivers/leds/trigger/ledtrig-backlight.c | 4 ++--
drivers/leds/trigger/ledtrig-camera.c | 4 ++--
drivers/leds/trigger/ledtrig-cpu.c | 4 ++--
drivers/leds/trigger/ledtrig-gpio.c | 4 ++--
drivers/leds/trigger/ledtrig-heartbeat.c | 4 ++--
drivers/leds/trigger/ledtrig-netdev.c | 6 ++---
drivers/leds/trigger/ledtrig-oneshot.c | 6 ++---
drivers/leds/trigger/ledtrig-panic.c | 2 +-
drivers/leds/trigger/ledtrig-pattern.c | 2 +-
drivers/leds/trigger/ledtrig-timer.c | 2 +-
drivers/leds/trigger/ledtrig-transient.c | 6 ++---
drivers/leds/trigger/ledtrig-tty.c | 4 ++--
74 files changed, 217 insertions(+), 217 deletions(-)
diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c
index 6f270c0272fb..26c17c64bd4f 100644
--- a/drivers/leds/blink/leds-lgm-sso.c
+++ b/drivers/leds/blink/leds-lgm-sso.c
@@ -51,7 +51,7 @@
#define SSO_LED_MAX_NUM SZ_32
#define MAX_FREQ_RANK 10
#define DEF_GPTC_CLK_RATE 200000000
-#define SSO_DEF_BRIGHTNESS LED_HALF
+#define SSO_DEF_BRIGHTNESS 127
#define DATA_CLK_EDGE 0 /* 0-rising, 1-falling */
static const u32 freq_div_tbl[] = {4000, 2000, 1000, 800};
@@ -244,7 +244,7 @@ static void sso_led_brightness_set(struct led_classdev *led_cdev,
desc->brightness = brightness;
regmap_write(priv->mmap, DUTY_CYCLE(desc->pin), brightness);
- if (brightness == LED_OFF)
+ if (brightness == 0)
val = 0;
else
val = 1;
@@ -360,7 +360,7 @@ static int sso_create_led(struct sso_led_priv *priv, struct sso_led *led,
led->cdev.brightness_set = sso_led_brightness_set;
led->cdev.brightness_get = sso_led_brightness_get;
led->cdev.brightness = desc->brightness;
- led->cdev.max_brightness = LED_FULL;
+ led->cdev.max_brightness = 255;
if (desc->retain_state_shutdown)
led->cdev.flags |= LED_RETAIN_AT_SHUTDOWN;
@@ -696,7 +696,7 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
if (!fwnode_property_read_string(fwnode_child, "default-state", &tmp)) {
if (!strcmp(tmp, "on"))
- desc->brightness = LED_FULL;
+ desc->brightness = 255;
}
ret = sso_create_led(priv, led, fwnode_child);
diff --git a/drivers/leds/flash/leds-ktd2692.c b/drivers/leds/flash/leds-ktd2692.c
index ed1f20a58bf6..30937156d156 100644
--- a/drivers/leds/flash/leds-ktd2692.c
+++ b/drivers/leds/flash/leds-ktd2692.c
@@ -161,7 +161,7 @@ static int ktd2692_led_brightness_set(struct led_classdev *led_cdev,
mutex_lock(&led->lock);
- if (brightness == LED_OFF) {
+ if (brightness == 0) {
led->mode = KTD2692_MODE_DISABLE;
gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
} else {
@@ -199,7 +199,7 @@ static int ktd2692_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,
ktd2692_expresswire_write(led, led->mode | KTD2692_REG_MODE_BASE);
- fled_cdev->led_cdev.brightness = LED_OFF;
+ fled_cdev->led_cdev.brightness = 0;
led->mode = KTD2692_MODE_DISABLE;
mutex_unlock(&led->lock);
diff --git a/drivers/leds/flash/leds-lm3601x.c b/drivers/leds/flash/leds-lm3601x.c
index d0e1d4814042..0edcb56a8e8d 100644
--- a/drivers/leds/flash/leds-lm3601x.c
+++ b/drivers/leds/flash/leds-lm3601x.c
@@ -185,9 +185,9 @@ static int lm3601x_brightness_set(struct led_classdev *cdev,
else
led_mode_val = LM3601X_MODE_IR_DRV;
- if (brightness == LED_OFF) {
+ if (brightness == 0) {
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
- led_mode_val, LED_OFF);
+ led_mode_val, 0);
goto out;
}
@@ -232,7 +232,7 @@ static int lm3601x_strobe_set(struct led_classdev_flash *fled_cdev,
LM3601X_MODE_STROBE);
else
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
- LM3601X_MODE_STROBE, LED_OFF);
+ LM3601X_MODE_STROBE, 0);
ret = lm3601x_read_faults(led);
out:
@@ -252,9 +252,9 @@ static int lm3601x_flash_brightness_set(struct led_classdev_flash *fled_cdev,
if (ret < 0)
goto out;
- if (brightness == LED_OFF) {
+ if (brightness == 0) {
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
- LM3601X_MODE_STROBE, LED_OFF);
+ LM3601X_MODE_STROBE, 0);
goto out;
}
diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
index e1066a52d2d2..69145a154b53 100644
--- a/drivers/leds/flash/leds-mt6360.c
+++ b/drivers/leds/flash/leds-mt6360.c
@@ -402,7 +402,7 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
return ret;
if (!(regval & MT6360_ISNK_ENMASK(led->led_no)))
- level = LED_OFF;
+ level = 0;
switch (led->default_state) {
case STATE_ON:
@@ -412,7 +412,7 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
led->isnk.brightness = min(level, led->isnk.max_brightness);
break;
default:
- led->isnk.brightness = LED_OFF;
+ led->isnk.brightness = 0;
}
return mt6360_isnk_brightness_set(&led->isnk, led->isnk.brightness);
@@ -440,7 +440,7 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
if ((regval & enable_mask) == enable_mask)
level += 1;
else
- level = LED_OFF;
+ level = 0;
switch (led->default_state) {
case STATE_ON:
@@ -451,7 +451,7 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
min(level, flash->led_cdev.max_brightness);
break;
default:
- flash->led_cdev.brightness = LED_OFF;
+ flash->led_cdev.brightness = 0;
}
return mt6360_torch_brightness_set(&flash->led_cdev,
@@ -542,7 +542,7 @@ static int mt6360_led_register(struct device *parent, struct mt6360_led *led,
switch (led->led_no) {
case MT6360_VIRTUAL_MULTICOLOR:
- ret = mt6360_mc_brightness_set(&led->mc.led_cdev, LED_OFF);
+ ret = mt6360_mc_brightness_set(&led->mc.led_cdev, 0);
if (ret) {
dev_err(parent,
"Failed to init multicolor brightness\n");
diff --git a/drivers/leds/flash/leds-rt4505.c b/drivers/leds/flash/leds-rt4505.c
index ee129ab7255d..d92899347928 100644
--- a/drivers/leds/flash/leds-rt4505.c
+++ b/drivers/leds/flash/leds-rt4505.c
@@ -59,7 +59,7 @@ static int rt4505_torch_brightness_set(struct led_classdev *lcdev,
mutex_lock(&priv->lock);
- if (level != LED_OFF) {
+ if (level != 0) {
ret = regmap_update_bits(priv->regmap,
RT4505_REG_ILED, RT4505_ITORCH_MASK,
(level - 1) << RT4505_ITORCH_SHIFT);
@@ -90,19 +90,19 @@ static enum led_brightness rt4505_torch_brightness_get(
ret = regmap_read(priv->regmap, RT4505_REG_ENABLE, &val);
if (ret) {
dev_err(lcdev->dev, "Failed to get LED enable\n");
- ret = LED_OFF;
+ ret = 0;
goto unlock;
}
if ((val & RT4505_ENABLE_MASK) != RT4505_TORCH_SET) {
- ret = LED_OFF;
+ ret = 0;
goto unlock;
}
ret = regmap_read(priv->regmap, RT4505_REG_ILED, &val);
if (ret) {
dev_err(lcdev->dev, "Failed to get LED brightness\n");
- ret = LED_OFF;
+ ret = 0;
goto unlock;
}
diff --git a/drivers/leds/flash/leds-rt8515.c b/drivers/leds/flash/leds-rt8515.c
index 44904fdee3cc..e9eb5f57fe50 100644
--- a/drivers/leds/flash/leds-rt8515.c
+++ b/drivers/leds/flash/leds-rt8515.c
@@ -95,7 +95,7 @@ static int rt8515_led_brightness_set(struct led_classdev *led,
mutex_lock(&rt->lock);
- if (brightness == LED_OFF) {
+ if (brightness == 0) {
/* Off */
rt8515_gpio_led_off(rt);
} else if (brightness < RT8515_TORCH_MAX) {
@@ -132,7 +132,7 @@ static int rt8515_led_flash_strobe_set(struct led_classdev_flash *fled,
rt8515_gpio_led_off(rt);
}
- fled->led_cdev.brightness = LED_OFF;
+ fled->led_cdev.brightness = 0;
/* After this the torch LED will be disabled */
mutex_unlock(&rt->lock);
diff --git a/drivers/leds/flash/leds-sgm3140.c b/drivers/leds/flash/leds-sgm3140.c
index f4f831570f11..4c36488a33bb 100644
--- a/drivers/leds/flash/leds-sgm3140.c
+++ b/drivers/leds/flash/leds-sgm3140.c
@@ -101,7 +101,7 @@ static int sgm3140_brightness_set(struct led_classdev *led_cdev,
{
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
struct sgm3140 *priv = flcdev_to_sgm3140(fled_cdev);
- bool enable = brightness == LED_ON;
+ bool enable = brightness == 1;
int ret;
if (priv->enabled == enable)
@@ -241,7 +241,7 @@ static int sgm3140_probe(struct platform_device *pdev)
fled_cdev->ops = &sgm3140_flash_ops;
led_cdev->brightness_set_blocking = sgm3140_brightness_set;
- led_cdev->max_brightness = LED_ON;
+ led_cdev->max_brightness = 1;
led_cdev->flags |= LED_DEV_CAP_FLASH;
sgm3140_init_flash_timeout(priv);
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 6a8ea94834fa..786132946a10 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -53,7 +53,7 @@ static ssize_t brightness_store(struct device *dev,
if (ret)
goto unlock;
- if (state == LED_OFF)
+ if (state == 0)
led_trigger_remove(led_cdev);
led_set_brightness(led_cdev, state);
flush_work(&led_cdev->set_brightness_work);
@@ -405,7 +405,7 @@ int led_classdev_register_ext(struct device *parent,
up_write(&leds_list_lock);
if (!led_cdev->max_brightness)
- led_cdev->max_brightness = LED_FULL;
+ led_cdev->max_brightness = 255;
led_update_brightness(led_cdev);
@@ -448,7 +448,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
led_stop_software_blink(led_cdev);
if (!(led_cdev->flags & LED_RETAIN_AT_SHUTDOWN))
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
flush_work(&led_cdev->set_brightness_work);
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 4a97cb745788..eb51f9f7d81c 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -64,7 +64,7 @@ static void led_timer_function(struct timer_list *t)
unsigned long delay;
if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
- led_set_brightness_nosleep(led_cdev, LED_OFF);
+ led_set_brightness_nosleep(led_cdev, 0);
clear_bit(LED_BLINK_SW, &led_cdev->work_flags);
return;
}
@@ -89,7 +89,7 @@ static void led_timer_function(struct timer_list *t)
* to restore it when the delay_off period is over.
*/
led_cdev->blink_brightness = brightness;
- brightness = LED_OFF;
+ brightness = 0;
delay = led_cdev->blink_delay_off;
}
@@ -121,7 +121,7 @@ static void set_brightness_delayed(struct work_struct *ws)
int ret = 0;
if (test_and_clear_bit(LED_BLINK_DISABLE, &led_cdev->work_flags)) {
- led_cdev->delayed_set_value = LED_OFF;
+ led_cdev->delayed_set_value = 0;
led_stop_software_blink(led_cdev);
}
@@ -154,7 +154,7 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
/* never on - just set to off */
if (!delay_on) {
- led_set_brightness_nosleep(led_cdev, LED_OFF);
+ led_set_brightness_nosleep(led_cdev, 0);
return;
}
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 072491d3e17b..17fba1ad0d3d 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -185,7 +185,7 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
led_cdev->activated = false;
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
}
if (trig) {
spin_lock(&trig->leddev_list_lock);
@@ -231,7 +231,7 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
synchronize_rcu();
led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
kfree(event);
return ret;
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c
index 5a0cc7af2df8..0cc92acffbed 100644
--- a/drivers/leds/leds-adp5520.c
+++ b/drivers/leds/leds-adp5520.c
@@ -125,7 +125,7 @@ static int adp5520_led_probe(struct platform_device *pdev)
led_dat->cdev.name = cur_led->name;
led_dat->cdev.default_trigger = cur_led->default_trigger;
led_dat->cdev.brightness_set_blocking = adp5520_led_set;
- led_dat->cdev.brightness = LED_OFF;
+ led_dat->cdev.brightness = 0;
if (cur_led->flags & ADP5520_FLAG_LED_MASK)
led_dat->flags = cur_led->flags;
diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c
index a0df1fb28774..8df45d78418b 100644
--- a/drivers/leds/leds-an30259a.c
+++ b/drivers/leds/leds-an30259a.c
@@ -93,7 +93,7 @@ static int an30259a_brightness_set(struct led_classdev *cdev,
goto error;
switch (brightness) {
- case LED_OFF:
+ case 0:
led_on &= ~AN30259A_LED_EN(led->num);
led_on &= ~AN30259A_LED_SLOPE(led->num);
led->sloping = false;
@@ -262,7 +262,7 @@ static void an30259a_init_default_state(struct an30259a_led *led)
switch (led->default_state) {
case STATE_ON:
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
break;
case STATE_KEEP:
err = regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on);
@@ -270,14 +270,14 @@ static void an30259a_init_default_state(struct an30259a_led *led)
break;
if (!(led_on & AN30259A_LED_EN(led->num))) {
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
break;
}
regmap_read(chip->regmap, AN30259A_REG_LEDCC(led->num),
&led->cdev.brightness);
break;
default:
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
}
an30259a_brightness_set(&led->cdev, led->cdev.brightness);
diff --git a/drivers/leds/leds-apu.c b/drivers/leds/leds-apu.c
index c409b80c236d..172f86daab3b 100644
--- a/drivers/leds/leds-apu.c
+++ b/drivers/leds/leds-apu.c
@@ -77,9 +77,9 @@ struct apu_led_pdata {
static struct apu_led_pdata *apu_led;
static const struct apu_led_profile apu1_led_profile[] = {
- { "apu:green:1", LED_ON, APU1_FCH_GPIO_BASE + 0 * APU1_IOSIZE },
- { "apu:green:2", LED_OFF, APU1_FCH_GPIO_BASE + 1 * APU1_IOSIZE },
- { "apu:green:3", LED_OFF, APU1_FCH_GPIO_BASE + 2 * APU1_IOSIZE },
+ { "apu:green:1", 1, APU1_FCH_GPIO_BASE + 0 * APU1_IOSIZE },
+ { "apu:green:2", 0, APU1_FCH_GPIO_BASE + 1 * APU1_IOSIZE },
+ { "apu:green:3", 0, APU1_FCH_GPIO_BASE + 2 * APU1_IOSIZE },
};
static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
diff --git a/drivers/leds/leds-ariel.c b/drivers/leds/leds-ariel.c
index 49e1bddaa15e..6a6cfdf7c7df 100644
--- a/drivers/leds/leds-ariel.c
+++ b/drivers/leds/leds-ariel.c
@@ -37,12 +37,12 @@ static enum led_brightness ariel_led_get(struct led_classdev *led_cdev)
unsigned int led_status = 0;
if (regmap_read(led->ec_ram, led->ec_index, &led_status))
- return LED_OFF;
+ return 0;
if (led_status == EC_LED_STILL)
- return LED_FULL;
+ return 255;
else
- return LED_OFF;
+ return 0;
}
static void ariel_led_set(struct led_classdev *led_cdev,
@@ -50,7 +50,7 @@ static void ariel_led_set(struct led_classdev *led_cdev,
{
struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);
- if (brightness == LED_OFF)
+ if (brightness == 0)
regmap_write(led->ec_ram, led->ec_index, EC_LED_OFF);
else
regmap_write(led->ec_ram, led->ec_index, EC_LED_STILL);
diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c
index 8cbc1b8bafa5..53b7b8551808 100644
--- a/drivers/leds/leds-asic3.c
+++ b/drivers/leds/leds-asic3.c
@@ -42,7 +42,7 @@ static void brightness_set(struct led_classdev *cdev,
u32 timebase;
unsigned int base;
- timebase = (value == LED_OFF) ? 0 : (LED_EN|0x4);
+ timebase = (value == 0) ? 0 : (LED_EN|0x4);
base = led_n_base[cell->id];
asic3_write_register(asic, (base + ASIC3_LED_PeriodTime), 32);
diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c
index 80d937454aee..4b3043ed1d69 100644
--- a/drivers/leds/leds-aw2013.c
+++ b/drivers/leds/leds-aw2013.c
@@ -206,7 +206,7 @@ static int aw2013_blink_set(struct led_classdev *cdev,
}
if (!led->cdev.brightness) {
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
ret = aw2013_brightness_set(&led->cdev, led->cdev.brightness);
if (ret)
return ret;
@@ -214,8 +214,8 @@ static int aw2013_blink_set(struct led_classdev *cdev,
/* Never on - just set to off */
if (!*delay_on) {
- led->cdev.brightness = LED_OFF;
- return aw2013_brightness_set(&led->cdev, LED_OFF);
+ led->cdev.brightness = 0;
+ return aw2013_brightness_set(&led->cdev, 0);
}
mutex_lock(&led->chip->mutex);
diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c
index 2d4d87957a30..7a2d26429653 100644
--- a/drivers/leds/leds-bcm6328.c
+++ b/drivers/leds/leds-bcm6328.c
@@ -138,8 +138,8 @@ static void bcm6328_led_set(struct led_classdev *led_cdev,
led->blink_leds[1] &= ~BIT(led->pin);
/* Set LED on/off */
- if ((led->active_low && value == LED_OFF) ||
- (!led->active_low && value != LED_OFF))
+ if ((led->active_low && value == 0) ||
+ (!led->active_low && value != 0))
bcm6328_led_mode(led, BCM6328_LED_MODE_ON);
else
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
@@ -348,7 +348,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
} else if (!strcmp(state, "keep")) {
void __iomem *mode;
unsigned long val, shift;
@@ -364,14 +364,14 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
val &= BCM6328_LED_MODE_MASK;
if ((led->active_low && val == BCM6328_LED_MODE_OFF) ||
(!led->active_low && val == BCM6328_LED_MODE_ON))
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
else
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
} else {
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
}
} else {
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
}
bcm6328_led_set(&led->cdev, led->cdev.brightness);
diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
index 9d2e487fa08a..955fdd4e0967 100644
--- a/drivers/leds/leds-bcm6358.c
+++ b/drivers/leds/leds-bcm6358.c
@@ -82,8 +82,8 @@ static void bcm6358_led_set(struct led_classdev *led_cdev,
spin_lock_irqsave(led->lock, flags);
bcm6358_led_busy(led->mem);
val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
- if ((led->active_low && value == LED_OFF) ||
- (!led->active_low && value != LED_OFF))
+ if ((led->active_low && value == 0) ||
+ (!led->active_low && value != 0))
val |= BIT(led->pin);
else
val &= ~(BIT(led->pin));
@@ -112,21 +112,21 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
} else if (!strcmp(state, "keep")) {
unsigned long val;
val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
val &= BIT(led->pin);
if ((led->active_low && !val) ||
(!led->active_low && val))
- led->cdev.brightness = LED_FULL;
+ led->cdev.brightness = 255;
else
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
} else {
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
}
} else {
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
}
bcm6358_led_set(&led->cdev, led->cdev.brightness);
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 8bbaef5a2986..096b8c86c0ea 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -522,7 +522,7 @@ static int bd2802_set_##name##_brightness(struct led_classdev *led_cdev,\
container_of(led_cdev, struct bd2802_led, cdev_##name); \
led->led_id = id; \
led->color = clr; \
- if (value == LED_OFF) { \
+ if (value == 0) { \
led->state = BD2802_OFF; \
bd2802_turn_off(led, led->led_id, led->color); \
} else { \
@@ -557,7 +557,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
int ret;
led->cdev_led1r.name = "led1_R";
- led->cdev_led1r.brightness = LED_OFF;
+ led->cdev_led1r.brightness = 0;
led->cdev_led1r.brightness_set_blocking = bd2802_set_led1r_brightness;
led->cdev_led1r.blink_set = bd2802_set_led1r_blink;
@@ -569,7 +569,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
}
led->cdev_led1g.name = "led1_G";
- led->cdev_led1g.brightness = LED_OFF;
+ led->cdev_led1g.brightness = 0;
led->cdev_led1g.brightness_set_blocking = bd2802_set_led1g_brightness;
led->cdev_led1g.blink_set = bd2802_set_led1g_blink;
@@ -581,7 +581,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
}
led->cdev_led1b.name = "led1_B";
- led->cdev_led1b.brightness = LED_OFF;
+ led->cdev_led1b.brightness = 0;
led->cdev_led1b.brightness_set_blocking = bd2802_set_led1b_brightness;
led->cdev_led1b.blink_set = bd2802_set_led1b_blink;
@@ -593,7 +593,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
}
led->cdev_led2r.name = "led2_R";
- led->cdev_led2r.brightness = LED_OFF;
+ led->cdev_led2r.brightness = 0;
led->cdev_led2r.brightness_set_blocking = bd2802_set_led2r_brightness;
led->cdev_led2r.blink_set = bd2802_set_led2r_blink;
@@ -605,7 +605,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
}
led->cdev_led2g.name = "led2_G";
- led->cdev_led2g.brightness = LED_OFF;
+ led->cdev_led2g.brightness = 0;
led->cdev_led2g.brightness_set_blocking = bd2802_set_led2g_brightness;
led->cdev_led2g.blink_set = bd2802_set_led2g_blink;
@@ -617,7 +617,7 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
}
led->cdev_led2b.name = "led2_B";
- led->cdev_led2b.brightness = LED_OFF;
+ led->cdev_led2b.brightness = 0;
led->cdev_led2b.brightness_set_blocking = bd2802_set_led2b_brightness;
led->cdev_led2b.blink_set = bd2802_set_led2b_blink;
led->cdev_led2b.flags |= LED_CORE_SUSPENDRESUME;
diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index f512e99b976b..24e985539b18 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -97,9 +97,9 @@ static void clevo_mail_led_set(struct led_classdev *led_cdev,
{
i8042_lock_chip();
- if (value == LED_OFF)
+ if (value == 0)
i8042_command(NULL, CLEVO_MAIL_LED_OFF);
- else if (value <= LED_HALF)
+ else if (value <= 127)
i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
else
i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
@@ -210,7 +210,7 @@ static void __exit clevo_mail_led_exit(void)
platform_device_unregister(pdev);
platform_driver_unregister(&clevo_mail_led_driver);
- clevo_mail_led_set(NULL, LED_OFF);
+ clevo_mail_led_set(NULL, 0);
}
module_init(clevo_mail_led_init);
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c
index ef22e1e94048..4af123a10342 100644
--- a/drivers/leds/leds-cobalt-qube.c
+++ b/drivers/leds/leds-cobalt-qube.c
@@ -29,7 +29,7 @@ static void qube_front_led_set(struct led_classdev *led_cdev,
static struct led_classdev qube_front_led = {
.name = "qube::front",
- .brightness = LED_FULL,
+ .brightness = 255,
.brightness_set = qube_front_led_set,
.default_trigger = "default-on",
};
diff --git a/drivers/leds/leds-cpcap.c b/drivers/leds/leds-cpcap.c
index 7d41ce8c9bb1..8f7eba98a636 100644
--- a/drivers/leds/leds-cpcap.c
+++ b/drivers/leds/leds-cpcap.c
@@ -108,13 +108,13 @@ static int cpcap_led_set(struct led_classdev *ledc, enum led_brightness value)
mutex_lock(&led->update_lock);
- if (value > LED_OFF) {
+ if (value > 0) {
err = cpcap_led_set_power(led, true);
if (err)
goto exit;
}
- if (value == LED_OFF) {
+ if (value == 0) {
/* Avoid HW issue by turning off current before duty cycle */
err = regmap_update_bits(led->regmap,
led->info->reg, led->info->mask, CPCAP_LED_NO_CURRENT);
@@ -123,9 +123,9 @@ static int cpcap_led_set(struct led_classdev *ledc, enum led_brightness value)
goto exit;
}
- brightness = cpcap_led_val(value, LED_OFF);
+ brightness = cpcap_led_val(value, 0);
} else {
- brightness = cpcap_led_val(value, LED_ON);
+ brightness = cpcap_led_val(value, 1);
}
err = regmap_update_bits(led->regmap, led->info->reg, led->info->mask,
@@ -135,7 +135,7 @@ static int cpcap_led_set(struct led_classdev *ledc, enum led_brightness value)
goto exit;
}
- if (value == LED_OFF) {
+ if (value == 0) {
err = cpcap_led_set_power(led, false);
if (err)
goto exit;
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c
index 2b5fb00438a2..a09446591add 100644
--- a/drivers/leds/leds-da903x.c
+++ b/drivers/leds/leds-da903x.c
@@ -66,7 +66,7 @@ static int da903x_led_set(struct led_classdev *led_cdev,
case DA9034_ID_LED_1:
case DA9034_ID_LED_2:
offset = DA9034_LED_OFFSET(led->id);
- val = (value * 0x5f / LED_FULL) & 0x7f;
+ val = (value * 0x5f / 255) & 0x7f;
val |= (led->flags & DA9034_LED_RAMP) ? 0x80 : 0;
ret = da903x_write(led->master, DA9034_LED1_CONTROL + offset,
val);
@@ -104,7 +104,7 @@ static int da903x_led_probe(struct platform_device *pdev)
led->cdev.name = pdata->name;
led->cdev.default_trigger = pdata->default_trigger;
led->cdev.brightness_set_blocking = da903x_led_set;
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
led->id = id;
led->flags = pdata->flags;
diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c
index 04060c862bf9..69b72892b540 100644
--- a/drivers/leds/leds-da9052.c
+++ b/drivers/leds/leds-da9052.c
@@ -119,7 +119,7 @@ static int da9052_led_probe(struct platform_device *pdev)
for (i = 0; i < pled->num_leds; i++) {
led[i].cdev.name = pled->leds[i].name;
led[i].cdev.brightness_set_blocking = da9052_led_set;
- led[i].cdev.brightness = LED_OFF;
+ led[i].cdev.brightness = 0;
led[i].cdev.max_brightness = DA9052_MAX_BRIGHTNESS;
led[i].led_index = pled->leds[i].flags;
led[i].da9052 = dev_get_drvdata(pdev->dev.parent);
@@ -169,7 +169,7 @@ static int da9052_led_remove(struct platform_device *pdev)
pled = pdata->pled;
for (i = 0; i < pled->num_leds; i++) {
- da9052_set_led_brightness(&led[i], LED_OFF);
+ da9052_set_led_brightness(&led[i], 0);
led_classdev_unregister(&led[i].cdev);
}
diff --git a/drivers/leds/leds-dac124s085.c b/drivers/leds/leds-dac124s085.c
index 20dc9b9d7dea..582d9a070115 100644
--- a/drivers/leds/leds-dac124s085.c
+++ b/drivers/leds/leds-dac124s085.c
@@ -66,7 +66,7 @@ static int dac124s085_probe(struct spi_device *spi)
snprintf(led->name, sizeof(led->name), "dac124s085-%d", i);
mutex_init(&led->mutex);
led->ldev.name = led->name;
- led->ldev.brightness = LED_OFF;
+ led->ldev.brightness = 0;
led->ldev.max_brightness = 0xfff;
led->ldev.brightness_set_blocking = dac124s085_set_brightness;
ret = led_classdev_register(&spi->dev, &led->ldev);
diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c
index f9eb59a25570..b1a7ceaca434 100644
--- a/drivers/leds/leds-el15203000.c
+++ b/drivers/leds/leds-el15203000.c
@@ -133,7 +133,7 @@ static int el15203000_set_blocking(struct led_classdev *ldev,
{
struct el15203000_led *led = to_el15203000_led(ldev);
- return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON);
+ return el15203000_cmd(led, brightness == 0 ? EL_OFF : EL_ON);
}
static int el15203000_pattern_set_S(struct led_classdev *ldev,
@@ -256,7 +256,7 @@ static int el15203000_probe_dt(struct el15203000 *priv)
}
led->priv = priv;
- led->ldev.max_brightness = LED_ON;
+ led->ldev.max_brightness = 1;
led->ldev.brightness_set_blocking = el15203000_set_blocking;
if (led->reg == 'S') {
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 092eb59a7d32..ac363efc37bc 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -38,7 +38,7 @@ static void gpio_led_set(struct led_classdev *led_cdev,
struct gpio_led_data *led_dat = cdev_to_gpio_led_data(led_cdev);
int level;
- if (value == LED_OFF)
+ if (value == 0)
level = 0;
else
level = 1;
@@ -292,7 +292,7 @@ static void gpio_led_shutdown(struct platform_device *pdev)
struct gpio_led_data *led = &priv->leds[i];
if (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN))
- gpio_led_set(&led->cdev, LED_OFF);
+ gpio_led_set(&led->cdev, 0);
}
}
diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index 4161b9dd7e48..2a9c8dcc9a2c 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -140,7 +140,7 @@ static int is31fl319x_brightness_set(struct led_classdev *cdev,
ret = regmap_read(is31->regmap, IS31FL319X_PWM(i), &pwm_value);
dev_dbg(&is31->client->dev, "%s read %d: ret=%d: %d\n",
__func__, i, ret, pwm_value);
- on = ret >= 0 && pwm_value > LED_OFF;
+ on = ret >= 0 && pwm_value > 0;
if (i < 3)
ctrl1 |= on << i; /* 0..2 => bit 0..2 */
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index e72393534b72..a5358cac5d4d 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -174,7 +174,7 @@ static void lm3530_als_configure(struct lm3530_platform_data *pdata,
for (i = 0; i < LM3530_ALS_ZB_MAX; i++)
als->zones[i] = (((als_vmin + LM3530_ALS_OFFSET_mV) +
- als_vstep + (i * als_vstep)) * LED_FULL) / 1000;
+ als_vstep + (i * als_vstep)) * 255) / 1000;
als->config =
(pdata->als_avrg_time << LM3530_ALS_AVG_TIME_SHIFT) |
@@ -436,7 +436,7 @@ static int lm3530_probe(struct i2c_client *client,
drvdata->mode = pdata->mode;
drvdata->client = client;
drvdata->pdata = pdata;
- drvdata->brightness = LED_OFF;
+ drvdata->brightness = 0;
drvdata->enable = false;
drvdata->led_dev.name = LM3530_LED_DEV;
drvdata->led_dev.brightness_set = lm3530_brightness_set;
diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index beb53040e09e..b0671fe4957b 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -354,7 +354,7 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev,
mutex_lock(&led->priv->lock);
if (led->mode == LM3532_ALS_CTRL) {
- if (brt_val > LED_OFF)
+ if (brt_val > 0)
ret = lm3532_led_enable(led);
else
ret = lm3532_led_disable(led);
@@ -362,7 +362,7 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev,
goto unlock;
}
- if (brt_val == LED_OFF) {
+ if (brt_val == 0) {
ret = lm3532_led_disable(led);
goto unlock;
}
@@ -459,9 +459,9 @@ static int lm3532_als_configure(struct lm3532_data *priv,
for (i = 0; i < LM3532_ALS_ZB_MAX; i++) {
als->zones_lo[i] = ((als_vmin + als_vstep + (i * als_vstep)) *
- LED_FULL) / 1000;
+ 255) / 1000;
als->zones_hi[i] = ((als_vmin + LM3532_ALS_OFFSET_mV +
- als_vstep + (i * als_vstep)) * LED_FULL) / 1000;
+ als_vstep + (i * als_vstep)) * 255) / 1000;
zone_reg = LM3532_REG_ZN_0_HI + i * 2;
ret = regmap_write(priv->regmap, zone_reg, als->zones_lo[i]);
diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index 43d5970d96aa..7411c528a0d4 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -678,7 +678,7 @@ static int lm3533_led_probe(struct platform_device *pdev)
led->cdev.brightness_set_blocking = lm3533_led_set;
led->cdev.brightness_get = lm3533_led_get;
led->cdev.blink_set = lm3533_led_blink_set;
- led->cdev.brightness = LED_OFF;
+ led->cdev.brightness = 0;
led->cdev.groups = lm3533_led_attribute_groups;
led->id = pdev->id;
@@ -738,7 +738,7 @@ static void lm3533_led_shutdown(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s\n", __func__);
lm3533_ctrlbank_disable(&led->cb);
- lm3533_led_set(&led->cdev, LED_OFF); /* disable blink */
+ lm3533_led_set(&led->cdev, 0); /* disable blink */
}
static struct platform_driver lm3533_led_driver = {
diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index afe6fb297855..be5fbed7f428 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -440,7 +440,7 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
}
ret = fwnode_property_read_u32(child, "led-max-microamp", &max_cur);
- led->led_dev.max_brightness = ret ? LED_FULL :
+ led->led_dev.max_brightness = ret ? 255 :
lm3692x_max_brightness(led, max_cur);
init_data.fwnode = child;
diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c
index a8c9322558cc..9366e0b7fb4d 100644
--- a/drivers/leds/leds-lm3697.c
+++ b/drivers/leds/leds-lm3697.c
@@ -52,7 +52,7 @@
* @lmu_data: Register and setting values for common code
* @control_bank: Control bank the LED is associated to. 0 is control bank A
* 1 is control bank B
- * @enabled: LED brightness level (or LED_OFF)
+ * @enabled: LED brightness level (or 0)
* @num_leds: Number of LEDs available
*/
struct lm3697_led {
@@ -130,7 +130,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
mutex_lock(&led->priv->lock);
- if (brt_val == LED_OFF) {
+ if (brt_val == 0) {
ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE,
ctrl_en_val, ~ctrl_en_val);
if (ret) {
@@ -138,7 +138,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
goto brightness_out;
}
- led->enabled = LED_OFF;
+ led->enabled = 0;
} else {
ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
if (ret) {
diff --git a/drivers/leds/leds-lp3952.c b/drivers/leds/leds-lp3952.c
index 6ee9131fbf25..3b65b0206312 100644
--- a/drivers/leds/leds-lp3952.c
+++ b/drivers/leds/leds-lp3952.c
@@ -67,7 +67,7 @@ static int lp3952_set_brightness(struct led_classdev *cdev,
dev_dbg(cdev->dev, "Brightness request: %d on %d\n", value,
led->channel);
- if (value == LED_OFF) {
+ if (value == 0) {
lp3952_on_off(priv, led->channel, false);
return 0;
}
@@ -124,7 +124,7 @@ static int lp3952_register_led_classdev(struct lp3952_led_array *priv)
continue;
priv->leds[i].cdev.name = priv->leds[i].name;
- priv->leds[i].cdev.brightness = LED_OFF;
+ priv->leds[i].cdev.brightness = 0;
priv->leds[i].cdev.max_brightness = LP3952_BRIGHT_MAX;
priv->leds[i].cdev.brightness_set_blocking =
lp3952_set_brightness;
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
index d0160fde0f94..dd69c190ce10 100644
--- a/drivers/leds/leds-lt3593.c
+++ b/drivers/leds/leds-lt3593.c
@@ -90,7 +90,7 @@ static int lt3593_led_probe(struct platform_device *pdev)
}
led_data->cdev.brightness_set_blocking = lt3593_led_set;
- led_data->cdev.brightness = state ? LED_FULL : LED_OFF;
+ led_data->cdev.brightness = state ? 255 : 0;
init_data.fwnode = child;
init_data.devicename = LED_LT3593_NAME;
diff --git a/drivers/leds/leds-max77650.c b/drivers/leds/leds-max77650.c
index 1eeac56b0014..5ea67e3c319c 100644
--- a/drivers/leds/leds-max77650.c
+++ b/drivers/leds/leds-max77650.c
@@ -45,14 +45,14 @@ static struct max77650_led *max77650_to_led(struct led_classdev *cdev)
}
static int max77650_led_brightness_set(struct led_classdev *cdev,
- enum led_brightness brightness)
+ unsigned int brightness)
{
struct max77650_led *led = max77650_to_led(cdev);
int val, mask;
mask = MAX77650_LED_BR_MASK | MAX77650_LED_EN_MASK;
- if (brightness == LED_OFF)
+ if (brightness == 0)
val = MAX77650_LED_DISABLE;
else
val = MAX77650_LED_ENABLE | brightness;
diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-menf21bmc.c
index 6b1b47160602..0203db50cda2 100644
--- a/drivers/leds/leds-menf21bmc.c
+++ b/drivers/leds/leds-menf21bmc.c
@@ -62,7 +62,7 @@ menf21bmc_led_set(struct led_classdev *led_cdev, enum led_brightness value)
if (led_val < 0)
goto err_out;
- if (value == LED_OFF)
+ if (value == 0)
led_val &= ~led->led_bit;
else
led_val |= led->led_bit;
diff --git a/drivers/leds/leds-mlxcpld.c b/drivers/leds/leds-mlxcpld.c
index 1355c84a2919..93526857e766 100644
--- a/drivers/leds/leds-mlxcpld.c
+++ b/drivers/leds/leds-mlxcpld.c
@@ -131,7 +131,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:fan1:green",
},
{
- 0x21, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x21, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:fan1:red",
},
{
@@ -139,7 +139,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:fan2:green",
},
{
- 0x21, 0x0f, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x21, 0x0f, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:fan2:red",
},
{
@@ -147,7 +147,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:fan3:green",
},
{
- 0x22, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x22, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:fan3:red",
},
{
@@ -155,7 +155,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:fan4:green",
},
{
- 0x22, 0x0f, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x22, 0x0f, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:fan4:red",
},
{
@@ -163,7 +163,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:psu:green",
},
{
- 0x20, 0x0f, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x20, 0x0f, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:psu:red",
},
{
@@ -171,7 +171,7 @@ static struct mlxcpld_led_profile mlxcpld_led_default_profile[] = {
"mlxcpld:status:green",
},
{
- 0x20, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x20, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:status:red",
},
};
@@ -183,7 +183,7 @@ static struct mlxcpld_led_profile mlxcpld_led_msn2100_profile[] = {
"mlxcpld:fan:green",
},
{
- 0x21, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x21, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:fan:red",
},
{
@@ -191,7 +191,7 @@ static struct mlxcpld_led_profile mlxcpld_led_msn2100_profile[] = {
"mlxcpld:psu1:green",
},
{
- 0x23, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x23, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:psu1:red",
},
{
@@ -199,7 +199,7 @@ static struct mlxcpld_led_profile mlxcpld_led_msn2100_profile[] = {
"mlxcpld:psu2:green",
},
{
- 0x23, 0x0f, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x23, 0x0f, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:psu2:red",
},
{
@@ -207,11 +207,11 @@ static struct mlxcpld_led_profile mlxcpld_led_msn2100_profile[] = {
"mlxcpld:status:green",
},
{
- 0x20, 0xf0, MLXCPLD_LED_RED_STATIC_ON, LED_OFF,
+ 0x20, 0xf0, MLXCPLD_LED_RED_STATIC_ON, 0,
"mlxcpld:status:red",
},
{
- 0x24, 0xf0, MLXCPLD_LED_GREEN_STATIC_ON, LED_OFF,
+ 0x24, 0xf0, MLXCPLD_LED_GREEN_STATIC_ON, 0,
"mlxcpld:uid:blue",
},
};
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
index b7855c93bd72..2340a205ce44 100644
--- a/drivers/leds/leds-mlxreg.c
+++ b/drivers/leds/leds-mlxreg.c
@@ -119,7 +119,7 @@ mlxreg_led_get_hw(struct mlxreg_led_data *led_data)
dev_warn(led_data->led_cdev.dev, "Failed to get current brightness, error: %d\n",
err);
/* Assume the LED is OFF */
- return LED_OFF;
+ return 0;
}
regval = regval & ~data->mask;
@@ -220,20 +220,20 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
led_data->data_parent = priv;
if (strstr(data->label, "red") ||
strstr(data->label, "orange")) {
- brightness = LED_OFF;
+ brightness = 0;
led_data->base_color = MLXREG_LED_RED_SOLID;
} else if (strstr(data->label, "amber")) {
- brightness = LED_OFF;
+ brightness = 0;
led_data->base_color = MLXREG_LED_AMBER_SOLID;
} else {
- brightness = LED_OFF;
+ brightness = 0;
led_data->base_color = MLXREG_LED_GREEN_SOLID;
}
snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name),
"mlxreg:%s", data->label);
led_cdev->name = led_data->led_cdev_name;
led_cdev->brightness = brightness;
- led_cdev->max_brightness = LED_ON;
+ led_cdev->max_brightness = 1;
led_cdev->brightness_set_blocking =
mlxreg_led_brightness_set;
led_cdev->brightness_get = mlxreg_led_brightness_get;
diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c
index f59e0e8bda8b..cbefd78f2d49 100644
--- a/drivers/leds/leds-mt6323.c
+++ b/drivers/leds/leds-mt6323.c
@@ -354,7 +354,7 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
ret =
mt6323_led_set_brightness(cdev, cdev->max_brightness);
} else {
- ret = mt6323_led_set_brightness(cdev, LED_OFF);
+ ret = mt6323_led_set_brightness(cdev, 0);
}
}
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
index 77213b79f84d..8ffbe5e19952 100644
--- a/drivers/leds/leds-netxbig.c
+++ b/drivers/leds/leds-netxbig.c
@@ -177,7 +177,7 @@ static void netxbig_led_set(struct led_classdev *led_cdev,
spin_lock_irqsave(&led_dat->lock, flags);
- if (value == LED_OFF) {
+ if (value == 0) {
mode = NETXBIG_LED_OFF;
set_brightness = 0;
} else {
@@ -295,7 +295,7 @@ static int create_netxbig_led(struct platform_device *pdev,
* the whole boot process (bootloader+linux).
*/
led_dat->sata = 0;
- led_dat->cdev.brightness = LED_OFF;
+ led_dat->cdev.brightness = 0;
led_dat->cdev.max_brightness = template->bright_max;
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
led_dat->mode_addr = template->mode_addr;
diff --git a/drivers/leds/leds-nic78bx.c b/drivers/leds/leds-nic78bx.c
index f196f52eec1e..25639c40975c 100644
--- a/drivers/leds/leds-nic78bx.c
+++ b/drivers/leds/leds-nic78bx.c
@@ -72,7 +72,7 @@ static enum led_brightness nic78bx_brightness_get(struct led_classdev *cdev)
value = inb(nled->data->io_base);
spin_unlock_irqrestore(&nled->data->lock, flags);
- return (value & nled->bit) ? 1 : LED_OFF;
+ return (value & nled->bit) ? 1 : 0;
}
static struct nic78bx_led nic78bx_leds[] = {
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index 1677d66d8b0e..34e899adfc0d 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -106,7 +106,7 @@ static void ns2_led_set(struct led_classdev *led_cdev,
struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev);
enum ns2_led_modes mode;
- if (value == LED_OFF)
+ if (value == 0)
mode = NS_V2_LED_OFF;
else if (led->sata)
mode = NS_V2_LED_SATA;
@@ -224,7 +224,7 @@ static int ns2_led_register(struct device *dev, struct fwnode_handle *node,
/* Set LED initial state. */
led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0;
- led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL;
+ led->cdev.brightness = (mode == NS_V2_LED_OFF) ? 0 : 255;
init_data.fwnode = node;
diff --git a/drivers/leds/leds-ot200.c b/drivers/leds/leds-ot200.c
index 12af1127d9b7..693fbfeced6c 100644
--- a/drivers/leds/leds-ot200.c
+++ b/drivers/leds/leds-ot200.c
@@ -105,7 +105,7 @@ static void ot200_led_brightness_set(struct led_classdev *led_cdev,
else
BUG();
- if (value == LED_OFF)
+ if (value == 0)
*val &= ~led->mask;
else
*val |= led->mask;
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 017794bb87ae..3e14a61e9807 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -177,9 +177,9 @@ static int pca9532_set_brightness(struct led_classdev *led_cdev,
int err = 0;
struct pca9532_led *led = ldev_to_led(led_cdev);
- if (value == LED_OFF)
+ if (value == 0)
led->state = PCA9532_OFF;
- else if (value == LED_FULL)
+ else if (value == 255)
led->state = PCA9532_ON;
else {
led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */
@@ -386,7 +386,7 @@ static int pca9532_configure(struct i2c_client *client,
led->name = pled->name;
led->ldev.name = led->name;
led->ldev.default_trigger = pled->default_trigger;
- led->ldev.brightness = LED_OFF;
+ led->ldev.brightness = 0;
led->ldev.brightness_set_blocking =
pca9532_set_brightness;
led->ldev.blink_set = pca9532_set_blink;
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index a6b5699aeae4..2230d3f0e846 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -57,9 +57,9 @@
#define PCA955X_LS_BLINK0 0x2 /* Blink at PWM0 rate */
#define PCA955X_LS_BLINK1 0x3 /* Blink at PWM1 rate */
-#define PCA955X_GPIO_INPUT LED_OFF
-#define PCA955X_GPIO_HIGH LED_OFF
-#define PCA955X_GPIO_LOW LED_FULL
+#define PCA955X_GPIO_INPUT 0
+#define PCA955X_GPIO_HIGH 0
+#define PCA955X_GPIO_LOW 255
enum pca955x_type {
pca9550,
@@ -265,13 +265,13 @@ static enum led_brightness pca955x_led_get(struct led_classdev *led_cdev)
ls = (ls >> ((pca955x_led->led_num % 4) << 1)) & 0x3;
switch (ls) {
case PCA955X_LS_LED_ON:
- ret = LED_FULL;
+ ret = 255;
break;
case PCA955X_LS_LED_OFF:
- ret = LED_OFF;
+ ret = 0;
break;
case PCA955X_LS_BLINK0:
- ret = LED_HALF;
+ ret = 127;
break;
case PCA955X_LS_BLINK1:
ret = pca955x_read_pwm(pca955x->client, 1, &pwm);
@@ -307,13 +307,13 @@ static int pca955x_led_set(struct led_classdev *led_cdev,
goto out;
switch (value) {
- case LED_FULL:
+ case 255:
ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON);
break;
- case LED_OFF:
+ case 0:
ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_OFF);
break;
- case LED_HALF:
+ case 127:
ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK0);
break;
default:
@@ -578,12 +578,12 @@ static int pca955x_probe(struct i2c_client *client)
if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_OFF) {
- err = pca955x_led_set(led, LED_OFF);
+ err = pca955x_led_set(led, 0);
if (err)
return err;
} else if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_ON) {
- err = pca955x_led_set(led, LED_FULL);
+ err = pca955x_led_set(led, 255);
if (err)
return err;
}
@@ -621,16 +621,16 @@ static int pca955x_probe(struct i2c_client *client)
*/
if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_KEEP) {
- if (led->brightness != LED_FULL &&
- led->brightness != LED_OFF &&
- led->brightness != LED_HALF)
+ if (led->brightness != 255 &&
+ led->brightness != 0 &&
+ led->brightness != 127)
keep_pwm = true;
}
}
}
/* PWM0 is used for half brightness or 50% duty cycle */
- err = pca955x_write_pwm(client, 0, 255 - LED_HALF);
+ err = pca955x_write_pwm(client, 0, 255 - 127);
if (err)
return err;
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 00aecd67e348..17612f5021b9 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -128,11 +128,11 @@ static int pca963x_brightness(struct pca963x_led *led,
ledout = i2c_smbus_read_byte_data(client, ledout_addr);
switch (brightness) {
- case LED_FULL:
+ case 255:
val = (ledout & ~mask) | (PCA963X_LED_ON << shift);
ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
break;
- case LED_OFF:
+ case 0:
val = ledout & ~mask;
ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
break;
diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c
index fb2ab72c0c40..535b471a634a 100644
--- a/drivers/leds/leds-pm8058.c
+++ b/drivers/leds/leds-pm8058.c
@@ -64,7 +64,7 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled)
ret = regmap_read(led->map, led->reg, &val);
if (ret) {
pr_err("Failed to get LED brightness\n");
- return LED_OFF;
+ return 0;
}
switch (led->ledtype) {
@@ -78,7 +78,7 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled)
val >>= PM8058_LED_TYPE_KEYPAD_SHIFT;
break;
default:
- val = LED_OFF;
+ val = 0;
break;
}
@@ -133,8 +133,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
led->cdev.brightness = maxbright;
pm8058_led_set(&led->cdev, maxbright);
} else {
- led->cdev.brightness = LED_OFF;
- pm8058_led_set(&led->cdev, LED_OFF);
+ led->cdev.brightness = 0;
+ pm8058_led_set(&led->cdev, 0);
}
}
diff --git a/drivers/leds/leds-powernv.c b/drivers/leds/leds-powernv.c
index 743e2cdd0891..9ee3ad46a82c 100644
--- a/drivers/leds/leds-powernv.c
+++ b/drivers/leds/leds-powernv.c
@@ -146,7 +146,7 @@ static enum led_brightness powernv_led_get(struct powernv_led_data *powernv_led)
if (rc != OPAL_SUCCESS && rc != OPAL_PARTIAL) {
dev_err(dev, "%s: OPAL get led call failed [rc=%d]\n",
__func__, rc);
- return LED_OFF;
+ return 0;
}
led_mask = be64_to_cpu(mask);
@@ -156,14 +156,14 @@ static enum led_brightness powernv_led_get(struct powernv_led_data *powernv_led)
if (!((led_mask >> powernv_led->led_type) & OPAL_SLOT_LED_STATE_ON)) {
dev_err(dev, "%s: LED status not available for %s\n",
__func__, powernv_led->cdev.name);
- return LED_OFF;
+ return 0;
}
/* LED status value */
if ((led_value >> powernv_led->led_type) & OPAL_SLOT_LED_STATE_ON)
- return LED_FULL;
+ return 255;
- return LED_OFF;
+ return 0;
}
/*
@@ -225,8 +225,8 @@ static int powernv_led_create(struct device *dev,
powernv_led->cdev.brightness_set_blocking = powernv_brightness_set;
powernv_led->cdev.brightness_get = powernv_brightness_get;
- powernv_led->cdev.brightness = LED_OFF;
- powernv_led->cdev.max_brightness = LED_FULL;
+ powernv_led->cdev.brightness = 0;
+ powernv_led->cdev.max_brightness = 255;
/* Register the classdev */
rc = devm_led_classdev_register(dev, &powernv_led->cdev);
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 6832180c1c54..50e97e70051a 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -67,7 +67,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
led_data->active_low = led->active_low;
led_data->cdev.name = led->name;
- led_data->cdev.brightness = LED_OFF;
+ led_data->cdev.brightness = 0;
led_data->cdev.max_brightness = led->max_brightness;
led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c
index b6447c1721b4..350418795353 100644
--- a/drivers/leds/leds-rb532.c
+++ b/drivers/leds/leds-rb532.c
@@ -27,7 +27,7 @@ static void rb532_led_set(struct led_classdev *cdev,
static enum led_brightness rb532_led_get(struct led_classdev *cdev)
{
- return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF;
+ return (get_latch_u5() & LO_ULED) ? 255 : 0;
}
static struct led_classdev rb532_uled = {
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
index 208c98918433..c99460ac1d3c 100644
--- a/drivers/leds/leds-regulator.c
+++ b/drivers/leds/leds-regulator.c
@@ -96,7 +96,7 @@ static int regulator_led_brightness_set(struct led_classdev *led_cdev,
mutex_lock(&led->mutex);
- if (value == LED_OFF) {
+ if (value == 0) {
regulator_led_disable(led);
goto out;
}
diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c
index e199ea15e406..e7c105e45a81 100644
--- a/drivers/leds/leds-sc27xx-bltc.c
+++ b/drivers/leds/leds-sc27xx-bltc.c
@@ -114,14 +114,14 @@ static int sc27xx_led_disable(struct sc27xx_led *leds)
(SC27XX_LED_RUN | SC27XX_LED_TYPE) << ctrl_shift, 0);
}
-static int sc27xx_led_set(struct led_classdev *ldev, enum led_brightness value)
+static int sc27xx_led_set(struct led_classdev *ldev, unsigned int value)
{
struct sc27xx_led *leds = to_sc27xx_led(ldev);
int err;
mutex_lock(&leds->priv->lock);
- if (value == LED_OFF)
+ if (value == 0)
err = sc27xx_led_disable(leds);
else
err = sc27xx_led_enable(leds, value);
@@ -161,7 +161,7 @@ static int sc27xx_led_pattern_clear(struct led_classdev *ldev)
err = regmap_update_bits(regmap, ctrl_base,
(SC27XX_LED_RUN | SC27XX_LED_TYPE) << ctrl_shift, 0);
- ldev->brightness = LED_OFF;
+ ldev->brightness = 0;
mutex_unlock(&leds->priv->lock);
diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c
index f1964c96fb15..e96fc874c0f4 100644
--- a/drivers/leds/leds-spi-byte.c
+++ b/drivers/leds/leds-spi-byte.c
@@ -103,7 +103,7 @@ static int spi_byte_probe(struct spi_device *spi)
mutex_init(&led->mutex);
led->cdef = device_get_match_data(dev);
led->ldev.name = led->name;
- led->ldev.brightness = LED_OFF;
+ led->ldev.brightness = 0;
led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value;
led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking;
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
index fcaa34706b6c..08cbe2ba5417 100644
--- a/drivers/leds/leds-ss4200.c
+++ b/drivers/leds/leds-ss4200.c
@@ -220,7 +220,7 @@ static void nasgpio_led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
u32 setting = 0;
- if (brightness >= LED_HALF)
+ if (brightness >= 127)
setting = 1;
/*
* Hold the lock across both operations. This ensures
@@ -433,12 +433,12 @@ static void set_power_light_amber_noblink(void)
if (!amber || !blue)
return;
/*
- * LED_OFF implies disabling future blinking
+ * 0 implies disabling future blinking
*/
pr_debug("setting blue off and amber on\n");
- nasgpio_led_set_brightness(&blue->led_cdev, LED_OFF);
- nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
+ nasgpio_led_set_brightness(&blue->led_cdev, 0);
+ nasgpio_led_set_brightness(&amber->led_cdev, 255);
}
static ssize_t blink_show(struct device *dev,
@@ -482,9 +482,9 @@ static int register_nasgpio_led(int led_nr)
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
led->name = nas_led->name;
- led->brightness = LED_OFF;
+ led->brightness = 0;
if (nasgpio_led_get_attr(led, GP_LVL))
- led->brightness = LED_FULL;
+ led->brightness = 255;
led->brightness_set = nasgpio_led_set_brightness;
led->blink_set = nasgpio_led_set_blink;
led->groups = nasgpio_led_groups;
diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c
index eba7313719bf..f9e42661d02a 100644
--- a/drivers/leds/leds-sunfire.c
+++ b/drivers/leds/leds-sunfire.c
@@ -144,7 +144,7 @@ static int sunfire_led_generic_probe(struct platform_device *pdev,
p->leds[i].reg = (void __iomem *) pdev->resource[0].start;
lp->name = types[i].name;
- lp->brightness = LED_FULL;
+ lp->brightness = 255;
lp->brightness_set = types[i].handler;
lp->default_trigger = types[i].default_trigger;
diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c
index 7eddb8ecb44e..1533b39e22ec 100644
--- a/drivers/leds/leds-syscon.c
+++ b/drivers/leds/leds-syscon.c
@@ -40,7 +40,7 @@ static void syscon_led_set(struct led_classdev *led_cdev,
u32 val;
int ret;
- if (value == LED_OFF) {
+ if (value == 0) {
val = 0;
sled->state = false;
} else {
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 1473ced8664c..e40d659b6119 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -423,7 +423,7 @@ static int led_prepare(struct tca6507_led *led)
if (best == -1) {
/* Best brightness is full-on */
set_select(tca, led->num, TCA6507_LS_LED_ON);
- led->led_cdev.brightness = LED_FULL;
+ led->led_cdev.brightness = 255;
return 0;
}
@@ -577,12 +577,12 @@ static int tca6507_blink_set(struct led_classdev *led_cdev,
if (led->offtime == 0)
led->offtime = 512;
- if (led->led_cdev.brightness == LED_OFF)
- led->led_cdev.brightness = LED_FULL;
+ if (led->led_cdev.brightness == 0)
+ led->led_cdev.brightness = 255;
if (led_assign(led) < 0) {
led->ontime = 0;
led->offtime = 0;
- led->led_cdev.brightness = LED_OFF;
+ led->led_cdev.brightness = 0;
return -EINVAL;
}
*delay_on = led->ontime;
diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c
index c48b80574f02..37328c0c00b1 100644
--- a/drivers/leds/leds-wm831x-status.c
+++ b/drivers/leds/leds-wm831x-status.c
@@ -52,7 +52,7 @@ static void wm831x_status_set(struct wm831x_status *led)
led->reg_val |= led->blink_time << WM831X_LED_DUR_SHIFT;
led->reg_val |= led->blink_cyc;
} else {
- if (led->brightness != LED_OFF)
+ if (led->brightness != 0)
led->reg_val |= 1 << WM831X_LED_MODE_SHIFT;
}
@@ -71,7 +71,7 @@ static int wm831x_status_brightness_set(struct led_classdev *led_cdev,
spin_lock_irqsave(&led->value_lock, flags);
led->brightness = value;
- if (value == LED_OFF)
+ if (value == 0)
led->blink = 0;
spin_unlock_irqrestore(&led->value_lock, flags);
wm831x_status_set(led);
@@ -248,9 +248,9 @@ static int wm831x_status_probe(struct platform_device *pdev)
drvdata->reg_val = wm831x_reg_read(wm831x, drvdata->reg);
if (drvdata->reg_val & WM831X_LED_MODE_MASK)
- drvdata->brightness = LED_FULL;
+ drvdata->brightness = 255;
else
- drvdata->brightness = LED_OFF;
+ drvdata->brightness = 0;
/* Set a default source if configured, otherwise leave the
* current hardware setting.
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c
index 8f243c413723..512bbc266258 100644
--- a/drivers/leds/leds-wm8350.c
+++ b/drivers/leds/leds-wm8350.c
@@ -150,7 +150,7 @@ static int wm8350_led_set(struct led_classdev *led_cdev,
spin_lock_irqsave(&led->value_lock, flags);
- if (led->value == LED_OFF) {
+ if (led->value == 0) {
spin_unlock_irqrestore(&led->value_lock, flags);
return wm8350_led_disable(led);
}
@@ -160,7 +160,7 @@ static int wm8350_led_set(struct led_classdev *led_cdev,
* brightness due to the non-linear current settings provided
* by the hardware.
*/
- uA = (led->max_uA_index * led->value) / LED_FULL;
+ uA = (led->max_uA_index * led->value) / 255;
spin_unlock_irqrestore(&led->value_lock, flags);
BUG_ON(uA >= ARRAY_SIZE(isink_cur));
@@ -179,7 +179,7 @@ static void wm8350_led_shutdown(struct platform_device *pdev)
{
struct wm8350_led *led = platform_get_drvdata(pdev);
- led->value = LED_OFF;
+ led->value = 0;
wm8350_led_disable(led);
}
@@ -236,7 +236,7 @@ static int wm8350_led_probe(struct platform_device *pdev)
pdata->max_uA);
spin_lock_init(&led->value_lock);
- led->value = LED_OFF;
+ led->value = 0;
platform_set_drvdata(pdev, led);
return led_classdev_register(&pdev->dev, &led->cdev);
diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c
index ff2c96e73241..be5d7e1e4145 100644
--- a/drivers/leds/simple/simatic-ipc-leds.c
+++ b/drivers/leds/simple/simatic-ipc-leds.c
@@ -73,7 +73,7 @@ static void simatic_ipc_led_set_io(struct led_classdev *led_cd,
spin_lock_irqsave(®_lock, flags);
val = inw(SIMATIC_IPC_LED_PORT_BASE);
- if (brightness == LED_OFF)
+ if (brightness == 0)
outw(val | led->value, SIMATIC_IPC_LED_PORT_BASE);
else
outw(val & ~led->value, SIMATIC_IPC_LED_PORT_BASE);
@@ -85,7 +85,7 @@ static enum led_brightness simatic_ipc_led_get_io(struct led_classdev *led_cd)
{
struct simatic_ipc_led *led = cdev_to_led(led_cd);
- return inw(SIMATIC_IPC_LED_PORT_BASE) & led->value ? LED_OFF : led_cd->max_brightness;
+ return inw(SIMATIC_IPC_LED_PORT_BASE) & led->value ? 0 : led_cd->max_brightness;
}
static void simatic_ipc_led_set_mem(struct led_classdev *led_cd,
@@ -96,7 +96,7 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd,
u32 *p;
p = simatic_ipc_led_memory + led->value;
- *p = (*p & ~1) | (brightness == LED_OFF);
+ *p = (*p & ~1) | (brightness == 0);
}
static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd)
@@ -106,7 +106,7 @@ static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd)
u32 *p;
p = simatic_ipc_led_memory + led->value;
- return (*p & 1) ? LED_OFF : led_cd->max_brightness;
+ return (*p & 1) ? 0 : led_cd->max_brightness;
}
static int simatic_ipc_leds_probe(struct platform_device *pdev)
@@ -176,7 +176,7 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
cdev->brightness_set = simatic_ipc_led_set_io;
cdev->brightness_get = simatic_ipc_led_get_io;
}
- cdev->max_brightness = LED_ON;
+ cdev->max_brightness = 1;
cdev->name = ipcled->name;
err = devm_led_classdev_register(dev, cdev);
diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
index 30bc9df03636..d0d8cc8db8c6 100644
--- a/drivers/leds/trigger/ledtrig-activity.c
+++ b/drivers/leds/trigger/ledtrig-activity.c
@@ -129,7 +129,7 @@ static void led_activity_function(struct timer_list *t)
activity_data->state = !activity_data->state;
led_set_brightness_nosleep(led_cdev,
(activity_data->state ^ activity_data->invert) ?
- led_cdev->blink_brightness : LED_OFF);
+ led_cdev->blink_brightness : 0);
}
target = (cpus > 1) ? (100 / cpus) : 50;
diff --git a/drivers/leds/trigger/ledtrig-backlight.c b/drivers/leds/trigger/ledtrig-backlight.c
index 487577d22cfc..ec965e192365 100644
--- a/drivers/leds/trigger/ledtrig-backlight.c
+++ b/drivers/leds/trigger/ledtrig-backlight.c
@@ -47,7 +47,7 @@ static int fb_notifier_callback(struct notifier_block *p,
if ((n->old_status == UNBLANK) ^ n->invert) {
n->brightness = led->brightness;
- led_set_brightness_nosleep(led, LED_OFF);
+ led_set_brightness_nosleep(led, 0);
} else {
led_set_brightness_nosleep(led, n->brightness);
}
@@ -84,7 +84,7 @@ static ssize_t bl_trig_invert_store(struct device *dev,
/* After inverting, we need to update the LED. */
if ((n->old_status == BLANK) ^ n->invert)
- led_set_brightness_nosleep(led, LED_OFF);
+ led_set_brightness_nosleep(led, 0);
else
led_set_brightness_nosleep(led, n->brightness);
diff --git a/drivers/leds/trigger/ledtrig-camera.c b/drivers/leds/trigger/ledtrig-camera.c
index ab1c410872ff..1c9707c60a19 100644
--- a/drivers/leds/trigger/ledtrig-camera.c
+++ b/drivers/leds/trigger/ledtrig-camera.c
@@ -19,7 +19,7 @@ DEFINE_LED_TRIGGER(ledtrig_torch);
void ledtrig_flash_ctrl(bool on)
{
- enum led_brightness brt = on ? LED_FULL : LED_OFF;
+ unsigned int brt = on ? 255 : 0;
led_trigger_event(ledtrig_flash, brt);
}
@@ -27,7 +27,7 @@ EXPORT_SYMBOL_GPL(ledtrig_flash_ctrl);
void ledtrig_torch_ctrl(bool on)
{
- enum led_brightness brt = on ? LED_FULL : LED_OFF;
+ unsigned int brt = on ? 255 : 0;
led_trigger_event(ledtrig_torch, brt);
}
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 8af4f9bb9cde..a7d358412f8a 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -84,11 +84,11 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
total_cpus = num_present_cpus();
led_trigger_event(trig->_trig,
- is_active ? LED_FULL : LED_OFF);
+ is_active ? 255 : 0);
led_trigger_event(trig_cpu_all,
- DIV_ROUND_UP(LED_FULL * active_cpus, total_cpus));
+ DIV_ROUND_UP(255 * active_cpus, total_cpus));
}
}
diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index 0120faa3dafa..d794e44f2eff 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -37,9 +37,9 @@ static irqreturn_t gpio_trig_irq(int irq, void *_led)
led_set_brightness_nosleep(gpio_data->led,
gpio_data->desired_brightness);
else
- led_set_brightness_nosleep(gpio_data->led, LED_FULL);
+ led_set_brightness_nosleep(gpio_data->led, 255);
} else {
- led_set_brightness_nosleep(gpio_data->led, LED_OFF);
+ led_set_brightness_nosleep(gpio_data->led, 0);
}
return IRQ_HANDLED;
diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c
index 7fe0a05574d2..0b5ec7dc14fa 100644
--- a/drivers/leds/trigger/ledtrig-heartbeat.c
+++ b/drivers/leds/trigger/ledtrig-heartbeat.c
@@ -35,13 +35,13 @@ static void led_heartbeat_function(struct timer_list *t)
struct heartbeat_trig_data *heartbeat_data =
from_timer(heartbeat_data, t, timer);
struct led_classdev *led_cdev;
- unsigned long brightness = LED_OFF;
+ unsigned long brightness = 0;
unsigned long delay = 0;
led_cdev = heartbeat_data->led_cdev;
if (unlikely(panic_heartbeats)) {
- led_set_brightness_nosleep(led_cdev, LED_OFF);
+ led_set_brightness_nosleep(led_cdev, 0);
return;
}
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index d5e774d83021..e3174d09111c 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -74,13 +74,13 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
led_cdev->blink_brightness = led_cdev->max_brightness;
if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode))
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
else {
if (test_bit(NETDEV_LED_LINK, &trigger_data->mode))
led_set_brightness(led_cdev,
led_cdev->blink_brightness);
else
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
/* If we are looking for RX/TX start periodically
* checking stats
@@ -355,7 +355,7 @@ static void netdev_trig_work(struct work_struct *work)
/* If we dont have a device, insure we are off */
if (!trigger_data->net_dev) {
- led_set_brightness(trigger_data->led_cdev, LED_OFF);
+ led_set_brightness(trigger_data->led_cdev, 0);
return;
}
diff --git a/drivers/leds/trigger/ledtrig-oneshot.c b/drivers/leds/trigger/ledtrig-oneshot.c
index bee3bd452abf..bc5ff2d2fd6c 100644
--- a/drivers/leds/trigger/ledtrig-oneshot.c
+++ b/drivers/leds/trigger/ledtrig-oneshot.c
@@ -58,9 +58,9 @@ static ssize_t led_invert_store(struct device *dev,
oneshot_data->invert = !!state;
if (oneshot_data->invert)
- led_set_brightness_nosleep(led_cdev, LED_FULL);
+ led_set_brightness_nosleep(led_cdev, 255);
else
- led_set_brightness_nosleep(led_cdev, LED_OFF);
+ led_set_brightness_nosleep(led_cdev, 0);
return size;
}
@@ -184,7 +184,7 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
kfree(oneshot_data);
/* Stop blinking */
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
}
static struct led_trigger oneshot_led_trigger = {
diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c
index 64abf2e91608..2576632d2264 100644
--- a/drivers/leds/trigger/ledtrig-panic.c
+++ b/drivers/leds/trigger/ledtrig-panic.c
@@ -58,7 +58,7 @@ static struct notifier_block led_trigger_panic_nb = {
static long led_panic_blink(int state)
{
- led_trigger_event(trigger, state ? LED_FULL : LED_OFF);
+ led_trigger_event(trigger, state ? 255 : 0);
return 0;
}
diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/ledtrig-pattern.c
index 43a265dc4696..d49e45395aca 100644
--- a/drivers/leds/trigger/ledtrig-pattern.c
+++ b/drivers/leds/trigger/ledtrig-pattern.c
@@ -432,7 +432,7 @@ static void pattern_trig_deactivate(struct led_classdev *led_cdev)
del_timer_sync(&data->timer);
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
kfree(data);
led_cdev->activated = false;
}
diff --git a/drivers/leds/trigger/ledtrig-timer.c b/drivers/leds/trigger/ledtrig-timer.c
index b4688d1d9d2b..cb2b4dcd4a2c 100644
--- a/drivers/leds/trigger/ledtrig-timer.c
+++ b/drivers/leds/trigger/ledtrig-timer.c
@@ -124,7 +124,7 @@ static int timer_trig_activate(struct led_classdev *led_cdev)
static void timer_trig_deactivate(struct led_classdev *led_cdev)
{
/* Stop blinking */
- led_set_brightness(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, 0);
}
static struct led_trigger timer_led_trigger = {
diff --git a/drivers/leds/trigger/ledtrig-transient.c b/drivers/leds/trigger/ledtrig-transient.c
index 80635183fac8..b35ba2527346 100644
--- a/drivers/leds/trigger/ledtrig-transient.c
+++ b/drivers/leds/trigger/ledtrig-transient.c
@@ -79,7 +79,7 @@ static ssize_t transient_activate_store(struct device *dev,
transient_data->activate = state;
led_set_brightness_nosleep(led_cdev, transient_data->state);
transient_data->restore_state =
- (transient_data->state == LED_FULL) ? LED_OFF : LED_FULL;
+ (transient_data->state == 255) ? 0 : 255;
mod_timer(&transient_data->timer,
jiffies + msecs_to_jiffies(transient_data->duration));
}
@@ -123,7 +123,7 @@ static ssize_t transient_state_show(struct device *dev,
led_trigger_get_drvdata(dev);
int state;
- state = (transient_data->state == LED_FULL) ? 1 : 0;
+ state = (transient_data->state == 255) ? 1 : 0;
return sprintf(buf, "%d\n", state);
}
@@ -142,7 +142,7 @@ static ssize_t transient_state_store(struct device *dev,
if (state != 1 && state != 0)
return -EINVAL;
- transient_data->state = (state == 1) ? LED_FULL : LED_OFF;
+ transient_data->state = (state == 1) ? 255 : 0;
return size;
}
diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
index f62db7e520b5..378ccb7b12df 100644
--- a/drivers/leds/trigger/ledtrig-tty.c
+++ b/drivers/leds/trigger/ledtrig-tty.c
@@ -122,12 +122,12 @@ static void ledtrig_tty_work(struct work_struct *work)
if (icount.rx != trigger_data->rx ||
icount.tx != trigger_data->tx) {
- led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
+ led_set_brightness_sync(trigger_data->led_cdev, 1);
trigger_data->rx = icount.rx;
trigger_data->tx = icount.tx;
} else {
- led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
+ led_set_brightness_sync(trigger_data->led_cdev, 0);
}
out:
--
2.34.1
^ permalink raw reply related
* Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
From: Richard Fontana @ 2022-01-21 18:09 UTC (permalink / raw)
To: Christophe Leroy
Cc: Greg Kroah-Hartman, linux-kernel@vger.kernel.org, Paul Mackerras,
linux-spdx@vger.kernel.org, Thomas Gleixner,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <d2c52284244d6dcb3472d2041abe43b456d116df.1642762977.git.christophe.leroy@csgroup.eu>
On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> Several files are missing SPDX license identifiers.
>
> Following files are given the following SPDX identifier based on the comments in the top of the file:
>
> include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */
> include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */
"BSD" is not a defined SPDX identifier. I believe what you want here
is "BSD-3-Clause" (see: https://spdx.org/licenses/BSD-3-Clause.html)
Richard
^ permalink raw reply
* Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
From: Richard Fontana @ 2022-01-21 18:17 UTC (permalink / raw)
To: Christophe Leroy
Cc: Greg Kroah-Hartman, linux-kernel@vger.kernel.org, Paul Mackerras,
linux-spdx@vger.kernel.org, Thomas Gleixner,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <d2c52284244d6dcb3472d2041abe43b456d116df.1642762977.git.christophe.leroy@csgroup.eu>
On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> Several files are missing SPDX license identifiers.
>
> Following files are given the following SPDX identifier based on the comments in the top of the file:
>
> include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD */
[...]
> platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD
"OpenIB BSD" is not a defined SPDX identifier. There is an SPDX
identifier "Linux-OpenIB"
https://spdx.org/licenses/Linux-OpenIB.html
but I believe that is not a match to what's in these files
(specifically, the wording of the disclaimer), rather I believe what
you want here is BSD-2-Clause, but you may want to check that.
Richard
^ permalink raw reply
* Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
From: J Lovejoy @ 2022-01-21 18:34 UTC (permalink / raw)
To: Richard Fontana, Christophe Leroy
Cc: Greg Kroah-Hartman, linux-kernel@vger.kernel.org, Paul Mackerras,
linux-spdx@vger.kernel.org, Thomas Gleixner,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <CAC1cPGypAKcAAia4ipgTWNu33HLW=fb0CSroqR=SK-umrOJb-Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]
I just saw this and have not followed the entire thread from the
beginning, but if you are unsure if a given license text to something on
the SPDX License List, I highly recommend using the SPDX License-diff
browser extension / add-on (for Chrome or Firefox) - once you have that,
you can simply highlight a text in your browser window and it will tell
you if it matches or how far off it is if not.
If a license is NOT a match to anything on the SPDX License List, please
submit it to the SPDX legal team here:
https://tools.spdx.org/app/submit_new_license/ (and preferably then tag
me in the Github issue, my Github ide is @jlovejoy ) Please make sure to
include that it's in the LInux kernel and a link to where you found it.
More about requesting a new license be added to the SPDX License List
can be found here:
https://github.com/spdx/license-list-XML/blob/master/DOCS/request-new-license.md
Thanks!
Jilayne
SPDX legal team co-lead
On 1/21/22 10:17 AM, Richard Fontana wrote:
> On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>> Several files are missing SPDX license identifiers.
>>
>> Following files are given the following SPDX identifier based on the comments in the top of the file:
>>
>> include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD */
> [...]
>> platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD
> "OpenIB BSD" is not a defined SPDX identifier. There is an SPDX
> identifier "Linux-OpenIB"
> https://spdx.org/licenses/Linux-OpenIB.html
> but I believe that is not a match to what's in these files
> (specifically, the wording of the disclaimer), rather I believe what
> you want here is BSD-2-Clause, but you may want to check that.
>
> Richard
>
[-- Attachment #2: Type: text/html, Size: 3003 bytes --]
^ permalink raw reply
* [RFC PATCH 0/3] powerpc/pseries/vas: VAS/NXGZIP support with LPM
From: Haren Myneni @ 2022-01-21 21:48 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin, nathanl; +Cc: haren
Virtual Accelerator Switchboard (VAS) is an engine stays on the
chip. So all windows opened on a specific engine belongs to VAS
the chip. The hypervisor expects the partition to close all
active windows on the sources system and reopen them after
migration on the destination machine.
This patch series adds VAS support with the partition migration.
When the migration initiates, the VAS code gets suspend notifier
which closes all active windows and sets VAS_WIN_MIGRATE_CLOSE as
window status. Whereas receives resume notifier after migration
to reopen all windows which has VAS_WIN_MIGRATE_CLOSE status.
These patches depend on VAS/DLPAR support patch series
(https://lists.ozlabs.org/pipermail/linuxppc-dev/2021-December/238331.html)
Also the suspend/resume notifier code is added in a separate patch
and will be posted later with the actual patches.
Haren Myneni (3):
powerpc/pseries/vas: Modify reconfig open/close functions for migration
powerpc/pseries/vas: Add VAS suspend/resume notifier
powerpc/pseries/vas: Disable window open during migration
arch/powerpc/include/asm/vas.h | 2 +
arch/powerpc/platforms/pseries/vas.c | 199 ++++++++++++++++++++++++---
2 files changed, 181 insertions(+), 20 deletions(-)
--
2.27.0
^ permalink raw reply
* [RFC PATCH 1/3] powerpc/pseries/vas: Modify reconfig open/close functions for migration
From: Haren Myneni @ 2022-01-21 21:49 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin, nathanl
In-Reply-To: <cb790b1d369457eb124ad9daa4b4833fa12e0832.camel@linux.ibm.com>
VAS is a hardware engine stays on the chip. So when the partition
migrates, all VAS windows on the source system have to be closed
and reopen them on the destination after migration.
This patch make changes to the current reconfig_open/close_windows
functions to support migration:
- Set VAS_WIN_MIGRATE_CLOSE to the window status when closes and
reopen windows with the same status during resume.
- Continue to close all windows even if deallocate HCALL failed
(should not happen) since no way to stop migration with the
current LPM implementation.
- If the DLPAR CPU event happens while migration is in progress,
set VAS_WIN_NO_CRED_CLOSE to the window status. Close window
happens with the first event (migration or DLPAR) and Reopen
window happens only with the last event (migration or DLPAR).
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/include/asm/vas.h | 2 +
arch/powerpc/platforms/pseries/vas.c | 88 ++++++++++++++++++++++------
2 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index ddc05a8fc2e3..f21e76f47175 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -42,6 +42,8 @@
/* Linux status bits */
#define VAS_WIN_NO_CRED_CLOSE 0x00000004 /* Window is closed due to */
/* lost credit */
+#define VAS_WIN_MIGRATE_CLOSE 0x00000008 /* Window is closed due to */
+ /* migration */
/*
* Get/Set bit fields
*/
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index 3400f4fc6609..e4797fc73553 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -456,11 +456,12 @@ static int vas_deallocate_window(struct vas_window *vwin)
mutex_lock(&vas_pseries_mutex);
/*
* VAS window is already closed in the hypervisor when
- * lost the credit. So just remove the entry from
- * the list, remove task references and free vas_window
+ * lost the credit or with migration. So just remove the entry
+ * from the list, remove task references and free vas_window
* struct.
*/
- if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) {
+ if (!(win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) &&
+ !(win->vas_win.status & VAS_WIN_MIGRATE_CLOSE)) {
rc = deallocate_free_window(win);
if (rc) {
mutex_unlock(&vas_pseries_mutex);
@@ -577,12 +578,14 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
* by setting the remapping to new paste address if the window is
* active.
*/
-static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
+static int reconfig_open_windows(struct vas_caps *vcaps, int creds,
+ bool migrate)
{
long domain[PLPAR_HCALL9_BUFSIZE] = {VAS_DEFAULT_DOMAIN_ID};
struct vas_cop_feat_caps *caps = &vcaps->caps;
struct pseries_vas_window *win = NULL, *tmp;
int rc, mv_ents = 0;
+ int flag;
/*
* Nothing to do if there are no closed windows.
@@ -601,8 +604,10 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
* (dedicated). If 1 core is added, this LPAR can have 20 more
* credits. It means the kernel can reopen 20 windows. So move
* 20 entries in the VAS windows lost and reopen next 20 windows.
+ * For partition migration, reopen all windows that are closed
+ * during resume.
*/
- if (vcaps->close_wins > creds)
+ if ((vcaps->close_wins > creds) && !migrate)
mv_ents = vcaps->close_wins - creds;
list_for_each_entry_safe(win, tmp, &vcaps->list, win_list) {
@@ -612,12 +617,35 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
mv_ents--;
}
+ /*
+ * Open windows if they are closed only with migration or
+ * DLPAR (lost credit) before.
+ */
+ if (migrate)
+ flag = VAS_WIN_MIGRATE_CLOSE;
+ else
+ flag = VAS_WIN_NO_CRED_CLOSE;
+
list_for_each_entry_safe_from(win, tmp, &vcaps->list, win_list) {
+ /*
+ * This window is closed with DLPAR and migration events.
+ * So reopen the window with the last event.
+ * The user space is not suspended with the current
+ * migration notifier. So the user space can issue DLPAR
+ * CPU hotplug while migration in progress. In this case
+ * this window will be opened with the last event.
+ */
+ if ((win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) &&
+ (win->vas_win.status & VAS_WIN_MIGRATE_CLOSE)) {
+ win->vas_win.status &= ~flag;
+ continue;
+ }
+
/*
* Nothing to do on this window if it is not closed
- * with VAS_WIN_NO_CRED_CLOSE
+ * with this flag
*/
- if (!(win->vas_win.status & VAS_WIN_NO_CRED_CLOSE))
+ if (!(win->vas_win.status & flag))
continue;
rc = allocate_setup_window(win, (u64 *)&domain[0],
@@ -633,7 +661,7 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
/*
* Set window status to active
*/
- win->vas_win.status &= ~VAS_WIN_NO_CRED_CLOSE;
+ win->vas_win.status &= ~flag;
mutex_unlock(&win->vas_win.task_ref.mmap_mutex);
win->win_type = caps->win_type;
if (!--vcaps->close_wins)
@@ -660,20 +688,32 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
* the user space to fall back to SW compression and manage with the
* existing windows.
*/
-static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
+static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds,
+ bool migrate)
{
struct pseries_vas_window *win, *tmp;
struct vas_user_win_ref *task_ref;
struct vm_area_struct *vma;
- int rc = 0;
+ int rc = 0, flag;
+
+ if (migrate)
+ flag = VAS_WIN_MIGRATE_CLOSE;
+ else
+ flag = VAS_WIN_NO_CRED_CLOSE;
list_for_each_entry_safe(win, tmp, &vcap->list, win_list) {
/*
* This window is already closed due to lost credit
- * before. Go for next window.
+ * or for migration before. Go for next window.
+ * For migration, nothing to do since this window
+ * closed for DLPAR and will be reopened even on
+ * the destination system with other DLPAR operation.
*/
- if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE)
+ if ((win->vas_win.status & VAS_WIN_MIGRATE_CLOSE) ||
+ (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE)) {
+ win->vas_win.status |= flag;
continue;
+ }
task_ref = &win->vas_win.task_ref;
mutex_lock(&task_ref->mmap_mutex);
@@ -682,7 +722,7 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
* Number of available credits are reduced, So select
* and close windows.
*/
- win->vas_win.status |= VAS_WIN_NO_CRED_CLOSE;
+ win->vas_win.status |= flag;
mmap_write_lock(task_ref->mm);
/*
@@ -705,12 +745,24 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
* later when the process issued with close(FD).
*/
rc = deallocate_free_window(win);
- if (rc)
+ /*
+ * This failure is from the hypervisor.
+ * No way to stop migration for these failures.
+ * So ignore error and continue closing other windows.
+ */
+ if (rc && !migrate)
return rc;
vcap->close_wins++;
- if (!--excess_creds)
+ /*
+ * For migration, do not depend on lpar_creds in case if
+ * mismatch with the hypervisor value (should not happen).
+ * So close all active windows in the list and will be
+ * reopened windows based on the new lpar_creds on the
+ * destination system during resume.
+ */
+ if (!migrate && !--excess_creds)
break;
}
@@ -765,7 +817,8 @@ int vas_reconfig_capabilties(u8 type)
* target, reopen windows if they are closed due to
* the previous DLPAR (core removal).
*/
- rc = reconfig_open_windows(vcaps, new_creds - lpar_creds);
+ rc = reconfig_open_windows(vcaps, new_creds - lpar_creds,
+ false);
} else {
/*
* # active windows is more than new LPAR available
@@ -773,7 +826,8 @@ int vas_reconfig_capabilties(u8 type)
*/
active_wins = vcaps->num_wins - vcaps->close_wins;
if (active_wins > new_creds)
- rc = reconfig_close_windows(vcaps, active_wins - new_creds);
+ rc = reconfig_close_windows(vcaps, active_wins - new_creds,
+ false);
}
out:
--
2.27.0
^ permalink raw reply related
* [RFC PATCH 2/3] powerpc/pseries/vas: Add VAS suspend/resume notifier
From: Haren Myneni @ 2022-01-21 21:49 UTC (permalink / raw)
To: mpe, linuxppc-dev, npiggin, nathanl
In-Reply-To: <cb790b1d369457eb124ad9daa4b4833fa12e0832.camel@linux.ibm.com>
Since the windows belong to the VAS hardware resource, the
hypervisor expects the partition to close them on source partition
and reopen them after the partition migrated on the destination
machine.
This suspend/resume notifier invokes suspend operation before
and resume operation after migration. All active windows for
both default and QoS types will be closed during suspend and
reopen them during resume. During migration, the user space
should expect paste instruction failure if issues copy/paste
on these active windows.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas.c | 97 +++++++++++++++++++++++++++-
1 file changed, 96 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index e4797fc73553..7087528e4246 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -16,6 +16,7 @@
#include <asm/machdep.h>
#include <asm/hvcall.h>
#include <asm/plpar_wrappers.h>
+#include <asm/pseries-suspend.h>
#include <asm/vas.h>
#include "vas.h"
@@ -873,6 +874,98 @@ static struct notifier_block pseries_vas_nb = {
.notifier_call = pseries_vas_notifier,
};
+/*
+ * For LPM, all windows have to be closed on the source partition
+ * before migration and reopen them on the destination partition
+ * after migration. So closing windows during suspend and
+ * reopen them during resume.
+ */
+static int vas_migrate_windows(bool suspend)
+{
+ struct hv_vas_cop_feat_caps *hv_caps;
+ struct vas_cop_feat_caps *caps;
+ int lpar_creds, new_creds = 0;
+ struct vas_caps *vcaps;
+ int i, rc = 0;
+
+ hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL);
+ if (!hv_caps)
+ return -ENOMEM;
+
+ mutex_lock(&vas_pseries_mutex);
+
+ for (i = 0; i < VAS_MAX_FEAT_TYPE; i++) {
+ vcaps = &vascaps[i];
+ caps = &vcaps->caps;
+ lpar_creds = atomic_read(&caps->target_creds);
+
+ rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
+ (u64)virt_to_phys(hv_caps));
+ if (!rc) {
+ new_creds = be16_to_cpu(hv_caps->target_lpar_creds);
+ /*
+ * Should not happen. But incase print messages, close all
+ * windows in the list during suspend and reopen windows
+ * based on new lpar_creds on the destination system.
+ */
+ if (lpar_creds != new_creds) {
+ pr_err("%s: lpar creds: %d HV lpar creds: %d\n",
+ suspend ? "Suspend" : "Resume", lpar_creds,
+ new_creds);
+ pr_err("Used creds: %d, Active creds: %d\n",
+ atomic_read(&caps->used_creds),
+ vcaps->num_wins - vcaps->close_wins);
+ }
+ } else {
+ pr_err("%s: Get VAS capabilities failed with %d\n",
+ suspend ? "Suspend" : "Resume", rc);
+ /*
+ * We can not stop migration with the current lpm
+ * implementation. So continue closing all windows in the
+ * list (during suspend) and return without opending windows
+ * (during resume) if VAS capabilities HCALL failed.
+ */
+ if (!suspend)
+ goto out;
+ }
+
+ if (suspend)
+ rc = reconfig_close_windows(vcaps, vcaps->num_wins, true);
+ else {
+ atomic_set(&caps->target_creds, new_creds);
+ rc = reconfig_open_windows(vcaps, new_creds, true);
+ }
+
+ /*
+ * Ignore errors during suspend and return for resume.
+ */
+ if (rc && !suspend)
+ goto out;
+ }
+
+out:
+ mutex_unlock(&vas_pseries_mutex);
+ kfree(hv_caps);
+ return rc;
+}
+
+static int vas_migration_handler(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ if (action == PSERIES_RESUMING)
+ return vas_migrate_windows(false);
+ else
+ return vas_migrate_windows(true);
+
+}
+
+static struct pseries_suspend_handler vas_suspend_handler = {
+ .notifier_block = {
+ .notifier_call = vas_migration_handler,
+ },
+};
+
+
static int __init pseries_vas_init(void)
{
struct hv_vas_cop_feat_caps *hv_cop_caps;
@@ -929,8 +1022,10 @@ static int __init pseries_vas_init(void)
}
/* Processors can be added/removed only on LPAR */
- if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR))
+ if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR)) {
of_reconfig_notifier_register(&pseries_vas_nb);
+ pseries_register_suspend_handler(&vas_suspend_handler);
+ }
pr_info("GZIP feature is available\n");
--
2.27.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox