Re: [PATCH v2] arm64: Kconfig.platforms: Enable GPIO_DAVINCI for ARCH_K3

2019-07-10 Thread Keerthy




On 29/06/19 2:07 AM, Nishanth Menon wrote:

On 09:08-20190628, Keerthy wrote:
[..]

+   select GPIO_SYSFS
+   select GPIO_DAVINCI



Could you help explain the logic of doing this? commit message is
basically the diff in English. To me, this does NOT make sense.

I understand GPIO_DAVINCI is the driver compatible, but we cant do this for
every single SoC driver that is NOT absolutely mandatory for basic
functionality.


In case of ARM64 could you help me find the right place to enable
such SoC specific configs?


Is'nt that what defconfig is supposed to be all about?

arch/arm64/configs/defconfig





Also keep in mind the impact to arm64/configs/defconfig -> every single
SoC in the arm64 world will be now rebuild with GPIO_SYSFS.. why force
that?


This was the practice in arm32 soc specific configs like
omap2plus_defconfig. GPIO_SYSFS was he only way to validate. Now i totally
understand your concern about every single SoC rebuilding but now where do
we need to enable the bare minimal GPIO_DAVINCI config?


Well, SYSFS, I cannot agree testing as the rationale in
Kconfig.platform. And, looking at [1], I see majority being mandatory
components for the SoC bootup. However, most of the "optional" drivers
go into arm64 as defconfig (preferably as a module?) and if you find a
rationale for recommending DEBUG_GPIO, you could propose that to the
community as well.

Now, Thinking about this, I'd even challenge the current list of configs as
being "select". I'd rather do an "imply"[2] - yes, you need this for the
default dtb to boot, however a carefully carved dtb could boot with
lesser driver set to get a smaller (and less functional) kernel.



v1 i received feedback from Tero to enable in Kconfig.platforms. Hence i
shifted to this approach.


I noticed that you were posting a v2, for future reference, please use
diffstat section to point to lore/patchworks link to point at v1 (I
did notice you mentioned you had an update, thanks - link will help
catch up on older discussions). This helps a later revision reviewer
like me to get context.

Tero, would you be able to help with a better rationale as to where the
boundaries are to be in your mind, rather than risk every single
peripheral driver getting into ARCH_K3?


Tero,

Could you point me to a better place for enabling?

- Keerthy



As of right now, I'd rather we do not explode the current list out of
bounds. NAK unless we can find a better rationale.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/Kconfig.platforms
[2] https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt



[PATCH v2 01/11] kbuild: do not create empty modules.order in the prepare stage

2019-07-10 Thread Masahiro Yamada
Currently, $(objtree)/modules.order is touched in two places.

In the 'prepare0' rule, scripts/Makefile.build creates an empty
modules.order while processing 'obj=.'

In the 'modules' rule, the top-level Makefile overwrites it with
the correct list of modules.

While this might be a good side-effect that modules.order is made
empty every time (probably this is not intended functionality),
I personally do not like this behavior.

Create modules.order only when it is sensible to do so.

This avoids creating the following pointless files:

  scripts/basic/modules.order
  scripts/dtc/modules.order
  scripts/gcc-plugins/modules.order
  scripts/genksyms/modules.order
  scripts/mod/modules.order
  scripts/modules.order
  scripts/selinux/genheaders/modules.order
  scripts/selinux/mdp/modules.order
  scripts/selinux/modules.order

Going forward, $(objtree)/modules.order lists the modules that
was built in the last successful build.

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
 - inverted the logic "preparing" -> need-modorder

 Makefile   | 4 ++--
 scripts/Makefile.build | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 5c75ea7177f6..d8421d245f75 100644
--- a/Makefile
+++ b/Makefile
@@ -1076,7 +1076,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
 
 PHONY += $(vmlinux-dirs)
 $(vmlinux-dirs): prepare
-   $(Q)$(MAKE) $(build)=$@ need-builtin=1
+   $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
 
 filechk_kernel.release = \
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) 
$(srctree)/scripts/setlocalversion $(srctree))"
@@ -1611,7 +1611,7 @@ $(objtree)/Module.symvers:
 module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
 PHONY += $(module-dirs) modules
 $(module-dirs): prepare $(objtree)/Module.symvers
-   $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
+   $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) need-modorder=1
 
 modules: $(module-dirs)
@$(kecho) '  Building modules, stage 2.';
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 776842b7e6a3..e9b3d88257dd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -63,7 +63,7 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),)
 builtin-target := $(obj)/built-in.a
 endif
 
-ifdef CONFIG_MODULES
+ifeq ($(CONFIG_MODULES)$(need-modorder),y1)
 modorder-target := $(obj)/modules.order
 endif
 
-- 
2.17.1



[PATCH v2 05/11] kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod

2019-07-10 Thread Masahiro Yamada
Towards the goal of removing MODVERDIR, read out modules.order to get
the list of modules to be installed. This is simpler than parsing *.mod
files in $(MODVERDIR).

For external modules, $(KBUILD_EXTMOD)/modules.order should be read.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.modinst | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 0dae402661f3..5a4579e76485 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -8,10 +8,7 @@ __modinst:
 
 include scripts/Kbuild.include
 
-#
-
-__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard 
$(MODVERDIR)/*.mod)))
-modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
+modules := $(sort $(shell cat $(if 
$(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order))
 
 PHONY += $(modules)
 __modinst: $(modules)
-- 
2.17.1



[PATCH v2 09/11] kbuild: remove the first line of *.mod files

2019-07-10 Thread Masahiro Yamada
The current format of *.mod is like this:

  line 1: directory path to the .ko file
  line 2: a list of objects linked into this module
  line 3: unresolved symbols (only when CONFIG_TRIM_UNUSED_KSYMS=y)

Now that *.mod and *.ko are created in the same directory, the line 1
provides no valuable information. It can be derived by replacing the
extension .mod with .ko.

Cut the first line.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.build  | 4 ++--
 scripts/adjust_autoksyms.sh | 2 +-
 scripts/mod/sumversion.c| 9 ++---
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 9fb30633acd2..2709646b1a5d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -279,7 +279,7 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) 
$(objtool_dep) FORCE
 $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) 
FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
-   @{ echo $(@:.o=.ko); echo $@; \
+   @{ echo $@; \
   $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)
 
 quiet_cmd_cc_lst_c = MKLST   $@
@@ -461,7 +461,7 @@ cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter 
%.o,$^) $(cmd_secanalysis
 
 $(multi-used-m): FORCE
$(call if_changed,link_multi-m)
-   @{ echo $(@:.o=.ko); echo $(filter %.o,$^); \
+   @{ echo $(filter %.o,$^); \
   $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)
 $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
 
diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh
index 8b44bb80a451..89871cae3954 100755
--- a/scripts/adjust_autoksyms.sh
+++ b/scripts/adjust_autoksyms.sh
@@ -48,7 +48,7 @@ cat > "$new_ksyms_file" << EOT
 
 EOT
 sed 's/ko$/mod/' modules.order |
-xargs -n1 sed -n -e '3{s/ /\n/g;/^$/!p;}' -- |
+xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
 sort -u |
 sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$new_ksyms_file"
 
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 166f3fa247a9..63062024ce0e 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -398,7 +398,7 @@ void get_src_version(const char *modname, char sum[], 
unsigned sumlen)
char *sources, *end, *fname;
char filelist[PATH_MAX + 1];
 
-   /* objects for a module are listed in the second line of *.mod file. */
+   /* objects for a module are listed in the first line of *.mod file. */
snprintf(filelist, sizeof(filelist), "%.*smod",
 (int)strlen(modname) - 1, modname);
 
@@ -407,13 +407,8 @@ void get_src_version(const char *modname, char sum[], 
unsigned sumlen)
/* not a module or .mod file missing - ignore */
return;
 
-   sources = strchr(file, '\n');
-   if (!sources) {
-   warn("malformed versions file for %s\n", modname);
-   goto release;
-   }
+   sources = file;
 
-   sources++;
end = strchr(sources, '\n');
if (!end) {
warn("bad ending versions file for %s\n", modname);
-- 
2.17.1



[PATCH v2 03/11] kbuild: remove duplication from modules.order in sub-directories

2019-07-10 Thread Masahiro Yamada
Currently, only the top-level modules.order drops duplicated entries.

The modules.order files in sub-directories potentially contain
duplication. To list out the paths of all modules, I want to use
modules.order instead of parsing *.mod files in $(MODVERDIR).

To achieve this, I want to rip off duplication from modules.order
of external modules too.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.build | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f21d691c776a..98dede0b2ca8 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -423,13 +423,10 @@ endif # builtin-target
 #
 # Create commands to either record .ko file or cat modules.order from
 # a subdirectory
-modorder-cmds =\
-   $(foreach m, $(modorder),   \
-   $(if $(filter %/modules.order, $m), \
-   cat $m;, echo $m;))
-
 $(modorder-target): $(subdir-ym) FORCE
-   $(Q)(cat /dev/null; $(modorder-cmds)) > $@
+   $(Q){ $(foreach m, $(modorder), \
+   $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
+   | $(AWK) '!x[$$0]++' - > $@
 
 #
 # Rule to compile a set of .o files into one .a file (with symbol table)
-- 
2.17.1



[PATCH v2 07/11] kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod

2019-07-10 Thread Masahiro Yamada
Towards the goal of removing MODVERDIR, read out modules.order to get
the list of modules to be processed. This is simpler than parsing *.mod
files in $(MODVERDIR).

For external modules, $(KBUILD_EXTMOD)/modules.order should be read.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.modpost | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index fec6ec2ffa47..2ab1694a7df3 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -8,9 +8,10 @@
 # b) A .o file which is the .o files above linked together
 # c) A .mod file in $(MODVERDIR)/, listing the name of the
 #the preliminary .o file, plus all .o files
+# d) modules.order, which lists all the modules
 
 # Stage 2 is handled by this file and does the following
-# 1) Find all modules from the files listed in $(MODVERDIR)/
+# 1) Find all modules listed in modules.order
 # 2) modpost is then used to
 # 3)  create one .mod.c file pr. module
 # 4)  create one Module.symvers file with CRC for all exported symbols
@@ -60,10 +61,10 @@ include scripts/Makefile.lib
 kernelsymfile := $(objtree)/Module.symvers
 modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
 
-# Step 1), find all modules listed in $(MODVERDIR)/
-MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | 
sort -u
-__modules := $(shell $(MODLISTCMD))
-modules   := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
+modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
+
+# Step 1), find all modules listed in modules.order
+modules := $(sort $(shell cat $(modorder)))
 
 # Stop after building .o files if NOFINAL is set. Makes compile tests quicker
 _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
@@ -84,7 +85,7 @@ MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
 
 # We can go over command line length here, so be careful.
 quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
-  cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) 
$(MODPOST_OPT) -s -T -
+  cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s 
-T -
 
 PHONY += __modpost
 __modpost: $(modules:.ko=.o) FORCE
-- 
2.17.1



[PATCH v2 06/11] kbuild: modsign: read modules.order instead of $(MODVERDIR)/*.mod

2019-07-10 Thread Masahiro Yamada
Towards the goal of removing MODVERDIR, read out modules.order to get
the list of modules to be signed. This is simpler than parsing *.mod
files in $(MODVERDIR).

The modules_sign target is only supported for in-kernel modules.
So, this commit does not take care of external modules.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.modsign | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/Makefile.modsign b/scripts/Makefile.modsign
index da56aa78d245..d7325cefe709 100644
--- a/scripts/Makefile.modsign
+++ b/scripts/Makefile.modsign
@@ -8,8 +8,7 @@ __modsign:
 
 include scripts/Kbuild.include
 
-__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard 
$(MODVERDIR)/*.mod)))
-modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
+modules := $(sort $(shell cat modules.order))
 
 PHONY += $(modules)
 __modsign: $(modules)
-- 
2.17.1



[PATCH v2 02/11] kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin}

2019-07-10 Thread Masahiro Yamada
Removing the 'kernel/' prefix will make our life easier because we can
simply do 'cat modules.order' to get all built modules with full paths.

Currently, we parse the first line of '*.mod' files in $(MODVERDIR).
Since we have duplicated functionality here, I plan to remove MODVERDIR
entirely.

In fact, modules.order is generated also for external modules in a
broken format. It adds the 'kernel/' prefix to the absolute path of
the module, like this:

  kernel//path/to/your/external/module/foo.ko

This is fine for now since modules.order is not used for external
modules. However, I want to sanitize the format everywhere towards
the goal of removing MODVERDIR.

We cannot change the format of installed module.{order,builtin}.
So, 'make modules_install' will add the 'kernel/' prefix while copying
them to $(MODLIB)/.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 Makefile| 4 ++--
 scripts/Makefile.build  | 2 +-
 scripts/Makefile.modbuiltin | 2 +-
 scripts/modules-check.sh| 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index d8421d245f75..b5e21d676ee2 100644
--- a/Makefile
+++ b/Makefile
@@ -1333,8 +1333,8 @@ _modinst_:
rm -f $(MODLIB)/build ; \
ln -s $(CURDIR) $(MODLIB)/build ; \
fi
-   @cp -f $(objtree)/modules.order $(MODLIB)/
-   @cp -f $(objtree)/modules.builtin $(MODLIB)/
+   @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
+   @sed 's:^:kernel/:' modules.builtin > $(MODLIB)/modules.builtin
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
 
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e9b3d88257dd..f21d691c776a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -426,7 +426,7 @@ endif # builtin-target
 modorder-cmds =\
$(foreach m, $(modorder),   \
$(if $(filter %/modules.order, $m), \
-   cat $m;, echo kernel/$m;))
+   cat $m;, echo $m;))
 
 $(modorder-target): $(subdir-ym) FORCE
$(Q)(cat /dev/null; $(modorder-cmds)) > $@
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin
index ea90a90b41a0..12ac300fe51b 100644
--- a/scripts/Makefile.modbuiltin
+++ b/scripts/Makefile.modbuiltin
@@ -40,7 +40,7 @@ __modbuiltin: $(modbuiltin-target) $(subdir-ym)
@:
 
 $(modbuiltin-target): $(subdir-ym) FORCE
-   $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \
+   $(Q)(for m in $(modbuiltin-mods); do echo $$m; done;\
cat /dev/null $(modbuiltin-subdirs)) > $@
 
 PHONY += FORCE
diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh
index 39e8cb36ba19..f51f446707b8 100755
--- a/scripts/modules-check.sh
+++ b/scripts/modules-check.sh
@@ -9,7 +9,7 @@ check_same_name_modules()
for m in $(sed 's:.*/::' modules.order | sort | uniq -d)
do
echo "warning: same module names found:" >&2
-   sed -n "/\/$m/s:^kernel/:  :p" modules.order >&2
+   sed -n "/\/$m/s:^:  :p" modules.order >&2
done
 }
 
-- 
2.17.1



[PATCH v2 10/11] kbuild: remove 'prepare1' target

2019-07-10 Thread Masahiro Yamada
Now that there is no rule for 'prepare1', it can go away.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 Makefile | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 4243b6daffcf..8de893e41149 100644
--- a/Makefile
+++ b/Makefile
@@ -1093,7 +1093,7 @@ scripts: scripts_basic scripts_dtc
 # archprepare is used in arch Makefiles and when processed asm symlink,
 # version.h and scripts_basic is processed / created.
 
-PHONY += prepare archprepare prepare1 prepare3
+PHONY += prepare archprepare prepare3
 
 # prepare3 is used to check if we are building in a separate output directory,
 # and if so do:
@@ -1110,10 +1110,8 @@ ifneq ($(srctree),.)
fi;
 endif
 
-prepare1: prepare3 outputmakefile asm-generic $(version_h) $(autoksyms_h) \
-   include/generated/utsrelease.h
-
-archprepare: archheaders archscripts prepare1 scripts
+archprepare: archheaders archscripts scripts prepare3 outputmakefile \
+   asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h
 
 prepare0: archprepare
$(Q)$(MAKE) $(build)=scripts/mod
-- 
2.17.1



[PATCH v2 08/11] kbuild: create *.mod with full directory path and remove MODVERDIR

2019-07-10 Thread Masahiro Yamada
While descending directories, Kbuild produces objects for modules,
but do not link final *.ko files; it is done in the modpost.

To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
for every module it is building. Some post-processing steps read the
necessary information from *.mod files. This avoids descending into
directories again. This mechanism was introduced in 2003 or so.

Later, commit 551559e13af1 ("kbuild: implement modules.order") added
modules.order. So, we can simply read it out to know all the modules
with directory paths. This is easier than parsing the first line of
*.mod files.

$(MODVERDIR) has a flat directory structure, that is, *.mod files
are named only with base names. This is based on the assumption that
the module name is unique across the tree. This assumption is really
fragile.

Stephen Rothwell reported a race condition caused by a module name
conflict:

  https://lkml.org/lkml/2019/5/13/991

In parallel building, two different threads could write to the same
$(MODVERDIR)/*.mod simultaneously.

Non-unique module names are the source of all kind of troubles, hence
commit 3a48a91901c5 ("kbuild: check uniqueness of module names")
introduced a new checker script.

However, it is still fragile in the build system point of view because
this race happens before scripts/modules-check.sh is invoked. If it
happens again, the modpost will emit unclear error messages.

To fix this issue completely, create *.mod in the same directory as
*.ko so that two threads never attempt to write to the same file.
$(MODVERDIR) is no longer needed.

Since modules with directory paths are listed in modules.order, Kbuild
is still able to find *.mod files without additional descending.

Signed-off-by: Masahiro Yamada 
Acked-by: Nicolas Pitre 
---

Changes in v2:
 - Remove -r of xargs, which is a GNU extension
 - Add '--' for extra safety

 .gitignore  |  1 +
 Documentation/dontdiff  |  1 +
 Makefile| 20 +++-
 scripts/Makefile.build  |  8 ++--
 scripts/Makefile.modpost|  4 ++--
 scripts/adjust_autoksyms.sh | 11 ---
 scripts/mod/sumversion.c| 16 +++-
 scripts/package/mkspec  |  2 +-
 8 files changed, 17 insertions(+), 46 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7587ef56b92d..8f5422cba6e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@
 *.lz4
 *.lzma
 *.lzo
+*.mod
 *.mod.c
 *.o
 *.o.*
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 5eba889ea84d..9f4392876099 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -30,6 +30,7 @@
 *.lzo
 *.mo
 *.moc
+*.mod
 *.mod.c
 *.o
 *.o.*
diff --git a/Makefile b/Makefile
index b5e21d676ee2..4243b6daffcf 100644
--- a/Makefile
+++ b/Makefile
@@ -488,11 +488,6 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE 
KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
 export KBUILD_ARFLAGS
 
-# When compiling out-of-tree modules, put MODVERDIR in the module
-# tree rather than in the kernel tree. The kernel tree might
-# even be read-only.
-export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword 
$(KBUILD_EXTMOD))/).tmp_versions
-
 # Files to ignore in find ... statements
 
 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o
\
@@ -1033,7 +1028,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) 
$(KBUILD_VMLINUX_LIBS)
 
 # Recurse until adjust_autoksyms.sh is satisfied
 PHONY += autoksyms_recursive
-autoksyms_recursive: $(vmlinux-deps)
+autoksyms_recursive: $(vmlinux-deps) modules.order
 ifdef CONFIG_TRIM_UNUSED_KSYMS
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
  "$(MAKE) -f $(srctree)/Makefile vmlinux"
@@ -1117,7 +1112,6 @@ endif
 
 prepare1: prepare3 outputmakefile asm-generic $(version_h) $(autoksyms_h) \
include/generated/utsrelease.h
-   $(cmd_crmodverdir)
 
 archprepare: archheaders archscripts prepare1 scripts
 
@@ -1375,7 +1369,7 @@ endif # CONFIG_MODULES
 # make distclean Remove editor backup files, patch leftover files and the like
 
 # Directories & files removed with 'make clean'
-CLEAN_DIRS  += $(MODVERDIR) include/ksym
+CLEAN_DIRS  += include/ksym
 CLEAN_FILES += modules.builtin.modinfo
 
 # Directories & files removed with 'make mrproper'
@@ -1636,7 +1630,6 @@ PHONY += $(clean-dirs) clean
 $(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
 
-clean: rm-dirs := $(MODVERDIR)
 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
 
 PHONY += help
@@ -1650,8 +1643,6 @@ help:
@echo  ''
 
 PHONY += prepare
-prepare:
-   $(cmd_crmodverdir)
 endif # KBUILD_EXTMOD
 
 clean: $(clean-dirs)
@@ -1662,7 +1653,7 @@ clean: $(clean-dirs)
-o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
-o -name '*.dwo' -o -name '*.lst' \
-   -o -name '*.su'  \
+   -o 

[PATCH v2 00/11] kbuild: create *.mod with directory path and remove MODVERDIR

2019-07-10 Thread Masahiro Yamada


This series kills the long standing MODVERDIR.

Since MODVERDIR has a flat structure, it cannot avoid a race
condition when somebody introduces a module name conflict.

Kbuild now reads modules.order to get the list of all modules.

The post-processing/installation stages will be more robust
and simpler.


Masahiro Yamada (11):
  kbuild: do not create empty modules.order in the prepare stage
  kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin}
  kbuild: remove duplication from modules.order in sub-directories
  scsi: remove pointless $(MODVERDIR)/$(obj)/53c700.ver
  kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod
  kbuild: modsign: read modules.order instead of $(MODVERDIR)/*.mod
  kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod
  kbuild: create *.mod with full directory path and remove MODVERDIR
  kbuild: remove the first line of *.mod files
  kbuild: remove 'prepare1' target
  kbuild: split out *.mod out of {single,multi}-used-m rules

 .gitignore  |  1 +
 Documentation/dontdiff  |  1 +
 Makefile| 36 ++--
 drivers/scsi/Makefile   |  2 +-
 scripts/Makefile.build  | 33 +++--
 scripts/Makefile.modbuiltin |  2 +-
 scripts/Makefile.modinst|  5 +
 scripts/Makefile.modpost| 17 +
 scripts/Makefile.modsign|  3 +--
 scripts/adjust_autoksyms.sh | 11 ---
 scripts/mod/sumversion.c| 23 ---
 scripts/modules-check.sh|  2 +-
 scripts/package/mkspec  |  2 +-
 13 files changed, 50 insertions(+), 88 deletions(-)

-- 
2.17.1



[PATCH v2 04/11] scsi: remove pointless $(MODVERDIR)/$(obj)/53c700.ver

2019-07-10 Thread Masahiro Yamada
Nothing depends on this, so it is dead code.

Signed-off-by: Masahiro Yamada 
---

I will apply this to kbuild tree since it is trivial.


Changes in v2: None

 drivers/scsi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 8826111fdf4a..acdd57e647f8 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -183,7 +183,7 @@ zalon7xx-objs   := zalon.o ncr53c8xx.o
 # Files generated that shall be removed upon make clean
 clean-files := 53c700_d.h 53c700_u.h scsi_devinfo_tbl.c
 
-$(obj)/53c700.o $(MODVERDIR)/$(obj)/53c700.ver: $(obj)/53c700_d.h
+$(obj)/53c700.o: $(obj)/53c700_d.h
 
 $(obj)/scsi_sysfs.o: $(obj)/scsi_devinfo_tbl.c
 
-- 
2.17.1



[PATCH v2 11/11] kbuild: split out *.mod out of {single,multi}-used-m rules

2019-07-10 Thread Masahiro Yamada
Currently, *.mod is created as a side-effect of obj-m.

Split out *.mod as a dedicated build rule, which allows to unify
the %.c -> %.o rule, and remove the single-used-m rule.

This also makes the incremental build of allmodconfig faster because
it saves $(NM) invocation when there is no change in the module.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 scripts/Makefile.build | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2709646b1a5d..63fc266b4985 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -67,8 +67,10 @@ ifeq ($(CONFIG_MODULES)$(need-modorder),y1)
 modorder-target := $(obj)/modules.order
 endif
 
+mod-targets := $(patsubst %.o, %.mod, $(obj-m))
+
 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
-$(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
+$(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \
 $(subdir-ym) $(always)
@:
 
@@ -266,7 +268,7 @@ endef
 
 # List module undefined symbols (or empty line if not enabled)
 ifdef CONFIG_TRIM_UNUSED_KSYMS
-cmd_undef_syms = $(NM) $@ | sed -n 's/^  *U //p' | xargs echo
+cmd_undef_syms = $(NM) $< | sed -n 's/^  *U //p' | xargs echo
 else
 cmd_undef_syms = echo
 endif
@@ -276,11 +278,15 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) 
$(objtool_dep) FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
 
-$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) 
FORCE
-   $(call cmd,force_checksrc)
-   $(call if_changed_rule,cc_o_c)
-   @{ echo $@; \
-  $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)
+cmd_mod = { \
+   echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) 
$($*-y) $($*-m)), $(@:.mod=.o)); \
+   $(cmd_undef_syms); \
+   } > $@
+
+$(obj)/%.mod: $(obj)/%.o FORCE
+   $(call if_changed,mod)
+
+targets += $(mod-targets)
 
 quiet_cmd_cc_lst_c = MKLST   $@
   cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
@@ -461,8 +467,6 @@ cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter 
%.o,$^) $(cmd_secanalysis
 
 $(multi-used-m): FORCE
$(call if_changed,link_multi-m)
-   @{ echo $(filter %.o,$^); \
-  $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)
 $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
 
 targets += $(multi-used-m)
-- 
2.17.1



[PATCH v1] KVM: x86: expose AVX512_BF16 feature to guest

2019-07-10 Thread Jing Liu
AVX512 BFLOAT16 instructions support 16-bit BFLOAT16 floating-point
format (BF16) for deep learning optimization.

Intel adds AVX512 BFLOAT16 feature in CooperLake, which is CPUID.7.1.EAX[5].

Detailed information of the CPUID bit can be found here,
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf.

Signed-off-by: Jing Liu 
---

This patch depends on kernel patch https://lkml.org/lkml/2019/6/19/912
and Paolo's patch set https://lkml.org/lkml/2019/7/4/468.

 arch/x86/kvm/cpuid.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 8fc6039..0c125dd 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -358,9 +358,13 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 
*entry, int index)
F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) |
F(MD_CLEAR);
 
+   /* cpuid 7.1.eax */
+   const u32 kvm_cpuid_7_1_eax_x86_features =
+   F(AVX512_BF16);
+
switch (index) {
case 0:
-   entry->eax = 0;
+   entry->eax = min(entry->eax, 1);
entry->ebx &= kvm_cpuid_7_0_ebx_x86_features;
cpuid_mask(>ebx, CPUID_7_0_EBX);
/* TSC_ADJUST is emulated */
@@ -384,6 +388,12 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 
*entry, int index)
 */
entry->edx |= F(ARCH_CAPABILITIES);
break;
+   case 1:
+   entry->eax &= kvm_cpuid_7_1_eax_x86_features;
+   entry->ebx = 0;
+   entry->ecx = 0;
+   entry->edx = 0;
+   break;
default:
WARN_ON_ONCE(1);
entry->eax = 0;
-- 
1.8.3.1



Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Leon Romanovsky
On Thu, Jul 11, 2019 at 01:16:03PM +1000, Stephen Rothwell wrote:
> Hi all,
>
> On Thu, 11 Jul 2019 13:13:44 +1000 Stephen Rothwell  
> wrote:
> >
> > On Thu, 11 Jul 2019 02:26:27 + Jason Gunthorpe  
> > wrote:
> > >
> > > On Thu, Jul 11, 2019 at 11:50:54AM +1000, Stephen Rothwell wrote:
> > >
> > > > So today this failed to build after I merged the rdma tree (previously
> > > > it didn;t until after the net-next tree was merged (I assume a
> > > > dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
> > > > in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
> > > > tree :-(
> > >
> > > ? I'm confused..
> > >
> > > rdma.git builds fine stand alone (I hope!)
> >
> > I have "Fixup to build SIW issue" from Leon (which switches to using
> > in_dev_for_each_ifa_rcu) included in the rmda tree merge commit because
> > without that the rdma tree would not build for me.  Are you saying that
> > I don't need that at all, now?
>
> Actually , I get it now, "Fixup to build SIW issue" is really just a
> fixup for the net-next and rdma trees merge ... OK, I will fix that up
> tomorrow.  Sorry for my confusion.

Yes, it was for build only.

>
> --
> Cheers,
> Stephen Rothwell




Re: [GIT PULL] clone3 for v5.3

2019-07-10 Thread Christian Brauner
On Wed, Jul 10, 2019 at 10:24:26PM -0700, Linus Torvalds wrote:
> On Mon, Jul 8, 2019 at 8:05 AM Christian Brauner  wrote:
> >
> > /* Syscall number 435 */
> > clone3() uses syscall number 435 and is coordinated with pidfd_open() which
> > uses syscall number 434. I'm not aware of any other syscall targeted for
> > 5.3 that has chosen the same number.
> 
> You say that, and 434/435 would make sense, but that's not what the
> code I see in the pull request actually does.
> 
> It seems to use syscall 436.
> 
> I think it's because openat2() is looking to use 435, but I'm a bit
> nervous about the conflict between the code and your commentary..

Sorry, that was just me being dumb and forgetting that there was
close_range() which had a chance of going through Al's tree. So I left a
hole for it.

I don't terribly mind if it's 435 or 436. People pointed out you might
even renumber yourself if something makes more sense to you.

Christian


Re: [PATCH v4 2/2] rtw88: pci: Use DMA sync instead of remapping in RX ISR

2019-07-10 Thread Jian-Hong Pan
Jian-Hong Pan  於 2019年7月11日 週四 下午1:25寫道:
>
> Since each skb in RX ring is reused instead of new allocation, we can
> treat the DMA in a more efficient way by DMA synchronization.
>
> Signed-off-by: Jian-Hong Pan 
> Cc: 
> ---

Sorry, also forget to place the version difference here

v2:
 - New patch by following [PATCH v3 1/2] rtw88: pci: Rearrange the
   memory usage for skb in RX ISR.

v3:
 - Remove rtw_pci_sync_rx_desc_cpu and call dma_sync_single_for_cpu in
   rtw_pci_rx_isr directly.
 - Remove the return value of rtw_pci_sync_rx_desc_device.
 - Use DMA_FROM_DEVICE instead of PCI_DMA_FROMDEVICE.

v4:
 - Same as v3.

>  drivers/net/wireless/realtek/rtw88/pci.c | 24 +---
>  1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/pci.c 
> b/drivers/net/wireless/realtek/rtw88/pci.c
> index c415f5e94fed..68fae52151dd 100644
> --- a/drivers/net/wireless/realtek/rtw88/pci.c
> +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> @@ -206,6 +206,23 @@ static int rtw_pci_reset_rx_desc(struct rtw_dev *rtwdev, 
> struct sk_buff *skb,
> return 0;
>  }
>
> +static void rtw_pci_sync_rx_desc_device(struct rtw_dev *rtwdev, dma_addr_t 
> dma,
> +   struct rtw_pci_rx_ring *rx_ring,
> +   u32 idx, u32 desc_sz)
> +{
> +   struct device *dev = rtwdev->dev;
> +   struct rtw_pci_rx_buffer_desc *buf_desc;
> +   int buf_sz = RTK_PCI_RX_BUF_SIZE;
> +
> +   dma_sync_single_for_device(dev, dma, buf_sz, DMA_FROM_DEVICE);
> +
> +   buf_desc = (struct rtw_pci_rx_buffer_desc *)(rx_ring->r.head +
> +idx * desc_sz);
> +   memset(buf_desc, 0, sizeof(*buf_desc));
> +   buf_desc->buf_size = cpu_to_le16(RTK_PCI_RX_BUF_SIZE);
> +   buf_desc->dma = cpu_to_le32(dma);
> +}
> +
>  static int rtw_pci_init_rx_ring(struct rtw_dev *rtwdev,
> struct rtw_pci_rx_ring *rx_ring,
> u8 desc_size, u32 len)
> @@ -782,8 +799,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
> rtw_pci *rtwpci,
> rtw_pci_dma_check(rtwdev, ring, cur_rp);
> skb = ring->buf[cur_rp];
> dma = *((dma_addr_t *)skb->cb);
> -   pci_unmap_single(rtwpci->pdev, dma, RTK_PCI_RX_BUF_SIZE,
> -PCI_DMA_FROMDEVICE);
> +   dma_sync_single_for_cpu(rtwdev->dev, dma, RTK_PCI_RX_BUF_SIZE,
> +   DMA_FROM_DEVICE);
> rx_desc = skb->data;
> chip->ops->query_rx_desc(rtwdev, rx_desc, _stat, 
> _status);
>
> @@ -818,7 +835,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
> rtw_pci *rtwpci,
>
>  next_rp:
> /* new skb delivered to mac80211, re-enable original skb DMA 
> */
> -   rtw_pci_reset_rx_desc(rtwdev, skb, ring, cur_rp, buf_desc_sz);
> +   rtw_pci_sync_rx_desc_device(rtwdev, dma, ring, cur_rp,
> +   buf_desc_sz);
>
> /* host read next element in ring */
> if (++cur_rp >= ring->r.len)
> --
> 2.22.0
>


Re: [GIT PULL] pidfd updates for v5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Mon,  8 Jul 2019 15:54:23 +0200:

> g...@gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux 
> tags/pidfd-updates-v5.3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5450e8a316a64cddcbc15f90733ebc78aa736545

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [git pull] m68k updates for 5.3 (take two)

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Wed, 10 Jul 2019 14:11:20 +0200:

> git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git 
> tags/m68k-for-v5.3-tag2

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/29cd581b59496c26334c910a8b848baa81a6becd

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [git pull] m68knommu changes for v5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Wed, 10 Jul 2019 15:22:09 +1000:

> git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu.git for-next

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/398364a35daed7361e76c3666fb9a97792edce09

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH v4 1/2] rtw88: pci: Rearrange the memory usage for skb in RX ISR

2019-07-10 Thread Jian-Hong Pan
Jian-Hong Pan  於 2019年7月11日 週四 下午1:25寫道:
>
> Testing with RTL8822BE hardware, when available memory is low, we
> frequently see a kernel panic and system freeze.
>
> First, rtw_pci_rx_isr encounters a memory allocation failure (trimmed):
>
> rx routine starvation
> WARNING: CPU: 7 PID: 9871 at drivers/net/wireless/realtek/rtw88/pci.c:822 
> rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]
> [ 2356.580313] RIP: 0010:rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]
>
> Then we see a variety of different error conditions and kernel panics,
> such as this one (trimmed):
>
> rtw_pci :02:00.0: pci bus timeout, check dma status
> skbuff: skb_over_panic: text:091b6e66 len:415 put:415 
> head:d2880c6f data:7a02b1ea tail:0x1df end:0xc0 dev:
> [ cut here ]
> kernel BUG at net/core/skbuff.c:105!
> invalid opcode:  [#1] SMP NOPTI
> RIP: 0010:skb_panic+0x43/0x45
>
> When skb allocation fails and the "rx routine starvation" is hit, the
> function returns immediately without updating the RX ring. At this
> point, the RX ring may continue referencing an old skb which was already
> handed off to ieee80211_rx_irqsafe(). When it comes to be used again,
> bad things happen.
>
> This patch allocates a new, data-sized skb first in RX ISR. After
> copying the data in, we pass it to the upper layers. However, if skb
> allocation fails, we effectively drop the frame. In both cases, the
> original, full size ring skb is reused.
>
> In addition, to fixing the kernel crash, the RX routine should now
> generally behave better under low memory conditions.
>
> Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=204053
> Signed-off-by: Jian-Hong Pan 
> Cc: 
> ---

Sorry, I forget to place the version difference here.

v2:
 - Allocate new data-sized skb and put data into it, then pass it to
   mac80211. Reuse the original skb in RX ring by DMA sync.
 - Modify the commit message.
 - Introduce following [PATCH v3 2/2] rtw88: pci: Use DMA sync instead
   of remapping in RX ISR.

v3:
 - Same as v2.

v4:
 - Fix comment: allocate a new skb for this frame, discard the frame
if none available

>  drivers/net/wireless/realtek/rtw88/pci.c | 49 +++-
>  1 file changed, 22 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/pci.c 
> b/drivers/net/wireless/realtek/rtw88/pci.c
> index cfe05ba7280d..c415f5e94fed 100644
> --- a/drivers/net/wireless/realtek/rtw88/pci.c
> +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> @@ -763,6 +763,7 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
> rtw_pci *rtwpci,
> u32 pkt_offset;
> u32 pkt_desc_sz = chip->rx_pkt_desc_sz;
> u32 buf_desc_sz = chip->rx_buf_desc_sz;
> +   u32 new_len;
> u8 *rx_desc;
> dma_addr_t dma;
>
> @@ -790,40 +791,34 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, 
> struct rtw_pci *rtwpci,
> pkt_offset = pkt_desc_sz + pkt_stat.drv_info_sz +
>  pkt_stat.shift;
>
> -   if (pkt_stat.is_c2h) {
> -   /* keep rx_desc, halmac needs it */
> -   skb_put(skb, pkt_stat.pkt_len + pkt_offset);
> +   /* allocate a new skb for this frame,
> +* discard the frame if none available
> +*/
> +   new_len = pkt_stat.pkt_len + pkt_offset;
> +   new = dev_alloc_skb(new_len);
> +   if (WARN_ONCE(!new, "rx routine starvation\n"))
> +   goto next_rp;
> +
> +   /* put the DMA data including rx_desc from phy to new skb */
> +   skb_put_data(new, skb->data, new_len);
>
> -   /* pass offset for further operation */
> -   *((u32 *)skb->cb) = pkt_offset;
> -   skb_queue_tail(>c2h_queue, skb);
> +   if (pkt_stat.is_c2h) {
> +/* pass rx_desc & offset for further operation */
> +   *((u32 *)new->cb) = pkt_offset;
> +   skb_queue_tail(>c2h_queue, new);
> ieee80211_queue_work(rtwdev->hw, >c2h_work);
> } else {
> -   /* remove rx_desc, maybe use skb_pull? */
> -   skb_put(skb, pkt_stat.pkt_len);
> -   skb_reserve(skb, pkt_offset);
> -
> -   /* alloc a smaller skb to mac80211 */
> -   new = dev_alloc_skb(pkt_stat.pkt_len);
> -   if (!new) {
> -   new = skb;
> -   } else {
> -   skb_put_data(new, skb->data, skb->len);
> -   dev_kfree_skb_any(skb);
> -   }
> -   /* TODO: merge into rx.c */
> -   rtw_rx_stats(rtwdev, pkt_stat.vif, skb);
> +   /* remove rx_desc */
> +   

Re: [GIT PULL] clone3 for v5.3

2019-07-10 Thread Linus Torvalds
On Mon, Jul 8, 2019 at 8:05 AM Christian Brauner  wrote:
>
> /* Syscall number 435 */
> clone3() uses syscall number 435 and is coordinated with pidfd_open() which
> uses syscall number 434. I'm not aware of any other syscall targeted for
> 5.3 that has chosen the same number.

You say that, and 434/435 would make sense, but that's not what the
code I see in the pull request actually does.

It seems to use syscall 436.

I think it's because openat2() is looking to use 435, but I'm a bit
nervous about the conflict between the code and your commentary..

  Linus


[PATCH v4 2/2] rtw88: pci: Use DMA sync instead of remapping in RX ISR

2019-07-10 Thread Jian-Hong Pan
Since each skb in RX ring is reused instead of new allocation, we can
treat the DMA in a more efficient way by DMA synchronization.

Signed-off-by: Jian-Hong Pan 
Cc: 
---
 drivers/net/wireless/realtek/rtw88/pci.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/pci.c 
b/drivers/net/wireless/realtek/rtw88/pci.c
index c415f5e94fed..68fae52151dd 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -206,6 +206,23 @@ static int rtw_pci_reset_rx_desc(struct rtw_dev *rtwdev, 
struct sk_buff *skb,
return 0;
 }
 
+static void rtw_pci_sync_rx_desc_device(struct rtw_dev *rtwdev, dma_addr_t dma,
+   struct rtw_pci_rx_ring *rx_ring,
+   u32 idx, u32 desc_sz)
+{
+   struct device *dev = rtwdev->dev;
+   struct rtw_pci_rx_buffer_desc *buf_desc;
+   int buf_sz = RTK_PCI_RX_BUF_SIZE;
+
+   dma_sync_single_for_device(dev, dma, buf_sz, DMA_FROM_DEVICE);
+
+   buf_desc = (struct rtw_pci_rx_buffer_desc *)(rx_ring->r.head +
+idx * desc_sz);
+   memset(buf_desc, 0, sizeof(*buf_desc));
+   buf_desc->buf_size = cpu_to_le16(RTK_PCI_RX_BUF_SIZE);
+   buf_desc->dma = cpu_to_le32(dma);
+}
+
 static int rtw_pci_init_rx_ring(struct rtw_dev *rtwdev,
struct rtw_pci_rx_ring *rx_ring,
u8 desc_size, u32 len)
@@ -782,8 +799,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
rtw_pci *rtwpci,
rtw_pci_dma_check(rtwdev, ring, cur_rp);
skb = ring->buf[cur_rp];
dma = *((dma_addr_t *)skb->cb);
-   pci_unmap_single(rtwpci->pdev, dma, RTK_PCI_RX_BUF_SIZE,
-PCI_DMA_FROMDEVICE);
+   dma_sync_single_for_cpu(rtwdev->dev, dma, RTK_PCI_RX_BUF_SIZE,
+   DMA_FROM_DEVICE);
rx_desc = skb->data;
chip->ops->query_rx_desc(rtwdev, rx_desc, _stat, 
_status);
 
@@ -818,7 +835,8 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
rtw_pci *rtwpci,
 
 next_rp:
/* new skb delivered to mac80211, re-enable original skb DMA */
-   rtw_pci_reset_rx_desc(rtwdev, skb, ring, cur_rp, buf_desc_sz);
+   rtw_pci_sync_rx_desc_device(rtwdev, dma, ring, cur_rp,
+   buf_desc_sz);
 
/* host read next element in ring */
if (++cur_rp >= ring->r.len)
-- 
2.22.0



[PATCH v4 1/2] rtw88: pci: Rearrange the memory usage for skb in RX ISR

2019-07-10 Thread Jian-Hong Pan
Testing with RTL8822BE hardware, when available memory is low, we
frequently see a kernel panic and system freeze.

First, rtw_pci_rx_isr encounters a memory allocation failure (trimmed):

rx routine starvation
WARNING: CPU: 7 PID: 9871 at drivers/net/wireless/realtek/rtw88/pci.c:822 
rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]
[ 2356.580313] RIP: 0010:rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]

Then we see a variety of different error conditions and kernel panics,
such as this one (trimmed):

rtw_pci :02:00.0: pci bus timeout, check dma status
skbuff: skb_over_panic: text:091b6e66 len:415 put:415 
head:d2880c6f data:7a02b1ea tail:0x1df end:0xc0 dev:
[ cut here ]
kernel BUG at net/core/skbuff.c:105!
invalid opcode:  [#1] SMP NOPTI
RIP: 0010:skb_panic+0x43/0x45

When skb allocation fails and the "rx routine starvation" is hit, the
function returns immediately without updating the RX ring. At this
point, the RX ring may continue referencing an old skb which was already
handed off to ieee80211_rx_irqsafe(). When it comes to be used again,
bad things happen.

This patch allocates a new, data-sized skb first in RX ISR. After
copying the data in, we pass it to the upper layers. However, if skb
allocation fails, we effectively drop the frame. In both cases, the
original, full size ring skb is reused.

In addition, to fixing the kernel crash, the RX routine should now
generally behave better under low memory conditions.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=204053
Signed-off-by: Jian-Hong Pan 
Cc: 
---
 drivers/net/wireless/realtek/rtw88/pci.c | 49 +++-
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/pci.c 
b/drivers/net/wireless/realtek/rtw88/pci.c
index cfe05ba7280d..c415f5e94fed 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -763,6 +763,7 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
rtw_pci *rtwpci,
u32 pkt_offset;
u32 pkt_desc_sz = chip->rx_pkt_desc_sz;
u32 buf_desc_sz = chip->rx_buf_desc_sz;
+   u32 new_len;
u8 *rx_desc;
dma_addr_t dma;
 
@@ -790,40 +791,34 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, struct 
rtw_pci *rtwpci,
pkt_offset = pkt_desc_sz + pkt_stat.drv_info_sz +
 pkt_stat.shift;
 
-   if (pkt_stat.is_c2h) {
-   /* keep rx_desc, halmac needs it */
-   skb_put(skb, pkt_stat.pkt_len + pkt_offset);
+   /* allocate a new skb for this frame,
+* discard the frame if none available
+*/
+   new_len = pkt_stat.pkt_len + pkt_offset;
+   new = dev_alloc_skb(new_len);
+   if (WARN_ONCE(!new, "rx routine starvation\n"))
+   goto next_rp;
+
+   /* put the DMA data including rx_desc from phy to new skb */
+   skb_put_data(new, skb->data, new_len);
 
-   /* pass offset for further operation */
-   *((u32 *)skb->cb) = pkt_offset;
-   skb_queue_tail(>c2h_queue, skb);
+   if (pkt_stat.is_c2h) {
+/* pass rx_desc & offset for further operation */
+   *((u32 *)new->cb) = pkt_offset;
+   skb_queue_tail(>c2h_queue, new);
ieee80211_queue_work(rtwdev->hw, >c2h_work);
} else {
-   /* remove rx_desc, maybe use skb_pull? */
-   skb_put(skb, pkt_stat.pkt_len);
-   skb_reserve(skb, pkt_offset);
-
-   /* alloc a smaller skb to mac80211 */
-   new = dev_alloc_skb(pkt_stat.pkt_len);
-   if (!new) {
-   new = skb;
-   } else {
-   skb_put_data(new, skb->data, skb->len);
-   dev_kfree_skb_any(skb);
-   }
-   /* TODO: merge into rx.c */
-   rtw_rx_stats(rtwdev, pkt_stat.vif, skb);
+   /* remove rx_desc */
+   skb_pull(new, pkt_offset);
+
+   rtw_rx_stats(rtwdev, pkt_stat.vif, new);
memcpy(new->cb, _status, sizeof(rx_status));
ieee80211_rx_irqsafe(rtwdev->hw, new);
}
 
-   /* skb delivered to mac80211, alloc a new one in rx ring */
-   new = dev_alloc_skb(RTK_PCI_RX_BUF_SIZE);
-   if (WARN(!new, "rx routine starvation\n"))
-   return;
-
-   ring->buf[cur_rp] = new;
-   rtw_pci_reset_rx_desc(rtwdev, new, ring, cur_rp, buf_desc_sz);
+next_rp:
+   /* new skb delivered to mac80211, 

RE: [PATCH v6 0/5] net: macb: cover letter

2019-07-10 Thread Parshuram Raju Thombare
Hi David,

Ok, I will resubmit it.

Regards,
Parshuram Thombare


linux-next: build failure after merge of the block tree

2019-07-10 Thread Stephen Rothwell
Hi all,

After merging the block tree, today's linux-next build (x86_64
allmodconfig) failed like this:

fs/f2fs/data.c: In function 'f2fs_merge_page_bio':
fs/f2fs/data.c:516:3: error: implicit declaration of function 'wbc_account_io'; 
did you mean 'blk_account_rq'? [-Werror=implicit-function-declaration]
   wbc_account_io(fio->io_wbc, page, PAGE_SIZE);
   ^~
   blk_account_rq

Caused by commit

  34e51a5e1a6e ("blkcg, writeback: Rename wbc_account_io() to 
wbc_account_cgroup_owner()")

interacting with commit

  8648de2c581e ("f2fs: add bio cache for IPU")

from the f2fs tree.

I added the following merge fix patch or today:

From: Stephen Rothwell 
Date: Thu, 11 Jul 2019 15:13:21 +1000
Subject: [PATCH] f2fs: fix for wbc_account_io rename

Signed-off-by: Stephen Rothwell 
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 323306630f93..4eb2f3920140 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -513,7 +513,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
}
 
if (fio->io_wbc)
-   wbc_account_io(fio->io_wbc, page, PAGE_SIZE);
+   wbc_account_cgroup_owner(fio->io_wbc, page, PAGE_SIZE);
 
inc_page_count(fio->sbi, WB_DATA_TYPE(page));
 
-- 
2.20.1

-- 
Cheers,
Stephen Rothwell


pgpNwc74pmPDS.pgp
Description: OpenPGP digital signature


Re: [PATCH net-next] net: mlx5: Fix compiling error in tls.c

2019-07-10 Thread Saeed Mahameed
On Wed, Jul 10, 2019 at 2:33 AM Mao Wenan  wrote:
>
> There are some errors while compiling tls.c if
> CONFIG_MLX5_FPGA_TLS is not obvious on.
>
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c: In function 
> mlx5e_tls_set_ipv4_flow:
> ./include/linux/mlx5/device.h:61:39: error: invalid application of sizeof to 
> incomplete type struct mlx5_ifc_tls_flow_bits
>  #define __mlx5_st_sz_bits(typ) sizeof(struct mlx5_ifc_##typ##_bits)
>^
> ./include/linux/compiler.h:330:9: note: in definition of macro 
> __compiletime_assert
>if (!(condition)) \
>  ^
> ...
>
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c: In function 
> mlx5e_tls_build_netdev:
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c:202:13: error: 
> MLX5_ACCEL_TLS_TX undeclared (first use in this function); did you mean 
> __MLX5_ACCEL_TLS_H__?
>   if (caps & MLX5_ACCEL_TLS_TX) {
>  ^
>  __MLX5_ACCEL_TLS_H__
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c:207:13: error: 
> MLX5_ACCEL_TLS_RX undeclared (first use in this function); did you mean 
> MLX5_ACCEL_TLS_TX?
>   if (caps & MLX5_ACCEL_TLS_RX) {
>  ^
>  MLX5_ACCEL_TLS_TX
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c:212:15: error: 
> MLX5_ACCEL_TLS_LRO undeclared (first use in this function); did you mean 
> MLX5_ACCEL_TLS_RX?
>   if (!(caps & MLX5_ACCEL_TLS_LRO)) {
>^~
>MLX5_ACCEL_TLS_RX
> make[5]: *** [drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.o] Error 1
> make[5]: *** Waiting for unfinished jobs
> make[4]: *** [drivers/net/ethernet/mellanox/mlx5/core] Error 2
> make[3]: *** [drivers/net/ethernet/mellanox] Error 2
> make[3]: *** Waiting for unfinished jobs
> make[2]: *** [drivers/net/ethernet] Error 2
> make[2]: *** Waiting for unfinished jobs
> make[1]: *** [drivers/net] Error 2
> make[1]: *** Waiting for unfinished jobs
> make: *** [drivers] Error 2
> make: *** Waiting for unfinished jobs
>
> this patch is to fix this error using 'depends on MLX5_FPGA_TLS' when 
> MLX5_TLS is set.
>

Hi Mao, Thanks for the patch. sorry for the delayed response, I was
out of office.

Actually MLX5_TLS doesn't depend on MLX5_FPGA_TLS anymore.
Tariq prepared a patch to fix this, we will submit it this week.


> Fixes: e2869fb2068b ("net/mlx5: Kconfig, Better organize compilation flags")
>
> Signed-off-by: Mao Wenan 
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig 
> b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
> index 37fef8c..1da2770 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
> @@ -139,6 +139,7 @@ config MLX5_TLS
> depends on MLX5_CORE_EN
> depends on TLS_DEVICE
> depends on TLS=y || MLX5_CORE=m
> +   depends on MLX5_FPGA_TLS
> select MLX5_ACCEL
> default n
> help
> --
> 2.7.4
>


RE: [PATCH AUTOSEL 5.1 08/39] arm64: dts: ls1028a: Fix CPU idle fail.

2019-07-10 Thread Ran Wang
Hi Sasha, 

Thanks for helping port this patch to stable.
May I know if I can submit other bug fixes which has been accepted by 
upstream to stable by myself?
If yes, where I can find related process for reference?

Thanks & Regards,
Ran

> -Original Message-
> From: Sasha Levin 
> Sent: Wednesday, July 03, 2019 10:15
> To: linux-kernel@vger.kernel.org; sta...@vger.kernel.org
> Cc: Ran Wang ; Shawn Guo ;
> Sasha Levin ; devicet...@vger.kernel.org
> Subject: [PATCH AUTOSEL 5.1 08/39] arm64: dts: ls1028a: Fix CPU idle fail.
> 
> From: Ran Wang 
> 
> [ Upstream commit 53f2ac9d3aa881ed419054076042898b77c27ee4 ]
> 
> PSCI spec define 1st parameter's bit 16 of function CPU_SUSPEND to indicate
> CPU State Type: 0 for standby, 1 for power down. In this case, we want to 
> select
> standby for CPU idle feature. But current setting wrongly select power down 
> and
> cause CPU SUSPEND fail every time. Need this fix.
> 
> Fixes: 8897f3255c9c ("arm64: dts: Add support for NXP LS1028A SoC")
> Signed-off-by: Ran Wang 
> Signed-off-by: Shawn Guo 
> Signed-off-by: Sasha Levin 
> ---
>  arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
> b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
> index 2896bbcfa3bb..228872549f01 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
> +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
> @@ -28,7 +28,7 @@
>   enable-method = "psci";
>   clocks = < 1 0>;
>   next-level-cache = <>;
> - cpu-idle-states = <_PH20>;
> + cpu-idle-states = <_PW20>;
>   };
> 
>   cpu1: cpu@1 {
> @@ -38,7 +38,7 @@
>   enable-method = "psci";
>   clocks = < 1 0>;
>   next-level-cache = <>;
> - cpu-idle-states = <_PH20>;
> + cpu-idle-states = <_PW20>;
>   };
> 
>   l2: l2-cache {
> @@ -53,13 +53,13 @@
>*/
>   entry-method = "arm,psci";
> 
> - CPU_PH20: cpu-ph20 {
> - compatible = "arm,idle-state";
> - idle-state-name = "PH20";
> - arm,psci-suspend-param = <0x0001>;
> - entry-latency-us = <1000>;
> - exit-latency-us = <1000>;
> - min-residency-us = <3000>;
> + CPU_PW20: cpu-pw20 {
> +   compatible = "arm,idle-state";
> +   idle-state-name = "PW20";
> +   arm,psci-suspend-param = <0x0>;
> +   entry-latency-us = <2000>;
> +   exit-latency-us = <2000>;
> +   min-residency-us = <6000>;
>   };
>   };
> 
> --
> 2.20.1



linux-next: build failure after merge of the block tree

2019-07-10 Thread Stephen Rothwell
Hi all,

After merging the block tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

fs/xfs/xfs_aops.c: In function 'xfs_add_to_ioend':
fs/xfs/xfs_aops.c:799:2: error: implicit declaration of function 
'wbc_account_io'; did you mean 'blk_account_rq'? 
[-Werror=implicit-function-declaration]
  wbc_account_io(wbc, page, len);
  ^~
  blk_account_rq

Caused by commit

  34e51a5e1a6e ("blkcg, writeback: Rename wbc_account_io() to 
wbc_account_cgroup_owner()")

interacting with commit

  adfb5fb46af0 ("xfs: implement cgroup aware writeback")

from the xfs tree.

I have applied the following merge fix patch:

From: Stephen Rothwell 
Date: Thu, 11 Jul 2019 15:01:54 +1000
Subject: [PATCH] xfs: fix up for wbc_account_io rename

Signed-off-by: Stephen Rothwell 
---
 fs/xfs/xfs_aops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 761248ee2778..f16d5f196c6b 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -796,7 +796,7 @@ xfs_add_to_ioend(
}
 
wpc->ioend->io_size += len;
-   wbc_account_io(wbc, page, len);
+   wbc_account_cgroup_owner(wbc, page, len);
 }
 
 STATIC void
-- 
2.20.1

-- 
Cheers,
Stephen Rothwell


pgpPNOxt7Dafy.pgp
Description: OpenPGP digital signature


Re: [PATCH v3 17/30] locking/lockdep: Add read-write type for a lock dependency

2019-07-10 Thread Yuyang Du
Thanks for review.

On Wed, 10 Jul 2019 at 13:18, Boqun Feng  wrote:
>
> On Fri, Jun 28, 2019 at 05:15:15PM +0800, Yuyang Du wrote:
> > Direct dependencies need to keep track of their read-write lock types.
> > Two bit fields, which share the distance field, are added to lock_list
> > struct so the types are stored there.
> >
> > With a dependecy lock1 -> lock2, lock_type1 has the type for lock1 and
> > lock_type2 has the type for lock2, where the values are one of the
> > lock_type enums.
> >
> > Signed-off-by: Yuyang Du 
> > ---
> >  include/linux/lockdep.h  | 15 ++-
> >  kernel/locking/lockdep.c | 25 +++--
> >  2 files changed, 37 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
> > index eb26e93..fd619ac 100644
> > --- a/include/linux/lockdep.h
> > +++ b/include/linux/lockdep.h
> > @@ -185,6 +185,8 @@ static inline void lockdep_copy_map(struct lockdep_map 
> > *to,
> >   to->class_cache[i] = NULL;
> >  }
> >
> > +#define LOCK_TYPE_BITS   2
> > +
> >  /*
> >   * Every lock has a list of other locks that were taken after or before
> >   * it as lock dependencies. These dependencies constitute a graph, which
> > @@ -207,7 +209,17 @@ struct lock_list {
> >   struct list_headchains;
> >   struct lock_class   *class[2];
> >   struct lock_trace   trace;
> > - int distance;
> > +
> > + /*
> > +  * The lock_type fields keep track of the lock type of this
> > +  * dependency.
> > +  *
> > +  * With L1 -> L2, lock_type1 stores the lock type of L1, and
> > +  * lock_type2 stores that of L2.
> > +  */
> > + unsigned intlock_type1 : LOCK_TYPE_BITS,
> > + lock_type2 : LOCK_TYPE_BITS,
>
> Bad names ;-) Maybe fw_dep_type and bw_dep_type? Which seems to be
> aligned with the naming schema other functions.

I think the types are for L1 -> L2 respectively, hence the names in
question. Let me reconsider this anyway and maybe hear from others.

Thanks,
Yuyang


Re: [PATCH] Fix perf stat repeat segfault

2019-07-10 Thread Ravi Bangoria
Hi Numfor,

On 7/11/19 2:15 AM, Numfor Mbiziwo-Tiapo wrote:
> -static bool perf_evsel__should_store_id(struct perf_evsel *counter)
> +static bool perf_evsel__should_store_id(struct perf_evsel *counter, int 
> run_idx)
>  {
> - return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID;
> + return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID
> + && run_idx < 1;
>  }

Build fails for me:

builtin-stat.c: In function ‘perf_evsel__should_store_id’:
builtin-stat.c:395:3: error: suggest parentheses around ‘&&’ within ‘||’ 
[-Werror=parentheses]
  return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID
~~
   && run_idx < 1;
   ^~
cc1: all warnings being treated as errors

And probably,
Fixes: 82bf311e15d2 ("perf stat: Use group read for event groups")



Re: [GIT PULL] vfs: fix copy_file_range bad behavior

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Tue, 9 Jul 2019 09:39:48 -0700:

> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git tags/copy-file-range-fixes-1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/40f06c799539739a08a56be8a096f56aeed05731

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] gfs2: 5.3 merge

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Thu, 11 Jul 2019 00:22:27 +0200:

> git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git 
> tags/gfs2-for-5.3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0248a8be6d21dad72b9ce80a7565cf13c11509d8

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] ext4 updates for 5.3-rc1

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Tue, 9 Jul 2019 18:55:48 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git 
> tags/ext4_for_linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2e756758e5cb4ea29cba5865d00fad476ce94a93

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH] media: i2c: adv748x: Convert to new i2c device probe()

2019-07-10 Thread Niklas Söderlund
Hi Kieran,

Thanks for your patch.

On 2019-07-10 13:37:19 +0100, Kieran Bingham wrote:
> The I2C core framework provides a simplified probe framework from commit
> b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type").
> 
> Convert the ADV748x to utilise this simplfied i2c driver registration.
> 
> Signed-off-by: Kieran Bingham 

Looks good,

Reviewed-by: Niklas Söderlund 

> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 13 ++---
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
> b/drivers/media/i2c/adv748x/adv748x-core.c
> index 097e94279cf7..ae2b6eb93e09 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -677,8 +677,7 @@ static void adv748x_dt_cleanup(struct adv748x_state 
> *state)
>   of_node_put(state->endpoints[i]);
>  }
>  
> -static int adv748x_probe(struct i2c_client *client,
> -  const struct i2c_device_id *id)
> +static int adv748x_probe(struct i2c_client *client)
>  {
>   struct adv748x_state *state;
>   int ret;
> @@ -806,13 +805,6 @@ static int adv748x_remove(struct i2c_client *client)
>   return 0;
>  }
>  
> -static const struct i2c_device_id adv748x_id[] = {
> - { "adv7481", 0 },
> - { "adv7482", 0 },
> - { },
> -};
> -MODULE_DEVICE_TABLE(i2c, adv748x_id);
> -
>  static const struct of_device_id adv748x_of_table[] = {
>   { .compatible = "adi,adv7481", },
>   { .compatible = "adi,adv7482", },
> @@ -825,9 +817,8 @@ static struct i2c_driver adv748x_driver = {
>   .name = "adv748x",
>   .of_match_table = adv748x_of_table,
>   },
> - .probe = adv748x_probe,
> + .probe_new = adv748x_probe,
>   .remove = adv748x_remove,
> - .id_table = adv748x_id,
>  };
>  
>  module_i2c_driver(adv748x_driver);
> -- 
> 2.20.1
> 

-- 
Regards,
Niklas Söderlund


Re: [GIT PULL] afs: Miscellany for 5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Fri, 05 Jul 2019 22:45:39 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git 
> tags/afs-next-20190628

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/8dda9957e3a1c871dfbabf84c4760f9b26032442

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] nfsd changes for 5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Wed, 10 Jul 2019 18:02:36 -0400:

> git://linux-nfs.org/~bfields/linux.git tags/nfsd-5.3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/d2b6b4c832f7e3067709e8d4970b7b82b44419ac

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] file lease fix and tracepoint for v5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Mon, 08 Jul 2019 08:43:10 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git 
> tags/locks-v5.3-1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/988052f47adc5c3b0b004180b59bb3761d91b752

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] fscrypt updates for v5.3

2019-07-10 Thread pr-tracker-bot
The pull request you sent on Mon, 8 Jul 2019 08:53:33 -0700:

> git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git tags/fscrypt-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/25cd6f355dab9d11b7c8a4005867d5a30b8b14ee

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[PATCH 2/6] pinctrl: aspeed: Rename pin declaration macros

2019-07-10 Thread Andrew Jeffery
Rename macros as follows:

* s/SS_PIN_DECL()/PIN_DECL_1()/
* s/MS_PIN_DECL()/PIN_DECL_2()/
* s/MS_PIN_DECL_()/PIN_DECL_()/

This is in preparation for adding PIN_DECL_3(). We could clean this up
with e.g. CPPMAGIC_MAP() from ccan, but that might be a bridge too far
given how much of a macro jungle we already have.

Signed-off-by: Andrew Jeffery 
---
 drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c | 372 +-
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 418 ++---
 drivers/pinctrl/aspeed/pinmux-aspeed.h |  20 +-
 3 files changed, 405 insertions(+), 405 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c 
b/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c
index 37f325fb5d7c..6d93bb4209f0 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c
@@ -86,14 +86,14 @@ SSSF_PIN_DECL(E6, GPIOA3, TIMER4, SIG_DESC_SET(SCU80, 3));
 #define C5 4
 SIG_EXPR_LIST_DECL_SINGLE(SCL9, I2C9, I2C9_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(TIMER5, TIMER5, SIG_DESC_SET(SCU80, 4));
-MS_PIN_DECL(C5, GPIOA4, SCL9, TIMER5);
+PIN_DECL_2(C5, GPIOA4, SCL9, TIMER5);
 
 FUNC_GROUP_DECL(TIMER5, C5);
 
 #define B4 5
 SIG_EXPR_LIST_DECL_SINGLE(SDA9, I2C9, I2C9_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(TIMER6, TIMER6, SIG_DESC_SET(SCU80, 5));
-MS_PIN_DECL(B4, GPIOA5, SDA9, TIMER6);
+PIN_DECL_2(B4, GPIOA5, SDA9, TIMER6);
 
 FUNC_GROUP_DECL(TIMER6, B4);
 FUNC_GROUP_DECL(I2C9, C5, B4);
@@ -103,14 +103,14 @@ FUNC_GROUP_DECL(I2C9, C5, B4);
 #define A3 6
 SIG_EXPR_LIST_DECL_SINGLE(MDC2, MDIO2, MDIO2_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(TIMER7, TIMER7, SIG_DESC_SET(SCU80, 6));
-MS_PIN_DECL(A3, GPIOA6, MDC2, TIMER7);
+PIN_DECL_2(A3, GPIOA6, MDC2, TIMER7);
 
 FUNC_GROUP_DECL(TIMER7, A3);
 
 #define D5 7
 SIG_EXPR_LIST_DECL_SINGLE(MDIO2, MDIO2, MDIO2_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(TIMER8, TIMER8, SIG_DESC_SET(SCU80, 7));
-MS_PIN_DECL(D5, GPIOA7, MDIO2, TIMER8);
+PIN_DECL_2(D5, GPIOA7, MDIO2, TIMER8);
 
 FUNC_GROUP_DECL(TIMER8, D5);
 FUNC_GROUP_DECL(MDIO2, A3, D5);
@@ -131,7 +131,7 @@ SSSF_PIN_DECL(F18, GPIOB3, SALT4, SIG_DESC_SET(SCU80, 11));
 SIG_EXPR_DECL(LPCRST, LPCRST, SIG_DESC_SET(SCU80, 12));
 SIG_EXPR_DECL(LPCRST, LPCRSTS, SIG_DESC_SET(HW_STRAP1, 14));
 SIG_EXPR_LIST_DECL_DUAL(LPCRST, LPCRST, LPCRSTS);
-SS_PIN_DECL(E19, GPIOB4, LPCRST);
+PIN_DECL_1(E19, GPIOB4, LPCRST);
 
 FUNC_GROUP_DECL(LPCRST, E19);
 
@@ -139,7 +139,7 @@ FUNC_GROUP_DECL(LPCRST, E19);
 #define H19_DESCSIG_DESC_SET(SCU80, 13)
 SIG_EXPR_LIST_DECL_SINGLE(LPCPD, LPCPD, H19_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(LPCSMI, LPCSMI, H19_DESC);
-MS_PIN_DECL(H19, GPIOB5, LPCPD, LPCSMI);
+PIN_DECL_2(H19, GPIOB5, LPCPD, LPCSMI);
 
 FUNC_GROUP_DECL(LPCPD, H19);
 FUNC_GROUP_DECL(LPCSMI, H19);
@@ -155,7 +155,7 @@ SIG_EXPR_LIST_DECL_SINGLE(EXTRST, EXTRST,
 SIG_EXPR_LIST_DECL_SINGLE(SPICS1, SPICS1,
SIG_DESC_SET(SCU80, 15),
SIG_DESC_SET(SCU90, 31));
-MS_PIN_DECL(E18, GPIOB7, EXTRST, SPICS1);
+PIN_DECL_2(E18, GPIOB7, EXTRST, SPICS1);
 
 FUNC_GROUP_DECL(EXTRST, E18);
 FUNC_GROUP_DECL(SPICS1, E18);
@@ -166,12 +166,12 @@ FUNC_GROUP_DECL(SPICS1, E18);
 #define C4 16
 SIG_EXPR_LIST_DECL_SINGLE(SD1CLK, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SCL10, I2C10, I2C10_DESC);
-MS_PIN_DECL(C4, GPIOC0, SD1CLK, SCL10);
+PIN_DECL_2(C4, GPIOC0, SD1CLK, SCL10);
 
 #define B3 17
 SIG_EXPR_LIST_DECL_SINGLE(SD1CMD, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SDA10, I2C10, I2C10_DESC);
-MS_PIN_DECL(B3, GPIOC1, SD1CMD, SDA10);
+PIN_DECL_2(B3, GPIOC1, SD1CMD, SDA10);
 
 FUNC_GROUP_DECL(I2C10, C4, B3);
 
@@ -180,12 +180,12 @@ FUNC_GROUP_DECL(I2C10, C4, B3);
 #define A2 18
 SIG_EXPR_LIST_DECL_SINGLE(SD1DAT0, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SCL11, I2C11, I2C11_DESC);
-MS_PIN_DECL(A2, GPIOC2, SD1DAT0, SCL11);
+PIN_DECL_2(A2, GPIOC2, SD1DAT0, SCL11);
 
 #define E5 19
 SIG_EXPR_LIST_DECL_SINGLE(SD1DAT1, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SDA11, I2C11, I2C11_DESC);
-MS_PIN_DECL(E5, GPIOC3, SD1DAT1, SDA11);
+PIN_DECL_2(E5, GPIOC3, SD1DAT1, SDA11);
 
 FUNC_GROUP_DECL(I2C11, A2, E5);
 
@@ -194,12 +194,12 @@ FUNC_GROUP_DECL(I2C11, A2, E5);
 #define D4 20
 SIG_EXPR_LIST_DECL_SINGLE(SD1DAT2, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SCL12, I2C12, I2C12_DESC);
-MS_PIN_DECL(D4, GPIOC4, SD1DAT2, SCL12);
+PIN_DECL_2(D4, GPIOC4, SD1DAT2, SCL12);
 
 #define C3 21
 SIG_EXPR_LIST_DECL_SINGLE(SD1DAT3, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SDA12, I2C12, I2C12_DESC);
-MS_PIN_DECL(C3, GPIOC5, SD1DAT3, SDA12);
+PIN_DECL_2(C3, GPIOC5, SD1DAT3, SDA12);
 
 FUNC_GROUP_DECL(I2C12, D4, C3);
 
@@ -208,12 +208,12 @@ FUNC_GROUP_DECL(I2C12, D4, C3);
 #define B2 22
 SIG_EXPR_LIST_DECL_SINGLE(SD1CD, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SCL13, I2C13, I2C13_DESC);
-MS_PIN_DECL(B2, GPIOC6, SD1CD, SCL13);
+PIN_DECL_2(B2, GPIOC6, SD1CD, SCL13);
 
 #define A1 23
 SIG_EXPR_LIST_DECL_SINGLE(SD1WP, SD1, SD1_DESC);
 SIG_EXPR_LIST_DECL_SINGLE(SDA13, I2C13, I2C13_DESC);
-MS_PIN_DECL(A1, GPIOC7, SD1WP, SDA13);
+PIN_DECL_2(A1, GPIOC7, 

[PATCH 5/6] pinctrl: aspeed: Add SIG_DESC_CLEAR() helper

2019-07-10 Thread Andrew Jeffery
The complement of SIG_DESC_SET().

Signed-off-by: Andrew Jeffery 
---
 drivers/pinctrl/aspeed/pinmux-aspeed.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/aspeed/pinmux-aspeed.h 
b/drivers/pinctrl/aspeed/pinmux-aspeed.h
index 474820df6263..c59e936a7dde 100644
--- a/drivers/pinctrl/aspeed/pinmux-aspeed.h
+++ b/drivers/pinctrl/aspeed/pinmux-aspeed.h
@@ -508,6 +508,7 @@ struct aspeed_pin_desc {
  * @idx: The bit index in the register
  */
 #define SIG_DESC_SET(reg, idx) SIG_DESC_IP_BIT(ASPEED_IP_SCU, reg, idx, 1)
+#define SIG_DESC_CLEAR(reg, idx) SIG_DESC_IP_BIT(ASPEED_IP_SCU, reg, idx, 0)
 
 #define SIG_DESC_LIST_SYM(sig, group) sig_descs_ ## sig ## _ ## group
 #define SIG_DESC_LIST_DECL(sig, group, ...) \
-- 
2.20.1



[PATCH 1/6] dt-bindings: pinctrl: aspeed: Document AST2600 pinmux

2019-07-10 Thread Andrew Jeffery
The AST260 differs from the 2400 and 2500 in that it supports multiple
groups for a subset of functions.

Signed-off-by: Andrew Jeffery 
---
 .../pinctrl/aspeed,ast2600-pinctrl.yaml   | 128 ++
 1 file changed, 128 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/aspeed,ast2600-pinctrl.yaml

diff --git 
a/Documentation/devicetree/bindings/pinctrl/aspeed,ast2600-pinctrl.yaml 
b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2600-pinctrl.yaml
new file mode 100644
index ..dd31f8e62433
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2600-pinctrl.yaml
@@ -0,0 +1,128 @@
+# SPDX-License-Identifier: GPL-2.0+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/aspeed,ast2600-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED AST2600 Pin Controller
+
+maintainers:
+  - Andrew Jeffery 
+
+description: |+
+  The pin controller node should be the child of a syscon node with the
+  required property:
+
+  - compatible: Should be one of the following:
+"aspeed,ast2600-scu", "syscon", "simple-mfd"
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.txt
+
+properties:
+  compatible:
+const: aspeed,ast2600-pinctrl
+
+patternProperties:
+  '^.*$':
+if:
+  type: object
+then:
+  patternProperties:
+"^function$":
+  allOf:
+- $ref: "/schemas/types.yaml#/definitions/string"
+- enum: [ "ADC0", "ADC1", "ADC10", "ADC11", "ADC12", "ADC13",
+  "ADC14", "ADC15", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7",
+  "ADC8", "ADC9", "BMCINT", "ESPI", "ESPIALT", "FSI1", "FSI2",
+  "FWSPIABR", "FWSPID", "FWSPIWP", "GPIT0", "GPIT1", "GPIT2",
+  "GPIT3", "GPIT4", "GPIT5", "GPIT6", "GPIT7", "GPIU0", "GPIU1",
+  "GPIU2", "GPIU3", "GPIU4", "GPIU5", "GPIU6", "GPIU7", "I2C1",
+  "I2C10", "I2C11", "I2C12", "I2C13", "I2C14", "I2C15", "I2C16",
+  "I2C2", "I2C3", "I2C4", "I2C5", "I2C6", "I2C7", "I2C8", "I2C9",
+  "I3C3", "I3C4", "I3C5", "I3C6", "JTAGM", "LHPD", "LHSIRQ", "LPC",
+  "LPCHC", "LPCPD", "LPCPME", "LPCSMI", "LSIRQ", "MACLINK1",
+  "MACLINK2", "MACLINK3", "MACLINK4", "MDIO1", "MDIO2", "MDIO3",
+  "MDIO4", "NCTS1", "NCTS2", "NCTS3", "NCTS4", "NDCD1", "NDCD2",
+  "NDCD3", "NDCD4", "NDSR1", "NDSR2", "NDSR3", "NDSR4", "NDTR1",
+  "NDTR2", "NDTR3", "NDTR4", "NRI1", "NRI2", "NRI3", "NRI4",
+  "NRTS1", "NRTS2", "NRTS3", "NRTS4", "OSCCLK", "PEWAKE", "PWM0",
+  "PWM1", "PWM10", "PWM11", "PWM12", "PWM13", "PWM14", "PWM15",
+  "PWM2", "PWM3", "PWM4", "PWM5", "PWM6", "PWM7", "PWM8", "PWM9",
+  "RGMII1", "RGMII2", "RGMII3", "RGMII4", "RMII1", "RMII2",
+  "RMII3", "RMII4", "RXD1", "RXD2", "RXD3", "RXD4", "SALT1",
+  "SALT10", "SALT11", "SALT12", "SALT13", "SALT14", "SALT15",
+  "SALT16", "SALT2", "SALT3", "SALT4", "SALT5", "SALT6", "SALT7",
+  "SALT8", "SALT9", "SD1", "SD2", "SD3", "SD3DAT4", "SD3DAT5",
+  "SD3DAT6", "SD3DAT7", "SGPM1", "SGPS1", "SIOONCTRL", "SIOPBI",
+  "SIOPBO", "SIOPWREQ", "SIOPWRGD", "SIOS3", "SIOS5", "SIOSCI",
+  "SPI1", "SPI1ABR", "SPI1CS1", "SPI1WP", "SPI2", "SPI2CS1",
+  "SPI2CS2", "TACH0", "TACH1", "TACH10", "TACH11", "TACH12",
+  "TACH13", "TACH14", "TACH15", "TACH2", "TACH3", "TACH4", "TACH5",
+  "TACH6", "TACH7", "TACH8", "TACH9", "THRU0", "THRU1", "THRU2",
+  "THRU3", "TXD1", "TXD2", "TXD3", "TXD4", "UART10", "UART11",
+  "UART12", "UART13", "UART6", "UART7", "UART8", "UART9", "VB",
+  "VGAHS", "VGAVS", "WDTRST1", "WDTRST2", "WDTRST3", "WDTRST4", ]
+"^groups$":
+  allOf:
+- $ref: "/schemas/types.yaml#/definitions/string"
+- enum: [ "ADC0", "ADC1", "ADC10", "ADC11", "ADC12", "ADC13",
+  "ADC14", "ADC15", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7",
+  "ADC8", "ADC9", "BMCINT", "ESPI", "ESPIALT", "FSI1", "FSI2",
+  "FWSPIABR", "FWSPID", "FWQSPID", "FWSPIWP", "GPIT0", "GPIT1",
+  "GPIT2", "GPIT3", "GPIT4", "GPIT5", "GPIT6", "GPIT7", "GPIU0",
+  "GPIU1", "GPIU2", "GPIU3", "GPIU4", "GPIU5", "GPIU6", "GPIU7",
+  "HVI3C3", "HVI3C4", "I2C1", "I2C10", "I2C11", "I2C12", "I2C13",
+  "I2C14", "I2C15", "I2C16", "I2C2", "I2C3", "I2C4", "I2C5",
+  "I2C6", "I2C7", "I2C8", "I2C9", "I3C3", "I3C4", "I3C5", "I3C6",
+  "JTAGM", "LHPD", "LHSIRQ", "LPC", "LPCHC", "LPCPD", "LPCPME",
+  "LPCSMI", "LSIRQ", "MACLINK1", "MACLINK2", "MACLINK3",
+  "MACLINK4", "MDIO1", "MDIO2", "MDIO3", "MDIO4", "NCTS1", "NCTS2",
+  "NCTS3", "NCTS4", "NDCD1", "NDCD2", "NDCD3", "NDCD4", 

[PATCH 6/6] pinctrl: aspeed: Add AST2600 pinmux support

2019-07-10 Thread Andrew Jeffery
The AST2600 pinmux is fairly similar to the previous generations of
ASPEED BMC SoCs in terms of architecture, though differ in some of the
design details. The complexity of the pin expressions is largely reduced
(e.g. there are no-longer signals with multiple expressions muxing them
to the associated pin), and there are now signals and buses with
multiple pin groups.

The driver implements pinmux support for all 244 GPIO-capable pins plus
a further four pins that are not GPIO capable but which expose multiple
signals. pinconf will be implemented in a follow-up patch.

The implementation has been smoke-tested under qemu, and run on hardware
by ASPEED.

Debugged-by: Johnny Huang 
Signed-off-by: Andrew Jeffery 
---
 drivers/pinctrl/aspeed/Kconfig |8 +
 drivers/pinctrl/aspeed/Makefile|1 +
 drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c | 2395 
 3 files changed, 2404 insertions(+)
 create mode 100644 drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c

diff --git a/drivers/pinctrl/aspeed/Kconfig b/drivers/pinctrl/aspeed/Kconfig
index 998eabef3a65..ceb415583dc0 100644
--- a/drivers/pinctrl/aspeed/Kconfig
+++ b/drivers/pinctrl/aspeed/Kconfig
@@ -22,3 +22,11 @@ config PINCTRL_ASPEED_G5
help
  Say Y here to enable pin controller support for Aspeed's 5th
  generation SoCs. GPIO is provided by a separate GPIO driver.
+
+config PINCTRL_ASPEED_G6
+   bool "Aspeed G6 SoC pin control"
+   depends on (MACH_ASPEED_G6 || COMPILE_TEST) && OF
+   select PINCTRL_ASPEED
+   help
+ Say Y here to enable pin controller support for Aspeed's 6th
+ generation SoCs. GPIO is provided by a separate GPIO driver.
diff --git a/drivers/pinctrl/aspeed/Makefile b/drivers/pinctrl/aspeed/Makefile
index 3a94e4db0c8e..3888ba601b7b 100644
--- a/drivers/pinctrl/aspeed/Makefile
+++ b/drivers/pinctrl/aspeed/Makefile
@@ -4,3 +4,4 @@ ccflags-y += $(call cc-option,-Woverride-init)
 obj-$(CONFIG_PINCTRL_ASPEED)   += pinctrl-aspeed.o pinmux-aspeed.o
 obj-$(CONFIG_PINCTRL_ASPEED_G4)+= pinctrl-aspeed-g4.o
 obj-$(CONFIG_PINCTRL_ASPEED_G5)+= pinctrl-aspeed-g5.o
+obj-$(CONFIG_PINCTRL_ASPEED_G6)+= pinctrl-aspeed-g6.o
diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c 
b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
new file mode 100644
index ..6012d7d4a22a
--- /dev/null
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
@@ -0,0 +1,2395 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (C) 2019 IBM Corp. */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../core.h"
+#include "../pinctrl-utils.h"
+#include "pinctrl-aspeed.h"
+
+#define SCU400 0x400 /* Multi-function Pin Control #1  */
+#define SCU404 0x404 /* Multi-function Pin Control #2  */
+#define SCU410 0x410 /* Multi-function Pin Control #4  */
+#define SCU414 0x414 /* Multi-function Pin Control #5  */
+#define SCU418 0x418 /* Multi-function Pin Control #6  */
+#define SCU41C 0x41C /* Multi-function Pin Control #7  */
+#define SCU430 0x430 /* Multi-function Pin Control #8  */
+#define SCU434 0x434 /* Multi-function Pin Control #9  */
+#define SCU438 0x438 /* Multi-function Pin Control #10 */
+#define SCU450 0x450 /* Multi-function Pin Control #14 */
+#define SCU4B0 0x4B0 /* Multi-function Pin Control #17 */
+#define SCU4B4 0x4B4 /* Multi-function Pin Control #18 */
+#define SCU4B8 0x4B8 /* Multi-function Pin Control #19 */
+#define SCU4BC 0x4BC /* Multi-function Pin Control #20 */
+#define SCU4D4 0x4D4 /* Multi-function Pin Control #22 */
+#define SCU4D8 0x4D8 /* Multi-function Pin Control #23 */
+#define SCU500 0x500 /* Hardware Strap 1 */
+#define SCU510 0x510 /* Hardware Strap 2 */
+#define SCU694 0x694 /* Multi-function Pin Control #25 */
+
+#define ASPEED_G6_NR_PINS 248
+
+#define M24 0
+SIG_EXPR_LIST_DECL_SESG(M24, MDC3, MDIO3, SIG_DESC_SET(SCU410, 0));
+SIG_EXPR_LIST_DECL_SESG(M24, SCL11, I2C11, SIG_DESC_SET(SCU4B0, 0));
+PIN_DECL_2(M24, GPIOA0, MDC3, SCL11);
+
+#define M25 1
+SIG_EXPR_LIST_DECL_SESG(M25, MDIO3, MDIO3, SIG_DESC_SET(SCU410, 1));
+SIG_EXPR_LIST_DECL_SESG(M25, SDA11, I2C11, SIG_DESC_SET(SCU4B0, 1));
+PIN_DECL_2(M25, GPIOA1, MDIO3, SDA11);
+
+FUNC_GROUP_DECL(MDIO3, M24, M25);
+FUNC_GROUP_DECL(I2C11, M24, M25);
+
+#define L26 2
+SIG_EXPR_LIST_DECL_SESG(L26, MDC4, MDIO4, SIG_DESC_SET(SCU410, 2));
+SIG_EXPR_LIST_DECL_SESG(L26, SCL12, I2C12, SIG_DESC_SET(SCU4B0, 2));
+PIN_DECL_2(L26, GPIOA2, MDC4, SCL12);
+
+#define K24 3
+SIG_EXPR_LIST_DECL_SESG(K24, MDIO4, MDIO4, SIG_DESC_SET(SCU410, 3));
+SIG_EXPR_LIST_DECL_SESG(K24, SDA12, I2C12, SIG_DESC_SET(SCU4B0, 3));
+PIN_DECL_2(K24, GPIOA3, MDIO4, SDA12);
+
+FUNC_GROUP_DECL(MDIO4, L26, K24);
+FUNC_GROUP_DECL(I2C12, L26, K24);
+
+#define K26 4

[PATCH 3/6] pinctrl: aspeed: Add PIN_DECL_3() helper

2019-07-10 Thread Andrew Jeffery
This case is common in the AST2600, so add to the collection.

Signed-off-by: Andrew Jeffery 
---
 drivers/pinctrl/aspeed/pinmux-aspeed.h | 72 ++
 1 file changed, 40 insertions(+), 32 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinmux-aspeed.h 
b/drivers/pinctrl/aspeed/pinmux-aspeed.h
index 0406beedd5ba..964dd5b242ac 100644
--- a/drivers/pinctrl/aspeed/pinmux-aspeed.h
+++ b/drivers/pinctrl/aspeed/pinmux-aspeed.h
@@ -604,38 +604,6 @@ struct aspeed_pin_desc {
static const struct aspeed_pin_desc PIN_SYM(pin) = \
{ #pin, PIN_EXPRS_PTR(pin) }
 
-/**
- * Declare a two-signal pin
- *
- * @pin: The pin number
- * @other: Macro name for "other" functionality (subjected to stringification)
- * @high: Macro name for the highest priority signal functions
- * @low: Macro name for the low signal functions
- *
- * For example:
- *
- * #define A8 56
- * SIG_EXPR_DECL(ROMD8, ROM16, SIG_DESC_SET(SCU90, 6));
- * SIG_EXPR_DECL(ROMD8, ROM16S, SIG_DESC_SET(HW_STRAP1, 4),
- *  { HW_STRAP1, GENMASK(1, 0), 0, 0 });
- * SIG_EXPR_LIST_DECL(ROMD8, SIG_EXPR_PTR(ROMD8, ROM16),
- *  SIG_EXPR_PTR(ROMD8, ROM16S));
- * SIG_EXPR_LIST_DECL_SINGLE(NCTS6, NCTS6, SIG_DESC_SET(SCU90, 7));
- * PIN_DECL_2(A8, GPIOH0, ROMD8, NCTS6);
- */
-#define PIN_DECL_2(pin, other, high, low) \
-   SIG_EXPR_LIST_DECL_SINGLE(other, other); \
-   PIN_DECL_(pin, \
-   SIG_EXPR_LIST_PTR(high), \
-   SIG_EXPR_LIST_PTR(low), \
-   SIG_EXPR_LIST_PTR(other))
-
-#define PIN_GROUP_SYM(func) pins_ ## func
-#define FUNC_GROUP_SYM(func) groups_ ## func
-#define FUNC_GROUP_DECL(func, ...) \
-   static const int PIN_GROUP_SYM(func)[] = { __VA_ARGS__ }; \
-   static const char *FUNC_GROUP_SYM(func)[] = { #func }
-
 /**
  * Declare a single signal pin
  *
@@ -670,6 +638,46 @@ struct aspeed_pin_desc {
SIG_EXPR_LIST_DECL_SINGLE(other, other); \
PIN_DECL_(pin, SIG_EXPR_LIST_PTR(sig), SIG_EXPR_LIST_PTR(other)); \
FUNC_GROUP_DECL(sig, pin)
+/**
+ * Declare a two-signal pin
+ *
+ * @pin: The pin number
+ * @other: Macro name for "other" functionality (subjected to stringification)
+ * @high: Macro name for the highest priority signal functions
+ * @low: Macro name for the low signal functions
+ *
+ * For example:
+ *
+ * #define A8 56
+ * SIG_EXPR_DECL(ROMD8, ROM16, SIG_DESC_SET(SCU90, 6));
+ * SIG_EXPR_DECL(ROMD8, ROM16S, SIG_DESC_SET(HW_STRAP1, 4),
+ *  { HW_STRAP1, GENMASK(1, 0), 0, 0 });
+ * SIG_EXPR_LIST_DECL(ROMD8, SIG_EXPR_PTR(ROMD8, ROM16),
+ *  SIG_EXPR_PTR(ROMD8, ROM16S));
+ * SIG_EXPR_LIST_DECL_SINGLE(NCTS6, NCTS6, SIG_DESC_SET(SCU90, 7));
+ * PIN_DECL_2(A8, GPIOH0, ROMD8, NCTS6);
+ */
+#define PIN_DECL_2(pin, other, high, low) \
+   SIG_EXPR_LIST_DECL_SINGLE(other, other); \
+   PIN_DECL_(pin, \
+   SIG_EXPR_LIST_PTR(high), \
+   SIG_EXPR_LIST_PTR(low), \
+   SIG_EXPR_LIST_PTR(other))
+
+#define PIN_DECL_3(pin, other, high, medium, low) \
+   SIG_EXPR_LIST_DECL_SINGLE(other, other); \
+   PIN_DECL_(pin, \
+   SIG_EXPR_LIST_PTR(high), \
+   SIG_EXPR_LIST_PTR(medium), \
+   SIG_EXPR_LIST_PTR(low), \
+   SIG_EXPR_LIST_PTR(other))
+
+#define PIN_GROUP_SYM(func) pins_ ## func
+#define FUNC_GROUP_SYM(func) groups_ ## func
+#define FUNC_GROUP_DECL(func, ...) \
+   static const int PIN_GROUP_SYM(func)[] = { __VA_ARGS__ }; \
+   static const char *FUNC_GROUP_SYM(func)[] = { #func }
+
 
 #define GPIO_PIN_DECL(pin, gpio) \
SIG_EXPR_LIST_DECL_SINGLE(gpio, gpio); \
-- 
2.20.1



[PATCH 0/6] pinctrl: aspeed: Add AST2600 pinmux support

2019-07-10 Thread Andrew Jeffery
Hello!

This series adds pinmux support for the AST2600. Some more rework was required
on top of the previous cleanup series, but this rework was focussed on
supporting features of the AST2600 pinmux rather than fixing issues with the
existing infrastructure for the ASPEED drivers. Due to the dependences it's
based on top of pinctrl/devel, so should avoid any more SPDX issues.

ASPEED have been testing the patches on hardware, so even for an initial pass
there's some confidence in the implementation.

Please review!

Andrew

Andrew Jeffery (6):
  dt-bindings: pinctrl: aspeed: Document AST2600 pinmux
  pinctrl: aspeed: Rename pin declaration macros
  pinctrl: aspeed: Add PIN_DECL_3() helper
  pinctrl: aspeed: Add multiple pin group support for functions
  pinctrl: aspeed: Add SIG_DESC_CLEAR() helper
  pinctrl: aspeed: Add AST2600 pinmux support

 .../pinctrl/aspeed,ast2600-pinctrl.yaml   |  128 +
 drivers/pinctrl/aspeed/Kconfig|8 +
 drivers/pinctrl/aspeed/Makefile   |1 +
 drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c| 1821 +++--
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c| 1865 +++--
 drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c| 2395 +
 drivers/pinctrl/aspeed/pinmux-aspeed.h|  227 +-
 7 files changed, 4643 insertions(+), 1802 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/aspeed,ast2600-pinctrl.yaml
 create mode 100644 drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c

-- 
2.20.1



Re: [PATCH RFC 2/4] arm64: mm: Add RAS extension system register check to SEA handling

2019-07-10 Thread Tyler Baicar OS
Hi James, Mark,

On Tue, Jul 9, 2019 at 8:52 PM Tyler Baicar OS  
wrote:
> On Mon, Jul 8, 2019 at 10:10 AM James Morse  wrote:
> > On 02/07/2019 17:51, Tyler Baicar OS wrote:
> > > @@ -632,6 +633,8 @@ static int do_sea(unsigned long addr, unsigned int 
> > > esr, struct pt_regs *regs)
> > >
> > >   inf = esr_to_fault_info(esr);
> > >
> > > + arch_arm_ras_report_error();
> > > +
> > >   /*
> > >* Return value ignored as we rely on signal merging.
> > >* Future patches will make this more robust.
> > >
> >
> > If we interrupted a preemptible context, do_sea() is preemptible too... 
> > This means we
> > can't know if we're still running on the same CPU as the one that took the 
> > external-abort.
> > (until this series, it hasn't mattered).
> >
> > Fixing this means cramming something into entry.S's el1_da, as this may 
> > unmask interrupts
> > before calling do_mem_abort(). But its going to be ugly because some of 
> > do_mem_abort()s
> > ESR values need to be preemptible because they sleep, e.g. page-faults 
> > calling
> > handle_mm_fault().
> > For do_sea(), do_exit() will 'fix' the preempt count if we kill the thread, 
> > but if we
> > don't, it still needs to be balanced. Doing all this in assembly is going 
> > to be unreadable!
> >
> > Mark Rutland has a series to move the entry assembly into C [0]. Based on 
> > that that it
> > should be possible for the new el1_abort() to spot a 
> > Synchronous-External-Abort ESR, and
> > wrap the do_mem_abort() with preempt enable/disable, before inheriting the 
> > flags. (which
> > for synchronous exceptions, I think we should always do)
> >
> > [0] 
> > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=arm64/entry-deasm
>
> Hey James,
>
> Good catch! I didn't think the synchronous route was preemptible.
>
> I wasn't seeing this issue when testing this on emulation, but I was able to
> test and prove the issue on a Neoverse N1 SDP:
>
> root@genericarmv8:~# echo 0x1 > /proc/cached_read
> [   42.985622] Reading from address 0x1
> [   42.989893] WARNING: CPU: 0 PID: 2812 at 
> /home/tyler/neoverse/arm-reference-
> platforms/linux/arch/arm64/kernel/cpufeature.c:1940 this_cpu_has_cap+0x68/0x78
> [..]
> [   43.119083] Call trace:
> [   43.121515]  this_cpu_has_cap+0x68/0x78
> [   43.125338]  do_sea+0x34/0x70
> [   43.128292]  do_mem_abort+0x3c/0x98
> [   43.131765]  el1_da+0x20/0x94
> [   43.134722]  cached_read+0x30/0x68
> [   43.138112]  simple_attr_write+0xbc/0x128
> [   43.142109]  proc_reg_write+0x60/0xa8
> [   43.145757]  __vfs_write+0x18/0x40
> [   43.149145]  vfs_write+0xa4/0x1b8
> [   43.152445]  ksys_write+0x64/0xe0
> [   43.155746]  __arm64_sys_write+0x14/0x20
> [   43.159654]  el0_svc_common.constprop.0+0xa8/0x100
> [   43.164430]  el0_svc_handler+0x28/0x78
> [   43.168165]  el0_svc+0x8/0xc
> [   43.171031] ---[ end trace 2c27619659261a1d ]---
> [   43.175647] Internal error: synchronous external abort: 96000410 [#1]
> PREEMPT SMP
> [..]
>
> That warning is because it's preemptible:
>
> if (!WARN_ON(preemptible()) && n < ARM64_NCAPS) {
>
> I'll pull Mark's series in and add the preempt enable/disable around the call
> to do_mem_abort() in el1_abort() and test that out!

I was able to pull in the series mentioned [0] and add a patch to wrap
do_mem_abort with preempt disable/enable and the warning has gone away.

diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index 43aa78331e72..26cdf7db511a 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -118,7 +118,25 @@ static void el1_abort(struct pt_regs *regs, unsigned long 
esr)
unsigned long far = read_sysreg(far_el1);
local_daif_inherit(regs);
far = untagged_addr(far);
-   do_mem_abort(far, esr, regs);
+
+   switch (esr & ESR_ELx_FSC) {
+   case ESR_ELx_FSC_EXTABT:// Synchronous External Abort
+   case 0x14:  // SEA level 0 translation table walk
+   case 0x15:  // SEA level 1 translation table walk
+   case 0x16:  // SEA level 2 translation table walk
+   case 0x17:  // SEA level 3 translation table walk
+   case 0x18:  // Synchronous ECC error
+   case 0x1c:  // SECC level 0 translation table walk
+   case 0x1d:  // SECC level 1 translation table walk
+   case 0x1e:  // SECC level 2 translation table walk
+   case 0x1f:  // SECC level 3 translation table walk
+   preempt_disable();
+   do_mem_abort(far, esr, regs);
+   preempt_enable();
+   break;
+   default:
+   do_mem_abort(far, esr, regs);
+   };
 }
 
 /* Stack or PC alignment exception handling */
-- 


Is that what you had in mind James?

Has this series [0] been accepted and is just waiting to 

Re: [PATCH] kbuild: Inform user to pass ARCH= for make mrproper

2019-07-10 Thread Masahiro Yamada
On Wed, Jul 10, 2019 at 1:30 AM Christoph Hellwig  wrote:
>
> Is there any chance we could save ARCH in .config?  That would make
> cross compile builds so much easier..  Same for CROSS_COMPILE.


Then, I have no idea how "make clean", "make help", etc. should work.

If a user has configured the kernel, do they work for CONFIG_ARCH
stored in the .config file or still for the host-arch?

If not yet, do they fall-back to host-arch?



-- 
Best Regards
Masahiro Yamada


Re: [PATCH V34 10/29] hibernate: Disable when the kernel is locked down

2019-07-10 Thread joeyli
Hi experts,

On Mon, Jun 24, 2019 at 03:21:23PM +0200, Jiri Kosina wrote:
> On Sat, 22 Jun 2019, Pavel Machek wrote:
> 
> > > There is currently no way to verify the resume image when returning
> > > from hibernate.  This might compromise the signed modules trust model,
> > > so until we can work with signed hibernate images we disable it when the
> > > kernel is locked down.
> > 
> > I keep getting these...
> > 
> > IIRC suse has patches to verify the images.
> 
> Yeah, Joey Lee is taking care of those. CCing.
>

The last time that I sent for hibernation encryption and authentication is
here:
https://lkml.org/lkml/2019/1/3/281

It needs some big changes after review:
 - Simplify the design: remove keyring dependency and trampoline.
 - Encrypted whole snapshot image instead of only data pages.
 - Using TPM:
- Direct use TPM API in hibernation instead of keyring
- Localities (suggested by James Bottomley)

I am still finding enough time to implement those changes, especial TPM
parts.

Thanks
Joey Lee


Re: [PATCH] x86/stacktrace: Fix infinite loop in arch_stack_walk_user()

2019-07-10 Thread Linus Torvalds
On Wed, Jul 10, 2019 at 7:35 PM Eiichi Tsukata  wrote:
>
> Once we find a lack of return address, there is no need to continue
> loop, so let's break out.

Looks good to me, feel free to add

  Acked-by: Linus Torvalds 

and I'll assume this comes through the x86 -tip tree..

 Linus


Re: [GIT PULL] dlm updates for 5.3

2019-07-10 Thread Linus Torvalds
On Tue, Jul 9, 2019 at 9:57 AM David Teigland  wrote:
>
> Apart from a couple trivial fixes, the more notable fix makes the dlm
> continuing waiting for a user space result if a signal interrupts the
> wait event.

What? No.

That's not sensible at all.

If wait_event_interruptible() returns -ERESTARTSYS, it means that we
have a signal pending.

And if we have a signal pending, then you can't go back and call
wait_event_interruptible() in a loop, because the signal will
*continue* to be pending, so now your "wait event" becomes a kernel
busy loop.

If you don't want to react to signals, then you shouldn't use the
"interruptible()" version of wait-event.

I'm not pulling this. Because the code looks completely and utterly wrong to me.

Am I missing something? Feel free to educate me and re-submit.

   Linus


Re: [PATCH v3 1/2] rtw88: pci: Rearrange the memory usage for skb in RX ISR

2019-07-10 Thread Jian-Hong Pan
David Laight  於 2019年7月10日 週三 下午4:57寫道:
>
> From: Jian-Hong Pan
> > Sent: 10 July 2019 09:38
> >
> > Testing with RTL8822BE hardware, when available memory is low, we
> > frequently see a kernel panic and system freeze.
> >
> > First, rtw_pci_rx_isr encounters a memory allocation failure (trimmed):
> >
> > rx routine starvation
> > WARNING: CPU: 7 PID: 9871 at drivers/net/wireless/realtek/rtw88/pci.c:822
> > rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]
> > [ 2356.580313] RIP: 0010:rtw_pci_rx_isr.constprop.25+0x35a/0x370 [rtwpci]
> >
> > Then we see a variety of different error conditions and kernel panics,
> > such as this one (trimmed):
> >
> > rtw_pci :02:00.0: pci bus timeout, check dma status
> > skbuff: skb_over_panic: text:091b6e66 len:415 put:415 
> > head:d2880c6f
> > data:7a02b1ea tail:0x1df end:0xc0 dev:
> > [ cut here ]
> > kernel BUG at net/core/skbuff.c:105!
> > invalid opcode:  [#1] SMP NOPTI
> > RIP: 0010:skb_panic+0x43/0x45
> >
> > When skb allocation fails and the "rx routine starvation" is hit, the
> > function returns immediately without updating the RX ring. At this
> > point, the RX ring may continue referencing an old skb which was already
> > handed off to ieee80211_rx_irqsafe(). When it comes to be used again,
> > bad things happen.
> >
> > This patch allocates a new, data-sized skb first in RX ISR. After
> > copying the data in, we pass it to the upper layers. However, if skb
> > allocation fails, we effectively drop the frame. In both cases, the
> > original, full size ring skb is reused.
> >
> > In addition, by fixing the kernel crash, the RX routine should now
> > generally behave better under low memory conditions.
>
> A couple of minor nits (see below).
> You may want to do a followup patch that changes the rx buffers
> (used by the hardware) to by just memory buffers.
> Nothing (probably) relies on them being skb with all the accociated
> baggage.

It is a good idea for later commit.

> David
>
> >
> > Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=204053
> > Signed-off-by: Jian-Hong Pan 
> > Cc: 
> > ---
> > v2:
> >  - Allocate new data-sized skb and put data into it, then pass it to
> >mac80211. Reuse the original skb in RX ring by DMA sync.
> >  - Modify the commit message.
> >  - Introduce following [PATCH v3 2/2] rtw88: pci: Use DMA sync instead
> >of remapping in RX ISR.
> >
> > v3:
> >  - Same as v2.
> >
> >  drivers/net/wireless/realtek/rtw88/pci.c | 49 +++-
> >  1 file changed, 22 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c 
> > b/drivers/net/wireless/realtek/rtw88/pci.c
> > index cfe05ba7280d..e9fe3ad896c8 100644
> > --- a/drivers/net/wireless/realtek/rtw88/pci.c
> > +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> > @@ -763,6 +763,7 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, 
> > struct rtw_pci *rtwpci,
> >   u32 pkt_offset;
> >   u32 pkt_desc_sz = chip->rx_pkt_desc_sz;
> >   u32 buf_desc_sz = chip->rx_buf_desc_sz;
> > + u32 new_len;
> >   u8 *rx_desc;
> >   dma_addr_t dma;
> >
> > @@ -790,40 +791,34 @@ static void rtw_pci_rx_isr(struct rtw_dev *rtwdev, 
> > struct rtw_pci *rtwpci,
> >   pkt_offset = pkt_desc_sz + pkt_stat.drv_info_sz +
> >pkt_stat.shift;
> >
> > - if (pkt_stat.is_c2h) {
> > - /* keep rx_desc, halmac needs it */
> > - skb_put(skb, pkt_stat.pkt_len + pkt_offset);
> > + /* discard current skb if the new skb cannot be allocated as a
> > +  * new one in rx ring later
> > +  */
>
> That comment isn't quite right.
> maybe: "Allocate a new skb for this frame, discard if none available"

Thanks!  I will tweak it.

> > + new_len = pkt_stat.pkt_len + pkt_offset;
> > + new = dev_alloc_skb(new_len);
> > + if (WARN_ONCE(!new, "rx routine starvation\n"))
>
> I think you should count these??

Larry has a different idea here. [1]
I agree with Larry that just need to know not enough memory here.

[1] https://lkml.org/lkml/2019/7/8/1049

Jian-Hong Pan

> > + goto next_rp;
> > +
> > + /* put the DMA data including rx_desc from phy to new skb */
> > + skb_put_data(new, skb->data, new_len);
> >
> > - /* pass offset for further operation */
> > - *((u32 *)skb->cb) = pkt_offset;
> > - skb_queue_tail(>c2h_queue, skb);
> > + if (pkt_stat.is_c2h) {
> > +  /* pass rx_desc & offset for further operation */
> > + *((u32 *)new->cb) = pkt_offset;
> > + skb_queue_tail(>c2h_queue, new);
> >   ieee80211_queue_work(rtwdev->hw, >c2h_work);
> >   } else {
> > - /* remove rx_desc, maybe use skb_pull? */
> > -  

[PATCH] ipvs: remove unnecessary space

2019-07-10 Thread yangxingwu
this patch removes the extra space and use bitmap_zalloc instead

Signed-off-by: yangxingwu 
---
 net/netfilter/ipvs/ip_vs_mh.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_mh.c b/net/netfilter/ipvs/ip_vs_mh.c
index 94d9d34..3229867 100644
--- a/net/netfilter/ipvs/ip_vs_mh.c
+++ b/net/netfilter/ipvs/ip_vs_mh.c
@@ -174,8 +174,7 @@ static int ip_vs_mh_populate(struct ip_vs_mh_state *s,
return 0;
}
 
-   table =  kcalloc(BITS_TO_LONGS(IP_VS_MH_TAB_SIZE),
-sizeof(unsigned long), GFP_KERNEL);
+   table = bitmap_zalloc(IP_VS_MH_TAB_SIZE, GFP_KERNEL);
if (!table)
return -ENOMEM;
 
-- 
1.8.3.1



Re: [PATCH] dax: Fix missed PMD wakeups

2019-07-10 Thread Matthew Wilcox
On Wed, Jul 10, 2019 at 09:02:04PM +0200, Jan Kara wrote:
> So how about the attached patch? That keeps the interface sane and passes a
> smoketest for me (full fstest run running). Obviously it also needs a
> proper changelog...

Changelog and slightly massaged version along the lines of my two comments
attached.

>From 57b63fdd38e7bea7eb8d6332f0163fb028570def Mon Sep 17 00:00:00 2001
From: "Matthew Wilcox (Oracle)" 
Date: Wed, 3 Jul 2019 23:21:25 -0400
Subject: [PATCH] dax: Fix missed wakeup with PMD faults

RocksDB can hang indefinitely when using a DAX file.  This is due to
a bug in the XArray conversion when handling a PMD fault and finding a
PTE entry.  We use the wrong index in the hash and end up waiting on
the wrong waitqueue.

There's actually no need to wait; if we find a PTE entry while looking
for a PMD entry, we can return immediately as we know we should fall
back to a PTE fault (which may not conflict with the lock held).

Cc: sta...@vger.kernel.org
Fixes: b15cd800682f ("dax: Convert page fault handlers to XArray")
Signed-off-by: Matthew Wilcox (Oracle) 
---
 fs/dax.c   | 47 --
 include/linux/xarray.h |  4 ++--
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 2e48c7ebb973..1ce1059af266 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -195,11 +195,13 @@ static void dax_wake_entry(struct xa_state *xas, void 
*entry, bool wake_all)
  * Look up entry in page cache, wait for it to become unlocked if it
  * is a DAX entry and return it.  The caller must subsequently call
  * put_unlocked_entry() if it did not lock the entry or dax_unlock_entry()
- * if it did.
+ * if it did.  The entry returned may have a larger order than @order.
+ * If @order is larger than the order of the entry found in i_pages, this
+ * function returns a CONFLICT entry.
  *
  * Must be called with the i_pages lock held.
  */
-static void *get_unlocked_entry(struct xa_state *xas)
+static void *get_unlocked_entry(struct xa_state *xas, unsigned int order)
 {
void *entry;
struct wait_exceptional_entry_queue ewait;
@@ -210,6 +212,8 @@ static void *get_unlocked_entry(struct xa_state *xas)
 
for (;;) {
entry = xas_find_conflict(xas);
+   if (dax_entry_order(entry) < order)
+   return XA_DAX_CONFLICT_ENTRY;
if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) ||
!dax_is_locked(entry))
return entry;
@@ -254,7 +258,7 @@ static void wait_entry_unlocked(struct xa_state *xas, void 
*entry)
 static void put_unlocked_entry(struct xa_state *xas, void *entry)
 {
/* If we were the only waiter woken, wake the next one */
-   if (entry)
+   if (entry && entry != XA_DAX_CONFLICT_ENTRY)
dax_wake_entry(xas, entry, false);
 }
 
@@ -461,7 +465,7 @@ void dax_unlock_page(struct page *page, dax_entry_t cookie)
  * overlap with xarray value entries.
  */
 static void *grab_mapping_entry(struct xa_state *xas,
-   struct address_space *mapping, unsigned long size_flag)
+   struct address_space *mapping, unsigned int order)
 {
unsigned long index = xas->xa_index;
bool pmd_downgrade = false; /* splitting PMD entry into PTE entries? */
@@ -469,20 +473,17 @@ static void *grab_mapping_entry(struct xa_state *xas,
 
 retry:
xas_lock_irq(xas);
-   entry = get_unlocked_entry(xas);
+   entry = get_unlocked_entry(xas, order);
 
if (entry) {
+   if (entry == XA_DAX_CONFLICT_ENTRY)
+   goto fallback;
if (!xa_is_value(entry)) {
xas_set_err(xas, EIO);
goto out_unlock;
}
 
-   if (size_flag & DAX_PMD) {
-   if (dax_is_pte_entry(entry)) {
-   put_unlocked_entry(xas, entry);
-   goto fallback;
-   }
-   } else { /* trying to grab a PTE entry */
+   if (order == 0) {
if (dax_is_pmd_entry(entry) &&
(dax_is_zero_entry(entry) ||
 dax_is_empty_entry(entry))) {
@@ -523,7 +524,11 @@ static void *grab_mapping_entry(struct xa_state *xas,
if (entry) {
dax_lock_entry(xas, entry);
} else {
-   entry = dax_make_entry(pfn_to_pfn_t(0), size_flag | DAX_EMPTY);
+   unsigned long flags = DAX_EMPTY;
+
+   if (order > 0)
+   flags |= DAX_PMD;
+   entry = dax_make_entry(pfn_to_pfn_t(0), flags);
dax_lock_entry(xas, entry);
if (xas_error(xas))
goto out_unlock;
@@ -594,7 +599,7 @@ struct page *dax_layout_busy_page(struct address_space 
*mapping)
if (WARN_ON_ONCE(!xa_is_value(entry)))
  

[PATCH -next] mfd: rk808: Mark rk8xx_resume and rk8xx_suspend as __maybe_unused

2019-07-10 Thread YueHaibing
Fix build warning:

drivers/mfd/rk808.c:752:12: warning: 'rk8xx_resume' defined but not used 
[-Wunused-function]
drivers/mfd/rk808.c:732:12: warning: 'rk8xx_suspend' defined but not used 
[-Wunused-function]

The function is declared unconditionally but only called
while CONFIG_PM_SLEEP is set.

Reported-by: Hulk Robot 
Signed-off-by: YueHaibing 
---
 drivers/mfd/rk808.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 601cefb..9a9e631 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -729,7 +729,7 @@ static int rk808_remove(struct i2c_client *client)
return 0;
 }
 
-static int rk8xx_suspend(struct device *dev)
+static int __maybe_unused rk8xx_suspend(struct device *dev)
 {
struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
int ret = 0;
@@ -749,7 +749,7 @@ static int rk8xx_suspend(struct device *dev)
return ret;
 }
 
-static int rk8xx_resume(struct device *dev)
+static int __maybe_unused rk8xx_resume(struct device *dev)
 {
struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
int ret = 0;
-- 
2.7.4




Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Stephen Rothwell
Hi all,

On Thu, 11 Jul 2019 13:16:03 +1000 Stephen Rothwell  
wrote:
> 
> On Thu, 11 Jul 2019 13:13:44 +1000 Stephen Rothwell  
> wrote:
> >
> > On Thu, 11 Jul 2019 02:26:27 + Jason Gunthorpe  
> > wrote:  
> > >
> > > On Thu, Jul 11, 2019 at 11:50:54AM +1000, Stephen Rothwell wrote:
> > > 
> > > > So today this failed to build after I merged the rdma tree (previously
> > > > it didn;t until after the net-next tree was merged (I assume a
> > > > dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
> > > > in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
> > > > tree :-(  
> > > 
> > > ? I'm confused.. 
> > > 
> > > rdma.git builds fine stand alone (I hope!)
> > 
> > I have "Fixup to build SIW issue" from Leon (which switches to using
> > in_dev_for_each_ifa_rcu) included in the rmda tree merge commit because
> > without that the rdma tree would not build for me.  Are you saying that
> > I don't need that at all, now?  
> 
> Actually , I get it now, "Fixup to build SIW issue" is really just a
> fixup for the net-next and rdma trees merge ... OK, I will fix that up
> tomorrow.  Sorry for my confusion.

Actually, I have rewound my tree and am starting from the merge of the
rdma tree again, so hopefully it should all be good today.

-- 
Cheers,
Stephen Rothwell


pgpWW2KrxtW0_.pgp
Description: OpenPGP digital signature


Re: [PATCH v2 6/7] x86/entry/64: Remove TRACE_IRQS_*_DEBUG

2019-07-10 Thread Steven Rostedt
On Thu, 04 Jul 2019 21:56:01 +0200
Peter Zijlstra  wrote:

> Since INT3/#BP no longer runs on an IST, this workaround is no longer
> required.
> 
> Tested by running lockdep+ftrace as described in the initial commit:
> 
>   5963e317b1e9 ("ftrace/x86: Do not change stacks in DEBUG when calling 
> lockdep")

It looks like a clean revert, and it passed my ftrace smoke tests with
lockdep enabled (although I triggered a locked warning unrelated to
this, with the text_mutex and module_mutex, but I'm hoping my tree has
the fixes for that).

Reviewed-by: Steven Rostedt (VMware) 

Hmm, does this mean we can remove the IDT switching in the NMI handler
as well?

-- Steve


> 
> Signed-off-by: Peter Zijlstra (Intel) 
> ---
>  arch/x86/entry/entry_64.S |   46 
> ++
>  1 file changed, 2 insertions(+), 44 deletions(-)
> 
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -68,44 +68,6 @@ END(native_usergs_sysret64)
>  .endm
>  
>  /*
> - * When dynamic function tracer is enabled it will add a breakpoint
> - * to all locations that it is about to modify, sync CPUs, update
> - * all the code, sync CPUs, then remove the breakpoints. In this time
> - * if lockdep is enabled, it might jump back into the debug handler
> - * outside the updating of the IST protection. (TRACE_IRQS_ON/OFF).
> - *
> - * We need to change the IDT table before calling TRACE_IRQS_ON/OFF to
> - * make sure the stack pointer does not get reset back to the top
> - * of the debug stack, and instead just reuses the current stack.
> - */
> -#if defined(CONFIG_DYNAMIC_FTRACE) && defined(CONFIG_TRACE_IRQFLAGS)
> -
> -.macro TRACE_IRQS_OFF_DEBUG
> - calldebug_stack_set_zero
> - TRACE_IRQS_OFF
> - calldebug_stack_reset
> -.endm
> -
> -.macro TRACE_IRQS_ON_DEBUG
> - calldebug_stack_set_zero
> - TRACE_IRQS_ON
> - calldebug_stack_reset
> -.endm
> -
> -.macro TRACE_IRQS_IRETQ_DEBUG
> - btl $9, EFLAGS(%rsp)/* interrupts off? */
> - jnc 1f
> - TRACE_IRQS_ON_DEBUG
> -1:
> -.endm
> -
> -#else
> -# define TRACE_IRQS_OFF_DEBUGTRACE_IRQS_OFF
> -# define TRACE_IRQS_ON_DEBUG TRACE_IRQS_ON
> -# define TRACE_IRQS_IRETQ_DEBUG  TRACE_IRQS_IRETQ
> -#endif
> -
> -/*
>   * 64-bit SYSCALL instruction entry. Up to 6 arguments in registers.
>   *
>   * This is the only entry point used for 64-bit system calls.  The
> @@ -879,11 +841,7 @@ apicinterrupt IRQ_WORK_VECTORirq_work
>   GET_CR2_INTO(%rdx); /* can clobber %rax */
>   .endif
>  
> - .if \shift_ist != -1
> - TRACE_IRQS_OFF_DEBUG/* reload IDT in case of 
> recursion */
> - .else
>   TRACE_IRQS_OFF
> - .endif
>  
>   .if \paranoid == 0
>   testb   $3, CS(%rsp)
> @@ -1292,7 +1250,7 @@ END(paranoid_entry)
>  ENTRY(paranoid_exit)
>   UNWIND_HINT_REGS
>   DISABLE_INTERRUPTS(CLBR_ANY)
> - TRACE_IRQS_OFF_DEBUG
> + TRACE_IRQS_OFF
>  
>   /* Handle GS depending on FSGSBASE availability */
>   ALTERNATIVE "jmp .Lparanoid_exit_checkgs", "nop",X86_FEATURE_FSGSBASE
> @@ -1312,7 +1270,7 @@ ENTRY(paranoid_exit)
>   jmp .Lparanoid_exit_restore
>  
>  .Lparanoid_exit_no_swapgs:
> - TRACE_IRQS_IRETQ_DEBUG
> + TRACE_IRQS_IRETQ
>   /* Always restore stashed CR3 value (see paranoid_entry) */
>   RESTORE_CR3 scratch_reg=%rbx save_reg=%r14
>  
> 



Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Stephen Rothwell
Hi all,

On Thu, 11 Jul 2019 13:13:44 +1000 Stephen Rothwell  
wrote:
>
> On Thu, 11 Jul 2019 02:26:27 + Jason Gunthorpe  wrote:
> >
> > On Thu, Jul 11, 2019 at 11:50:54AM +1000, Stephen Rothwell wrote:
> >   
> > > So today this failed to build after I merged the rdma tree (previously
> > > it didn;t until after the net-next tree was merged (I assume a
> > > dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
> > > in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
> > > tree :-(
> > 
> > ? I'm confused.. 
> > 
> > rdma.git builds fine stand alone (I hope!)  
> 
> I have "Fixup to build SIW issue" from Leon (which switches to using
> in_dev_for_each_ifa_rcu) included in the rmda tree merge commit because
> without that the rdma tree would not build for me.  Are you saying that
> I don't need that at all, now?

Actually , I get it now, "Fixup to build SIW issue" is really just a
fixup for the net-next and rdma trees merge ... OK, I will fix that up
tomorrow.  Sorry for my confusion.

-- 
Cheers,
Stephen Rothwell


pgp8K9IVUrTBo.pgp
Description: OpenPGP digital signature


[PATCH v2 1/6] ARM: tegra: Remove cpuidle drivers

2019-07-10 Thread Dmitry Osipenko
Remove the old drivers to replace them cleanly with a new one later on.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/mach-tegra/Makefile   |  13 --
 arch/arm/mach-tegra/cpuidle-tegra114.c |  89 ---
 arch/arm/mach-tegra/cpuidle-tegra20.c  | 212 -
 arch/arm/mach-tegra/cpuidle-tegra30.c  | 132 ---
 arch/arm/mach-tegra/cpuidle.c  |  50 --
 arch/arm/mach-tegra/cpuidle.h  |  21 ---
 arch/arm/mach-tegra/irq.c  |  18 ---
 arch/arm/mach-tegra/irq.h  |  11 --
 arch/arm/mach-tegra/pm.c   |   7 -
 arch/arm/mach-tegra/pm.h   |   1 -
 arch/arm/mach-tegra/reset-handler.S|  11 --
 arch/arm/mach-tegra/reset.h|   9 +-
 arch/arm/mach-tegra/sleep-tegra20.S| 190 +-
 arch/arm/mach-tegra/sleep.h|  12 --
 arch/arm/mach-tegra/tegra.c|   3 -
 drivers/soc/tegra/Kconfig  |   1 -
 include/soc/tegra/cpuidle.h|   4 -
 17 files changed, 5 insertions(+), 779 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra114.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra20.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra30.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle.h
 delete mode 100644 arch/arm/mach-tegra/irq.h

diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 6c1dff2eccc2..5d93a0b36866 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -8,29 +8,16 @@ obj-y += reset.o
 obj-y  += reset-handler.o
 obj-y  += sleep.o
 obj-y  += tegra.o
-obj-$(CONFIG_CPU_IDLE) += cpuidle.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)+= sleep-tegra20.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)+= pm-tegra20.o
-ifeq ($(CONFIG_CPU_IDLE),y)
-obj-$(CONFIG_ARCH_TEGRA_2x_SOC)+= cpuidle-tegra20.o
-endif
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)+= sleep-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)+= pm-tegra30.o
-ifeq ($(CONFIG_CPU_IDLE),y)
-obj-$(CONFIG_ARCH_TEGRA_3x_SOC)+= cpuidle-tegra30.o
-endif
 obj-$(CONFIG_SMP)  += platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)   += hotplug.o
 
 obj-$(CONFIG_ARCH_TEGRA_114_SOC)   += sleep-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_114_SOC)   += pm-tegra30.o
-ifeq ($(CONFIG_CPU_IDLE),y)
-obj-$(CONFIG_ARCH_TEGRA_114_SOC)   += cpuidle-tegra114.o
-endif
 obj-$(CONFIG_ARCH_TEGRA_124_SOC)   += sleep-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_124_SOC)   += pm-tegra30.o
-ifeq ($(CONFIG_CPU_IDLE),y)
-obj-$(CONFIG_ARCH_TEGRA_124_SOC)   += cpuidle-tegra114.o
-endif
 
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)+= board-paz00.o
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c 
b/arch/arm/mach-tegra/cpuidle-tegra114.c
deleted file mode 100644
index 5118f777fd66..
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ /dev/null
@@ -1,89 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include "cpuidle.h"
-#include "pm.h"
-#include "sleep.h"
-
-#ifdef CONFIG_PM_SLEEP
-#define TEGRA114_MAX_STATES 2
-#else
-#define TEGRA114_MAX_STATES 1
-#endif
-
-#ifdef CONFIG_PM_SLEEP
-static int tegra114_idle_power_down(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
-{
-   local_fiq_disable();
-
-   tegra_set_cpu_in_lp2();
-   cpu_pm_enter();
-
-   call_firmware_op(prepare_idle, TF_PM_MODE_LP2_NOFLUSH_L2);
-
-   /* Do suspend by ourselves if the firmware does not implement it */
-   if (call_firmware_op(do_idle, 0) == -ENOSYS)
-   cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
-
-   cpu_pm_exit();
-   tegra_clear_cpu_in_lp2();
-
-   local_fiq_enable();
-
-   return index;
-}
-
-static void tegra114_idle_enter_s2idle(struct cpuidle_device *dev,
-  struct cpuidle_driver *drv,
-  int index)
-{
-   tegra114_idle_power_down(dev, drv, index);
-}
-#endif
-
-static struct cpuidle_driver tegra_idle_driver = {
-   .name = "tegra_idle",
-   .owner = THIS_MODULE,
-   .state_count = TEGRA114_MAX_STATES,
-   .states = {
-   [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
-#ifdef CONFIG_PM_SLEEP
-   [1] = {
-   .enter  = tegra114_idle_power_down,
-   .enter_s2idle   = tegra114_idle_enter_s2idle,
-   .exit_latency   = 500,
-   

[PATCH v2 4/6] cpuidle: tegra: Support CPU cluster power-down on Tegra30

2019-07-10 Thread Dmitry Osipenko
The new CPU Idle driver has all necessary features in order to allow
the deepest idling state on Tegra30 SoC where the whole CPU cluster is
power-gated using the coupled idle state.

Note that outer_disable() now need to be invoked directly since it
produces erroneous warning message about secondary CPUs being online
because it doesn't know that secondaries are turned off at that point
by the cpuidle driver.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/mach-tegra/pm.c| 4 ++--
 drivers/cpuidle/cpuidle-tegra.c | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c
index f9c9bce9e15d..cc941b0c97e8 100644
--- a/arch/arm/mach-tegra/pm.c
+++ b/arch/arm/mach-tegra/pm.c
@@ -146,8 +146,8 @@ static int tegra_sleep_cpu(unsigned long v2p)
 * if any of secondary CPU's is online and this is the LP2-idle
 * code-path only for Tegra20/30.
 */
-   if (trusted_foundations_registered())
-   outer_disable();
+   if (trusted_foundations_registered() && outer_cache.disable)
+   outer_cache.disable();
 
/*
 * Note that besides of setting up CPU reset vector this firmware
diff --git a/drivers/cpuidle/cpuidle-tegra.c b/drivers/cpuidle/cpuidle-tegra.c
index 54974cd2255f..1412c4b0f6ee 100644
--- a/drivers/cpuidle/cpuidle-tegra.c
+++ b/drivers/cpuidle/cpuidle-tegra.c
@@ -278,7 +278,6 @@ static int tegra_cpuidle_probe(struct platform_device *pdev)
tegra_idle_driver.states[TEGRA_C7].disabled = true;
break;
case TEGRA30:
-   tegra_idle_driver.states[TEGRA_CC6].disabled = true;
break;
case TEGRA114:
case TEGRA124:
-- 
2.22.0



[PATCH v2 6/6] ARM: tegra: Enable Tegra cpuidle driver in tegra_defconfig

2019-07-10 Thread Dmitry Osipenko
The Tegra CPU Idle driver was moved out into driver/cpuidle/ directory and
it is now a proper platform driver.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/configs/tegra_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index 8f5c6a5b444c..9a2f11a780a8 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -25,6 +25,7 @@ CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPUFREQ_DT=y
 CONFIG_CPU_IDLE=y
+CONFIG_ARM_TEGRA_CPUIDLE=y
 CONFIG_VFP=y
 CONFIG_NEON=y
 CONFIG_TRUSTED_FOUNDATIONS=y
-- 
2.22.0



Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Stephen Rothwell
Hi Jason,

On Thu, 11 Jul 2019 02:26:27 + Jason Gunthorpe  wrote:
>
> On Thu, Jul 11, 2019 at 11:50:54AM +1000, Stephen Rothwell wrote:
> 
> > So today this failed to build after I merged the rdma tree (previously
> > it didn;t until after the net-next tree was merged (I assume a
> > dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
> > in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
> > tree :-(  
> 
> ? I'm confused.. 
> 
> rdma.git builds fine stand alone (I hope!)

I have "Fixup to build SIW issue" from Leon (which switches to using
in_dev_for_each_ifa_rcu) included in the rmda tree merge commit because
without that the rdma tree would not build for me.  Are you saying that
I don't need that at all, now?

-- 
Cheers,
Stephen Rothwell


pgpV4K8k1bq2t.pgp
Description: OpenPGP digital signature


[PATCH v2 2/6] ARM: tegra: Expose functions required for cpuidle driver

2019-07-10 Thread Dmitry Osipenko
The upcoming unified CPUIDLE driver will be added to the drivers/cpuidle/
directory and it will require all these Tegra PM-core functions.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/mach-tegra/Makefile  |  2 +-
 arch/arm/mach-tegra/platsmp.c |  2 --
 arch/arm/mach-tegra/pm.c  | 16 +++-
 arch/arm/mach-tegra/pm.h  |  3 ---
 arch/arm/mach-tegra/sleep.h   |  1 -
 include/linux/clk/tegra.h | 13 +
 include/soc/tegra/pm.h| 28 
 7 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 5d93a0b36866..27bd5d9865e3 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC)   += pm-tegra20.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)+= sleep-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)+= pm-tegra30.o
 obj-$(CONFIG_SMP)  += platsmp.o
-obj-$(CONFIG_HOTPLUG_CPU)   += hotplug.o
+obj-y  += hotplug.o
 
 obj-$(CONFIG_ARCH_TEGRA_114_SOC)   += sleep-tegra30.o
 obj-$(CONFIG_ARCH_TEGRA_114_SOC)   += pm-tegra30.o
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index e6911a14c096..c8a63719a143 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -183,8 +183,6 @@ const struct smp_operations tegra_smp_ops __initconst = {
.smp_prepare_cpus   = tegra_smp_prepare_cpus,
.smp_secondary_init = tegra_secondary_init,
.smp_boot_secondary = tegra_boot_secondary,
-#ifdef CONFIG_HOTPLUG_CPU
.cpu_kill   = tegra_cpu_kill,
.cpu_die= tegra_cpu_die,
-#endif
 };
diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c
index 6aaacb5757e1..f9c9bce9e15d 100644
--- a/arch/arm/mach-tegra/pm.c
+++ b/arch/arm/mach-tegra/pm.c
@@ -123,11 +123,9 @@ void tegra_clear_cpu_in_lp2(void)
spin_unlock(_lp2_lock);
 }
 
-bool tegra_set_cpu_in_lp2(void)
+void tegra_set_cpu_in_lp2(void)
 {
int phy_cpu_id = cpu_logical_map(smp_processor_id());
-   bool last_cpu = false;
-   cpumask_t *cpu_lp2_mask = tegra_cpu_lp2_mask;
u32 *cpu_in_lp2 = tegra_cpu_lp2_mask;
 
spin_lock(_lp2_lock);
@@ -135,11 +133,7 @@ bool tegra_set_cpu_in_lp2(void)
BUG_ON((*cpu_in_lp2 & BIT(phy_cpu_id)));
*cpu_in_lp2 |= BIT(phy_cpu_id);
 
-   if ((phy_cpu_id == 0) && cpumask_equal(cpu_lp2_mask, cpu_online_mask))
-   last_cpu = true;
-
spin_unlock(_lp2_lock);
-   return last_cpu;
 }
 
 static int tegra_sleep_cpu(unsigned long v2p)
@@ -195,14 +189,16 @@ static void tegra_pm_set(enum tegra_suspend_mode mode)
tegra_pmc_enter_suspend_mode(mode);
 }
 
-void tegra_idle_lp2_last(void)
+int tegra_idle_lp2_last(void)
 {
+   int err;
+
tegra_pm_set(TEGRA_SUSPEND_LP2);
 
cpu_cluster_pm_enter();
suspend_cpu_complex();
 
-   cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, _sleep_cpu);
+   err = cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, _sleep_cpu);
 
/*
 * Resume L2 cache if it wasn't re-enabled early during resume,
@@ -214,6 +210,8 @@ void tegra_idle_lp2_last(void)
 
restore_cpu_complex();
cpu_cluster_pm_exit();
+
+   return err;
 }
 
 enum tegra_suspend_mode tegra_pm_validate_suspend_mode(
diff --git a/arch/arm/mach-tegra/pm.h b/arch/arm/mach-tegra/pm.h
index 1e51a9b636eb..81525f5f4a44 100644
--- a/arch/arm/mach-tegra/pm.h
+++ b/arch/arm/mach-tegra/pm.h
@@ -23,9 +23,6 @@ void tegra20_sleep_core_init(void);
 void tegra30_lp1_iram_hook(void);
 void tegra30_sleep_core_init(void);
 
-void tegra_clear_cpu_in_lp2(void);
-bool tegra_set_cpu_in_lp2(void);
-void tegra_idle_lp2_last(void);
 extern void (*tegra_tear_down_cpu)(void);
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/arch/arm/mach-tegra/sleep.h b/arch/arm/mach-tegra/sleep.h
index d219872b7546..0d9956e9a8ea 100644
--- a/arch/arm/mach-tegra/sleep.h
+++ b/arch/arm/mach-tegra/sleep.h
@@ -124,7 +124,6 @@ void tegra30_hotplug_shutdown(void);
 #endif
 
 void tegra20_tear_down_cpu(void);
-int tegra30_sleep_cpu_secondary_finish(unsigned long);
 void tegra30_tear_down_cpu(void);
 
 #endif
diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
index b8aef62cc3f5..cf0f2cb5e109 100644
--- a/include/linux/clk/tegra.h
+++ b/include/linux/clk/tegra.h
@@ -108,6 +108,19 @@ static inline void tegra_cpu_clock_resume(void)
 
tegra_cpu_car_ops->resume();
 }
+#else
+static inline bool tegra_cpu_rail_off_ready(void)
+{
+   return false;
+}
+
+static inline void tegra_cpu_clock_suspend(void)
+{
+}
+
+static inline void tegra_cpu_clock_resume(void)
+{
+}
 #endif
 
 extern void tegra210_xusb_pll_hw_control_enable(void);
diff --git a/include/soc/tegra/pm.h b/include/soc/tegra/pm.h
index 951fcd738d55..fa18c2df5028 100644
--- a/include/soc/tegra/pm.h
+++ 

[PATCH v2 3/6] cpuidle: Add unified driver for NVIDIA Tegra SoCs

2019-07-10 Thread Dmitry Osipenko
The new driver is based on the old CPU Idle drivers that are removed now
from arm/arch/mach-tegra/ directory. Those removed drivers were reworked
and squashed into a single unified driver that covers multiple hardware
generations, starting from Tegra20 and ending with Tegra124.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/mach-tegra/tegra.c |   4 +
 drivers/cpuidle/Kconfig.arm |   8 +
 drivers/cpuidle/Makefile|   1 +
 drivers/cpuidle/cpuidle-tegra.c | 304 
 include/soc/tegra/cpuidle.h |   4 +
 5 files changed, 321 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-tegra.c

diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index d9237769a37c..f1ce2857a251 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "board.h"
@@ -92,6 +93,9 @@ static void __init tegra_dt_init_late(void)
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
of_machine_is_compatible("nvidia,tegra20"))
platform_device_register_simple("tegra20-cpufreq", -1, NULL, 0);
+
+   if (IS_ENABLED(CONFIG_ARM_TEGRA_CPUIDLE) && !psci_smp_available())
+   platform_device_register_simple("tegra-cpuidle", -1, NULL, 0);
 }
 
 static const char * const tegra_dt_board_compat[] = {
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 48cb3d4bb7d1..d90861361f1d 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -76,3 +76,11 @@ config ARM_MVEBU_V7_CPUIDLE
depends on ARCH_MVEBU && !ARM64
help
  Select this to enable cpuidle on Armada 370, 38x and XP processors.
+
+config ARM_TEGRA_CPUIDLE
+   bool "CPU Idle Driver for NVIDIA Tegra SoCs"
+   depends on ARCH_TEGRA && !ARM64
+   select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
+   select ARM_CPU_SUSPEND
+   help
+ Select this to enable cpuidle for NVIDIA Tegra20/30/114/124 SoCs.
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 9d7176cee3d3..470d17fa8746 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
 obj-$(CONFIG_ARM_AT91_CPUIDLE)  += cpuidle-at91.o
 obj-$(CONFIG_ARM_EXYNOS_CPUIDLE)+= cpuidle-exynos.o
 obj-$(CONFIG_ARM_CPUIDLE)  += cpuidle-arm.o
+obj-$(CONFIG_ARM_TEGRA_CPUIDLE)+= cpuidle-tegra.o
 
 ###
 # MIPS drivers
diff --git a/drivers/cpuidle/cpuidle-tegra.c b/drivers/cpuidle/cpuidle-tegra.c
new file mode 100644
index ..54974cd2255f
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-tegra.c
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * CPU idle driver for Tegra CPUs
+ *
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
+ * Copyright (c) 2011 Google, Inc.
+ * Author: Colin Cross 
+ * Gary King 
+ *
+ * Rework for 3.3 by Peter De Schrijver 
+ *
+ * Tegra20/124 driver unification by Dmitry Osipenko 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define TEGRA_C1   0
+#define TEGRA_C7   1
+#define TEGRA_CC6  2
+
+static atomic_t tegra_idle_barrier;
+
+static inline bool tegra_cpuidle_using_firmware(void)
+{
+   return firmware_ops->prepare_idle && firmware_ops->do_idle;
+}
+
+static int tegra_shutdown_secondary_cpu(unsigned long cpu)
+{
+   tegra_cpu_die(cpu);
+
+   return -EINVAL;
+}
+
+static int tegra_await_secondary_cpus_shutdown(void)
+{
+   ktime_t timeout = ktime_add_ms(ktime_get(), 1);
+
+   /*
+* The boot CPU shall await for the secondaries shutdown in order
+* to power-off CPU's cluster safely.
+*/
+   do {
+   if (tegra_cpu_rail_off_ready())
+   return 0;
+
+   } while (ktime_compare(ktime_get(), timeout) < 0);
+
+   return -ETIMEDOUT;
+}
+
+static void tegra_wake_up_secondary_cpus(void)
+{
+   unsigned int cpu, lcpu;
+
+   for_each_cpu(lcpu, cpu_online_mask) {
+   cpu = cpu_logical_map(lcpu);
+
+   if (cpu > 0) {
+   tegra_enable_cpu_clock(cpu);
+   tegra_cpu_out_of_reset(cpu);
+   flowctrl_write_cpu_halt(cpu, 0);
+   }
+   }
+}
+
+static int tegra_cpuidle_cc6_enter(void)
+{
+   int err;
+
+   err = tegra_await_secondary_cpus_shutdown();
+   if (err)
+   return err;
+
+   err = tegra_idle_lp2_last();
+
+   tegra_wake_up_secondary_cpus();
+
+   return err;
+}
+
+static int tegra_cpuidle_c7_enter(void)
+{
+   int err;
+
+   if (tegra_cpuidle_using_firmware()) {
+   err = 

[PATCH v2 5/6] ARM: multi_v7_defconfig: Enable Tegra cpuidle driver

2019-07-10 Thread Dmitry Osipenko
The Tegra CPU Idle driver was moved out into driver/cpuidle/ directory and
it is now a proper platform driver.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 6a40bc2ef271..2c0fc7968c42 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -107,6 +107,7 @@ CONFIG_CPU_IDLE=y
 CONFIG_ARM_CPUIDLE=y
 CONFIG_ARM_ZYNQ_CPUIDLE=y
 CONFIG_ARM_EXYNOS_CPUIDLE=y
+CONFIG_ARM_TEGRA_CPUIDLE=y
 CONFIG_KERNEL_MODE_NEON=y
 CONFIG_RASPBERRYPI_FIRMWARE=y
 CONFIG_TRUSTED_FOUNDATIONS=y
-- 
2.22.0



[PATCH v2 0/6] Consolidate and improve NVIDIA Tegra CPUIDLE driver(s)

2019-07-10 Thread Dmitry Osipenko
Hello,

I was spending quite some time recently trying to hunt down CPU-suspend
bug on Tegra30 SoC and in the end it was nailed. During that time I
realized that the CPU Idle drivers could get some polish and gain new
features, thus that's what this series does:

  1. Unifies Tegra20/30/114 drivers into a single driver and moves it out
 into common drivers/cpuidle/ directory.

  2. Enables CPU cluster power-down idling state on Tegra30.

In the end there is a quite nice clean up of the Tegra CPUIDLE driver(s)
and of the Tegra's arch code in general. Please review, thanks!

Changelog:

v2: - Added patches to enable the new cpuidle driver in the defconfigs:

ARM: multi_v7_defconfig: Enable Tegra cpuidle driver
ARM: tegra: Enable Tegra cpuidle driver in tegra_defconfig

- Dropped patches that removed CPUIDLE_FLAG_TIMER_STOP from the idling
  states because that flag actually doesn't have any negative effects,
  but still is correct for the case of a local CPU timer on older Tegra
  SoCs:

cpuidle: tegra: Remove CPUIDLE_FLAG_TIMER_STOP from Tegra114/124 
idle-state
cpuidle: tegra: Remove CPUIDLE_FLAG_TIMER_STOP from all states

- The "Add unified driver for NVIDIA Tegra SoCs" patch got more polish.
  Tegra30 and Terga114 states are now squashed into a single common C7
  state (following Parker TRM terminology, see 17.2.2.2 Power Management
  States), more comments added, etc minor changes.

Dmitry Osipenko (6):
  ARM: tegra: Remove cpuidle drivers
  ARM: tegra: Expose functions required for cpuidle driver
  cpuidle: Add unified driver for NVIDIA Tegra SoCs
  cpuidle: tegra: Support CPU cluster power-down on Tegra30
  ARM: multi_v7_defconfig: Enable Tegra cpuidle driver
  ARM: tegra: Enable Tegra cpuidle driver in tegra_defconfig

 arch/arm/configs/multi_v7_defconfig|   1 +
 arch/arm/configs/tegra_defconfig   |   1 +
 arch/arm/mach-tegra/Makefile   |  15 +-
 arch/arm/mach-tegra/cpuidle-tegra114.c |  89 
 arch/arm/mach-tegra/cpuidle-tegra20.c  | 212 -
 arch/arm/mach-tegra/cpuidle-tegra30.c  | 132 ---
 arch/arm/mach-tegra/cpuidle.c  |  50 
 arch/arm/mach-tegra/cpuidle.h  |  21 --
 arch/arm/mach-tegra/irq.c  |  18 --
 arch/arm/mach-tegra/irq.h  |  11 -
 arch/arm/mach-tegra/platsmp.c  |   2 -
 arch/arm/mach-tegra/pm.c   |  27 +--
 arch/arm/mach-tegra/pm.h   |   4 -
 arch/arm/mach-tegra/reset-handler.S|  11 -
 arch/arm/mach-tegra/reset.h|   9 +-
 arch/arm/mach-tegra/sleep-tegra20.S| 190 +---
 arch/arm/mach-tegra/sleep.h|  13 --
 arch/arm/mach-tegra/tegra.c|   7 +-
 drivers/cpuidle/Kconfig.arm|   8 +
 drivers/cpuidle/Makefile   |   1 +
 drivers/cpuidle/cpuidle-tegra.c| 303 +
 drivers/soc/tegra/Kconfig  |   1 -
 include/linux/clk/tegra.h  |  13 ++
 include/soc/tegra/cpuidle.h|   2 +-
 include/soc/tegra/pm.h |  28 +++
 25 files changed, 375 insertions(+), 794 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra114.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra20.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle-tegra30.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle.c
 delete mode 100644 arch/arm/mach-tegra/cpuidle.h
 delete mode 100644 arch/arm/mach-tegra/irq.h
 create mode 100644 drivers/cpuidle/cpuidle-tegra.c

-- 
2.22.0



Re: [PATCH] ARM: fix O= building with CONFIG_FPE_FASTFPE

2019-07-10 Thread Masahiro Yamada
Arnd, Olof,

Please ignore this.

I wanted to put this patch into Russell's patch tracker,
but just sent it to a wrong ML.


Masahiro Yamada

On Thu, Jul 11, 2019 at 12:08 PM Masahiro Yamada
 wrote:
>
> To use Fastfpe, a user is supposed to enable CONFIG_FPE_FASTFPE
> and put downstream source files into arch/arm/fastfpe/.
>
> It is not working for O= build because $(wildcard arch/arm/fastfpe)
> checks if it exists in $(objtree), not in $(srctree).
>
> Add the $(srctree)/ prefix to fix it.
>
> While I was here, I slightly refactored the code.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
> KernelVersion: 5.2
>
>  arch/arm/Makefile | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index f863c6935d0e..792f7fa16a24 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -271,14 +271,9 @@ endif
>
>  export TEXT_OFFSET GZFLAGS MMUEXT
>
> -# Do we have FASTFPE?
> -FASTFPE:=arch/arm/fastfpe
> -ifeq ($(FASTFPE),$(wildcard $(FASTFPE)))
> -FASTFPE_OBJ:=$(FASTFPE)/
> -endif
> -
>  core-$(CONFIG_FPE_NWFPE)   += arch/arm/nwfpe/
> -core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ)
> +# Put arch/arm/fastfpe/ to use this.
> +core-$(CONFIG_FPE_FASTFPE) += $(patsubst $(srctree)/%,%,$(wildcard 
> $(srctree)/arch/arm/fastfpe/))
>  core-$(CONFIG_VFP) += arch/arm/vfp/
>  core-$(CONFIG_XEN) += arch/arm/xen/
>  core-$(CONFIG_KVM_ARM_HOST)+= arch/arm/kvm/
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


[PATCH 2/2] dmaengine: pl330: use the same attriobutes when freeing pl330->mcode_cpu

2019-07-10 Thread Fuqian Huang
In function dmac_alloc_recources(), pl330->mcode_cpu is allocated using
dma_alloc_attrs() but freed with dma_free_coherent().
Use the correct dma_free_attrs() function to free pl330->mcode_cpu.

Signed-off-by: Fuqian Huang 
---
 drivers/dma/pl330.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 56f9fabc99c4..d9c6ae0732c6 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1918,9 +1918,10 @@ static int dmac_alloc_resources(struct pl330_dmac *pl330)
if (ret) {
dev_err(pl330->ddma.dev, "%s:%d Can't to create channels for 
DMAC!\n",
__func__, __LINE__);
-   dma_free_coherent(pl330->ddma.dev,
+   dma_free_attrs(pl330->ddma.dev,
chans * pl330->mcbufsz,
-   pl330->mcode_cpu, pl330->mcode_bus);
+   pl330->mcode_cpu, pl330->mcode_bus,
+   DMA_ATTR_PRIVILEGED);
return ret;
}
 
@@ -1999,9 +2000,9 @@ static void pl330_del(struct pl330_dmac *pl330)
/* Free DMAC resources */
dmac_free_threads(pl330);
 
-   dma_free_coherent(pl330->ddma.dev,
+   dma_free_attrs(pl330->ddma.dev,
pl330->pcfg.num_chan * pl330->mcbufsz, pl330->mcode_cpu,
-   pl330->mcode_bus);
+   pl330->mcode_bus, DMA_ATTR_PRIVILEGED);
 }
 
 /* forward declaration */
-- 
2.11.0



Re: [PATCH 4/6] irqchip/irq-pruss-intc: Add helper functions to configure internal mapping

2019-07-10 Thread David Lechner

On 7/7/19 10:52 PM, Suman Anna wrote:

The PRUSS INTC receives a number of system input interrupt source events
and supports individual control configuration and hardware prioritization.
These input events can be mapped to some output host interrupts through 2
levels of many-to-one mapping i.e. events to channel mapping and channels
to host interrupts.

This mapping information is provided through the PRU firmware that is
loaded onto a PRU core/s or through the device tree node of the PRU


What will the device tree bindings for this look like?

Looking back at Rob's comment on the initial series [1], I still think
that increasing the #interrupt-cells sounds like a reasonable solution.

[1]: https://patchwork.kernel.org/patch/10697705/#22375155




application. The mapping is configured by the PRU remoteproc driver, and
is setup before the PRU core is started and cleaned up after the PRU core
is stopped. This event mapping configuration logic is optimized to program
the Channel Map Registers (CMRx) and Host-Interrupt Map Registers (HMRx)
only when a new program is being loaded/started and simply disables the
same events and interrupt channels without zeroing out the corresponding
map registers when stopping a PRU.

Add two helper functions: pruss_intc_configure() & pruss_intc_unconfigure()
that the PRU remoteproc driver can use to configure the PRUSS INTC.

Signed-off-by: Suman Anna 
Signed-off-by: Andrew F. Davis 
Signed-off-by: Roger Quadros 
---
  drivers/irqchip/irq-pruss-intc.c   | 258 -
  include/linux/irqchip/irq-pruss-intc.h |  33 
  2 files changed, 289 insertions(+), 2 deletions(-)
  create mode 100644 include/linux/irqchip/irq-pruss-intc.h

diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c
index 142d01b434e0..8118c2a2ac43 100644
--- a/drivers/irqchip/irq-pruss-intc.c
+++ b/drivers/irqchip/irq-pruss-intc.c
@@ -9,6 +9,7 @@
  
  #include 

  #include 
+#include 
  #include 
  #include 
  #include 
@@ -24,8 +25,8 @@
  /* minimum starting host interrupt number for MPU */
  #define MIN_PRU_HOST_INT  2
  
-/* maximum number of system events */

-#define MAX_PRU_SYS_EVENTS 64
+/* maximum number of host interrupts */
+#define MAX_PRU_HOST_INT   10
  
  /* PRU_ICSS_INTC registers */

  #define PRU_INTC_REVID0x
@@ -57,15 +58,29 @@
  #define PRU_INTC_HINLR(x) (0x1100 + (x) * 4)
  #define PRU_INTC_HIER 0x1500
  
+/* CMR register bit-field macros */

+#define CMR_EVT_MAP_MASK   0xf
+#define CMR_EVT_MAP_BITS   8
+#define CMR_EVT_PER_REG4
+
+/* HMR register bit-field macros */
+#define HMR_CH_MAP_MASK0xf
+#define HMR_CH_MAP_BITS8
+#define HMR_CH_PER_REG 4
+
  /* HIPIR register bit-fields */
  #define INTC_HIPIR_NONE_HINT  0x8000
  
+/* use -1 to mark unassigned events and channels */

+#define FREE   -1


It could be helpful to have this macro in the public header.


+
  /**
   * struct pruss_intc - PRUSS interrupt controller structure
   * @irqs: kernel irq numbers corresponding to PRUSS host interrupts
   * @base: base virtual address of INTC register space
   * @irqchip: irq chip for this interrupt controller
   * @domain: irq domain for this interrupt controller
+ * @config_map: stored INTC configuration mapping data
   * @lock: mutex to serialize access to INTC
   * @host_mask: indicate which HOST IRQs are enabled
   * @shared_intr: bit-map denoting if the MPU host interrupt is shared
@@ -76,6 +91,7 @@ struct pruss_intc {
void __iomem *base;
struct irq_chip *irqchip;
struct irq_domain *domain;
+   struct pruss_intc_config config_map;
struct mutex lock; /* PRUSS INTC lock */
u32 host_mask;
u16 shared_intr;
@@ -107,6 +123,238 @@ static int pruss_intc_check_write(struct pruss_intc 
*intc, unsigned int reg,
return 0;
  }
  
+static struct pruss_intc *to_pruss_intc(struct device *pru_dev)

+{
+   struct device_node *np;
+   struct platform_device *pdev;
+   struct device *pruss_dev = pru_dev->parent;
+   struct pruss_intc *intc = ERR_PTR(-ENODEV);
+
+   np = of_get_child_by_name(pruss_dev->of_node, "interrupt-controller");
+   if (!np) {
+   dev_err(pruss_dev, "pruss does not have an interrupt-controller 
node\n");
+   return intc;
+   }
+
+   pdev = of_find_device_by_node(np);
+   if (!pdev) {
+   dev_err(pruss_dev, "no associated platform device\n");
+   goto out;
+   }
+
+   intc = platform_get_drvdata(pdev);
+   if (!intc) {
+   dev_err(pruss_dev, "pruss intc device probe failed?\n");
+   intc = ERR_PTR(-EINVAL);
+   }
+
+out:
+   of_node_put(np);
+   return intc;
+}
+
+/**
+ * pruss_intc_configure() - configure the PRUSS INTC
+ * @dev: pru device pointer
+ * @intc_config: PRU core-specific INTC configuration
+ *
+ * Configures 

[PATCH 1/2] drm/ttm: use the same attributes when freeing d_page->vaddr

2019-07-10 Thread Fuqian Huang
In function __ttm_dma_alloc_page(), d_page->addr is allocated
by dma_alloc_attrs() but freed with use dma_free_coherent() in
__ttm_dma_free_page().
Use the correct dma_free_attrs() to free d_page->vaddr.

Signed-off-by: Fuqian Huang 
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c 
b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index d594f7520b7b..7d78e6deac89 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -285,9 +285,13 @@ static int ttm_set_pages_caching(struct dma_pool *pool,
 
 static void __ttm_dma_free_page(struct dma_pool *pool, struct dma_page *d_page)
 {
+   unsigned long attrs = 0;
dma_addr_t dma = d_page->dma;
d_page->vaddr &= ~VADDR_FLAG_HUGE_POOL;
-   dma_free_coherent(pool->dev, pool->size, (void *)d_page->vaddr, dma);
+   if (pool->type & IS_HUGE)
+   attrs = DMA_ATTR_NO_WARN;
+
+   dma_free_attrs(pool->dev, pool->size, (void *)d_page->vaddr, dma, 
attrs);
 
kfree(d_page);
d_page = NULL;
-- 
2.11.0



[PATCH] ARM: fix O= building with CONFIG_FPE_FASTFPE

2019-07-10 Thread Masahiro Yamada
To use Fastfpe, a user is supposed to enable CONFIG_FPE_FASTFPE
and put downstream source files into arch/arm/fastfpe/.

It is not working for O= build because $(wildcard arch/arm/fastfpe)
checks if it exists in $(objtree), not in $(srctree).

Add the $(srctree)/ prefix to fix it.

While I was here, I slightly refactored the code.

Signed-off-by: Masahiro Yamada 
---

KernelVersion: 5.2

 arch/arm/Makefile | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index f863c6935d0e..792f7fa16a24 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -271,14 +271,9 @@ endif
 
 export TEXT_OFFSET GZFLAGS MMUEXT
 
-# Do we have FASTFPE?
-FASTFPE:=arch/arm/fastfpe
-ifeq ($(FASTFPE),$(wildcard $(FASTFPE)))
-FASTFPE_OBJ:=$(FASTFPE)/
-endif
-
 core-$(CONFIG_FPE_NWFPE)   += arch/arm/nwfpe/
-core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ)
+# Put arch/arm/fastfpe/ to use this.
+core-$(CONFIG_FPE_FASTFPE) += $(patsubst $(srctree)/%,%,$(wildcard 
$(srctree)/arch/arm/fastfpe/))
 core-$(CONFIG_VFP) += arch/arm/vfp/
 core-$(CONFIG_XEN) += arch/arm/xen/
 core-$(CONFIG_KVM_ARM_HOST)+= arch/arm/kvm/
-- 
2.17.1



Re: [PATCH] dax: Fix missed PMD wakeups

2019-07-10 Thread Matthew Wilcox
On Wed, Jul 10, 2019 at 09:02:04PM +0200, Jan Kara wrote:
> @@ -848,7 +853,7 @@ static int dax_writeback_one(struct xa_state *xas, struct 
> dax_device *dax_dev,
>   if (unlikely(dax_is_locked(entry))) {
>   void *old_entry = entry;
>  
> - entry = get_unlocked_entry(xas);
> + entry = get_unlocked_entry(xas, 0);
>  
>   /* Entry got punched out / reallocated? */
>   if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))

I'm not sure about this one.  Are we sure there will never be a dirty
PMD entry?  Even if we can't create one today, it feels like a bit of
a landmine to leave for someone who creates one in the future.



[PATCH] ARM: fix O= building with CONFIG_FPE_FASTFPE

2019-07-10 Thread Masahiro Yamada
To use Fastfpe, a user is supposed to enable CONFIG_FPE_FASTFPE
and put downstream source files into arch/arm/fastfpe/.

It is not working for O= build because $(wildcard arch/arm/fastfpe)
checks if it exists in $(objtree), not in $(srctree).

Add the $(srctree)/ prefix to fix it.

While I was here, I slightly refactored the code.

Signed-off-by: Masahiro Yamada 
---

KernelVersion: 5.2

 arch/arm/Makefile | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index f863c6935d0e..792f7fa16a24 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -271,14 +271,9 @@ endif
 
 export TEXT_OFFSET GZFLAGS MMUEXT
 
-# Do we have FASTFPE?
-FASTFPE:=arch/arm/fastfpe
-ifeq ($(FASTFPE),$(wildcard $(FASTFPE)))
-FASTFPE_OBJ:=$(FASTFPE)/
-endif
-
 core-$(CONFIG_FPE_NWFPE)   += arch/arm/nwfpe/
-core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ)
+# Put arch/arm/fastfpe/ to use this.
+core-$(CONFIG_FPE_FASTFPE) += $(patsubst $(srctree)/%,%,$(wildcard 
$(srctree)/arch/arm/fastfpe/))
 core-$(CONFIG_VFP) += arch/arm/vfp/
 core-$(CONFIG_XEN) += arch/arm/xen/
 core-$(CONFIG_KVM_ARM_HOST)+= arch/arm/kvm/
-- 
2.17.1



Re: [GIT PULL] Keys: Set 4 - Key ACLs for 5.3

2019-07-10 Thread Mimi Zohar
Hi Linus,

On Wed, 2019-07-10 at 18:59 -0700, Linus Torvalds wrote:
> Anyway, since it does seem like David is offline, I've just reverted
> this from my tree, and will be continuing my normal merge window pull
> requests (the other issues I have seen have fixes in their respective
> trees).

Sorry for the delay.  An exception is needed for loading builtin keys
"KEY_ALLOC_BUILT_IN" onto a keyring that is not writable by userspace.
 The following works, but probably is not how David would handle the
exception.

diff --git a/security/keys/key.c b/security/keys/key.c
index 519211a996e7..a99332c1e014 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -896,7 +896,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
/* if we're going to allocate a new key, we're going to have
 * to modify the keyring */
ret = key_permission(keyring_ref, KEY_NEED_WRITE);
-   if (ret < 0) {
+   if (ret < 0 && !(flags & KEY_ALLOC_BUILT_IN)) {
key_ref = ERR_PTR(ret);
goto error_link_end;
}

Mimi



Re: [PATCH] rdma/siw: Use proper enumerated type in map_cqe_status

2019-07-10 Thread Nathan Chancellor
On Wed, Jul 10, 2019 at 04:53:50PM -0700, Nick Desaulniers wrote:
> On Wed, Jul 10, 2019 at 11:26 AM Jason Gunthorpe  wrote:
> >
> > On Wed, Jul 10, 2019 at 10:48:00AM -0700, Nathan Chancellor wrote:
> > > clang warns several times:
> > >
> > > drivers/infiniband/sw/siw/siw_cq.c:31:4: warning: implicit conversion
> > > from enumeration type 'enum siw_wc_status' to different enumeration type
> > > 'enum siw_opcode' [-Wenum-conversion]
> > Weird that gcc doesn't warn on this by default..
> 
> Based on the sheer number of -Wenum-conversion that Nathan has fixed,
> I don't think gcc has -Wenum-conversion (or it's somehow disabled just
> for gcc).
> -- 
> Thanks,
> ~Nick Desaulniers

Yes, as far as I am aware, GCC does not warn on implicit enum
conversions (which I think defeats the purpose of enumerated types
*shrugs*).

Cheers,
Nathan


[PATCH 1/2] dt-bindings: imx-ocotp: Add i.MX8MN compatible

2019-07-10 Thread Anson . Huang
From: Anson Huang 

Add compatible for i.MX8MN and add i.MX8MM/i.MX8MN to the description.

Signed-off-by: Anson Huang 
---
 Documentation/devicetree/bindings/nvmem/imx-ocotp.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt 
b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
index 96ffd06..904dadf 100644
--- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
+++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
@@ -2,7 +2,7 @@ Freescale i.MX6 On-Chip OTP Controller (OCOTP) device tree 
bindings
 
 This binding represents the on-chip eFuse OTP controller found on
 i.MX6Q/D, i.MX6DL/S, i.MX6SL, i.MX6SX, i.MX6UL, i.MX6ULL/ULZ, i.MX6SLL,
-i.MX7D/S, i.MX7ULP and i.MX8MQ SoCs.
+i.MX7D/S, i.MX7ULP, i.MX8MQ, i.MX8MM and i.MX8MN SoCs.
 
 Required properties:
 - compatible: should be one of
@@ -16,6 +16,7 @@ Required properties:
"fsl,imx7ulp-ocotp" (i.MX7ULP),
"fsl,imx8mq-ocotp" (i.MX8MQ),
"fsl,imx8mm-ocotp" (i.MX8MM),
+   "fsl,imx8mn-ocotp" (i.MX8MN),
followed by "syscon".
 - #address-cells : Should be 1
 - #size-cells : Should be 1
-- 
2.7.4



[PATCH 2/2] nvmem: imx-ocotp: Add i.MX8MN support

2019-07-10 Thread Anson . Huang
From: Anson Huang 

i.MX8MN is a new SoC of i.MX8M series, it is similar to i.MX8MM
in terms of addressing and clock setup, add support for its fuse
read/write.

Signed-off-by: Anson Huang 
---
 drivers/nvmem/imx-ocotp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index 42d4451..dff2f3c 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -479,6 +479,12 @@ static const struct ocotp_params imx8mm_params = {
.set_timing = imx_ocotp_set_imx6_timing,
 };
 
+static const struct ocotp_params imx8mn_params = {
+   .nregs = 256,
+   .bank_address_words = 0,
+   .set_timing = imx_ocotp_set_imx6_timing,
+};
+
 static const struct of_device_id imx_ocotp_dt_ids[] = {
{ .compatible = "fsl,imx6q-ocotp",  .data = _params },
{ .compatible = "fsl,imx6sl-ocotp", .data = _params },
@@ -490,6 +496,7 @@ static const struct of_device_id imx_ocotp_dt_ids[] = {
{ .compatible = "fsl,imx7ulp-ocotp", .data = _params },
{ .compatible = "fsl,imx8mq-ocotp", .data = _params },
{ .compatible = "fsl,imx8mm-ocotp", .data = _params },
+   { .compatible = "fsl,imx8mn-ocotp", .data = _params },
{ },
 };
 MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
-- 
2.7.4



[PATCH 1/1] riscv: Fix perf record without libelf support

2019-07-10 Thread Mao Han
This patch fix following perf record error by linking vdso.so with
build id.

perf.data  perf.data.old
[ perf record: Woken up 1 times to write data ]
free(): double free detected in tcache 2
Aborted

perf record use filename__read_build_id(util/symbol-minimal.c) to get
build id when libelf is not supported. When vdso.so is linked without
build id, the section size of PT_NOTE will be zero, buf size will
realloc to zero and cause memory corruption.

Signed-off-by: Mao Han 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: Albert Ou 
---
 arch/riscv/kernel/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index f1d6ffe..49a5852 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -37,7 +37,7 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
 # these symbols in the kernel code rather than hand-coded addresses.
 
 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
-   -Wl,--hash-style=both
+   -Wl,--build-id -Wl,--hash-style=both
 $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
$(call if_changed,vdsold)
 
-- 
2.7.4



[PATCH] x86/stacktrace: Fix infinite loop in arch_stack_walk_user()

2019-07-10 Thread Eiichi Tsukata
Current arch_stack_walk_user() checks `if (fp == frame.next_fp)`
to prevent infinite loop by self reference but it's not enogh for
circular reference.

Once we find a lack of return address, there is no need to continue
loop, so let's break out.

Fixes: 02b67518e2b1 ("tracing: add support for userspace stacktraces in 
tracing/iter_ctrl")
Signed-off-by: Eiichi Tsukata 
---
 arch/x86/kernel/stacktrace.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 2abf27d7df6b..b1a1f4b4c943 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -129,11 +129,8 @@ void arch_stack_walk_user(stack_trace_consume_fn 
consume_entry, void *cookie,
break;
if ((unsigned long)fp < regs->sp)
break;
-   if (frame.ret_addr) {
-   if (!consume_entry(cookie, frame.ret_addr, false))
-   return;
-   }
-   if (fp == frame.next_fp)
+   if (!frame.ret_addr ||
+   !consume_entry(cookie, frame.ret_addr, false))
break;
fp = frame.next_fp;
}
-- 
2.21.0



Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Jason Gunthorpe
On Thu, Jul 11, 2019 at 11:50:54AM +1000, Stephen Rothwell wrote:

> So today this failed to build after I merged the rdma tree (previously
> it didn;t until after the net-next tree was merged (I assume a
> dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
> in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
> tree :-(

? I'm confused.. 

rdma.git builds fine stand alone (I hope!)

If you merge it with netdev then the above patch is needed afer the
merge as netdev changed to ifa_rcu

I just did this a few hours ago to make and test the patch I sent
above..

Jason


Re: [PATCH v3 1/4] perf pmu: Support more complex PMU event aliasing

2019-07-10 Thread John Garry

On 02/07/2019 20:07, Arnaldo Carvalho de Melo wrote:

Em Fri, Jun 28, 2019 at 10:35:49PM +0800, John Garry escreveu:

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard,
to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi
DDRC uncore PMU for example, where the name is in the form
hisi_scclX_ddrcY.

For for current jevent parsing, we would be required to hardcode an uncore
alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where
we can match by hisi_scclX and ddrcY. Tokens  in Unit field
are delimited by ','.

Signed-off-by: John Garry 
---
 tools/perf/util/pmu.c | 46 ++-
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 7e7299fee550..cfc916819c59 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -700,6 +700,46 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu 
*pmu)
return map;
 }

+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+   char *tmp, *tok, *str;
+   bool res;
+
+   str = strdup(pmu_name);
+   if (!str)
+   return false;
+
+   /*
+* uncore alias may be from different PMU with common prefix
+*/
+   tok = strtok_r(str, ",", );


In some places, e.g. gcc version 4.1.2:

  CC   /tmp/build/perf/util/pmu.o
cc1: warnings being treated as errors
util/pmu.c: In function ‘pmu_lookup’:
util/pmu.c:706: warning: ‘tmp’ may be used uninitialized in this function
mv: cannot stat `/tmp/build/perf/util/.pmu.o.tmp': No such file or directory



Hi Arnaldo,

Sorry for the delayed resposne. Your fix, below, looks ok.

Regards,
John


This silences it, adding.

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 913633ae0bf8..55f4de6442e3 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -703,7 +703,7 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu 
*pmu)

 static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
 {
-   char *tmp, *tok, *str;
+   char *tmp = NULL, *tok, *str;
bool res;

str = strdup(pmu_name);



+   if (strncmp(pmu_name, tok, strlen(tok))) {
+   res = false;
+   goto out;
+   }
+
+   /*
+* Match more complex aliases where the alias name is a comma-delimited
+* list of tokens, orderly contained in the matching PMU name.
+*
+* Example: For alias "socket,pmuname" and PMU "socketX_pmunameY", we
+*  match "socket" in "socketX_pmunameY" and then "pmuname" in
+*  "pmunameY".
+*/
+   for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", )) {
+   name = strstr(name, tok);
+   if (!name) {
+   res = false;
+   goto out;
+   }
+   }
+
+   res = true;
+out:
+   free(str);
+   return res;
+}
+
 /*
  * From the pmu_events_map, find the table of PMU events that corresponds
  * to the current running CPU. Then, add all PMU events from that table
@@ -730,12 +770,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, 
struct perf_pmu *pmu)
break;
}

-   /*
-* uncore alias may be from different PMU
-* with common prefix
-*/
if (pmu_is_uncore(name) &&
-   !strncmp(pname, name, strlen(pname)))
+   pmu_uncore_alias_match(pname, name))
goto new_alias;

if (strcmp(pname, name))
--
2.17.1







[PATCH v1 1/1] arm64: dts: rockchip: Add support for TB-96AI board

2019-07-10 Thread Elon Zhang
Add devicetree support for RK3399Pro TB-96AI board, one of
the 96Boards family.

The TB-96AI board is a 96Boards Compute SOM design, launched
by Linaro, Rockchip and Beiqicloud.

More information can be obtained from the following websites:
1.https://www.96boards.org/product/tb-96ai/
2.http://t.rock-chips.com/
3.http://www.beiqicloud.com/

This patch add basic node for the board and support booting up
to Fedora.

Signed-off-by: Elon Zhang 

diff --git a/arch/arm64/boot/dts/rockchip/Makefile 
b/arch/arm64/boot/dts/rockchip/Makefile
index 5f2687acbf94..3d6c8d4363b5 100644
--- a/arch/arm64/boot/dts/rockchip/Makefile
+++ b/arch/arm64/boot/dts/rockchip/Makefile
@@ -27,3 +27,4 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock960.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rockpro64.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-sapphire.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-sapphire-excavator.dtb
+dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399pro-tb-96ai.dtb
diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-tb-96ai.dts 
b/arch/arm64/boot/dts/rockchip/rk3399pro-tb-96ai.dts
new file mode 100644
index ..1935df99065d
--- /dev/null
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-tb-96ai.dts
@@ -0,0 +1,629 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+/dts-v1/;
+#include "rk3399pro.dtsi"
+#include "rk3399-opp.dtsi"
+
+/ {
+   compatible = "rockchip,rk3399pro-tb-96ai", "rockchip,rk3399pro";
+
+   chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   xin32k: xin32k {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   clock-output-names = "xin32k";
+   #clock-cells = <0>;
+   };
+
+   vcc_phy: vcc-phy-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_phy";
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vcc5v0_sys: vccsys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   };
+
+   vdd_log: vdd_log {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_log";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <90>;
+   regulator-max-microvolt = <90>;
+   };
+
+   leds: gpio-leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 =<_gpio>;
+
+   led@1 {
+   gpios = < 5 GPIO_ACTIVE_HIGH>;
+   label = "system_work_led1";
+   retain-state-suspended;
+   };
+
+   led@2 {
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   label = "system_work_led2";
+   retain-state-suspended;
+   };
+
+   led@3 {
+   gpios = < 3 GPIO_ACTIVE_HIGH>;
+   label = "system_work_led3";
+   retain-state-suspended;
+   };
+   };
+};
+
+_l0 {
+   cpu-supply = <_cpu_l>;
+};
+
+_l1 {
+   cpu-supply = <_cpu_l>;
+};
+
+_l2 {
+   cpu-supply = <_cpu_l>;
+};
+
+_l3 {
+   cpu-supply = <_cpu_l>;
+};
+
+_b0 {
+   cpu-supply = <_cpu_b>;
+};
+
+_b1 {
+   cpu-supply = <_cpu_b>;
+};
+
+_phy {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+   i2c-scl-rising-time-ns = <180>;
+   i2c-scl-falling-time-ns = <30>;
+   clock-frequency = <40>;
+
+   rk809: pmic@20 {
+   compatible = "rockchip,rk809";
+   reg = <0x20>;
+   interrupt-parent = <>;
+   interrupts = ;
+   pinctrl-names = "default", "pmic-sleep",
+   "pmic-power-off", "pmic-reset";
+   pinctrl-0 = <_int_l>;
+   pinctrl-1 = <_slppin_slp>, <_slppin_slp>;
+   pinctrl-2 = <_slppin_gpio>, <_slppin_pwrdn>;
+   pinctrl-3 = <_slppin_gpio>,<_slppin_null>;
+   rockchip,system-power-controller;
+   pmic-reset-func = <1>;
+   wakeup-source;
+   #clock-cells = <1>;
+   clock-output-names = "rk808-clkout1", "rk808-clkout2";
+
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc5-supply = <_buck5>;
+   vcc6-supply = <_buck5>;
+   vcc7-supply = <_sys>;
+   vcc8-supply = <_sys>;
+   vcc9-supply = <_sys>;
+
+   pwrkey {
+   status = "okay";
+   };
+
+   

[PATCH v2] arm: dts: mediatek: add basic support for MT7629 SoC

2019-07-10 Thread ryder.lee
From: Ryder Lee 

This adds basic support for MT7629 reference board.

Tested-by: Kevin Hilman 
Signed-off-by: Ryder Lee 
---
Changes since v2:
- fix 'no newline at end of file'.
- fix addresses/sizes cells.
- update u3phy0 node.
- add eth/pcie related nodes.
- add the 'fixed-partitions' nodes in flash node.
- remove arm,cpu-registers-not-fw-configured.

Changes since v1:
-Fix unit-address warnings.
-Put all the mmio peripherals under a simple-bus node.
-Drop all the 'partitions' nodes in flash node.
---
 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/mt7629-rfb.dts  | 263 
 arch/arm/boot/dts/mt7629.dtsi | 481 ++
 include/dt-bindings/reset/mt7629-resets.h |  71 
 4 files changed, 816 insertions(+)
 create mode 100644 arch/arm/boot/dts/mt7629-rfb.dts
 create mode 100644 arch/arm/boot/dts/mt7629.dtsi
 create mode 100644 include/dt-bindings/reset/mt7629-resets.h

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index dab2914fa293..080784da8ae1 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -1258,6 +1258,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7623a-rfb-nand.dtb \
mt7623n-rfb-emmc.dtb \
mt7623n-bananapi-bpi-r2.dtb \
+   mt7629-rfb.dtb \
mt8127-moose.dtb \
mt8135-evbp1.dtb
 dtb-$(CONFIG_ARCH_MILBEAUT) += milbeaut-m10v-evb.dtb
diff --git a/arch/arm/boot/dts/mt7629-rfb.dts b/arch/arm/boot/dts/mt7629-rfb.dts
new file mode 100644
index ..3621b7d2b22a
--- /dev/null
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
@@ -0,0 +1,263 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ * Author: Ryder Lee 
+ */
+
+/dts-v1/;
+#include 
+#include "mt7629.dtsi"
+
+/ {
+   model = "MediaTek MT7629 reference board";
+   compatible = "mediatek,mt7629-rfb", "mediatek,mt7629";
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   reset {
+   label = "factory";
+   linux,code = ;
+   gpios = < 60 GPIO_ACTIVE_LOW>;
+   };
+
+   wps {
+   label = "wps";
+   linux,code = ;
+   gpios = < 58 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0x4000 0x1000>;
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   reg_5v: regulator-5v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-5V";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   pinctrl-1 = <_leds_pins>;
+   status = "okay";
+
+   gmac1: mac@1 {
+   compatible = "mediatek,eth-mac";
+   reg = <1>;
+   phy-handle = <>;
+   };
+
+   mdio: mdio-bus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   phy0: ethernet-phy@0 {
+   reg = <0>;
+   phy-mode = "gmii";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "u-boot";
+   reg = <0x0 0x6>;
+   read-only;
+   };
+
+   partition@6 {
+   label = "u-boot-env";
+   reg = <0x6 0x1>;
+   read-only;
+   };
+
+   factory: partition@7 {
+   label = "factory";
+   reg = <0x7 0x4>;
+   read-only;
+   };
+
+   partition@b {
+   label = "kernel";
+  

Re: [GIT PULL] Keys: Set 4 - Key ACLs for 5.3

2019-07-10 Thread Linus Torvalds
On Wed, Jul 10, 2019 at 1:15 PM Eric Biggers  wrote:
>
> Also worth noting that the key ACL patches were only in linux-next for 9 days
> before the pull request was sent.

Yes. I was not entirely happy with the whole key subsystem situation.
See my concerns in

  
https://lore.kernel.org/lkml/CAHk-=wjeowdfg7v_4ttu3xhf9gqopj1+q1ngg86+mgfgdte...@mail.gmail.com/

for more. That was before I realized it was buggy.

So it really would be good to have more people involved, and more
structure to the keys development (and, I suspect, much else under
security/)

Anyway, since it does seem like David is offline, I've just reverted
this from my tree, and will be continuing my normal merge window pull
requests (the other issues I have seen have fixes in their respective
trees).

 Linus


RE: [PATCH v3 0/3] kernel/notifier.c: avoid duplicate registration

2019-07-10 Thread Nixiaoming
On Wed, July 10, 2019 1:49 PM Vasily Averin wrote:
>On 7/10/19 6:09 AM, Xiaoming Ni wrote:
>> Registering the same notifier to a hook repeatedly can cause the hook
>> list to form a ring or lose other members of the list.
>
>I think is not enough to _prevent_ 2nd register attempt,
>it's enough to detect just attempt and generate warning to mark host in bad 
>state.
>

Duplicate registration is prevented in my patch, not just "mark host in bad 
state"

Duplicate registration is checked and exited in notifier_chain_cond_register()

Duplicate registration was checked in notifier_chain_register() but only 
the alarm was triggered without exiting. added by commit 831246570d34692e 
("kernel/notifier.c: double register detection")

My patch is like a combination of 831246570d34692e and 
notifier_chain_cond_register(),
 which triggers an alarm and exits when a duplicate registration is detected.

>Unexpected 2nd register of the same hook most likely will lead to 2nd 
>unregister,
>and it can lead to host crash in any time: 
>you can unregister notifier on first attempt it can be too early, it can be 
>still in use.
>on the other hand you can never call 2nd unregister at all.

Since the member was not added to the linked list at the time of the second 
registration, 
no linked list ring was formed. 
The member is released on the first unregistration and -ENOENT on the second 
unregistration.
After patching, the fault has been alleviated

It may be more helpful to return an error code when someone tries to register 
the same
notification program a second time.
But I noticed that notifier_chain_cond_register() returns 0 when duplicate 
registration 
is detected. At the same time, in all the existing export function comments of 
notify,
"Currently always returns zero"

I am a bit confused: which is better?

>
>Unfortunately I do not see any ways to handle such cases properly,
>and it seems for me your patches does not resolve this problem.
>
>Am I missed something probably?
> 
>> case1: An infinite loop in notifier_chain_register() can cause soft lockup
>> atomic_notifier_chain_register(_notifier_list, );
>> atomic_notifier_chain_register(_notifier_list, );
>> atomic_notifier_chain_register(_notifier_list, );

Thanks

Xiaoming Ni


Re: [PATCH 08/16] nfsd: escape high characters in binary data

2019-07-10 Thread Kees Cook
On Wed, Jul 10, 2019 at 06:09:31PM -0400, J. Bruce Fields wrote:
> On Fri, Jun 28, 2019 at 12:33:58PM -0400, J. Bruce Fields wrote:
> > But I may just give up and go with my existing patch and put
> > off that project indefinitely, especially if there's no real need to fix
> > the existing callers.
> 
> I went with the existing patch, but gave a little more thought to
> string_escape_mem.  Stuff that bugs me:
> 
>   - ESCAPE_NP sounds like it means "escape nonprinting
> characters", but actually means "do not escape printing
> characters"
>   - the use of the "only" string to limit the list of escaped
> characters rather than supplement them is confusing and kind
> of unhelpful.
>   - most of the flags are actually totally unused
> 
> So what I'd like to do is:
> 
>   - eliminate unused flags
>   - use the "only" string to add to, rather than replace, the list
> of characters to escape
>   - separate flags into those that select which characters to
> escape, and those that choose the format of the escaping ("\ "
> vs "\x20" vs "\040".)
> 
> I've got some patches that do all that and I think it works.  I need to
> clean them up a bit and fix up the tests.

This sounds amazing; thanks! Luckily there are self-tests for this code,
so anything really surprising should stand out. I'm looking forward to
it -- I want to see if I can refactor a few of the callers (if you
haven't already do so) too.

Yay!

-- 
Kees Cook


Re: linux-next: build failure after merge of the net-next tree

2019-07-10 Thread Stephen Rothwell
Hi all,

On Wed, 10 Jul 2019 17:52:17 + Jason Gunthorpe  wrote:
>
> On Tue, Jul 09, 2019 at 09:43:46AM +0300, Leon Romanovsky wrote:
> > On Tue, Jul 09, 2019 at 01:56:36PM +1000, Stephen Rothwell wrote:  
> > > Hi all,
> > >
> > > After merging the net-next tree, today's linux-next build (x86_64
> > > allmodconfig) failed like this:
> > >
> > > drivers/infiniband/sw/siw/siw_cm.c: In function 'siw_create_listen':
> > > drivers/infiniband/sw/siw/siw_cm.c:1978:3: error: implicit declaration of 
> > > function 'for_ifa'; did you mean 'fork_idle'? 
> > > [-Werror=implicit-function-declaration]
> > >for_ifa(in_dev)
> > >^~~
> > >fork_idle
> > > drivers/infiniband/sw/siw/siw_cm.c:1978:18: error: expected ';' before 
> > > '{' token
> > >for_ifa(in_dev)
> > >   ^
> > >   ;
> > >{
> > >~
> > >
> > > Caused by commit
> > >
> > >   6c52fdc244b5 ("rdma/siw: connection management")
> > >
> > > from the rdma tree.  I don't know why this didn't fail after I mereged
> > > that tree.  
> > 
> > I had the same question, because I have this fix for a couple of days 
> > already.
> > 
> > From 56c9e15ec670af580daa8c3ffde9503af3042d67 Mon Sep 17 00:00:00 2001
> > From: Leon Romanovsky 
> > Date: Sun, 7 Jul 2019 10:43:42 +0300
> > Subject: [PATCH] Fixup to build SIW issue
> > 
> > Signed-off-by: Leon Romanovsky 
> >  drivers/infiniband/sw/siw/siw_cm.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/infiniband/sw/siw/siw_cm.c 
> > b/drivers/infiniband/sw/siw/siw_cm.c
> > index 8e618cb7261f..c883bf514341 100644
> > +++ b/drivers/infiniband/sw/siw/siw_cm.c
> > @@ -1954,6 +1954,7 @@ static void siw_drop_listeners(struct iw_cm_id *id)
> >  int siw_create_listen(struct iw_cm_id *id, int backlog)
> >  {
> > struct net_device *dev = to_siw_dev(id->device)->netdev;
> > +   const struct in_ifaddr *ifa;
> > int rv = 0, listeners = 0;
> > 
> > siw_dbg(id->device, "id 0x%p: backlog %d\n", id, backlog);
> > @@ -1975,8 +1976,7 @@ int siw_create_listen(struct iw_cm_id *id, int 
> > backlog)
> > id, _laddr.sin_addr, ntohs(s_laddr.sin_port),
> > _raddr->sin_addr, ntohs(s_raddr->sin_port));
> > 
> > -   for_ifa(in_dev)
> > -   {
> > +   in_dev_for_each_ifa_rcu(ifa, in_dev) {
> > if (ipv4_is_zeronet(s_laddr.sin_addr.s_addr) ||  
> 
> Hum. There is no rcu lock held here and we can't use RCU anyhow as
> siw_listen_address will sleep.
> 
> I think this needs to use rtnl, as below. Bernard, please urgently
> confirm. Thanks
> 
> diff --git a/drivers/infiniband/sw/siw/siw_cm.c 
> b/drivers/infiniband/sw/siw/siw_cm.c
> index 8e618cb7261f62..ee98e96a5bfaba 100644
> --- a/drivers/infiniband/sw/siw/siw_cm.c
> +++ b/drivers/infiniband/sw/siw/siw_cm.c
> @@ -1965,6 +1965,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
>*/
>   if (id->local_addr.ss_family == AF_INET) {
>   struct in_device *in_dev = in_dev_get(dev);
> + const struct in_ifaddr *ifa;
>   struct sockaddr_in s_laddr, *s_raddr;
>  
>   memcpy(_laddr, >local_addr, sizeof(s_laddr));
> @@ -1975,8 +1976,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
>   id, _laddr.sin_addr, ntohs(s_laddr.sin_port),
>   _raddr->sin_addr, ntohs(s_raddr->sin_port));
>  
> - for_ifa(in_dev)
> - {
> + rtnl_lock();
> + in_dev_for_each_ifa_rtnl(ifa, in_dev) {
>   if (ipv4_is_zeronet(s_laddr.sin_addr.s_addr) ||
>   s_laddr.sin_addr.s_addr == ifa->ifa_address) {
>   s_laddr.sin_addr.s_addr = ifa->ifa_address;
> @@ -1988,7 +1989,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
>   listeners++;
>   }
>   }
> - endfor_ifa(in_dev);
> + rtnl_unlock();
>   in_dev_put(in_dev);
>   } else if (id->local_addr.ss_family == AF_INET6) {
>   struct inet6_dev *in6_dev = in6_dev_get(dev);

So today this failed to build after I merged the rdma tree (previously
it didn;t until after the net-next tree was merged (I assume a
dependency changed).  It failed because in_dev_for_each_ifa_rcu (and
in_dev_for_each_ifa_rtnl) is only defined in a commit in the net-next
tree :-(

I have disabled the driver again.

-- 
Cheers,
Stephen Rothwell


pgpJEKLB09OgD.pgp
Description: OpenPGP digital signature


Re: [PATCH 2/3 v2] ARM: dts: aspeed: Add SGPIO driver

2019-07-10 Thread Andrew Jeffery



On Thu, 11 Jul 2019, at 00:56, Hongwei Zhang wrote:
> Add SGPIO driver support for Aspeed AST2500 SoC.
> 
> Signed-off-by: Hongwei Zhang 
> ---
>  drivers/gpio/sgpio-aspeed.c | 450 
> 
>  1 file changed, 450 insertions(+)
>  create mode 100644 drivers/gpio/sgpio-aspeed.c
> 
> diff --git a/drivers/gpio/sgpio-aspeed.c b/drivers/gpio/sgpio-aspeed.c
> new file mode 100644
> index 000..0743d22
> --- /dev/null
> +++ b/drivers/gpio/sgpio-aspeed.c
> @@ -0,0 +1,450 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2019 American Megatrends International LLC.
> + *
> + * Author: Karthikeyan Mani 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define NR_SGPIO80
> +
> +struct aspeed_sgpio {
> + struct gpio_chip chip;
> + spinlock_t lock;
> + void __iomem *base;
> + int irq;
> +};
> +
> +struct aspeed_sgpio_bank {
> + uint16_tval_regs;
> + uint16_trdata_reg;
> + uint16_tirq_regs;
> + const char  names[4][3];
> +};
> +
> +/*
> + * Note: The "value" register returns the input value sampled on the
> + *   line even when the GPIO is configured as an output. Since
> + *   that input goes through synchronizers, writing, then reading
> + *   back may not return the written value right away.
> + *
> + *   The "rdata" register returns the content of the write latch
> + *   and thus can be used to read back what was last written
> + *   reliably.
> + */
> +
> +static const struct aspeed_sgpio_bank aspeed_sgpio_banks[] = {
> + {
> + .val_regs = 0x,
> + .rdata_reg = 0x0070,
> + .irq_regs = 0x0004,
> + .names = { "A", "B", "C", "D" },
> + },
> + {
> + .val_regs = 0x001C,
> + .rdata_reg = 0x0074,
> + .irq_regs = 0x0020,
> + .names = { "E", "F", "G", "H" },
> + },
> + {
> + .val_regs = 0x0038,
> + .rdata_reg = 0x0078,
> + .irq_regs = 0x003C,
> + .names = { "I", "J" },
> + },
> +};
> +
> +enum aspeed_sgpio_reg {
> + reg_val,
> + reg_rdata,
> + reg_irq_enable,
> + reg_irq_type0,
> + reg_irq_type1,
> + reg_irq_type2,
> + reg_irq_status,
> +};
> +
> +#define GPIO_VAL_VALUE  0x00
> +#define GPIO_VAL_DIR0x04
> +#define GPIO_IRQ_ENABLE 0x00
> +#define GPIO_IRQ_TYPE0  0x04
> +#define GPIO_IRQ_TYPE1  0x08
> +#define GPIO_IRQ_TYPE2  0x0C
> +#define GPIO_IRQ_STATUS 0x10
> +
> +/* This will be resolved at compile time */
> +static inline void __iomem *bank_reg(struct aspeed_sgpio *gpio,
> +  const struct aspeed_sgpio_bank *bank,
> +  const enum aspeed_sgpio_reg reg)
> +{
> + switch (reg) {
> + case reg_val:
> + return gpio->base + bank->val_regs + GPIO_VAL_VALUE;
> + case reg_rdata:
> + return gpio->base + bank->rdata_reg;
> + case reg_irq_enable:
> + return gpio->base + bank->irq_regs + GPIO_IRQ_ENABLE;
> + case reg_irq_type0:
> + return gpio->base + bank->irq_regs + GPIO_IRQ_TYPE0;
> + case reg_irq_type1:
> + return gpio->base + bank->irq_regs + GPIO_IRQ_TYPE1;
> + case reg_irq_type2:
> + return gpio->base + bank->irq_regs + GPIO_IRQ_TYPE2;
> + case reg_irq_status:
> + return gpio->base + bank->irq_regs + GPIO_IRQ_STATUS;
> + default:
> + /* acturally if code runs to here, it's an error case */
> + WARN_ON(reg);
> + return gpio->base;
> + }
> +}
> +
> +#define GPIO_BANK(x)((x) >> 5)
> +#define GPIO_OFFSET(x)  ((x) & 0x1f)
> +#define GPIO_BIT(x) BIT(GPIO_OFFSET(x))
> +
> +static const struct aspeed_sgpio_bank *to_bank(unsigned int offset)
> +{
> + unsigned int bank = GPIO_BANK(offset);
> +
> + WARN_ON(bank >= ARRAY_SIZE(aspeed_sgpio_banks));
> + return _sgpio_banks[bank];
> +}
> +
> +static int aspeed_sgpio_get(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct aspeed_sgpio *gpio = gpiochip_get_data(gc);
> + const struct aspeed_sgpio_bank *bank = to_bank(offset);
> +
> + return !!(ioread32(bank_reg(gpio, bank, reg_val)) & GPIO_BIT(offset));
> +}
> +
> +static void aspeed_sgpio_set(struct gpio_chip *gc, unsigned int 
> offset, int val)
> +{
> + struct aspeed_sgpio *gpio = gpiochip_get_data(gc);
> + const struct aspeed_sgpio_bank *bank = to_bank(offset);
> + unsigned long flags;
> + void __iomem *addr;
> + u32 reg = 0;
> +
> + spin_lock_irqsave(>lock, flags);
> +
> + addr = bank_reg(gpio, bank, reg_val);
> +
> + if (val)
> + reg |= GPIO_BIT(offset);
> + else
> + reg &= ~GPIO_BIT(offset);
> +
> + iowrite32(reg, addr);
> + 

Re: [PATCH 2/3 v1] ARM: dts: aspeed: Add SGPIO driver

2019-07-10 Thread Andrew Jeffery



On Thu, 11 Jul 2019, at 00:24, Hongwei Zhang wrote:
> Hello Andrew,
> 
> Thanks for your review and comments, please find our inline response at 
> below.

Out of interest, who is Karthik? Are they the one developing the code? If so
the patch should have their authorship/Signed-off-by. It's fine if you send it,
git will attribute the code to the right people just fine.

> I will email updated driver code separately, because Outlook breaks 
> source code's tabs.

No worries. Can you use e.g. a gmail account instead? Might make things
easier for you.

> 
> There is one place need your more input for clarification, which is 
> about DATA_READ/DATA_VALUE registers, 
> please see it at below.
> 
> Best Regards,
> -- Hongwei
> 
> > From:   Andrew Jeffery 
> > Sent:   Wednesday, July 3, 2019 8:06 PM
> > To: Hongwei Zhang; Bartosz Golaszewski; Joel Stanley; Linus Walleij
> > Cc: linux-g...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; 
> > linux-asp...@lists.ozlabs.org; 
> > linux-kernel@vger.kernel.org
> > Subject:Re: [PATCH 2/3 linux,dev-5.1 v1] ARM: dts: aspeed: Add SGPIO 
> > driver
> > 
> > Hello Hongwei,
> > 
> > As this is patch is sent to the upstream lists (linux-gpio@ etc) please 
> > drop the OpenBMC-specific 
> > "linux,dev-5.1" from the subject.
> > 
> 
> Got it but to be more specific, for the situation of mixed recipients, 
> should I send out separate emails with 
> different subject line format in the future?

It boils down to:

* If the patches are for the upstream kernel, follow upstream's process.
* If the patches are for the OpenBMC kernel, follow the OpenBMC kernel
   development process.

Those processes are independent, though vastly similar. Make sure to
read through the relevant documentation for each. A big part of OpenBMC's
kernel development process is "send your patches upstream" :)

> 
> > Also, it looks like you may have manually added the series revision (v1).
> > For the record you can make `git format-patch` do this for you with the 
> > `-v`option (e.g. if you really want 
> > it here, `-v 1`).
> > 
> > On Thu, 4 Jul 2019, at 07:09, Hongwei Zhang wrote:
> > > Add SGPIO driver support for Aspeed AST2500 SoC.
> > > 
> > > Signed-off-by: Hongwei Zhang 
> > > ---
> > >  drivers/gpio/sgpio-aspeed.c | 470 
> > > 
> > >  1 file changed, 470 insertions(+)
> > >  create mode 100644 drivers/gpio/sgpio-aspeed.c
> > > 
> > > diff --git a/drivers/gpio/sgpio-aspeed.c b/drivers/gpio/sgpio-aspeed.c 
> > > new file mode 100644 index 000..108ed13
> > > --- /dev/null
> > > +++ b/drivers/gpio/sgpio-aspeed.c
> > > @@ -0,0 +1,470 @@
> > > +/*
> > > + * Copyright 2019 American Megatrends International LLC. 
> > > + *
> > > + * This program 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 of the License, or (at your option) any later version.
> > 
> > You should use the SPDX license identifier here rather than the GPL blurb, 
> > and it should be the first line 
> > of the file. Keep your copyright line in place though:
> > 
> OK
> 
> > // SPDX-License-Identifier: GPL-2.0-or-later // Copyright 2019 American 
> > Megatrends International LLC.
> > 
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +#define NR_SGPIO80
> > > +
> > > +struct aspeed_sgpio {
> > > + struct gpio_chip chip;
> > > + spinlock_t lock;
> > > + void __iomem *base;
> > > + int irq;
> > > +};
> > > +
> > > +struct aspeed_sgpio_bank {
> > > + uint16_tval_regs;
> > > + uint16_trdata_reg;
> > > + uint16_tirq_regs;
> > > + const char  names[4][3];
> > > +};
> > > +
> > > +/*
> > > + * Note: The "value" register returns the input value sampled on the
> > > + *   line even when the GPIO is configured as an output. Since
> > > + *   that input goes through synchronizers, writing, then reading
> > > + *   back may not return the written value right away.
> > > + *
> > > + *   The "rdata" register returns the content of the write latch
> > > + *   and thus can be used to read back what was last written
> > > + *   reliably.
> > > + */
> > > +
> > > +static const struct aspeed_sgpio_bank aspeed_sgpio_banks[] = {
> > > + {
> > > + .val_regs = 0x,
> > > + .rdata_reg = 0x0070,
> > > + .irq_regs = 0x0004,
> > > + .names = { "A", "B", "C", "D" },
> > > + },
> > > + {
> > > + .val_regs = 0x001C,
> > > + .rdata_reg = 0x0074,
> > > + .irq_regs = 0x0020,
> > > + .names = { "E", "F", "G", "H" },
> > > + },
> > > + {
> > > + .val_regs = 0x0038,
> > > + .rdata_reg = 0x0078,
> > > + .irq_regs = 0x003C,
> > > + .names = { "I", 

RE: [PATCH v3 0/3] kernel/notifier.c: avoid duplicate registration

2019-07-10 Thread Nixiaoming
On Wed, July 10, 2019 1:56 PM Greg KH wrote:
>On Wed, Jul 10, 2019 at 11:09:07AM +0800, Xiaoming Ni wrote:
>> Registering the same notifier to a hook repeatedly can cause the hook
>> list to form a ring or lose other members of the list.
>
>Then don't do that :)
>

Duplicate registration is checked and exited in notifier_chain_cond_register()

Duplicate registration was checked in notifier_chain_register() but only 
the alarm was triggered without exiting. added by commit 831246570d34692e 
("kernel/notifier.c: double register detection")

This patch is similar to commit 8312465 and notifier_chain_cond_register(),
 with actual prevention for such behaviour,  which I think is necessary to 
 avoid the formation of a linked list ring.

>Is there any in-kernel users that do do this?  If so, please just fix
>them.
>
Notifier_chain_register() is not a hotspot path.
Adding a check here can make the kernel more stable.

Thanks

Xiaoming Ni


>thanks,
>
>greg k-h
>


linux-next: build warning after merge of the pm tree

2019-07-10 Thread Stephen Rothwell
Hi all,

After merging the pm tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:

drivers/cpufreq/pasemi-cpufreq.c: In function 'pas_cpufreq_cpu_init':
drivers/cpufreq/pasemi-cpufreq.c:199:1: warning: label 'out_unmap_sdcpwr' 
defined but not used [-Wunused-label]
 out_unmap_sdcpwr:
 ^~~~

Introduced by commit

  f43e075f7252 ("cpufreq/pasemi: fix an use-after-free in 
pas_cpufreq_cpu_init()")

-- 
Cheers,
Stephen Rothwell


pgp1Oz9hoBIPp.pgp
Description: OpenPGP digital signature


I WANT YOU TO USE THIS DONATION TO HELP THE POOR URGENT.

2019-07-10 Thread Mrs.Ivvone Balakiwal
My Sincere Greetings ,

I am  Mrs  Ivvone Davida Balakiwal, I decided to donate what I have to
you for investment towards the good work of charity organization, and
also to help the motherless and the less privileged ones and to carry
out a charitable works in your Country and around the World on my
Behalf.

I am diagnosing of throat Cancer, hospitalize for good 2 years and
some months now and quite obvious that I have few days to live, and I
am a Widow no child; I decided to will/donate the sum of $ 9.5 million
to you for the good work of God, and also to help the motherless and
less privilege and also forth assistance of the widows. At the moment
I can not take any telephone calls right now due to the fact that my
relatives (that have squandered the funds for this purpose before) are
around me and my health status also. I have adjusted my will and my
lawyer is aware.

I have willed those properties to you by quoting my Personal File
Routing and Account Information. And I have also notified the bank
that I am willing that properties to you for a good, effective and
prudent work.

It is right to say that I have been directed to do this by God.

I will be going in for a surgery soon and I want to make sure that I
make this donation before undergoing this surgery. I will need your
support to make this dream come through, could you let me know your
interest to enable me give you further information.And I hereby advice
to contact me by this email address  (
mrslvvonebalakiwa...@citromail.hu )

Looking forward to hearing from you  soon,

Yours sincerely,
Mrs Ivvone Davida Balakiwal


Re: [PATCH v2 1/2] dt-bindings: mmc: add DT bindings for Milbeaut SD controller

2019-07-10 Thread orito.takao

Thanks for checking my patch.

> On Thu, May 30, 2019 at 06:22:11PM +0900, Takao Orito wrote:
> > Add the device-tree binding documentation for Milbeaut SDHCI driver.
> > 
> > Signed-off-by: Takao Orito 
> > ---
> >  .../devicetree/bindings/mmc/sdhci-milbeaut.txt | 32 
> > ++
> >  1 file changed, 32 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-milbeaut.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/mmc/sdhci-milbeaut.txt 
> > b/Documentation/devicetree/bindings/mmc/sdhci-milbeaut.txt
> > new file mode 100644
> > index 000..6063116
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mmc/sdhci-milbeaut.txt
> > @@ -0,0 +1,32 @@
> > +* SOCIONEXT Milbeaut SDHCI controller
> > +
> > +This file documents differences between the core properties in mmc.txt
> > +and the properties used by the sdhci_milbeaut driver.
> > +
> > +Required properties:
> > +- compatible: "socionext,milbeaut-m10v-sdhci-3.0"
> > +- clocks: Must contain an entry for each entry in clock-names. It is a
> > +  list of phandles and clock-specifier pairs.
> > +  See ../clocks/clock-bindings.txt for details.
> > +- clock-names: Should contain the following two entries:
> > +   "iface" - clock used for sdhci interface
> > +   "core"  - core clock for sdhci controller
> > +- vmmc-supply: a phandle of a fixed GPIO regulator
> 
> Being a fixed GPIO regulator is board specific and outside the scope of 
> the binding. Otherwise,
> 
> Reviewed-by: Rob Herring 

I see. I will remove vmmc-supply and send new patch.

Thanks
Orito

> 
> > +
> > +Optional properties:
> > +- fujitsu,cmd-dat-delay-select: boolean property indicating that this host
> > +  requires the CMD_DAT_DELAY control to be enabled.
> > +
> > +Example:
> > +   sdhci3: mmc@1b01 {
> > +   compatible = "socionext,milbeaut-m10v-sdhci-3.0";
> > +   reg = <0x1b01 0x1>;
> > +   interrupts = <0 265 0x4>;
> > +   voltage-ranges = <3300 3300>;
> > +   bus-width = <4>;
> > +   clocks = < 7>, <_clk>;
> > +   clock-names = "core", "iface";
> > +   cap-sdio-irq;
> > +   vmmc-supply = <_sdhci3>;
> > +   fujitsu,cmd-dat-delay-select;
> > +   };
> > -- 
> > 1.9.1
> > 
> > 

-- 
Takao Orito 


[PATCH v4 4/4] mm: introduce MADV_PAGEOUT

2019-07-10 Thread Minchan Kim
When a process expects no accesses to a certain memory range
for a long time, it could hint kernel that the pages can be
reclaimed instantly but data should be preserved for future use.
This could reduce workingset eviction so it ends up increasing
performance.

This patch introduces the new MADV_PAGEOUT hint to madvise(2)
syscall. MADV_PAGEOUT can be used by a process to mark a memory
range as not expected to be used for a long time so that kernel
reclaims *any LRU* pages instantly. The hint can help kernel in
deciding which pages to evict proactively.

A note: It doesn't apply SWAP_CLUSTER_MAX LRU page isolation limit
intentionally because it's automatically bounded by PMD size.
If PMD size(e.g., 256) makes some trouble, we could fix it later
by limit it to SWAP_CLUSTER_MAX[1].

- man-page material

MADV_PAGEOUT (since Linux x.x)

Do not expect access in the near future so pages in the specified
regions could be reclaimed instantly regardless of memory pressure.
Thus, access in the range after successful operation could cause
major page fault but never lose the up-to-date contents unlike
MADV_DONTNEED. Pages belonging to a shared mapping are only processed
if a write access is allowed for the calling process.

MADV_PAGEOUT cannot be applied to locked pages, Huge TLB pages, or
VM_PFNMAP pages.

* v3
 * man page material modification - mhocko
 * remove using SWAP_CLUSTER_MAX - mhocko

* v2
 * add comment about SWAP_CLUSTER_MAX - mhocko
 * add permission check to prevent sidechannel attack - mhocko
 * add man page stuff - dave

* v1
 * change pte to old and rely on the other's reference - hannes
 * remove page_mapcount to check shared page - mhocko

* RFC v2
 * make reclaim_pages simple via factoring out isolate logic - hannes

* RFCv1
 * rename from MADV_COLD to MADV_PAGEOUT - hannes
 * bail out if process is being killed - Hillf
 * fix reclaim_pages bugs - Hillf

[1] https://lore.kernel.org/lkml/20190710194719.gs29...@dhcp22.suse.cz/
Acked-by: Michal Hocko 
Signed-off-by: Minchan Kim 
---
 include/linux/swap.h   |   1 +
 include/uapi/asm-generic/mman-common.h |   1 +
 mm/madvise.c   | 197 +
 mm/vmscan.c|  55 +++
 4 files changed, 254 insertions(+)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 0ce997edb8bb..063c0c1e112b 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -365,6 +365,7 @@ extern int vm_swappiness;
 extern int remove_mapping(struct address_space *mapping, struct page *page);
 extern unsigned long vm_total_pages;
 
+extern unsigned long reclaim_pages(struct list_head *page_list);
 #ifdef CONFIG_NUMA
 extern int node_reclaim_mode;
 extern int sysctl_min_unmapped_ratio;
diff --git a/include/uapi/asm-generic/mman-common.h 
b/include/uapi/asm-generic/mman-common.h
index ef8a56927b12..c613abdb7284 100644
--- a/include/uapi/asm-generic/mman-common.h
+++ b/include/uapi/asm-generic/mman-common.h
@@ -46,6 +46,7 @@
 #define MADV_WILLNEED  3   /* will need these pages */
 #define MADV_DONTNEED  4   /* don't need these pages */
 #define MADV_COLD  5   /* deactivatie these pages */
+#define MADV_PAGEOUT   6   /* reclaim these pages */
 
 /* common parameters: try to keep these consistent across architectures */
 #define MADV_FREE  8   /* free pages only if memory pressure */
diff --git a/mm/madvise.c b/mm/madvise.c
index bae0055f9724..bc2f0138982e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,6 +42,7 @@ static int madvise_need_mmap_write(int behavior)
case MADV_WILLNEED:
case MADV_DONTNEED:
case MADV_COLD:
+   case MADV_PAGEOUT:
case MADV_FREE:
return 0;
default:
@@ -480,6 +482,198 @@ static long madvise_cold(struct vm_area_struct *vma,
return 0;
 }
 
+static int madvise_pageout_pte_range(pmd_t *pmd, unsigned long addr,
+   unsigned long end, struct mm_walk *walk)
+{
+   struct mmu_gather *tlb = walk->private;
+   struct mm_struct *mm = tlb->mm;
+   struct vm_area_struct *vma = walk->vma;
+   pte_t *orig_pte, *pte, ptent;
+   spinlock_t *ptl;
+   LIST_HEAD(page_list);
+   struct page *page;
+   unsigned long next;
+
+   if (fatal_signal_pending(current))
+   return -EINTR;
+
+   next = pmd_addr_end(addr, end);
+   if (pmd_trans_huge(*pmd)) {
+   pmd_t orig_pmd;
+
+   tlb_change_page_size(tlb, HPAGE_PMD_SIZE);
+   ptl = pmd_trans_huge_lock(pmd, vma);
+   if (!ptl)
+   return 0;
+
+   orig_pmd = *pmd;
+   if (is_huge_zero_pmd(orig_pmd))
+   goto huge_unlock;
+
+   if (unlikely(!pmd_present(orig_pmd))) {
+   

[PATCH v4 3/4] mm: account nr_isolated_xxx in [isolate|putback]_lru_page

2019-07-10 Thread Minchan Kim
The isolate counting is pecpu counter so it would be not huge gain
to work them by batch. Rather than complicating to make them batch,
let's make it more stright-foward via adding the counting logic
into [isolate|putback]_lru_page API.

* v1
 * fix accounting bug - Hillf

Link: http://lkml.kernel.org/r/20190531165927.ga20...@cmpxchg.org
Acked-by: Michal Hocko 
Suggested-by: Johannes Weiner 
Signed-off-by: Minchan Kim 
---
 mm/compaction.c |  2 --
 mm/gup.c|  7 +--
 mm/khugepaged.c |  3 ---
 mm/memory-failure.c |  3 ---
 mm/memory_hotplug.c |  4 
 mm/mempolicy.c  |  6 +-
 mm/migrate.c| 37 -
 mm/vmscan.c | 22 --
 8 files changed, 26 insertions(+), 58 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 9e1b9acb116b..c6591682deda 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -982,8 +982,6 @@ isolate_migratepages_block(struct compact_control *cc, 
unsigned long low_pfn,
 
/* Successfully isolated */
del_page_from_lru_list(page, lruvec, page_lru(page));
-   inc_node_page_state(page,
-   NR_ISOLATED_ANON + page_is_file_cache(page));
 
 isolate_success:
list_add(>lru, >migratepages);
diff --git a/mm/gup.c b/mm/gup.c
index 98f13ab37bac..11d0634ce613 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1475,13 +1475,8 @@ static long check_and_migrate_cma_pages(struct 
task_struct *tsk,
drain_allow = false;
}
 
-   if (!isolate_lru_page(head)) {
+   if (!isolate_lru_page(head))
list_add_tail(>lru, 
_page_list);
-   mod_node_page_state(page_pgdat(head),
-   NR_ISOLATED_ANON +
-   
page_is_file_cache(head),
-   
hpage_nr_pages(head));
-   }
}
}
 
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index eaaa21b23215..a8b517d6df4a 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -503,7 +503,6 @@ void __khugepaged_exit(struct mm_struct *mm)
 
 static void release_pte_page(struct page *page)
 {
-   dec_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page));
unlock_page(page);
putback_lru_page(page);
 }
@@ -602,8 +601,6 @@ static int __collapse_huge_page_isolate(struct 
vm_area_struct *vma,
result = SCAN_DEL_PAGE_LRU;
goto out;
}
-   inc_node_page_state(page,
-   NR_ISOLATED_ANON + page_is_file_cache(page));
VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_PAGE(PageLRU(page), page);
 
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 7ef849da8278..9900bb95d774 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1791,9 +1791,6 @@ static int __soft_offline_page(struct page *page, int 
flags)
 * so use !__PageMovable instead for LRU page's mapping
 * cannot have PAGE_MAPPING_MOVABLE.
 */
-   if (!__PageMovable(page))
-   inc_node_page_state(page, NR_ISOLATED_ANON +
-   page_is_file_cache(page));
list_add(>lru, );
ret = migrate_pages(, new_page, NULL, MPOL_MF_MOVE_ALL,
MIGRATE_SYNC, MR_MEMORY_FAILURE);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index b9ba5b85f9f7..15bad2043b41 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1383,10 +1383,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long 
end_pfn)
ret = isolate_movable_page(page, ISOLATE_UNEVICTABLE);
if (!ret) { /* Success */
list_add_tail(>lru, );
-   if (!__PageMovable(page))
-   inc_node_page_state(page, NR_ISOLATED_ANON +
-   page_is_file_cache(page));
-
} else {
pr_warn("failed to isolate pfn %lx\n", pfn);
dump_page(page, "isolation failed");
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 4acc2d14bc77..a5685eee6d1d 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -994,12 +994,8 @@ static int migrate_page_add(struct page *page, struct 
list_head *pagelist,
 * Avoid migrating a page that is shared with others.
 */
if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(head) == 1) {
-   if (!isolate_lru_page(head)) {
+   if (!isolate_lru_page(head))
  

[PATCH v4 0/4] Introduce MADV_COLD and MADV_PAGEOUT

2019-07-10 Thread Minchan Kim
This patch is part of previous series:
https://lore.kernel.org/lkml/20190531064313.193437-1-minc...@kernel.org/
Originally, it was created for external madvise hinting feature.

https://lkml.org/lkml/2019/5/31/463
Michal wanted to separte the discussion from external hinting interface
so this patchset includes only first part of my entire patchset

  - introduce MADV_COLD and MADV_PAGEOUT hint to madvise.

However, I keep entire description for others for easier understanding
why this kinds of hint was born.

Thanks.

This patchset is against on next-20190710.

Below is description of previous entire patchset.

= &< =

- Background

The Android terminology used for forking a new process and starting an app
from scratch is a cold start, while resuming an existing app is a hot start.
While we continually try to improve the performance of cold starts, hot
starts will always be significantly less power hungry as well as faster so
we are trying to make hot start more likely than cold start.

To increase hot start, Android userspace manages the order that apps should
be killed in a process called ActivityManagerService. ActivityManagerService
tracks every Android app or service that the user could be interacting with
at any time and translates that into a ranked list for lmkd(low memory
killer daemon). They are likely to be killed by lmkd if the system has to
reclaim memory. In that sense they are similar to entries in any other cache.
Those apps are kept alive for opportunistic performance improvements but
those performance improvements will vary based on the memory requirements of
individual workloads.

- Problem

Naturally, cached apps were dominant consumers of memory on the system.
However, they were not significant consumers of swap even though they are
good candidate for swap. Under investigation, swapping out only begins
once the low zone watermark is hit and kswapd wakes up, but the overall
allocation rate in the system might trip lmkd thresholds and cause a cached
process to be killed(we measured performance swapping out vs. zapping the
memory by killing a process. Unsurprisingly, zapping is 10x times faster
even though we use zram which is much faster than real storage) so kill
from lmkd will often satisfy the high zone watermark, resulting in very
few pages actually being moved to swap.

- Approach

The approach we chose was to use a new interface to allow userspace to
proactively reclaim entire processes by leveraging platform information.
This allowed us to bypass the inaccuracy of the kernel’s LRUs for pages
that are known to be cold from userspace and to avoid races with lmkd
by reclaiming apps as soon as they entered the cached state. Additionally,
it could provide many chances for platform to use much information to
optimize memory efficiency.

To achieve the goal, the patchset introduce two new options for madvise.
One is MADV_COLD which will deactivate activated pages and the other is
MADV_PAGEOUT which will reclaim private pages instantly. These new options
complement MADV_DONTNEED and MADV_FREE by adding non-destructive ways to
gain some free memory space. MADV_PAGEOUT is similar to MADV_DONTNEED in a way
that it hints the kernel that memory region is not currently needed and
should be reclaimed immediately; MADV_COLD is similar to MADV_FREE in a way
that it hints the kernel that memory region is not currently needed and
should be reclaimed when memory pressure rises.

* v3 - http://lore.kernel.org/lkml/20190627115405.255259-1-minc...@kernel.org
* v2 - http://lore.kernel.org/lkml/20190610111252.239156-1-minc...@kernel.org
* v1 - http://lore.kernel.org/lkml/20190603053655.127730-1-minc...@kernel.org

Minchan Kim (4):
  mm: introduce MADV_COLD
  mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM
  mm: account nr_isolated_xxx in [isolate|putback]_lru_page
  mm: introduce MADV_PAGEOUT

 include/linux/swap.h   |   2 +
 include/uapi/asm-generic/mman-common.h |   2 +
 mm/compaction.c|   2 -
 mm/gup.c   |   7 +-
 mm/internal.h  |   2 +-
 mm/khugepaged.c|   3 -
 mm/madvise.c   | 377 -
 mm/memory-failure.c|   3 -
 mm/memory_hotplug.c|   4 -
 mm/mempolicy.c |   6 +-
 mm/migrate.c   |  37 +--
 mm/oom_kill.c  |   2 +-
 mm/swap.c  |  42 +++
 mm/vmscan.c|  83 +-
 14 files changed, 507 insertions(+), 65 deletions(-)

-- 
2.22.0.410.gd8fdbe21b5-goog



[PATCH v4 1/4] mm: introduce MADV_COLD

2019-07-10 Thread Minchan Kim
When a process expects no accesses to a certain memory range, it could
give a hint to kernel that the pages can be reclaimed when memory pressure
happens but data should be preserved for future use.  This could reduce
workingset eviction so it ends up increasing performance.

This patch introduces the new MADV_COLD hint to madvise(2) syscall.
MADV_COLD can be used by a process to mark a memory range as not expected
to be used in the near future. The hint can help kernel in deciding which
pages to evict early during memory pressure.

It works for every LRU pages like MADV_[DONTNEED|FREE]. IOW, It moves

active file page -> inactive file LRU
active anon page -> inacdtive anon LRU

Unlike MADV_FREE, it doesn't move active anonymous pages to inactive
file LRU's head because MADV_COLD is a little bit different symantic.
MADV_FREE means it's okay to discard when the memory pressure because
the content of the page is *garbage* so freeing such pages is almost zero
overhead since we don't need to swap out and access afterward causes just
minor fault. Thus, it would make sense to put those freeable pages in
inactive file LRU to compete other used-once pages. It makes sense for
implmentaion point of view, too because it's not swapbacked memory any
longer until it would be re-dirtied. Even, it could give a bonus to make
them be reclaimed on swapless system. However, MADV_COLD doesn't mean
garbage so reclaiming them requires swap-out/in in the end so it's bigger
cost. Since we have designed VM LRU aging based on cost-model, anonymous
cold pages would be better to position inactive anon's LRU list, not file
LRU. Furthermore, it would help to avoid unnecessary scanning if system
doesn't have a swap device. Let's start simpler way without adding
complexity at this moment. However, keep in mind, too that it's a caveat
that workloads with a lot of pages cache are likely to ignore MADV_COLD
on anonymous memory because we rarely age anonymous LRU lists.

* man-page material

MADV_COLD (since Linux x.x)

Pages in the specified regions will be treated as less-recently-accessed
compared to pages in the system with similar access frequencies.
In contrast to MADV_FREE, the contents of the region are preserved
regardless of subsequent writes to pages.

MADV_COLD cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP
pages.

* v2
 * add up the warn with lots of page cache workload - mhocko
 * add man page stuff - dave

* v1
 * remove page_mapcount filter - hannes, mhocko
 * remove idle page handling - joelaf

* RFCv2
 * add more description - mhocko

* RFCv1
 * renaming from MADV_COOL to MADV_COLD - hannes

* internal review
 * use clear_page_youn in deactivate_page - joelaf
 * Revise the description - surenb
 * Renaming from MADV_WARM to MADV_COOL - surenb

Acked-by: Michal Hocko 
Signed-off-by: Minchan Kim 
---
 include/linux/swap.h   |   1 +
 include/uapi/asm-generic/mman-common.h |   1 +
 mm/internal.h  |   2 +-
 mm/madvise.c   | 180 -
 mm/oom_kill.c  |   2 +-
 mm/swap.c  |  42 ++
 6 files changed, 224 insertions(+), 4 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index de2c67a33b7e..0ce997edb8bb 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -340,6 +340,7 @@ extern void lru_add_drain_cpu(int cpu);
 extern void lru_add_drain_all(void);
 extern void rotate_reclaimable_page(struct page *page);
 extern void deactivate_file_page(struct page *page);
+extern void deactivate_page(struct page *page);
 extern void mark_page_lazyfree(struct page *page);
 extern void swap_setup(void);
 
diff --git a/include/uapi/asm-generic/mman-common.h 
b/include/uapi/asm-generic/mman-common.h
index 63b1f506ea67..ef8a56927b12 100644
--- a/include/uapi/asm-generic/mman-common.h
+++ b/include/uapi/asm-generic/mman-common.h
@@ -45,6 +45,7 @@
 #define MADV_SEQUENTIAL2   /* expect sequential page 
references */
 #define MADV_WILLNEED  3   /* will need these pages */
 #define MADV_DONTNEED  4   /* don't need these pages */
+#define MADV_COLD  5   /* deactivatie these pages */
 
 /* common parameters: try to keep these consistent across architectures */
 #define MADV_FREE  8   /* free pages only if memory pressure */
diff --git a/mm/internal.h b/mm/internal.h
index f53a14d67538..c61b215ff265 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -39,7 +39,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf);
 void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
unsigned long floor, unsigned long ceiling);
 
-static inline bool can_madv_dontneed_vma(struct vm_area_struct *vma)
+static inline bool can_madv_lru_vma(struct vm_area_struct *vma)
 {
return !(vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP));
 }
diff --git a/mm/madvise.c 

[PATCH v4 2/4] mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM

2019-07-10 Thread Minchan Kim
The local variable references in shrink_page_list is PAGEREF_RECLAIM_CLEAN
as default. It is for preventing to reclaim dirty pages when CMA try to
migrate pages. Strictly speaking, we don't need it because CMA didn't allow
to write out by .may_writepage = 0 in reclaim_clean_pages_from_list.

Moreover, it has a problem to prevent anonymous pages's swap out even
though force_reclaim = true in shrink_page_list on upcoming patch.
So this patch makes references's default value to PAGEREF_RECLAIM and
rename force_reclaim with ignore_references to make it more clear.

This is a preparatory work for next patch.

* RFCv1
 * use ignore_referecnes as parameter name - hannes

Acked-by: Michal Hocko 
Acked-by: Johannes Weiner 
Signed-off-by: Minchan Kim 
---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a0301edd8d03..b4fa04d10ba6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1119,7 +1119,7 @@ static unsigned long shrink_page_list(struct list_head 
*page_list,
  struct scan_control *sc,
  enum ttu_flags ttu_flags,
  struct reclaim_stat *stat,
- bool force_reclaim)
+ bool ignore_references)
 {
LIST_HEAD(ret_pages);
LIST_HEAD(free_pages);
@@ -1133,7 +1133,7 @@ static unsigned long shrink_page_list(struct list_head 
*page_list,
struct address_space *mapping;
struct page *page;
int may_enter_fs;
-   enum page_references references = PAGEREF_RECLAIM_CLEAN;
+   enum page_references references = PAGEREF_RECLAIM;
bool dirty, writeback;
unsigned int nr_pages;
 
@@ -1264,7 +1264,7 @@ static unsigned long shrink_page_list(struct list_head 
*page_list,
}
}
 
-   if (!force_reclaim)
+   if (!ignore_references)
references = page_check_references(page, sc);
 
switch (references) {
-- 
2.22.0.410.gd8fdbe21b5-goog



[PATCH v2] KVM: x86: PMU Event Filter

2019-07-10 Thread Eric Hankland
- Add a VM ioctl that can control which events the guest can monitor.

Signed-off-by: ehankland 
---
Changes since v1:
-Moved to a vm ioctl rather than a vcpu one
-Changed from a whitelist to a configurable filter which can either be
white or black
-Only restrict GP counters since fixed counters require extra handling
and they can be disabled by setting the guest cpuid (though only by
setting the number - they can't be disabled individually)
---
 Documentation/virtual/kvm/api.txt | 25 +
 arch/x86/include/asm/kvm_host.h   |  2 +
 arch/x86/include/uapi/asm/kvm.h   | 10 +
 arch/x86/kvm/pmu.c| 61 +++
 arch/x86/kvm/pmu.h|  1 +
 arch/x86/kvm/x86.c|  6 +++
 include/uapi/linux/kvm.h  |  3 ++
 7 files changed, 108 insertions(+)

diff --git a/Documentation/virtual/kvm/api.txt
b/Documentation/virtual/kvm/api.txt
index 91fd86fcc49f..a9ee8da36595 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -4065,6 +4065,31 @@ KVM_ARM_VCPU_FINALIZE call.
 See KVM_ARM_VCPU_INIT for details of vcpu features that require finalization
 using this ioctl.

+4.120 KVM_SET_PMU_EVENT_FILTER
+
+Capability: KVM_CAP_PMU_EVENT_FILTER
+Architectures: x86
+Type: vm ioctl
+Parameters: struct kvm_pmu_event_filter (in)
+Returns: 0 on success, -1 on error
+
+struct kvm_pmu_event_filter {
+   __u32 type;
+   __u32 nevents;
+   __u64 events[0];
+};
+
+This ioctl restricts the set of PMU events that the guest can program to either
+a whitelist or a blacklist of events. The eventsel+umask of each event the
+guest attempts to program is compared against the events field to determine
+whether the guest should have access. This only affects general purpose
+counters; fixed purpose counters can be disabled by changing the perfmon
+CPUID leaf.
+
+Valid values for 'type':
+#define KVM_PMU_EVENT_WHITELIST 0
+#define KVM_PMU_EVENT_BLACKLIST 1
+

 5. The kvm_run structure
 

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f46a12a5cf2e..34d017bd1d1b 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -933,6 +933,8 @@ struct kvm_arch {

bool guest_can_read_msr_platform_info;
bool exception_payload_enabled;
+
+   struct kvm_pmu_event_filter *pmu_event_filter;
 };

 struct kvm_vm_stat {
diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index f9b021e16ebc..4d2e905b7d79 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -422,4 +422,14 @@ struct kvm_nested_state {
__u8 data[0];
 };

+/* for KVM_CAP_PMU_EVENT_FILTER */
+struct kvm_pmu_event_filter {
+   __u32 type;
+   __u32 nevents;
+   __u64 events[0];
+};
+
+#define KVM_PMU_EVENT_WHITELIST 0
+#define KVM_PMU_EVENT_BLACKLIST 1
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index dd745b58ffd8..d674b79ff8da 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -22,6 +22,9 @@
 #include "lapic.h"
 #include "pmu.h"

+/* This keeps the total size of the filter under 4k. */
+#define KVM_PMU_EVENT_FILTER_MAX_EVENTS 63
+
 /* NOTE:
  * - Each perf counter is defined as "struct kvm_pmc";
  * - There are two types of perf counters: general purpose (gp) and fixed.
@@ -144,6 +147,10 @@ void reprogram_gp_counter(struct kvm_pmc *pmc,
u64 eventsel)
 {
unsigned config, type = PERF_TYPE_RAW;
u8 event_select, unit_mask;
+   struct kvm_arch *arch = >vcpu->kvm->arch;
+   struct kvm_pmu_event_filter *filter;
+   int i;
+   bool allow_event = true;

if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
printk_once("kvm pmu: pin control bit is ignored\n");
@@ -155,6 +162,24 @@ void reprogram_gp_counter(struct kvm_pmc *pmc,
u64 eventsel)
if (!(eventsel & ARCH_PERFMON_EVENTSEL_ENABLE) || !pmc_is_enabled(pmc))
return;

+   rcu_read_lock();
+   filter = rcu_dereference(arch->pmu_event_filter);
+   if (filter) {
+   for (i = 0; i < filter->nevents; i++)
+   if (filter->events[i] ==
+   (eventsel & AMD64_RAW_EVENT_MASK_NB))
+   break;
+   if (filter->type == KVM_PMU_EVENT_WHITELIST &&
+   i == filter->nevents)
+   allow_event = false;
+   if (filter->type == KVM_PMU_EVENT_BLACKLIST &&
+   i < filter->nevents)
+   allow_event = false;
+   }
+   rcu_read_unlock();
+   if (!allow_event)
+   return;
+
event_select = eventsel & ARCH_PERFMON_EVENTSEL_EVENT;
unit_mask = (eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;

@@ -351,3 +376,39 @@ void kvm_pmu_destroy(struct kvm_vcpu *vcpu)
 {
kvm_pmu_reset(vcpu);
 }
+
+int kvm_vm_ioctl_set_pmu_event_filter(struct kvm 

Re: [bpf-next v3 05/12] selftests/bpf: Allow passing more information to BPF prog test run

2019-07-10 Thread Andrii Nakryiko
On Mon, Jul 8, 2019 at 3:42 PM Krzesimir Nowak  wrote:
>
> The test case can now specify a custom length of the data member,
> context data and its length, which will be passed to
> bpf_prog_test_run_xattr. For backward compatilibity, if the data
> length is 0 (which is what will happen when the field is left
> unspecified in the designated initializer of a struct), then the
> length passed to the bpf_prog_test_run_xattr is TEST_DATA_LEN.
>
> Also for backward compatilibity, if context data length is 0, NULL is
> passed as a context to bpf_prog_test_run_xattr. This is to avoid
> breaking other tests, where context data being NULL and context data
> length being 0 is handled differently from the case where context data
> is not NULL and context data length is 0.
>
> Custom lengths still can't be greater than hardcoded 64 bytes for data
> and 192 for context data.
>
> 192 for context data was picked to allow passing struct
> bpf_perf_event_data as a context for perf event programs. The struct
> is quite large, because it contains struct pt_regs.
>
> Test runs for perf event programs will not allow the copying the data
> back to data_out buffer, so they require data_out_size to be zero and
> data_out to be NULL. Since test_verifier hardcodes it, make it
> possible to override the size. Overriding the size to zero will cause
> the buffer to be NULL.
>
> Changes since v2:
> - Allow overriding the data out size and buffer.
>
> Signed-off-by: Krzesimir Nowak 
> ---
>  tools/testing/selftests/bpf/test_verifier.c | 105 +---
>  1 file changed, 93 insertions(+), 12 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c 
> b/tools/testing/selftests/bpf/test_verifier.c
> index 1640ba9f12c1..6f124cc4ee34 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -54,6 +54,7 @@
>  #define MAX_TEST_RUNS  8
>  #define POINTER_VALUE  0xcafe4all
>  #define TEST_DATA_LEN  64
> +#define TEST_CTX_LEN   192
>
>  #define F_NEEDS_EFFICIENT_UNALIGNED_ACCESS (1 << 0)
>  #define F_LOAD_WITH_STRICT_ALIGNMENT   (1 << 1)
> @@ -96,7 +97,12 @@ struct bpf_test {
> enum bpf_prog_type prog_type;
> uint8_t flags;
> __u8 data[TEST_DATA_LEN];
> +   __u32 data_len;
> +   __u8 ctx[TEST_CTX_LEN];
> +   __u32 ctx_len;
> void (*fill_helper)(struct bpf_test *self);
> +   bool override_data_out_len;
> +   __u32 overridden_data_out_len;
> uint8_t runs;
> struct {
> uint32_t retval, retval_unpriv;
> @@ -104,6 +110,9 @@ struct bpf_test {
> __u8 data[TEST_DATA_LEN];
> __u64 data64[TEST_DATA_LEN / 8];
> };
> +   __u32 data_len;
> +   __u8 ctx[TEST_CTX_LEN];
> +   __u32 ctx_len;
> } retvals[MAX_TEST_RUNS];
>  };
>
> @@ -818,21 +827,35 @@ static int set_admin(bool admin)
>  }
>
>  static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val,
> -   void *data, size_t size_data)
> +   void *data, size_t size_data, void *ctx,
> +   size_t size_ctx, u32 *overridden_data_out_size)
>  {
> -   __u8 tmp[TEST_DATA_LEN << 2];
> -   __u32 size_tmp = sizeof(tmp);
> -   int saved_errno;
> -   int err;
> struct bpf_prog_test_run_attr attr = {
> .prog_fd = fd_prog,
> .repeat = 1,
> .data_in = data,
> .data_size_in = size_data,
> -   .data_out = tmp,
> -   .data_size_out = size_tmp,
> +   .ctx_in = ctx,
> +   .ctx_size_in = size_ctx,
> };
> +   __u8 tmp[TEST_DATA_LEN << 2];
> +   __u32 size_tmp = sizeof(tmp);
> +   __u32 size_buf = size_tmp;
> +   __u8 *buf = tmp;
> +   int saved_errno;
> +   int err;
>
> +   if (overridden_data_out_size)
> +   size_buf = *overridden_data_out_size;
> +   if (size_buf > size_tmp) {
> +   printf("FAIL: out data size (%d) greater than a buffer size 
> (%d) ",
> +  size_buf, size_tmp);
> +   return -EINVAL;
> +   }
> +   if (!size_buf)
> +   buf = NULL;
> +   attr.data_size_out = size_buf;
> +   attr.data_out = buf;
> if (unpriv)
> set_admin(true);
> err = bpf_prog_test_run_xattr();
> @@ -956,13 +979,45 @@ static void do_test_single(struct bpf_test *test, bool 
> unpriv,
> if (!alignment_prevented_execution && fd_prog >= 0) {
> uint32_t expected_val;
> int i;
> +   __u32 size_data;
> +   __u32 size_ctx;
> +   bool bad_size;
> +   void *ctx;
> +   __u32 *overridden_data_out_size;
>
> if (!test->runs) {
> +   if (test->data_len > 0)
> +   

RE: [PATCH V4 2/5] clocksource/drivers/sysctr: Add clock-frequency property

2019-07-10 Thread Anson Huang
Hi, Rob

> On Tue, Jul 9, 2019 at 7:30 PM Anson Huang  wrote:
> >
> > Hi, Rob
> >
> > > On Mon, Jul 1, 2019 at 3:47 AM  wrote:
> > > >
> > > > From: Anson Huang 
> > >
> > > 'dt-bindings: timer: ...' for the subject.
> >
> > OK, I made a mistake.
> >
> > >
> > > >
> > > > Systems which use platform driver model for clock driver require
> > > > the clock frequency to be supplied via device tree when system
> > > > counter driver is enabled.
> > >
> > > This is a DT binding. What's a platform driver?
> >
> > It is just trying to explain why we need to introduce this "clock-frequency"
> > property, nothing about the binding and platform driver.
> >
> > >
> > > >
> > > > This is necessary as in the platform driver model the of_clk
> > > > operations do not work correctly because system counter driver is
> > > > initialized in early phase of system boot up, and clock driver
> > > > using platform driver model is NOT ready at that time, it will
> > > > cause system counter driver initialization failed.
> > > >
> > > > Add clock-frequency property to the device tree bindings of the
> > > > NXP system counter, so the driver can tell timer-of driver to get
> > > > clock frequency from DT directly instead of doing of_clk
> > > > operations via clk APIs.
> > >
> > > While you've now given a good explanation why you need this, it all
> > > sounds like linux specific issues and a DT change should not be necessary.
> > >
> > > Presumably, 'clocks' points to a fixed-clock node, right? Just parse the
> 'clocks'
> > > phandle and fetch the frequency from that node if you need to get
> > > the frequency 'early'.
> >
> > Sound like a better solution, I will try that, since the system
> > counter's clock is from osc_24m and divided by 3, since different
> > platforms may have different divider, so maybe I can create a
> > fixed-clock node in DT, then system counter driver can parse the clock and
> fetch the frequency from that node, will redo a V5 patch.
> 
> The divide by 3 can be implied by the compatible. If you need a different
> divider, add another compatible.

Yes, we can consider it later, till now, all the platforms used are with an 
internal
divider of 3 in system counter block, so I make it fixed divided by 3 in system 
counter
driver.

> 
> > >
> > > > Signed-off-by: Anson Huang 
> > > > ---
> > > > No change.
> > > > ---
> > > >  .../devicetree/bindings/timer/nxp,sysctr-timer.txt| 15 
> > > > +--
> 
> > > >  1 file changed, 9 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git
> > > > a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
> > > > b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
> > > > index d576599..7088a0e 100644
> > > > --- a/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
> > > > +++ b/Documentation/devicetree/bindings/timer/nxp,sysctr-timer.txt
> > > > @@ -11,15 +11,18 @@ Required properties:
> > > >  - reg : Specifies the base physical address and size of the
> comapre
> > > >  frame and the counter control, read & compare.
> > > >  - interrupts :  should be the first compare frames' interrupt
> > > > -- clocks : Specifies the counter clock.
> > > > -- clock-names: Specifies the clock's name of this module
> > > > +- clocks :  Specifies the counter clock, mutually exclusive 
> > > > with
> clock-
> > > frequency.
> > > > +- clock-names : Specifies the clock's name of this module, mutually
> > > exclusive with
> > > > +   clock-frequency.
> > > > +- clock-frequency : Specifies system counter clock frequency,
> > > > +mutually
> > > exclusive with
> > > > +   clocks/clock-names.
> > >
> > > It doesn't really work to say one or the other is needed unless you
> > > make the OS support both cases.
> >
> > The OS already support both cases now with this patch series.
> 
> What about FreeBSD or any other OS?

Now that in V5, I use the fixed clock of OSC as clock input of system counter,
no need to have all these changes now. And also no changes needed in DT
binding, thanks for your review.

Anson.


  1   2   3   4   5   6   7   8   >